mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
macOS: disable minimizing to system tray
In macOS, there is a "Quit" menu item in the Dock context menu. We can't not distinguish it from the close button in the title bar. For now, we just disable the ability to being minimized to system tray.
This commit is contained in:
parent
98ef7c2cfa
commit
b47982ab25
@ -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()
|
||||
{
|
||||
if (m_systemTray->isEnabled()) {
|
||||
vconfig.setMinimizeToSystemTray(m_systemTray->isChecked() ? 1 : 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user