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 | | |||
184 | void Application::detachView(Session *session) | 187 | template<typename T> | ||
185 | { | 188 | void detach(Application *application, QObject *sender, const T&& functor) { | ||
186 | MainWindow *currentWindow = qobject_cast<MainWindow*>(sender()); | 189 | MainWindow *currentWindow = qobject_cast<MainWindow*>(sender); | ||
187 | MainWindow *window = newMainWindow(); | 190 | MainWindow *window = application->newMainWindow(); | ||
188 | ViewManager *manager = window->viewManager(); | 191 | ViewManager *manager = window->viewManager(); | ||
192 | functor(manager); | ||||
193 | window->show(); | ||||
194 | window->setGeometry(currentWindow->geometry()); | ||||
195 | window->move(QCursor::pos()); | ||||
196 | } | ||||
189 | 197 | | |||
190 | manager->createView(manager->activeContainer(), session); | 198 | void Application::detachTab(ViewSplitter *splitter, QHash<TerminalDisplay*, Session*> sessionsMap) | ||
199 | { | ||||
200 | detach(this, sender(), [=](ViewManager *manager) { | ||||
201 | foreach(TerminalDisplay* terminal, splitter->getTerminalDisplays()) { | ||||
202 | manager->attachView(terminal, sessionsMap[terminal]); | ||||
203 | } | ||||
204 | manager->activeContainer()->addSplitter(splitter); | ||||
205 | }); | ||||
206 | } | ||||
191 | 207 | | |||
192 | // Since user is dragging and dropping, move dnd window to where | 208 | void Application::detachView(Session *session) | ||
193 | // the user has the cursor (correct multiple monitor setups). | 209 | { | ||
194 | window->move(QCursor::pos()); | 210 | detach(this, sender(), [=](ViewManager *manager) { | ||
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… | |||||
195 | window->resize(currentWindow->geometry().width(), currentWindow->geometry().height()); | 211 | auto view = manager->createView(session); | ||
196 | window->show(); | 212 | manager->activeContainer()->addView(view); | ||
213 | }); | ||||
197 | } | 214 | } | ||
198 | 215 | | |||
199 | int Application::newInstance() | 216 | int Application::newInstance() | ||
200 | { | 217 | { | ||
201 | // handle session management | 218 | // handle session management | ||
202 | 219 | | |||
203 | // returns from processWindowArgs(args, createdNewMainWindow) | 220 | // returns from processWindowArgs(args, createdNewMainWindow) | ||
204 | // if a new window was created | 221 | // if a new window was created | ||
▲ Show 20 Lines • Show All 401 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.