diff --git a/src/Application.h b/src/Application.h --- a/src/Application.h +++ b/src/Application.h @@ -73,6 +73,8 @@ void toggleBackgroundInstance(); + void handleLastTabClosed(MainWindow *window); + public Q_SLOTS: void slotActivateRequested(QStringList args, const QString &workingDir); diff --git a/src/Application.cpp b/src/Application.cpp --- a/src/Application.cpp +++ b/src/Application.cpp @@ -168,6 +168,7 @@ connect(window, &Konsole::MainWindow::newWindowRequest, this, &Konsole::Application::createWindow); connect(window, &Konsole::MainWindow::viewDetached, this, &Konsole::Application::detachView); + connect(window, &Konsole::MainWindow::lastTabClosed, this, &Konsole::Application::handleLastTabClosed); return window; } @@ -561,6 +562,20 @@ _backgroundInstance = window; } +void Application::handleLastTabClosed(MainWindow *window) +{ + if (_backgroundInstance == nullptr) { + window->close(); + + return; + } + + Profile::Ptr defaultProfile = ProfileManager::instance()->defaultProfile(); + _backgroundInstance->createSession(defaultProfile, QString()); + + _backgroundInstance->hide(); +} + void Application::toggleBackgroundInstance() { Q_ASSERT(_backgroundInstance); diff --git a/src/MainWindow.h b/src/MainWindow.h --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -116,6 +116,11 @@ */ void viewDetached(Session *session); + /** + * Emitted when the last tab has been closed + */ + void lastTabClosed(MainWindow *window); + protected: // Reimplemented for internal reasons. void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; @@ -156,7 +161,6 @@ void setProfileList(ProfileList *list); void applyKonsoleSettings(); - void handleLastTabClosed(); void updateUseTransparency(); @@ -171,6 +175,7 @@ void setupActions(); QString activeSessionDir() const; void triggerAction(const QString &name) const; + void allTabsClosed(); /** * Returns the bookmark handler associated with this window. diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -97,7 +97,8 @@ // create view manager _viewManager = new ViewManager(this, actionCollection()); - connect(_viewManager, &Konsole::ViewManager::empty, this, &Konsole::MainWindow::handleLastTabClosed); + connect(_viewManager, &Konsole::ViewManager::empty, this, &Konsole::MainWindow::allTabsClosed); + connect(_viewManager, &Konsole::ViewManager::activeViewChanged, this, &Konsole::MainWindow::activeViewChanged); connect(_viewManager, &Konsole::ViewManager::unplugController, this, @@ -775,18 +776,6 @@ updateWindowCaption(); } -void MainWindow::handleLastTabClosed() -{ - if (!KonsoleSettings::persistAfterLastClose()) { - close(); - } - - Profile::Ptr defaultProfile = ProfileManager::instance()->defaultProfile(); - createSession(defaultProfile, QString()); - - hide(); -} - void MainWindow::activateMenuBar() { const QList menuActions = menuBar()->actions(); @@ -888,3 +877,9 @@ // Kpart is another different story return false; } + + +void MainWindow::allTabsClosed() +{ + emit lastTabClosed(this); +} diff --git a/src/settings/GeneralSettings.ui b/src/settings/GeneralSettings.ui --- a/src/settings/GeneralSettings.ui +++ b/src/settings/GeneralSettings.ui @@ -125,19 +125,6 @@ - - - - - 0 - 0 - - - - Persist after closing last tab - - - diff --git a/src/settings/konsole.kcfg b/src/settings/konsole.kcfg --- a/src/settings/konsole.kcfg +++ b/src/settings/konsole.kcfg @@ -40,11 +40,6 @@ When launching Konsole re-use existing process if possible false - - - If the last tab is closed Konsole will keep running and create a new tab - false -