summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-13 12:07:29 (GMT)
committerMartin T. H. Sandsmark <martin.sandsmark@kde.org>2016-08-28 22:10:08 (GMT)
commite21fc13c473cff47654f02b1e5ecd6ff8e3636f4 (patch)
treee57a9b4d0ab735dd2c9779caead5a920ac0d5983
parent30fe2a0b9d93617c80f6e3d5a61d845a5fb526ab (diff)
Warn when trying to close window with open tabs
REVIEW: 128668 BUG: 333023
-rw-r--r--src/MainWindow.cpp40
1 files changed, 29 insertions, 11 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 803eeaf..07d5096 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -531,9 +531,7 @@ bool MainWindow::queryClose()
return true;
}
- // Check what processes are running,
- // if just the default shell is running don't ask for confirmation
-
+ // Check what processes are running, excluding the shell
QStringList processesRunning;
foreach(Session *session, _viewManager->sessions()) {
if (!session || !session->isForegroundProcessActive()) {
@@ -550,7 +548,12 @@ bool MainWindow::queryClose()
processesRunning.append(currentProc);
}
}
- if (processesRunning.count() == 0) {
+
+ // Get number of open tabs
+ const int openTabs = _viewManager->viewProperties().count();
+
+ // If no processes running (except the shell) and no extra tabs, just close
+ if (processesRunning.count() == 0 && openTabs < 2) {
return true;
}
@@ -562,19 +565,34 @@ bool MainWindow::queryClose()
if (isMinimized()) {
KWindowSystem::unminimizeWindow(winId(), true);
}
-
- int result = KMessageBox::warningYesNoCancelList(this,
- i18ncp("@info", "There is a process running in this window. "
- "Do you still want to quit?",
- "There are %1 processes running in this window. "
- "Do you still want to quit?",
- processesRunning.count()),
+ int result;
+
+ if (processesRunning.count() > 0) {
+ result = KMessageBox::warningYesNoCancelList(this,
+ i18ncp("@info", "There is a process running in this window. "
+ "Do you still want to quit?",
+ "There are %1 processes running in this window. "
+ "Do you still want to quit?",
+ processesRunning.count()),
processesRunning,
i18nc("@title", "Confirm Close"),
KGuiItem(i18nc("@action:button", "Close &Window"), QStringLiteral("window-close")),
KGuiItem(i18nc("@action:button", "Close Current &Tab"), QStringLiteral("tab-close")),
KStandardGuiItem::cancel(),
QStringLiteral("CloseAllTabs"));
+ } else {
+ result = KMessageBox::warningYesNoCancel(this,
+ i18nc("@info",
+ "There are %1 open tabs in this window. "
+ "Do you still want to quit?",
+ openTabs),
+ i18nc("@title", "Confirm Close"),
+ KGuiItem(i18nc("@action:button", "Close &Window"), QStringLiteral("window-close")),
+ KGuiItem(i18nc("@action:button", "Close Current &Tab"), QStringLiteral("tab-close")),
+ KStandardGuiItem::cancel(),
+ QStringLiteral("CloseAllEmptyTabs"));
+
+ }
switch (result) {
case KMessageBox::Yes: