From c0922a81d88affaded8b8ff22b8671eedecf900c Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Thu, 13 Aug 2009 18:54:16 +0000 Subject: [PATCH] Do not warn the user about closing Dolphin windows with multiple tabs if Dolphin is closed by the session manager, i.e., if the user logs out. The fix is inspired by the way this issue is handled in Konqueror. BUG: 201803 svn path=/trunk/KDE/kdebase/apps/; revision=1011002 --- src/dolphinapplication.cpp | 13 ++++++++++++- src/dolphinapplication.h | 17 +++++++++++++++++ src/dolphinmainwindow.cpp | 10 +++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/dolphinapplication.cpp b/src/dolphinapplication.cpp index f61bf795a..988019de1 100644 --- a/src/dolphinapplication.cpp +++ b/src/dolphinapplication.cpp @@ -28,7 +28,7 @@ #include DolphinApplication::DolphinApplication() : - m_lastId(0) + m_lastId(0), m_closedBySessionManager(false) { new ApplicationAdaptor(this); QDBusConnection::sessionBus().registerObject("/dolphin/Application", this); @@ -100,6 +100,17 @@ int DolphinApplication::newInstance() return 0; } +bool DolphinApplication::closedBySessionManager() const +{ + return m_closedBySessionManager; +} + +void DolphinApplication::commitData(QSessionManager& sessionManager) { + m_closedBySessionManager = true; + KUniqueApplication::commitData(sessionManager); + m_closedBySessionManager = false; +} + int DolphinApplication::openWindow(const KUrl& url) { DolphinMainWindow* win = createMainWindow(); diff --git a/src/dolphinapplication.h b/src/dolphinapplication.h index af2006e7d..4c6544361 100644 --- a/src/dolphinapplication.h +++ b/src/dolphinapplication.h @@ -56,6 +56,20 @@ public: /** @see KUniqueApplication::newInstance(). */ virtual int newInstance(); + /** + * Find out if Dolphin is closed directly by the user or + * by the session manager because the session is closed + */ + bool closedBySessionManager() const; + + /** + * This virtual function is called by the session manager when + * it closes Dolphin. It is reimplemented to make the information + * if Dolphin is closed by the session manager or not accessible in + * DolphinMainWindow (via the function closedBySessionManager()). + */ + virtual void commitData(QSessionManager& sessionManager); + public slots: int openWindow(const KUrl& url); int openSplitWindow(const KUrl& leftUrl,const KUrl& rightUrl); @@ -67,6 +81,9 @@ protected: private: QList m_mainWindows; int m_lastId; + + /** Is true if Dolphin is closed by the session manager **/ + bool m_closedBySessionManager; }; #endif diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index bf39db15d..6443494ef 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -426,7 +426,15 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) DolphinSettings& settings = DolphinSettings::instance(); GeneralSettings* generalSettings = settings.generalSettings(); - if ((m_viewTab.count() > 1) && generalSettings->confirmClosingMultipleTabs()) { + // Find out if Dolphin is closed directly by the user or + // by the session manager because the session is closed + bool closedByUser = true; + DolphinApplication *application = qobject_cast(qApp); + if (application && application->closedBySessionManager()) { + closedByUser = false; + } + + if ((m_viewTab.count() > 1) && generalSettings->confirmClosingMultipleTabs() && closedByUser) { // Ask the user if he really wants to quit and close all tabs. // Open a confirmation dialog with 3 buttons: // KDialog::Yes -> Quit -- 2.47.3