@@ -92,12 +92,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
92
92
windowTitle += tr (" Node" );
93
93
}
94
94
windowTitle += " " + networkStyle->getTitleAddText ();
95
- #ifndef Q_OS_MAC
96
95
QApplication::setWindowIcon (networkStyle->getTrayAndWindowIcon ());
97
96
setWindowIcon (networkStyle->getTrayAndWindowIcon ());
98
- #else
99
- MacDockIconHandler::instance ()->setIcon (networkStyle->getAppIcon ());
100
- #endif
101
97
setWindowTitle (windowTitle);
102
98
103
99
rpcConsole = new RPCConsole (node, _platformStyle, 0 );
@@ -278,17 +274,17 @@ void BitcoinGUI::createActions()
278
274
#ifdef ENABLE_WALLET
279
275
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
280
276
// can be triggered from the tray menu, and need to show the GUI to be useful.
281
- connect (overviewAction, &QAction::triggered, this , static_cast < void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized) );
277
+ connect (overviewAction, &QAction::triggered, [ this ]{ showNormalIfMinimized (); } );
282
278
connect (overviewAction, &QAction::triggered, this , &BitcoinGUI::gotoOverviewPage);
283
- connect (sendCoinsAction, &QAction::triggered, this , static_cast < void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized) );
279
+ connect (sendCoinsAction, &QAction::triggered, [ this ]{ showNormalIfMinimized (); } );
284
280
connect (sendCoinsAction, &QAction::triggered, [this ]{ gotoSendCoinsPage (); });
285
- connect (sendCoinsMenuAction, &QAction::triggered, this , static_cast < void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized) );
281
+ connect (sendCoinsMenuAction, &QAction::triggered, [ this ]{ showNormalIfMinimized (); } );
286
282
connect (sendCoinsMenuAction, &QAction::triggered, [this ]{ gotoSendCoinsPage (); });
287
- connect (receiveCoinsAction, &QAction::triggered, this , static_cast < void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized) );
283
+ connect (receiveCoinsAction, &QAction::triggered, [ this ]{ showNormalIfMinimized (); } );
288
284
connect (receiveCoinsAction, &QAction::triggered, this , &BitcoinGUI::gotoReceiveCoinsPage);
289
- connect (receiveCoinsMenuAction, &QAction::triggered, this , static_cast < void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized) );
285
+ connect (receiveCoinsMenuAction, &QAction::triggered, [ this ]{ showNormalIfMinimized (); } );
290
286
connect (receiveCoinsMenuAction, &QAction::triggered, this , &BitcoinGUI::gotoReceiveCoinsPage);
291
- connect (historyAction, &QAction::triggered, this , static_cast < void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized) );
287
+ connect (historyAction, &QAction::triggered, [ this ]{ showNormalIfMinimized (); } );
292
288
connect (historyAction, &QAction::triggered, this , &BitcoinGUI::gotoHistoryPage);
293
289
#endif // ENABLE_WALLET
294
290
@@ -355,7 +351,9 @@ void BitcoinGUI::createActions()
355
351
connect (encryptWalletAction, &QAction::triggered, walletFrame, &WalletFrame::encryptWallet);
356
352
connect (backupWalletAction, &QAction::triggered, walletFrame, &WalletFrame::backupWallet);
357
353
connect (changePassphraseAction, &QAction::triggered, walletFrame, &WalletFrame::changePassphrase);
354
+ connect (signMessageAction, &QAction::triggered, [this ]{ showNormalIfMinimized (); });
358
355
connect (signMessageAction, &QAction::triggered, [this ]{ gotoSignMessageTab (); });
356
+ connect (verifyMessageAction, &QAction::triggered, [this ]{ showNormalIfMinimized (); });
359
357
connect (verifyMessageAction, &QAction::triggered, [this ]{ gotoVerifyMessageTab (); });
360
358
connect (usedSendingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedSendingAddresses);
361
359
connect (usedReceivingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedReceivingAddresses);
@@ -604,7 +602,7 @@ void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
604
602
void BitcoinGUI::createTrayIconMenu ()
605
603
{
606
604
#ifndef Q_OS_MAC
607
- // return if trayIcon is unset (only on non-Mac OSes )
605
+ // return if trayIcon is unset (only on non-macOSes )
608
606
if (!trayIcon)
609
607
return ;
610
608
@@ -613,15 +611,17 @@ void BitcoinGUI::createTrayIconMenu()
613
611
614
612
connect (trayIcon, &QSystemTrayIcon::activated, this , &BitcoinGUI::trayIconActivated);
615
613
#else
616
- // Note: On Mac , the dock icon is used to provide the tray's functionality.
614
+ // Note: On macOS , the Dock icon is used to provide the tray's functionality.
617
615
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance ();
618
- dockIconHandler->setMainWindow (static_cast <QMainWindow*>(this ));
619
- trayIconMenu = dockIconHandler->dockMenu ();
616
+ connect (dockIconHandler, &MacDockIconHandler::dockIconClicked, this , &BitcoinGUI::macosDockIconActivated);
617
+
618
+ trayIconMenu = new QMenu (this );
619
+ trayIconMenu->setAsDockMenu ();
620
620
#endif
621
621
622
- // Configuration of the tray icon (or dock icon) icon menu
622
+ // Configuration of the tray icon (or Dock icon) menu
623
623
#ifndef Q_OS_MAC
624
- // Note: On Mac , the dock icon's menu already has show / hide action.
624
+ // Note: On macOS , the Dock icon's menu already has Show / Hide action.
625
625
trayIconMenu->addAction (toggleHideAction);
626
626
trayIconMenu->addSeparator ();
627
627
#endif
@@ -635,7 +635,7 @@ void BitcoinGUI::createTrayIconMenu()
635
635
trayIconMenu->addAction (openRPCConsoleAction);
636
636
}
637
637
trayIconMenu->addAction (optionsAction);
638
- #ifndef Q_OS_MAC // This is built-in on Mac
638
+ #ifndef Q_OS_MAC // This is built-in on macOS
639
639
trayIconMenu->addSeparator ();
640
640
trayIconMenu->addAction (quitAction);
641
641
#endif
@@ -650,6 +650,12 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
650
650
toggleHidden ();
651
651
}
652
652
}
653
+ #else
654
+ void BitcoinGUI::macosDockIconActivated ()
655
+ {
656
+ show ();
657
+ activateWindow ();
658
+ }
653
659
#endif
654
660
655
661
void BitcoinGUI::optionsClicked ()
@@ -668,10 +674,7 @@ void BitcoinGUI::aboutClicked()
668
674
669
675
void BitcoinGUI::showDebugWindow ()
670
676
{
671
- rpcConsole->showNormal ();
672
- rpcConsole->show ();
673
- rpcConsole->raise ();
674
- rpcConsole->activateWindow ();
677
+ GUIUtil::bringToFront (rpcConsole);
675
678
}
676
679
677
680
void BitcoinGUI::showDebugWindowActivateConsole ()
@@ -1158,24 +1161,11 @@ void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
1158
1161
if (!clientModel)
1159
1162
return ;
1160
1163
1161
- // activateWindow() (sometimes) helps with keyboard focus on Windows
1162
- if (isHidden ())
1163
- {
1164
- show ();
1165
- activateWindow ();
1166
- }
1167
- else if (isMinimized ())
1168
- {
1169
- showNormal ();
1170
- activateWindow ();
1171
- }
1172
- else if (GUIUtil::isObscured (this ))
1173
- {
1174
- raise ();
1175
- activateWindow ();
1176
- }
1177
- else if (fToggleHidden )
1164
+ if (!isHidden () && !isMinimized () && !GUIUtil::isObscured (this ) && fToggleHidden ) {
1178
1165
hide ();
1166
+ } else {
1167
+ GUIUtil::bringToFront (this );
1168
+ }
1179
1169
}
1180
1170
1181
1171
void BitcoinGUI::toggleHidden ()
0 commit comments