diff --git a/src/dialog/vsettingsdialog.cpp b/src/dialog/vsettingsdialog.cpp index 275abb19..29498061 100644 --- a/src/dialog/vsettingsdialog.cpp +++ b/src/dialog/vsettingsdialog.cpp @@ -122,7 +122,12 @@ VGeneralTab::VGeneralTab(QWidget *p_parent) // System tray checkbox. m_systemTray = new QCheckBox(this); - m_systemTray->setToolTip(tr("Minimized to the system tray after closing VNote")); + m_systemTray->setToolTip(tr("Minimized to the system tray after closing VNote" + " (not supported in macOS)")); +#if defined(Q_OS_MACOS) || defined(Q_OS_MAC) + // Do not support minimized to tray on macOS. + m_systemTray->setEnabled(false); +#endif QLabel *trayLabel = new QLabel(tr("System tray:"), this); trayLabel->setToolTip(m_systemTray->toolTip()); @@ -203,7 +208,10 @@ bool VGeneralTab::loadSystemTray() bool VGeneralTab::saveSystemTray() { - vconfig.setMinimizeToSystemTray(m_systemTray->isChecked() ? 1 : 0); + if (m_systemTray->isEnabled()) { + vconfig.setMinimizeToSystemTray(m_systemTray->isChecked() ? 1 : 0); + } + return true; } diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index 34a0ba56..ce31e733 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -1576,6 +1576,11 @@ void VMainWindow::closeEvent(QCloseEvent *event) bool isExit = m_requestQuit || !vconfig.getMinimizeToStystemTray(); m_requestQuit = false; +#if defined(Q_OS_MACOS) || defined(Q_OS_MAC) + // Do not support minimized to tray on macOS. + isExit = true; +#endif + if (!isExit && vconfig.getMinimizeToStystemTray() == -1) { // Not initialized yet. Prompt for user. int ret = VUtils::showMessage(QMessageBox::Information, @@ -2030,6 +2035,8 @@ void VMainWindow::showMainWindow() } } else { this->show(); + // Need to call raise() in macOS. + this->raise(); } this->activateWindow();