Skip to content

Commit 58e1603

Browse files
committed
qt, refactor: Drop BitcoinGUI::{send,receive}CoinsMenuAction members
1 parent fd667e7 commit 58e1603

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/qt/bitcoingui.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,21 +261,13 @@ void BitcoinGUI::createActions()
261261
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
262262
tabGroup->addAction(sendCoinsAction);
263263

264-
sendCoinsMenuAction = new QAction(sendCoinsAction->text(), this);
265-
sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip());
266-
sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip());
267-
268264
receiveCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
269265
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and bitcoin: URIs)"));
270266
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
271267
receiveCoinsAction->setCheckable(true);
272268
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
273269
tabGroup->addAction(receiveCoinsAction);
274270

275-
receiveCoinsMenuAction = new QAction(receiveCoinsAction->text(), this);
276-
receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip());
277-
receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip());
278-
279271
historyAction = new QAction(platformStyle->SingleColorIcon(":/icons/history"), tr("&Transactions"), this);
280272
historyAction->setStatusTip(tr("Browse transaction history"));
281273
historyAction->setToolTip(historyAction->statusTip());
@@ -290,12 +282,8 @@ void BitcoinGUI::createActions()
290282
connect(overviewAction, &QAction::triggered, this, &BitcoinGUI::gotoOverviewPage);
291283
connect(sendCoinsAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
292284
connect(sendCoinsAction, &QAction::triggered, [this]{ gotoSendCoinsPage(); });
293-
connect(sendCoinsMenuAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
294-
connect(sendCoinsMenuAction, &QAction::triggered, [this]{ gotoSendCoinsPage(); });
295285
connect(receiveCoinsAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
296286
connect(receiveCoinsAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage);
297-
connect(receiveCoinsMenuAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
298-
connect(receiveCoinsMenuAction, &QAction::triggered, this, &BitcoinGUI::gotoReceiveCoinsPage);
299287
connect(historyAction, &QAction::triggered, [this]{ showNormalIfMinimized(); });
300288
connect(historyAction, &QAction::triggered, this, &BitcoinGUI::gotoHistoryPage);
301289
#endif // ENABLE_WALLET
@@ -747,9 +735,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
747735
{
748736
overviewAction->setEnabled(enabled);
749737
sendCoinsAction->setEnabled(enabled);
750-
sendCoinsMenuAction->setEnabled(enabled);
751738
receiveCoinsAction->setEnabled(enabled);
752-
receiveCoinsMenuAction->setEnabled(enabled);
753739
historyAction->setEnabled(enabled);
754740
encryptWalletAction->setEnabled(enabled);
755741
backupWalletAction->setEnabled(enabled);
@@ -790,9 +776,11 @@ void BitcoinGUI::createTrayIconMenu()
790776
trayIconMenu->addSeparator();
791777
#endif // Q_OS_MAC
792778

779+
QAction* send_action{nullptr};
780+
QAction* receive_action{nullptr};
793781
if (enableWallet) {
794-
trayIconMenu->addAction(sendCoinsMenuAction);
795-
trayIconMenu->addAction(receiveCoinsMenuAction);
782+
send_action = trayIconMenu->addAction(sendCoinsAction->text(), sendCoinsAction, &QAction::trigger);
783+
receive_action = trayIconMenu->addAction(receiveCoinsAction->text(), receiveCoinsAction, &QAction::trigger);
796784
trayIconMenu->addSeparator();
797785
trayIconMenu->addAction(signMessageAction);
798786
trayIconMenu->addAction(verifyMessageAction);
@@ -826,11 +814,15 @@ void BitcoinGUI::createTrayIconMenu()
826814
// Using QSystemTrayIcon::Context is not reliable.
827815
// See https://bugreports.qt.io/browse/QTBUG-91697
828816
trayIconMenu.get(), &QMenu::aboutToShow,
829-
[this, show_hide_action] {
817+
[this, show_hide_action, send_action, receive_action] {
830818
if (show_hide_action) show_hide_action->setText(
831819
(!isHidden() && !isMinimized() && !GUIUtil::isObscured(this)) ?
832820
tr("&Hide") :
833821
tr("S&how"));
822+
if (enableWallet) {
823+
send_action->setEnabled(sendCoinsAction->isEnabled());
824+
receive_action->setEnabled(receiveCoinsAction->isEnabled());
825+
}
834826
});
835827
}
836828

src/qt/bitcoingui.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class BitcoinGUI : public QMainWindow
137137
QAction* historyAction = nullptr;
138138
QAction* quitAction = nullptr;
139139
QAction* sendCoinsAction = nullptr;
140-
QAction* sendCoinsMenuAction = nullptr;
141140
QAction* usedSendingAddressesAction = nullptr;
142141
QAction* usedReceivingAddressesAction = nullptr;
143142
QAction* signMessageAction = nullptr;
@@ -146,7 +145,6 @@ class BitcoinGUI : public QMainWindow
146145
QAction* m_load_psbt_clipboard_action = nullptr;
147146
QAction* aboutAction = nullptr;
148147
QAction* receiveCoinsAction = nullptr;
149-
QAction* receiveCoinsMenuAction = nullptr;
150148
QAction* optionsAction = nullptr;
151149
QAction* encryptWalletAction = nullptr;
152150
QAction* backupWalletAction = nullptr;

0 commit comments

Comments
 (0)