diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-04-13 18:53:30 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-04-13 18:53:30 +0200 |
commit | 88855cf4570f1c9b39fdc5957a551d37d4835011 (patch) | |
tree | b76dcce8be4c8d0843fcc07946e5875c056f9d2f /src/mainwindow.cpp | |
parent | updated TODO (diff) | |
download | rekonq-88855cf4570f1c9b39fdc5957a551d37d4835011.tar.xz |
dolphin && konqueror -like exit confirmation dialog
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0fdd538e..809a209e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -50,6 +50,7 @@ #include <KFileDialog> #include <KMenu> #include <KGlobalSettings> +#include <KPushButton> // Qt Includes @@ -791,16 +792,52 @@ void MainWindow::slotShowMenubar(bool enable) bool MainWindow::queryClose() { + KConfig config("rekonqrc"); + KConfigGroup group = config.group("Hand Settings"); + bool doNotAskAgainResult = group.readEntry("ExitConfirmationDialog", false); + + if(doNotAskAgainResult) + return true; + if (m_view->count() > 1) { - int ret = KMessageBox::warningYesNo(this, - i18n("Are you sure you want to close the window?\nThere are %1 tab open" , m_view->count() ), - i18n("Closing") - ); - if (ret == KMessageBox::No) + KDialog *dialog = new KDialog(this, Qt::Dialog); + dialog->setCaption( i18n("Closing") ); + dialog->setButtons(KDialog::Yes | KDialog::No | KDialog::Cancel ); + dialog->setModal(true); + dialog->showButtonSeparator(true); + dialog->setButtonGuiItem(KDialog::Yes, KStandardGuiItem::quit()); + dialog->setButtonGuiItem(KDialog::No, KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close"))); + dialog->setButtonGuiItem(KDialog::Cancel, KStandardGuiItem::cancel()); + dialog->setDefaultButton(KDialog::Yes); + + int ret = KMessageBox::createKMessageBox( dialog, + QMessageBox::Warning, + i18n("Are you sure you want to close the window?\nThere are %1 tab open" , m_view->count() ), + QStringList(), + i18n("Do not ask again"), + &doNotAskAgainResult, + KMessageBox::Notify + ); + + if (doNotAskAgainResult) { - return false; + group.writeEntry("ExitConfirmationDialog", true); + } + + switch (ret) + { + case KDialog::Yes: + // Quit + return true; + break; + case KDialog::No: + // Close only the current tab + m_view->slotCloseTab(); + default: + return false; } } + return true; -} +}
\ No newline at end of file |