Changeset View
Changeset View
Standalone View
Standalone View
src/Application.cpp
Show All 37 Lines | |||||
38 | #include "ProfileManager.h" | 38 | #include "ProfileManager.h" | ||
39 | #include "MainWindow.h" | 39 | #include "MainWindow.h" | ||
40 | #include "Session.h" | 40 | #include "Session.h" | ||
41 | #include "ShellCommand.h" | 41 | #include "ShellCommand.h" | ||
42 | #include "KonsoleSettings.h" | 42 | #include "KonsoleSettings.h" | ||
43 | #include "ViewManager.h" | 43 | #include "ViewManager.h" | ||
44 | #include "SessionController.h" | 44 | #include "SessionController.h" | ||
45 | #include "WindowSystemInfo.h" | 45 | #include "WindowSystemInfo.h" | ||
46 | #include "ViewContainer.h" | ||||
47 | #include "TerminalDisplay.h" | ||||
46 | 48 | | |||
47 | using namespace Konsole; | 49 | using namespace Konsole; | ||
48 | 50 | | |||
49 | Application::Application(QSharedPointer<QCommandLineParser> parser, | 51 | Application::Application(QSharedPointer<QCommandLineParser> parser, | ||
50 | const QStringList &customCommand) : | 52 | const QStringList &customCommand) : | ||
51 | _backgroundInstance(nullptr), | 53 | _backgroundInstance(nullptr), | ||
52 | m_parser(parser), | 54 | m_parser(parser), | ||
53 | m_customCommand(customCommand) | 55 | m_customCommand(customCommand) | ||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Line(s) | |||||
164 | { | 166 | { | ||
165 | WindowSystemInfo::HAVE_TRANSPARENCY = !m_parser->isSet(QStringLiteral("notransparency")); | 167 | WindowSystemInfo::HAVE_TRANSPARENCY = !m_parser->isSet(QStringLiteral("notransparency")); | ||
166 | 168 | | |||
167 | auto window = new MainWindow(); | 169 | auto window = new MainWindow(); | ||
168 | 170 | | |||
169 | connect(window, &Konsole::MainWindow::newWindowRequest, this, | 171 | connect(window, &Konsole::MainWindow::newWindowRequest, this, | ||
170 | &Konsole::Application::createWindow); | 172 | &Konsole::Application::createWindow); | ||
171 | connect(window, &Konsole::MainWindow::viewDetached, this, &Konsole::Application::detachView); | 173 | connect(window, &Konsole::MainWindow::viewDetached, this, &Konsole::Application::detachView); | ||
174 | connect(window, &Konsole::MainWindow::tabDetached, this, &Konsole::Application::detachTab); | ||||
172 | 175 | | |||
173 | return window; | 176 | return window; | ||
174 | } | 177 | } | ||
175 | 178 | | |||
176 | void Application::createWindow(const Profile::Ptr &profile, const QString &directory) | 179 | void Application::createWindow(const Profile::Ptr &profile, const QString &directory) | ||
177 | { | 180 | { | ||
178 | MainWindow *window = newMainWindow(); | 181 | MainWindow *window = newMainWindow(); | ||
179 | ViewManager *viewManager = window->viewManager(); | 182 | ViewManager *viewManager = window->viewManager(); | ||
180 | window->createSession(viewManager->activeContainer(), profile, directory); | 183 | window->createSession(viewManager->activeContainer(), profile, directory); | ||
181 | finalizeNewMainWindow(window); | 184 | finalizeNewMainWindow(window); | ||
182 | } | 185 | } | ||
183 | 186 | | |||
187 | void Application::detachTab(ViewSplitter *splitter, QHash<TerminalDisplay*, Session*> sessionsMap) | ||||
188 | { | ||||
189 | MainWindow *currentWindow = qobject_cast<MainWindow*>(sender()); | ||||
190 | MainWindow *window = newMainWindow(); | ||||
191 | ViewManager *manager = window->viewManager(); | ||||
192 | | ||||
193 | foreach(TerminalDisplay* terminal, splitter->getTerminalDisplays()) { | ||||
194 | manager->attachView(terminal, sessionsMap[terminal]); | ||||
195 | } | ||||
196 | | ||||
197 | manager->activeContainer()->addSplitter(splitter); | ||||
198 | | ||||
199 | // Since user is dragging and dropping, move dnd window to where | ||||
200 | // the user has the cursor (correct multiple monitor setups). | ||||
201 | window->move(QCursor::pos()); | ||||
202 | window->resize(currentWindow->geometry().width(), currentWindow->geometry().height()); | ||||
203 | window->show(); | ||||
204 | } | ||||
205 | | ||||
184 | void Application::detachView(Session *session) | 206 | void Application::detachView(Session *session) | ||
185 | { | 207 | { | ||
186 | MainWindow *currentWindow = qobject_cast<MainWindow*>(sender()); | 208 | MainWindow *currentWindow = qobject_cast<MainWindow*>(sender()); | ||
187 | MainWindow *window = newMainWindow(); | 209 | MainWindow *window = newMainWindow(); | ||
188 | ViewManager *manager = window->viewManager(); | 210 | ViewManager *manager = window->viewManager(); | ||
189 | 211 | | |||
190 | manager->createView(manager->activeContainer(), session); | 212 | auto view = manager->createView(session); | ||
213 | manager->activeContainer()->addView(view); | ||||
191 | 214 | | |||
192 | // Since user is dragging and dropping, move dnd window to where | 215 | // Since user is dragging and dropping, move dnd window to where | ||
193 | // the user has the cursor (correct multiple monitor setups). | 216 | // the user has the cursor (correct multiple monitor setups). | ||
194 | window->move(QCursor::pos()); | 217 | window->move(QCursor::pos()); | ||
195 | window->resize(currentWindow->geometry().width(), currentWindow->geometry().height()); | 218 | window->resize(currentWindow->geometry().width(), currentWindow->geometry().height()); | ||
196 | window->show(); | 219 | window->show(); | ||
197 | } | 220 | } | ||
198 | 221 | | |||
anthonyfieroni: It's not work on Wayland, no? Also don't set geometry, KWin will not like it. Use resize and… | |||||
I did not tested on wayland, my system woesn't work with it yet because of nvidia. I accept patches. :) tcanabrava: I did not tested on wayland, my system woesn't work with it yet because of nvidia. I accept… | |||||
199 | int Application::newInstance() | 222 | int Application::newInstance() | ||
200 | { | 223 | { | ||
201 | // handle session management | 224 | // handle session management | ||
202 | 225 | | |||
203 | // returns from processWindowArgs(args, createdNewMainWindow) | 226 | // returns from processWindowArgs(args, createdNewMainWindow) | ||
204 | // if a new window was created | 227 | // if a new window was created | ||
205 | bool createdNewMainWindow = false; | 228 | bool createdNewMainWindow = false; | ||
206 | 229 | | |||
▲ Show 20 Lines • Show All 399 Lines • Show Last 20 Lines |
It's not work on Wayland, no? Also don't set geometry, KWin will not like it. Use resize and move to coor by parents ones.