-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect dialog modality and fix a regression in wallet unlock #509
Changes from all commits
c3ca836
66afa28
78189da
ee151d0
fd667e7
58e1603
9242735
8c0eb80
89c277a
5d7666b
f730bd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,21 +261,13 @@ void BitcoinGUI::createActions() | |
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); | ||
tabGroup->addAction(sendCoinsAction); | ||
|
||
sendCoinsMenuAction = new QAction(sendCoinsAction->text(), this); | ||
sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip()); | ||
sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip()); | ||
|
||
receiveCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/receiving_addresses"), tr("&Receive"), this); | ||
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and bitcoin: URIs)")); | ||
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip()); | ||
receiveCoinsAction->setCheckable(true); | ||
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3)); | ||
tabGroup->addAction(receiveCoinsAction); | ||
|
||
receiveCoinsMenuAction = new QAction(receiveCoinsAction->text(), this); | ||
receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip()); | ||
receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip()); | ||
|
||
historyAction = new QAction(platformStyle->SingleColorIcon(":/icons/history"), tr("&Transactions"), this); | ||
historyAction->setStatusTip(tr("Browse transaction history")); | ||
historyAction->setToolTip(historyAction->statusTip()); | ||
|
@@ -290,12 +282,8 @@ void BitcoinGUI::createActions() | |
connect(overviewAction, &QAction::triggered, this, &BitcoinGUI::gotoOverviewPage); | ||
connect(sendCoinsAction, &QAction::triggered, [this]{ showNormalIfMinimized(); }); | ||
connect(sendCoinsAction, &QAction::triggered, [this]{ gotoSendCoinsPage(); }); | ||
connect(sendCoinsMenuAction, &QAction::triggered, [this]{ showNormalIfMinimized(); }); | ||
connect(sendCoinsMenuAction, &QAction::triggered, [this]{ gotoSendCoinsPage(); }); | ||
connect(receiveCoinsAction, &QAction::triggered, [this]{ showNormalIfMinimized(); }); | ||
connect(receiveCoinsAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage); | ||
connect(receiveCoinsMenuAction, &QAction::triggered, [this]{ showNormalIfMinimized(); }); | ||
connect(receiveCoinsMenuAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage); | ||
connect(historyAction, &QAction::triggered, [this]{ showNormalIfMinimized(); }); | ||
connect(historyAction, &QAction::triggered, this, &BitcoinGUI::gotoHistoryPage); | ||
#endif // ENABLE_WALLET | ||
|
@@ -315,8 +303,6 @@ void BitcoinGUI::createActions() | |
optionsAction->setStatusTip(tr("Modify configuration options for %1").arg(PACKAGE_NAME)); | ||
optionsAction->setMenuRole(QAction::PreferencesRole); | ||
optionsAction->setEnabled(false); | ||
toggleHideAction = new QAction(tr("&Show / Hide"), this); | ||
toggleHideAction->setStatusTip(tr("Show or hide the main Window")); | ||
|
||
encryptWalletAction = new QAction(tr("&Encrypt Wallet…"), this); | ||
encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet")); | ||
|
@@ -376,7 +362,6 @@ void BitcoinGUI::createActions() | |
connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked); | ||
connect(aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt); | ||
connect(optionsAction, &QAction::triggered, this, &BitcoinGUI::optionsClicked); | ||
connect(toggleHideAction, &QAction::triggered, this, &BitcoinGUI::toggleHidden); | ||
connect(showHelpMessageAction, &QAction::triggered, this, &BitcoinGUI::showHelpMessageClicked); | ||
connect(openRPCConsoleAction, &QAction::triggered, this, &BitcoinGUI::showDebugWindow); | ||
// prevents an open debug window from becoming stuck/unusable on client shutdown | ||
|
@@ -627,8 +612,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH | |
trayIcon->setVisible(optionsModel->getShowTrayIcon()); | ||
} | ||
} else { | ||
// Disable possibility to show main window via action | ||
toggleHideAction->setEnabled(false); | ||
hebasto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if(trayIconMenu) | ||
{ | ||
// Disable context menu on tray icon | ||
|
@@ -752,9 +735,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) | |
{ | ||
overviewAction->setEnabled(enabled); | ||
sendCoinsAction->setEnabled(enabled); | ||
sendCoinsMenuAction->setEnabled(enabled); | ||
receiveCoinsAction->setEnabled(enabled); | ||
receiveCoinsMenuAction->setEnabled(enabled); | ||
historyAction->setEnabled(enabled); | ||
encryptWalletAction->setEnabled(enabled); | ||
backupWalletAction->setEnabled(enabled); | ||
|
@@ -784,57 +765,82 @@ 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, &BitcoinGUI::trayIconActivated); | ||
#else | ||
// Note: On macOS, the Dock icon is used to provide the tray's functionality. | ||
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); | ||
connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, this, &BitcoinGUI::macosDockIconActivated); | ||
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. | ||
QAction* show_hide_action{nullptr}; | ||
#ifndef Q_OS_MAC | ||
// Note: On macOS, the Dock icon's menu already has Show / Hide action. | ||
trayIconMenu->addAction(toggleHideAction); | ||
show_hide_action = trayIconMenu->addAction(QString(), this, &BitcoinGUI::toggleHidden); | ||
trayIconMenu->addSeparator(); | ||
#endif | ||
#endif // Q_OS_MAC | ||
hebasto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
QAction* send_action{nullptr}; | ||
QAction* receive_action{nullptr}; | ||
QAction* sign_action{nullptr}; | ||
QAction* verify_action{nullptr}; | ||
if (enableWallet) { | ||
trayIconMenu->addAction(sendCoinsMenuAction); | ||
trayIconMenu->addAction(receiveCoinsMenuAction); | ||
send_action = trayIconMenu->addAction(sendCoinsAction->text(), sendCoinsAction, &QAction::trigger); | ||
receive_action = trayIconMenu->addAction(receiveCoinsAction->text(), receiveCoinsAction, &QAction::trigger); | ||
trayIconMenu->addSeparator(); | ||
trayIconMenu->addAction(signMessageAction); | ||
trayIconMenu->addAction(verifyMessageAction); | ||
sign_action = trayIconMenu->addAction(signMessageAction->text(), signMessageAction, &QAction::trigger); | ||
verify_action = trayIconMenu->addAction(verifyMessageAction->text(), verifyMessageAction, &QAction::trigger); | ||
trayIconMenu->addSeparator(); | ||
} | ||
trayIconMenu->addAction(optionsAction); | ||
trayIconMenu->addAction(openRPCConsoleAction); | ||
#ifndef Q_OS_MAC // This is built-in on macOS | ||
QAction* options_action = trayIconMenu->addAction(optionsAction->text(), optionsAction, &QAction::trigger); | ||
options_action->setMenuRole(QAction::PreferencesRole); | ||
QAction* node_window_action = trayIconMenu->addAction(openRPCConsoleAction->text(), openRPCConsoleAction, &QAction::trigger); | ||
QAction* quit_action{nullptr}; | ||
#ifndef Q_OS_MAC | ||
// Note: On macOS, the Dock icon's menu already has Quit action. | ||
trayIconMenu->addSeparator(); | ||
trayIconMenu->addAction(quitAction); | ||
#endif | ||
} | ||
quit_action = trayIconMenu->addAction(quitAction->text(), quitAction, &QAction::trigger); | ||
|
||
#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(); | ||
} | ||
} | ||
trayIcon->setContextMenu(trayIconMenu.get()); | ||
connect(trayIcon, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) { | ||
if (reason == QSystemTrayIcon::Trigger) { | ||
hebasto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Click on system tray icon triggers show/hide of the main window | ||
toggleHidden(); | ||
} | ||
}); | ||
#else | ||
void BitcoinGUI::macosDockIconActivated() | ||
{ | ||
show(); | ||
activateWindow(); | ||
// 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 | ||
|
||
connect( | ||
// Using QSystemTrayIcon::Context is not reliable. | ||
// See https://bugreports.qt.io/browse/QTBUG-91697 | ||
trayIconMenu.get(), &QMenu::aboutToShow, | ||
[this, show_hide_action, send_action, receive_action, sign_action, verify_action, options_action, node_window_action, quit_action] { | ||
if (show_hide_action) show_hide_action->setText( | ||
(!isHidden() && !isMinimized() && !GUIUtil::isObscured(this)) ? | ||
tr("&Hide") : | ||
tr("S&how")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fd667e7: you may want to delay this keyboard shortcut, because we're past the translation cut-off? |
||
if (QApplication::activeModalWidget()) { | ||
for (QAction* a : trayIconMenu.get()->actions()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 97692af: I don't see any difference in behavior on macOS; before and after this commit, if I open coin selection, it disables everything except the macOS standard items (Options, Show all windows, Hide, Stop) |
||
a->setEnabled(false); | ||
} | ||
} else { | ||
if (show_hide_action) show_hide_action->setEnabled(true); | ||
if (enableWallet) { | ||
send_action->setEnabled(sendCoinsAction->isEnabled()); | ||
receive_action->setEnabled(receiveCoinsAction->isEnabled()); | ||
sign_action->setEnabled(signMessageAction->isEnabled()); | ||
verify_action->setEnabled(verifyMessageAction->isEnabled()); | ||
} | ||
options_action->setEnabled(optionsAction->isEnabled()); | ||
node_window_action->setEnabled(openRPCConsoleAction->isEnabled()); | ||
if (quit_action) quit_action->setEnabled(true); | ||
} | ||
}); | ||
} | ||
#endif | ||
|
||
void BitcoinGUI::optionsClicked() | ||
{ | ||
|
@@ -847,7 +853,7 @@ void BitcoinGUI::aboutClicked() | |
return; | ||
|
||
auto dlg = new HelpMessageDialog(this, /* about */ true); | ||
GUIUtil::ShowModalDialogAndDeleteOnClose(dlg); | ||
GUIUtil::ShowModalDialogAsynchronously(dlg); | ||
} | ||
|
||
void BitcoinGUI::showDebugWindow() | ||
|
@@ -992,7 +998,7 @@ void BitcoinGUI::openOptionsDialogWithTab(OptionsDialog::Tab tab) | |
connect(dlg, &OptionsDialog::quitOnReset, this, &BitcoinGUI::quitRequested); | ||
dlg->setCurrentTab(tab); | ||
dlg->setModel(clientModel->getOptionsModel()); | ||
GUIUtil::ShowModalDialogAndDeleteOnClose(dlg); | ||
GUIUtil::ShowModalDialogAsynchronously(dlg); | ||
} | ||
|
||
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header, SynchronizationState sync_state) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cda881a : on macOS when I'm in coin control, before and after this commit, Command + Q is ignored (not delayed). Same with Stop from the tray menu. (that's fine by the way, a delayed shutdown seems confusing)
But when I hit ctrl + c in the terminal, before this commit it would shut QT down, with this commit it indeed delays the shutdown until the dialog is closed. (that's also fine, because this method of shutdown is probably only used by developers)