From 66afa286e519deda2fcfd580f190b7af13407e72 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Tue, 8 Feb 2022 16:21:45 +0200 Subject: [PATCH] qt, refactor: Replace BitcoinGUI::trayIconActivated with a lambda --- src/qt/bitcoingui.cpp | 18 ++++++------------ src/qt/bitcoingui.h | 4 ---- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index ca351060fd4..dd3e1b41a78 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -789,7 +789,12 @@ void BitcoinGUI::createTrayIconMenu() return; trayIcon->setContextMenu(trayIconMenu.get()); - connect(trayIcon, &QSystemTrayIcon::activated, this, &BitcoinGUI::trayIconActivated); + 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(); @@ -822,17 +827,6 @@ void BitcoinGUI::createTrayIconMenu() #endif } -#ifndef Q_OS_MAC -void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) -{ - if(reason == QSystemTrayIcon::Trigger) - { - // Click on system tray icon triggers show/hide of the main window - toggleHidden(); - } -} -#endif - void BitcoinGUI::optionsClicked() { openOptionsDialogWithTab(OptionsDialog::TAB_MAIN); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index ae9cb9f11d4..896c4c52c66 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -302,10 +302,6 @@ public Q_SLOTS: void showDebugWindowActivateConsole(); /** Show help message dialog */ void showHelpMessageClicked(); -#ifndef Q_OS_MAC - /** Handle tray icon clicked */ - void trayIconActivated(QSystemTrayIcon::ActivationReason reason); -#endif /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */ void showNormalIfMinimized() { showNormalIfMinimized(false); }