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 109 Lines • ▼ Show 20 Line(s) | |||||
163 | MainWindow *Application::newMainWindow() | 165 | MainWindow *Application::newMainWindow() | ||
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::terminalsDetached, this, &Konsole::Application::detachTerminals); | ||
172 | 174 | | |||
173 | return window; | 175 | return window; | ||
174 | } | 176 | } | ||
175 | 177 | | |||
176 | void Application::createWindow(const Profile::Ptr &profile, const QString &directory) | 178 | void Application::createWindow(const Profile::Ptr &profile, const QString &directory) | ||
177 | { | 179 | { | ||
178 | MainWindow *window = newMainWindow(); | 180 | MainWindow *window = newMainWindow(); | ||
179 | ViewManager *viewManager = window->viewManager(); | 181 | window->createSession(profile, directory); | ||
180 | window->createSession(viewManager->activeContainer(), profile, directory); | | |||
181 | finalizeNewMainWindow(window); | 182 | finalizeNewMainWindow(window); | ||
182 | } | 183 | } | ||
183 | 184 | | |||
184 | void Application::detachView(Session *session) | 185 | template<typename T> | ||
185 | { | 186 | void detach(Application *application, QObject *sender, const T&& functor) { | ||
186 | MainWindow *currentWindow = qobject_cast<MainWindow*>(sender()); | 187 | MainWindow *currentWindow = qobject_cast<MainWindow*>(sender); | ||
187 | MainWindow *window = newMainWindow(); | 188 | MainWindow *window = application->newMainWindow(); | ||
188 | ViewManager *manager = window->viewManager(); | 189 | ViewManager *manager = window->viewManager(); | ||
189 | 190 | functor(manager); | |||
190 | manager->createView(manager->activeContainer(), session); | | |||
191 | | ||||
192 | // Since user is dragging and dropping, move dnd window to where | | |||
193 | // the user has the cursor (correct multiple monitor setups). | | |||
194 | window->move(QCursor::pos()); | | |||
195 | window->resize(currentWindow->geometry().width(), currentWindow->geometry().height()); | | |||
196 | window->show(); | 191 | window->show(); | ||
192 | window->setGeometry(currentWindow->geometry()); | ||||
193 | window->move(QCursor::pos()); | ||||
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… | |||||
194 | } | ||||
195 | | ||||
196 | void Application::detachTerminals(ViewSplitter *splitter, QHash<TerminalDisplay*, Session*> sessionsMap) | ||||
197 | { | ||||
198 | detach(this, sender(), [=](ViewManager *manager) { | ||||
199 | foreach(TerminalDisplay* terminal, splitter->getTerminalDisplays()) { | ||||
200 | manager->attachView(terminal, sessionsMap[terminal]); | ||||
201 | } | ||||
202 | manager->activeContainer()->addSplitter(splitter); | ||||
203 | }); | ||||
197 | } | 204 | } | ||
198 | 205 | | |||
199 | int Application::newInstance() | 206 | int Application::newInstance() | ||
200 | { | 207 | { | ||
201 | // handle session management | 208 | // handle session management | ||
202 | 209 | | |||
203 | // returns from processWindowArgs(args, createdNewMainWindow) | 210 | // returns from processWindowArgs(args, createdNewMainWindow) | ||
204 | // if a new window was created | 211 | // if a new window was created | ||
Show All 18 Lines | |||||
223 | // select profile to use | 230 | // select profile to use | ||
224 | Profile::Ptr baseProfile = processProfileSelectArgs(); | 231 | Profile::Ptr baseProfile = processProfileSelectArgs(); | ||
225 | 232 | | |||
226 | // process various command-line options which cause a property of the | 233 | // process various command-line options which cause a property of the | ||
227 | // selected profile to be changed | 234 | // selected profile to be changed | ||
228 | Profile::Ptr newProfile = processProfileChangeArgs(baseProfile); | 235 | Profile::Ptr newProfile = processProfileChangeArgs(baseProfile); | ||
229 | 236 | | |||
230 | // create new session | 237 | // create new session | ||
231 | ViewManager *viewManager = window->viewManager(); | 238 | Session *session = window->createSession(newProfile, QString()); | ||
232 | Session *session = window->createSession(viewManager->activeContainer(), newProfile, QString()); | | |||
233 | 239 | | |||
234 | if (m_parser->isSet(QStringLiteral("noclose"))) { | 240 | if (m_parser->isSet(QStringLiteral("noclose"))) { | ||
235 | session->setAutoClose(false); | 241 | session->setAutoClose(false); | ||
236 | } | 242 | } | ||
237 | 243 | | |||
238 | // if the background-mode argument is supplied, start the background | 244 | // if the background-mode argument is supplied, start the background | ||
239 | // session ( or bring to the front if it already exists ) | 245 | // session ( or bring to the front if it already exists ) | ||
240 | if (m_parser->isSet(QStringLiteral("background-mode"))) { | 246 | if (m_parser->isSet(QStringLiteral("background-mode"))) { | ||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Line(s) | 339 | { | |||
371 | 377 | | |||
372 | if (!workdir.isEmpty()) { | 378 | if (!workdir.isEmpty()) { | ||
373 | newProfile->setProperty(Profile::Directory, workdir); | 379 | newProfile->setProperty(Profile::Directory, workdir); | ||
374 | shouldUseNewProfile = true; | 380 | shouldUseNewProfile = true; | ||
375 | } | 381 | } | ||
376 | 382 | | |||
377 | // Create the new session | 383 | // Create the new session | ||
378 | Profile::Ptr theProfile = shouldUseNewProfile ? newProfile : baseProfile; | 384 | Profile::Ptr theProfile = shouldUseNewProfile ? newProfile : baseProfile; | ||
379 | ViewManager *viewManager = window->viewManager(); | 385 | Session *session = window->createSession(theProfile, QString()); | ||
380 | Session *session = window->createSession(viewManager->activeContainer(), theProfile, QString()); | | |||
381 | 386 | | |||
382 | if (m_parser->isSet(QStringLiteral("noclose"))) { | 387 | if (m_parser->isSet(QStringLiteral("noclose"))) { | ||
383 | session->setAutoClose(false); | 388 | session->setAutoClose(false); | ||
384 | } | 389 | } | ||
385 | 390 | | |||
386 | if (!window->testAttribute(Qt::WA_Resized)) { | 391 | if (!window->testAttribute(Qt::WA_Resized)) { | ||
387 | window->resize(window->sizeHint()); | 392 | window->resize(window->sizeHint()); | ||
388 | } | 393 | } | ||
▲ Show 20 Lines • Show All 217 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.