┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinmainwindow.cpp
diff options
context:
space:
mode:
authorNate Graham <[email protected]>2019-01-19 08:11:26 -0700
committerNate Graham <[email protected]>2019-01-19 08:15:11 -0700
commit2100a7a5c85931d46b72d391faa3d136d4401010 (patch)
tree2ca5faa610a36fd431f9db20879eb2072e36ad84 /src/dolphinmainwindow.cpp
parent784734ca16803f5109e6268d1afc6c4f33d41def (diff)
Ask for confirmation when Closing Dolphin windows with a terminal panel running a program
Summary: Ask for confirmation when Closing Dolphin windows with a terminal panel running a program. FEATURE: 304816 FIXED-IN: 19.04.0 Test Plan: # Open terminal panel # Run `watch ls` # Close Dolphin # Observe confirmation # Disable confirmation # Repeat, observe no confirmation # Enable confirmation in the settings # Repeat, observe a confirmation Reviewers: #dolphin, markg, elvisangelaccio, rominf Reviewed By: #dolphin, elvisangelaccio Subscribers: kfm-devel, elvisangelaccio, markg, ngraham, rkflx, broulik, #dolphin Tags: #dolphin Differential Revision: https://phabricator.kde.org/D10960
Diffstat (limited to 'src/dolphinmainwindow.cpp')
-rw-r--r--src/dolphinmainwindow.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index ae586bc34..ea19468f9 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -407,7 +407,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
bool doNotAskAgainCheckboxResult = false;
- const int result = KMessageBox::createKMessageBox(dialog,
+ const auto result = KMessageBox::createKMessageBox(dialog,
buttons,
QMessageBox::Warning,
i18n("You have multiple tabs open in this window, are you sure you want to quit?"),
@@ -434,6 +434,58 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
}
}
+ if (m_terminalPanel->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser) {
+ // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel
+ // Open a confirmation dialog with 3 buttons:
+ // QDialogButtonBox::Yes -> Quit
+ // QDialogButtonBox::No -> Show Terminal Panel
+ // QDialogButtonBox::Cancel -> do nothing
+ QDialog *dialog = new QDialog(this, Qt::Dialog);
+ dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
+ dialog->setModal(true);
+ auto standardButtons = QDialogButtonBox::Yes | QDialogButtonBox::Cancel;
+ if (!m_terminalPanel->isVisible()) {
+ standardButtons |= QDialogButtonBox::No;
+ }
+ QDialogButtonBox *buttons = new QDialogButtonBox(standardButtons);
+ KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KStandardGuiItem::quit());
+ if (!m_terminalPanel->isVisible()) {
+ KGuiItem::assign(
+ buttons->button(QDialogButtonBox::No),
+ KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("utilities-terminal"))));
+ }
+ KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
+
+ bool doNotAskAgainCheckboxResult = false;
+
+ const auto result = KMessageBox::createKMessageBox(
+ dialog,
+ buttons,
+ QMessageBox::Warning,
+ i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel->runningProgramName()),
+ QStringList(),
+ i18n("Do not ask again"),
+ &doNotAskAgainCheckboxResult,
+ KMessageBox::Dangerous);
+
+ if (doNotAskAgainCheckboxResult) {
+ GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
+ }
+
+ switch (result) {
+ case QDialogButtonBox::Yes:
+ // Quit
+ break;
+ case QDialogButtonBox::No:
+ actionCollection()->action("show_terminal_panel")->trigger();
+ // Do not quit, ignore quit event
+ Q_FALLTHROUGH();
+ default:
+ event->ignore();
+ return;
+ }
+ }
+
GeneralSettings::setVersion(CurrentDolphinVersion);
GeneralSettings::self()->save();