Skip to content

Commit

Permalink
Merge pull request #583 from keepassxreboot/feature/macos-minimize-on…
Browse files Browse the repository at this point in the history
…close

Add trayicon on macOS and enable minimize onClose
  • Loading branch information
phoerious authored May 19, 2017
2 parents aa64b2e + 379e17c commit 6c050c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
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

0 comments on commit 6c050c5

Please # to comment.