aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-02-08 16:27:00 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-02-08 18:41:29 +0200
commit78189daac8d13870ab6ed8421b9ed067cf7ebac5 (patch)
tree5160257fb584ba5a4d41d711c16b8553aed7d6e3 /src/qt/bitcoingui.cpp
parent66afa286e519deda2fcfd580f190b7af13407e72 (diff)
downloadbitcoin-78189daac8d13870ab6ed8421b9ed067cf7ebac5.tar.xz
qt, refactor: Fill up trayIconMenu before connections
This change is required for the following commits.
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index dd3e1b41a7..1c497960cb 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -784,33 +784,16 @@ void BitcoinGUI::createTrayIcon()
void BitcoinGUI::createTrayIconMenu()
{
#ifndef Q_OS_MAC
- // return if trayIcon is unset (only on non-macOSes)
- if (!trayIcon)
- return;
-
- trayIcon->setContextMenu(trayIconMenu.get());
- connect(trayIcon, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) {
- if (reason == QSystemTrayIcon::Trigger) {
- // Click on system tray icon triggers show/hide of the main window
- toggleHidden();
- }
- });
-#else
- // Note: On macOS, the Dock icon is used to provide the tray's functionality.
- MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
- connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, [this] {
- show();
- activateWindow();
- });
- trayIconMenu->setAsDockMenu();
-#endif
+ if (!trayIcon) return;
+#endif // Q_OS_MAC
- // Configuration of the tray icon (or Dock icon) menu
+ // Configuration of the tray icon (or Dock icon) menu.
#ifndef Q_OS_MAC
// Note: On macOS, the Dock icon's menu already has Show / Hide action.
trayIconMenu->addAction(toggleHideAction);
trayIconMenu->addSeparator();
-#endif
+#endif // Q_OS_MAC
+
if (enableWallet) {
trayIconMenu->addAction(sendCoinsMenuAction);
trayIconMenu->addAction(receiveCoinsMenuAction);
@@ -821,10 +804,27 @@ void BitcoinGUI::createTrayIconMenu()
}
trayIconMenu->addAction(optionsAction);
trayIconMenu->addAction(openRPCConsoleAction);
-#ifndef Q_OS_MAC // This is built-in on macOS
+#ifndef Q_OS_MAC
+ // Note: On macOS, the Dock icon's menu already has Quit action.
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
-#endif
+
+ trayIcon->setContextMenu(trayIconMenu.get());
+ connect(trayIcon, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) {
+ if (reason == QSystemTrayIcon::Trigger) {
+ // Click on system tray icon triggers show/hide of the main window
+ toggleHidden();
+ }
+ });
+#else
+ // Note: On macOS, the Dock icon is used to provide the tray's functionality.
+ MacDockIconHandler* dockIconHandler = MacDockIconHandler::instance();
+ connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, [this] {
+ show();
+ activateWindow();
+ });
+ trayIconMenu->setAsDockMenu();
+#endif // Q_OS_MAC
}
void BitcoinGUI::optionsClicked()