Skip to content

Commit fd667e7

Browse files
committed
qt: Make show_hide_action dependent on the main window actual state
1 parent ee151d0 commit fd667e7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/qt/bitcoingui.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ void BitcoinGUI::createTrayIconMenu()
786786
QAction* show_hide_action{nullptr};
787787
#ifndef Q_OS_MAC
788788
// Note: On macOS, the Dock icon's menu already has Show / Hide action.
789-
show_hide_action = trayIconMenu->addAction(tr("Show / &Hide"), this, &BitcoinGUI::toggleHidden);
789+
show_hide_action = trayIconMenu->addAction(QString(), this, &BitcoinGUI::toggleHidden);
790790
trayIconMenu->addSeparator();
791791
#endif // Q_OS_MAC
792792

@@ -821,6 +821,17 @@ void BitcoinGUI::createTrayIconMenu()
821821
});
822822
trayIconMenu->setAsDockMenu();
823823
#endif // Q_OS_MAC
824+
825+
connect(
826+
// Using QSystemTrayIcon::Context is not reliable.
827+
// See https://bugreports.qt.io/browse/QTBUG-91697
828+
trayIconMenu.get(), &QMenu::aboutToShow,
829+
[this, show_hide_action] {
830+
if (show_hide_action) show_hide_action->setText(
831+
(!isHidden() && !isMinimized() && !GUIUtil::isObscured(this)) ?
832+
tr("&Hide") :
833+
tr("S&how"));
834+
});
824835
}
825836

826837
void BitcoinGUI::optionsClicked()

0 commit comments

Comments
 (0)