Add an option to display a tray icon.

Also implement "Minimize to tray" functionality.
This commit is contained in:
Felix Geyer 2014-11-02 10:15:44 +01:00
parent 870d7355ca
commit 4cdb9a645d
6 changed files with 111 additions and 1 deletions

View file

@ -20,6 +20,7 @@
#include <QActionGroup>
#include <QMainWindow>
#include <QSystemTrayIcon>
#include "core/SignalMultiplexer.h"
#include "gui/DatabaseWidget.h"
@ -44,6 +45,7 @@ public Q_SLOTS:
protected:
void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
private Q_SLOTS:
void setMenuActionState(DatabaseWidget::Mode mode = DatabaseWidget::None);
@ -61,6 +63,8 @@ private Q_SLOTS:
void saveToolbarState(bool value);
void rememberOpenDatabases(const QString& filePath);
void applySettingsChanges();
void trayIconTriggered(QSystemTrayIcon::ActivationReason reason);
void toggleWindow();
private:
static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);
@ -69,6 +73,8 @@ private:
void saveWindowInformation();
bool saveLastDatabases();
void updateTrayIcon();
bool isTrayIconEnabled() const;
const QScopedPointer<Ui::MainWindow> m_ui;
SignalMultiplexer m_actionMultiplexer;
@ -78,6 +84,7 @@ private:
QStringList m_openDatabases;
InactivityTimer* m_inactivityTimer;
int m_countDefaultAttributes;
QSystemTrayIcon* m_trayIcon;
Q_DISABLE_COPY(MainWindow)
};