diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-02-08 16:31:43 +0200 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-02-08 18:41:41 +0200 |
commit | fd667e73cd109bbfc14011f8c2c08556648b4c50 (patch) | |
tree | 36f7f32b487e3d6d4b7079dc758665add6258b20 | |
parent | ee151d032789fa03daa44ab44dd0fd70e51b145c (diff) |
qt: Make show_hide_action dependent on the main window actual state
-rw-r--r-- | src/qt/bitcoingui.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index ea976302ab..90925b643c 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -786,7 +786,7 @@ void BitcoinGUI::createTrayIconMenu() QAction* show_hide_action{nullptr}; #ifndef Q_OS_MAC // Note: On macOS, the Dock icon's menu already has Show / Hide action. - show_hide_action = trayIconMenu->addAction(tr("Show / &Hide"), this, &BitcoinGUI::toggleHidden); + show_hide_action = trayIconMenu->addAction(QString(), this, &BitcoinGUI::toggleHidden); trayIconMenu->addSeparator(); #endif // Q_OS_MAC @@ -821,6 +821,17 @@ void BitcoinGUI::createTrayIconMenu() }); trayIconMenu->setAsDockMenu(); #endif // Q_OS_MAC + + connect( + // Using QSystemTrayIcon::Context is not reliable. + // See https://bugreports.qt.io/browse/QTBUG-91697 + trayIconMenu.get(), &QMenu::aboutToShow, + [this, show_hide_action] { + if (show_hide_action) show_hide_action->setText( + (!isHidden() && !isMinimized() && !GUIUtil::isObscured(this)) ? + tr("&Hide") : + tr("S&how")); + }); } void BitcoinGUI::optionsClicked() |