Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add trayicon on macOS and enable minimize onClose #583

Merged
merged 6 commits into from
May 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,10 +759,17 @@ void MainWindow::updateTrayIcon()
QAction* actionToggle = new QAction(tr("Toggle window"), menu);
menu->addAction(actionToggle);

#ifdef Q_OS_MAC
QAction* actionQuit = new QAction(tr("Quit KeePassXC"), menu);
menu->addAction(actionQuit);

connect(actionQuit, SIGNAL(triggered()), SLOT(appExit()));
#else
menu->addAction(m_ui->actionQuit);

connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
SLOT(trayIconTriggered(QSystemTrayIcon::ActivationReason)));
#endif
connect(actionToggle, SIGNAL(triggered()), SLOT(toggleWindow()));

m_trayIcon->setContextMenu(menu);
Expand Down Expand Up @@ -842,7 +849,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()) {
Expand Down Expand Up @@ -925,13 +934,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)
Expand Down
5 changes: 0 additions & 5 deletions src/gui/SettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down