From 8d6db27b3430543e6f262a566be0cbd0331a404e Mon Sep 17 00:00:00 2001 From: thez3ro Date: Thu, 11 May 2017 13:44:08 +0200 Subject: [PATCH] add tray icon to MacOS X --- src/gui/MainWindow.cpp | 15 +++------------ src/gui/SettingsWidget.cpp | 5 ----- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index c3ab306eb..4e25a9426 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -660,13 +660,7 @@ void MainWindow::databaseTabChanged(int tabIndex) void MainWindow::closeEvent(QCloseEvent* event) { - bool minimizeOnClose = config()->get("GUI/MinimizeOnClose").toBool(); -#ifndef Q_OS_MAC - // if we aren't on OS X, check if the tray is enabled. - // on OS X we are using the dock for the minimize action - minimizeOnClose = isTrayIconEnabled() && minimizeOnClose; -#endif - if (minimizeOnClose && !appExitCalled) + if (isTrayIconEnabled() && config()->get("GUI/MinimizeOnClose").toBool() && !appExitCalled) { event->ignore(); hideWindow(); @@ -836,7 +830,9 @@ void MainWindow::trayIconTriggered(QSystemTrayIcon::ActivationReason reason) void MainWindow::hideWindow() { +#ifndef Q_OS_MAC setWindowState(windowState() | Qt::WindowMinimized); +#endif QTimer::singleShot(0, this, SLOT(hide())); if (config()->get("security/lockdatabaseminimize").toBool()) { @@ -919,13 +915,8 @@ void MainWindow::repairDatabase() bool MainWindow::isTrayIconEnabled() const { -#ifdef Q_OS_MAC - // systray not useful on OS X - return false; -#else return config()->get("GUI/ShowTrayIcon").toBool() && QSystemTrayIcon::isSystemTrayAvailable(); -#endif } void MainWindow::displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton) diff --git a/src/gui/SettingsWidget.cpp b/src/gui/SettingsWidget.cpp index 716eb14f1..46910a5a3 100644 --- a/src/gui/SettingsWidget.cpp +++ b/src/gui/SettingsWidget.cpp @@ -66,11 +66,6 @@ SettingsWidget::SettingsWidget(QWidget* parent) m_generalUi->generalSettingsTabWidget->removeTab(1); } -#ifdef Q_OS_MAC - // systray not useful on OS X - m_generalUi->systraySettings->setVisible(false); -#endif - connect(this, SIGNAL(accepted()), SLOT(saveSettings())); connect(this, SIGNAL(rejected()), SLOT(reject()));