add tray icon to MacOS X

This commit is contained in:
thez3ro 2017-05-11 13:44:08 +02:00
parent b3160a17ea
commit 8d6db27b34
No known key found for this signature in database
GPG Key ID: F628F9E41DD7C073
2 changed files with 3 additions and 17 deletions

View File

@ -660,13 +660,7 @@ void MainWindow::databaseTabChanged(int tabIndex)
void MainWindow::closeEvent(QCloseEvent* event) void MainWindow::closeEvent(QCloseEvent* event)
{ {
bool minimizeOnClose = config()->get("GUI/MinimizeOnClose").toBool(); if (isTrayIconEnabled() && config()->get("GUI/MinimizeOnClose").toBool() && !appExitCalled)
#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)
{ {
event->ignore(); event->ignore();
hideWindow(); hideWindow();
@ -836,7 +830,9 @@ void MainWindow::trayIconTriggered(QSystemTrayIcon::ActivationReason reason)
void MainWindow::hideWindow() void MainWindow::hideWindow()
{ {
#ifndef Q_OS_MAC
setWindowState(windowState() | Qt::WindowMinimized); setWindowState(windowState() | Qt::WindowMinimized);
#endif
QTimer::singleShot(0, this, SLOT(hide())); QTimer::singleShot(0, this, SLOT(hide()));
if (config()->get("security/lockdatabaseminimize").toBool()) { if (config()->get("security/lockdatabaseminimize").toBool()) {
@ -919,13 +915,8 @@ void MainWindow::repairDatabase()
bool MainWindow::isTrayIconEnabled() const bool MainWindow::isTrayIconEnabled() const
{ {
#ifdef Q_OS_MAC
// systray not useful on OS X
return false;
#else
return config()->get("GUI/ShowTrayIcon").toBool() return config()->get("GUI/ShowTrayIcon").toBool()
&& QSystemTrayIcon::isSystemTrayAvailable(); && QSystemTrayIcon::isSystemTrayAvailable();
#endif
} }
void MainWindow::displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton) void MainWindow::displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton)

View File

@ -66,11 +66,6 @@ SettingsWidget::SettingsWidget(QWidget* parent)
m_generalUi->generalSettingsTabWidget->removeTab(1); 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(accepted()), SLOT(saveSettings()));
connect(this, SIGNAL(rejected()), SLOT(reject())); connect(this, SIGNAL(rejected()), SLOT(reject()));