Properly save and restore the mainwindow state
[quassel.git] / src / qtui / mainwin.h
index 000e570..13b5466 100644 (file)
 #  include <QMainWindow>
 #endif
 
+#ifdef Q_WS_WIN
+#  include <windows.h>
+#endif
+
 #include <QSystemTrayIcon>
 
 #include "qtui.h"
-#include "sessionsettings.h"
 #include "titlesetter.h"
+#include "uisettings.h"
 
 class ActionCollection;
 class BufferView;
@@ -70,19 +74,29 @@ class MainWin
 
     inline SystemTray *systemTray() const;
 
-    virtual bool event(QEvent *event);
+    bool event(QEvent *event);
 
     static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
     static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
 
+    void saveStateToSettings(UiSettings &);
+    void restoreStateFromSettings(UiSettings &);
+
   public slots:
     void saveStateToSession(const QString &sessionId);
     void saveStateToSessionSettings(SessionSettings &s);
     void showStatusBarMessage(const QString &message);
 
+    void toggleMinimizedToTray();
+
+    //! Bring window to front and focus it
+    void forceActivated();
+
   protected:
     void closeEvent(QCloseEvent *event);
-    virtual void changeEvent(QEvent *event);
+    void changeEvent(QEvent *event);
+    void moveEvent(QMoveEvent *event);
+    void resizeEvent(QResizeEvent *event);
 
   protected slots:
     void connectedToCore();
@@ -90,7 +104,6 @@ class MainWin
     void updateLagIndicator(int lag = -1);
     void disconnectedFromCore();
     void setDisconnectedState();
-    void systrayActivated(QSystemTrayIcon::ActivationReason);
 
   private slots:
     void addBufferView(int bufferViewConfigId);
@@ -112,6 +125,7 @@ class MainWin
     void on_actionConfigureViews_triggered();
     void on_actionLockLayout_toggled(bool lock);
     void on_actionDebugNetworkModel_triggered();
+    void on_actionDebugBufferViewOverlay_triggered();
     void on_actionDebugMessageModel_triggered();
     void on_actionDebugLog_triggered();
 
@@ -121,10 +135,13 @@ class MainWin
     void connectOrDisconnectFromNet();
 
     void saveStatusBarStatus(bool enabled);
+    void aboutToQuit();
 
     void loadLayout();
     void saveLayout();
 
+    void bufferViewToggled(bool enabled);
+
   signals:
     void connectToCore(const QVariantMap &connInfo);
     void disconnectFromCore();
@@ -153,10 +170,10 @@ class MainWin
     void setupToolBars();
 
     void updateIcon();
-    void hideToTray();
-    void toggleMinimizedToTray();
     void enableMenus();
 
+    void hideToTray();
+
     SystemTray *_systemTray;
 
     QList<BufferViewDock *> _bufferViews;
@@ -169,6 +186,15 @@ class MainWin
     QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
 
     QWidget *_awayLog;
+
+    QSize _normalSize; //!< Size of the non-maximized window
+    QPoint _normalPos; //!< Position of the non-maximized window
+    bool _isHidden;
+
+#ifdef Q_WS_WIN
+    DWORD dwTickCount;
+#endif
+
     friend class QtUi;
 };