Merge #14123: gui: Add GUIUtil::bringToFront
0a656f85a9qt: All tray menu actions call showNormalIfMinimized (João Barbosa)6fc21aca6dqt: Use GUIUtil::bringToFront where possible (João Barbosa)5796671e1dqt: Add GUIUtil::bringToFront (João Barbosa)6b1d2972bfRemove obj_c for macOS Dock icon menu (Hennadii Stepanov)2464925e7bUse Qt signal for macOS Dock icon click event (Hennadii Stepanov)53bb6be3f8Remove obj_c for macOS Dock icon setting (Hennadii Stepanov) Pull request description: The sequence `show -> raise -> activateWindow` is factored out to the new function `GUIUtil::bringToFront` where a macOS fix is added in order to fix #13829. Also included: - simplification of `BitcoinGUI::showNormalIfMinimized` - simplified some connections to `BitcoinGUI::showNormalIfMinimized` - added missing connections to `BitcoinGUI::showNormalIfMinimized`. Tree-SHA512: a8e301aebc359aa353821e2af352ae356f44555724921b01da907e128653ef9dc55d8764a1bff72a579e5ff96df8a681f6804bfe83acba441da92fedff974a55
This commit is contained in:
+28
-38
@@ -92,12 +92,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
|
||||
windowTitle += tr("Node");
|
||||
}
|
||||
windowTitle += " " + networkStyle->getTitleAddText();
|
||||
#ifndef Q_OS_MAC
|
||||
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
|
||||
setWindowIcon(networkStyle->getTrayAndWindowIcon());
|
||||
#else
|
||||
MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
|
||||
#endif
|
||||
setWindowTitle(windowTitle);
|
||||
|
||||
rpcConsole = new RPCConsole(node, _platformStyle, 0);
|
||||
@@ -278,17 +274,17 @@ void BitcoinGUI::createActions()
|
||||
#ifdef ENABLE_WALLET
|
||||
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
|
||||
// can be triggered from the tray menu, and need to show the GUI to be useful.
|
||||
connect(overviewAction, &QAction::triggered, this, static_cast<void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized));
|
||||
connect(overviewAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
|
||||
connect(overviewAction, &QAction::triggered, this, &BitcoinGUI::gotoOverviewPage);
|
||||
connect(sendCoinsAction, &QAction::triggered, this, static_cast<void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized));
|
||||
connect(sendCoinsAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
|
||||
connect(sendCoinsAction, &QAction::triggered, [this]{ gotoSendCoinsPage(); });
|
||||
connect(sendCoinsMenuAction, &QAction::triggered, this, static_cast<void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized));
|
||||
connect(sendCoinsMenuAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
|
||||
connect(sendCoinsMenuAction, &QAction::triggered, [this]{ gotoSendCoinsPage(); });
|
||||
connect(receiveCoinsAction, &QAction::triggered, this, static_cast<void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized));
|
||||
connect(receiveCoinsAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
|
||||
connect(receiveCoinsAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage);
|
||||
connect(receiveCoinsMenuAction, &QAction::triggered, this, static_cast<void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized));
|
||||
connect(receiveCoinsMenuAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
|
||||
connect(receiveCoinsMenuAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage);
|
||||
connect(historyAction, &QAction::triggered, this, static_cast<void (BitcoinGUI::*)()>(&BitcoinGUI::showNormalIfMinimized));
|
||||
connect(historyAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
|
||||
connect(historyAction, &QAction::triggered, this, &BitcoinGUI::gotoHistoryPage);
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
@@ -355,7 +351,9 @@ void BitcoinGUI::createActions()
|
||||
connect(encryptWalletAction, &QAction::triggered, walletFrame, &WalletFrame::encryptWallet);
|
||||
connect(backupWalletAction, &QAction::triggered, walletFrame, &WalletFrame::backupWallet);
|
||||
connect(changePassphraseAction, &QAction::triggered, walletFrame, &WalletFrame::changePassphrase);
|
||||
connect(signMessageAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
|
||||
connect(signMessageAction, &QAction::triggered, [this]{ gotoSignMessageTab(); });
|
||||
connect(verifyMessageAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
|
||||
connect(verifyMessageAction, &QAction::triggered, [this]{ gotoVerifyMessageTab(); });
|
||||
connect(usedSendingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedSendingAddresses);
|
||||
connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame, &WalletFrame::usedReceivingAddresses);
|
||||
@@ -604,7 +602,7 @@ void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
|
||||
void BitcoinGUI::createTrayIconMenu()
|
||||
{
|
||||
#ifndef Q_OS_MAC
|
||||
// return if trayIcon is unset (only on non-Mac OSes)
|
||||
// return if trayIcon is unset (only on non-macOSes)
|
||||
if (!trayIcon)
|
||||
return;
|
||||
|
||||
@@ -613,15 +611,17 @@ void BitcoinGUI::createTrayIconMenu()
|
||||
|
||||
connect(trayIcon, &QSystemTrayIcon::activated, this, &BitcoinGUI::trayIconActivated);
|
||||
#else
|
||||
// Note: On Mac, the dock icon is used to provide the tray's functionality.
|
||||
// Note: On macOS, the Dock icon is used to provide the tray's functionality.
|
||||
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
|
||||
dockIconHandler->setMainWindow(static_cast<QMainWindow*>(this));
|
||||
trayIconMenu = dockIconHandler->dockMenu();
|
||||
connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, this, &BitcoinGUI::macosDockIconActivated);
|
||||
|
||||
trayIconMenu = new QMenu(this);
|
||||
trayIconMenu->setAsDockMenu();
|
||||
#endif
|
||||
|
||||
// Configuration of the tray icon (or dock icon) icon menu
|
||||
// Configuration of the tray icon (or Dock icon) menu
|
||||
#ifndef Q_OS_MAC
|
||||
// Note: On Mac, the dock icon's menu already has show / hide action.
|
||||
// Note: On macOS, the Dock icon's menu already has Show / Hide action.
|
||||
trayIconMenu->addAction(toggleHideAction);
|
||||
trayIconMenu->addSeparator();
|
||||
#endif
|
||||
@@ -635,7 +635,7 @@ void BitcoinGUI::createTrayIconMenu()
|
||||
trayIconMenu->addAction(openRPCConsoleAction);
|
||||
}
|
||||
trayIconMenu->addAction(optionsAction);
|
||||
#ifndef Q_OS_MAC // This is built-in on Mac
|
||||
#ifndef Q_OS_MAC // This is built-in on macOS
|
||||
trayIconMenu->addSeparator();
|
||||
trayIconMenu->addAction(quitAction);
|
||||
#endif
|
||||
@@ -650,6 +650,12 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||
toggleHidden();
|
||||
}
|
||||
}
|
||||
#else
|
||||
void BitcoinGUI::macosDockIconActivated()
|
||||
{
|
||||
show();
|
||||
activateWindow();
|
||||
}
|
||||
#endif
|
||||
|
||||
void BitcoinGUI::optionsClicked()
|
||||
@@ -668,10 +674,7 @@ void BitcoinGUI::aboutClicked()
|
||||
|
||||
void BitcoinGUI::showDebugWindow()
|
||||
{
|
||||
rpcConsole->showNormal();
|
||||
rpcConsole->show();
|
||||
rpcConsole->raise();
|
||||
rpcConsole->activateWindow();
|
||||
GUIUtil::bringToFront(rpcConsole);
|
||||
}
|
||||
|
||||
void BitcoinGUI::showDebugWindowActivateConsole()
|
||||
@@ -1158,24 +1161,11 @@ void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
|
||||
if(!clientModel)
|
||||
return;
|
||||
|
||||
// activateWindow() (sometimes) helps with keyboard focus on Windows
|
||||
if (isHidden())
|
||||
{
|
||||
show();
|
||||
activateWindow();
|
||||
}
|
||||
else if (isMinimized())
|
||||
{
|
||||
showNormal();
|
||||
activateWindow();
|
||||
}
|
||||
else if (GUIUtil::isObscured(this))
|
||||
{
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
else if(fToggleHidden)
|
||||
if (!isHidden() && !isMinimized() && !GUIUtil::isObscured(this) && fToggleHidden) {
|
||||
hide();
|
||||
} else {
|
||||
GUIUtil::bringToFront(this);
|
||||
}
|
||||
}
|
||||
|
||||
void BitcoinGUI::toggleHidden()
|
||||
|
||||
Reference in New Issue
Block a user