From e2bd010b1965da573dd2610e811e0039c8bc676c Mon Sep 17 00:00:00 2001 From: shenleban tongying Date: Thu, 29 Dec 2022 11:36:01 -0500 Subject: [PATCH] fix: Unsatisfactory "Close To Tray" behavior on macOS --- mainwindow.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mainwindow.cc b/mainwindow.cc index e93a6bc1..5cae5c1b 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -2922,10 +2922,23 @@ void MainWindow::toggleMainWindow( bool onlyShow ) else if ( !onlyShow ) { + +// On Windows and Linux, a hidden window won't show a task bar icon +// When trayicon is enabled, the duplication is unneeded + +// On macOS, a hidden window will still show on the Dock, +// but click it won't bring it back, thus we can only minimize it. + +#ifdef Q_OS_MAC + if (cfg.preferences.enableTrayIcon) + showMinimized(); +#else if (cfg.preferences.enableTrayIcon) - hide(); + hide(); else - showMinimized(); + showMinimized(); +#endif + if( headwordsDlg ) headwordsDlg->hide();