]> git.lyx.org Git - features.git/commitdiff
New 'Save all on shutdown or cancel' feature from Stephan Witt.
authorAbdelrazak Younes <younes@lyx.org>
Mon, 27 Aug 2007 06:35:24 +0000 (06:35 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 27 Aug 2007 06:35:24 +0000 (06:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19824 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h

index aaf7add1170615015cd53c8d87056b8be272b8ec..a4a9df859f721cb1355c2f87d8021f753dadb2a8 100644 (file)
@@ -27,6 +27,7 @@
 #include "support/os.h"
 #include "support/Package.h"
 
+#include "BufferList.h"
 #include "BufferView.h"
 #include "Color.h"
 #include "debug.h"
@@ -43,6 +44,7 @@
 #include <QLocale>
 #include <QLibraryInfo>
 #include <QPixmapCache>
+#include <QSessionManager>
 #include <QTextCodec>
 #include <QTimer>
 #include <QTranslator>
@@ -318,6 +320,20 @@ void GuiApplication::unregisterSocketCallback(int fd)
        socket_callbacks_.erase(fd);
 }
 
+
+void GuiApplication::commitData(QSessionManager & sm)
+{
+       /// The implementation is required to avoid an application exit
+       /// when session state save is triggered by session manager.
+       /// The default implementation sends a close event to all
+       /// visible top level widgets when session managment allows
+       /// interaction.
+       /// We are changing that to write all unsaved buffers...
+       if (sm.allowsInteraction() && !theBufferList().quitWriteAll())
+               sm.cancel();
+}
+
+
 ////////////////////////////////////////////////////////////////////////
 // X11 specific stuff goes here...
 #ifdef Q_WS_X11
index ba0b4c2d72505b57e670a5fb8d5ca51e530b89d1..954c48e06470ba269963f66c2e63cf464fba2341 100644 (file)
@@ -26,6 +26,8 @@
 #include <QApplication>
 #include <QTranslator>
 
+class QSessionManager;
+
 namespace lyx {
 
 class BufferView;
@@ -74,9 +76,10 @@ public:
        void unregisterSocketCallback(int fd);
        //@}
 
-       /// Methods inherited from \c Application class
+       /// Methods inherited from \c QApplication class
        //@{
-       virtual bool notify(QObject * receiver, QEvent * event);
+       bool notify(QObject * receiver, QEvent * event);
+       void commitData(QSessionManager & sm);
        //@}
 
        ///