Skip to content

Commit 304df16

Browse files
hebastoUdjinM6
authored andcommitted
qt: Make show_hide_action dependent on the main window actual state
1 parent b56ed8a commit 304df16

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
@@ -1038,7 +1038,7 @@ void BitcoinGUI::createIconMenu(QMenu *pmenu)
10381038
QAction* show_hide_action{nullptr};
10391039
#ifndef Q_OS_MAC
10401040
// Note: On macOS, the Dock icon is used to provide the tray's functionality.
1041-
show_hide_action = pmenu->addAction(tr("Show / &Hide"), this, &BitcoinGUI::toggleHidden);
1041+
show_hide_action = pmenu->addAction(QString(), this, &BitcoinGUI::toggleHidden);
10421042
pmenu->addSeparator();
10431043
#endif // Q_OS_MAC
10441044

@@ -1069,6 +1069,17 @@ void BitcoinGUI::createIconMenu(QMenu *pmenu)
10691069
pmenu->addSeparator();
10701070
pmenu->addAction(quitAction);
10711071
#endif // Q_OS_MAC
1072+
1073+
connect(
1074+
// Using QSystemTrayIcon::Context is not reliable.
1075+
// See https://bugreports.qt.io/browse/QTBUG-91697
1076+
pmenu, &QMenu::aboutToShow,
1077+
[this, show_hide_action] {
1078+
if (show_hide_action) show_hide_action->setText(
1079+
(!isHidden() && !isMinimized() && !GUIUtil::isObscured(this)) ?
1080+
tr("&Hide") :
1081+
tr("S&how"));
1082+
});
10721083
}
10731084

10741085
void BitcoinGUI::optionsClicked()

0 commit comments

Comments
 (0)