Skip to content

Commit 78189da

Browse files
committed
qt, refactor: Fill up trayIconMenu before connections
This change is required for the following commits.
1 parent 66afa28 commit 78189da

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/qt/bitcoingui.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -784,33 +784,16 @@ void BitcoinGUI::createTrayIcon()
784784
void BitcoinGUI::createTrayIconMenu()
785785
{
786786
#ifndef Q_OS_MAC
787-
// return if trayIcon is unset (only on non-macOSes)
788-
if (!trayIcon)
789-
return;
790-
791-
trayIcon->setContextMenu(trayIconMenu.get());
792-
connect(trayIcon, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) {
793-
if (reason == QSystemTrayIcon::Trigger) {
794-
// Click on system tray icon triggers show/hide of the main window
795-
toggleHidden();
796-
}
797-
});
798-
#else
799-
// Note: On macOS, the Dock icon is used to provide the tray's functionality.
800-
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
801-
connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, [this] {
802-
show();
803-
activateWindow();
804-
});
805-
trayIconMenu->setAsDockMenu();
806-
#endif
787+
if (!trayIcon) return;
788+
#endif // Q_OS_MAC
807789

808-
// Configuration of the tray icon (or Dock icon) menu
790+
// Configuration of the tray icon (or Dock icon) menu.
809791
#ifndef Q_OS_MAC
810792
// Note: On macOS, the Dock icon's menu already has Show / Hide action.
811793
trayIconMenu->addAction(toggleHideAction);
812794
trayIconMenu->addSeparator();
813-
#endif
795+
#endif // Q_OS_MAC
796+
814797
if (enableWallet) {
815798
trayIconMenu->addAction(sendCoinsMenuAction);
816799
trayIconMenu->addAction(receiveCoinsMenuAction);
@@ -821,10 +804,27 @@ void BitcoinGUI::createTrayIconMenu()
821804
}
822805
trayIconMenu->addAction(optionsAction);
823806
trayIconMenu->addAction(openRPCConsoleAction);
824-
#ifndef Q_OS_MAC // This is built-in on macOS
807+
#ifndef Q_OS_MAC
808+
// Note: On macOS, the Dock icon's menu already has Quit action.
825809
trayIconMenu->addSeparator();
826810
trayIconMenu->addAction(quitAction);
827-
#endif
811+
812+
trayIcon->setContextMenu(trayIconMenu.get());
813+
connect(trayIcon, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) {
814+
if (reason == QSystemTrayIcon::Trigger) {
815+
// Click on system tray icon triggers show/hide of the main window
816+
toggleHidden();
817+
}
818+
});
819+
#else
820+
// Note: On macOS, the Dock icon is used to provide the tray's functionality.
821+
MacDockIconHandler* dockIconHandler = MacDockIconHandler::instance();
822+
connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, [this] {
823+
show();
824+
activateWindow();
825+
});
826+
trayIconMenu->setAsDockMenu();
827+
#endif // Q_OS_MAC
828828
}
829829

830830
void BitcoinGUI::optionsClicked()

0 commit comments

Comments
 (0)