mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge bitcoin-core/gui#263: Revamp context menus
16c157de3c316517e095994fa8d526253225a672 qt, refactor: Use better QMenu::addAction overloaded function (Hennadii Stepanov) 79311750b58d650d49a3f0edd59d31dd132ab8c0 qt: Do not assign Alt+<KEY> shortcuts to context menu actions (Hennadii Stepanov) 963e12058f3ca3cdaeefd9aa5a8305fa41afd1a0 qt: Drop menu separator that separates nothing (Hennadii Stepanov) 1398a6536c710368d9f1d0cf6e280fe63d07c9f0 qt, refactor: Make AddressBookPage::deleteAction a local variable (Hennadii Stepanov) Pull request description: This PR: 1. removes useless `Alt` + `<KEY>` shortcuts from context menu items 2. replaces 3 lines of code with the only call of [`QMenu::addAction`](https://doc.qt.io/qt-5/qmenu.html#addAction-5) for each context menu item (it became possible since https://github.com/bitcoin/bitcoin/pull/21286 was merged) 3. makes other minor cleanups No behavior change. ACKs for top commit: kristapsk: ACK 16c157de3c316517e095994fa8d526253225a672 promag: Code review ACK 16c157de3c316517e095994fa8d526253225a672. Nice code cleanup that takes advantage of more recent Qt API. jarolrod: ACK 16c157de3c316517e095994fa8d526253225a672 Tree-SHA512: e5555fe957058cc67b351aaf9f09fe3635edb2d07a2223d3093913a25607ae538f0a2fde84c0b0cd43e7475b248949548eb4a5d4b21d8f7391fa2fa8541c04ff
This commit is contained in:
parent
c36bb8e6fb
commit
4f89c98dc4
@ -107,32 +107,20 @@ AddressBookPage::AddressBookPage(Mode _mode, Tabs _tab, QWidget* parent) :
|
||||
break;
|
||||
}
|
||||
|
||||
// Context menu actions
|
||||
QAction *copyAddressAction = new QAction(tr("&Copy Address"), this);
|
||||
QAction *copyLabelAction = new QAction(tr("Copy &Label"), this);
|
||||
QAction *editAction = new QAction(tr("&Edit"), this);
|
||||
QAction *showAddressQRCodeAction = new QAction(tr("&Show address QR code"), this);
|
||||
deleteAction = new QAction(ui->deleteAddress->text(), this);
|
||||
#ifndef USE_QRCODE
|
||||
showAddressQRCodeAction->setEnabled(false);
|
||||
#endif
|
||||
|
||||
// Build context menu
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->addAction(copyAddressAction);
|
||||
contextMenu->addAction(copyLabelAction);
|
||||
contextMenu->addAction(editAction);
|
||||
if(tab == SendingTab)
|
||||
contextMenu->addAction(deleteAction);
|
||||
contextMenu->addSeparator();
|
||||
contextMenu->addAction(showAddressQRCodeAction);
|
||||
contextMenu->addAction(tr("Copy Address"), this, &AddressBookPage::on_copyAddress_clicked);
|
||||
contextMenu->addAction(tr("Copy Label"), this, &AddressBookPage::onCopyLabelAction);
|
||||
contextMenu->addAction(tr("Edit"), this, &AddressBookPage::onEditAction);
|
||||
[[maybe_unused]] QAction* qrAction = contextMenu->addAction(tr("Show address QR code"), this, &AddressBookPage::on_showAddressQRCode_clicked);
|
||||
#ifndef USE_QRCODE
|
||||
qrAction->setEnabled(false);
|
||||
#endif
|
||||
|
||||
if (tab == SendingTab) {
|
||||
contextMenu->addAction(tr("Delete"), this, &AddressBookPage::on_deleteAddress_clicked);
|
||||
}
|
||||
|
||||
// Connect signals for context menu actions
|
||||
connect(copyAddressAction, &QAction::triggered, this, &AddressBookPage::on_copyAddress_clicked);
|
||||
connect(copyLabelAction, &QAction::triggered, this, &AddressBookPage::onCopyLabelAction);
|
||||
connect(editAction, &QAction::triggered, this, &AddressBookPage::onEditAction);
|
||||
connect(deleteAction, &QAction::triggered, this, &AddressBookPage::on_deleteAddress_clicked);
|
||||
connect(showAddressQRCodeAction, &QAction::triggered, this, &AddressBookPage::on_showAddressQRCode_clicked);
|
||||
connect(ui->tableView, &QWidget::customContextMenuRequested, this, &AddressBookPage::contextualMenu);
|
||||
connect(ui->closeButton, &QPushButton::clicked, this, &QDialog::accept);
|
||||
|
||||
@ -267,13 +255,11 @@ void AddressBookPage::selectionChanged()
|
||||
// In sending tab, allow deletion of selection
|
||||
ui->deleteAddress->setEnabled(true);
|
||||
ui->deleteAddress->setVisible(true);
|
||||
deleteAction->setEnabled(true);
|
||||
break;
|
||||
case ReceivingTab:
|
||||
// Deleting receiving addresses, however, is not allowed
|
||||
ui->deleteAddress->setEnabled(false);
|
||||
ui->deleteAddress->setVisible(false);
|
||||
deleteAction->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
ui->copyAddress->setEnabled(true);
|
||||
|
@ -54,7 +54,6 @@ private:
|
||||
QString returnValue;
|
||||
AddressBookSortFilterProxyModel *proxyModel;
|
||||
QMenu *contextMenu;
|
||||
QAction *deleteAction; // to be able to explicitly disable it
|
||||
QString newAddressToSelect;
|
||||
|
||||
private Q_SLOTS:
|
||||
|
@ -2054,11 +2054,8 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
|
||||
void UnitDisplayStatusBarControl::createContextMenu()
|
||||
{
|
||||
menu = new QMenu(this);
|
||||
for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
|
||||
{
|
||||
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
|
||||
menuAction->setData(QVariant(u));
|
||||
menu->addAction(menuAction);
|
||||
for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) {
|
||||
menu->addAction(BitcoinUnits::name(u))->setData(QVariant(u));
|
||||
}
|
||||
connect(menu, &QMenu::triggered, this, &UnitDisplayStatusBarControl::onMenuSelection);
|
||||
}
|
||||
|
@ -62,32 +62,16 @@ CoinControlDialog::CoinControlDialog(CCoinControl& coin_control, WalletModel* _m
|
||||
|
||||
GUIUtil::disableMacFocusRect(this);
|
||||
|
||||
// context menu actions
|
||||
QAction *copyAddressAction = new QAction(tr("Copy address"), this);
|
||||
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
|
||||
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
|
||||
copyTransactionHashAction = new QAction(tr("Copy transaction ID"), this); // we need to enable/disable this
|
||||
lockAction = new QAction(tr("Lock unspent"), this); // we need to enable/disable this
|
||||
unlockAction = new QAction(tr("Unlock unspent"), this); // we need to enable/disable this
|
||||
|
||||
// context menu
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->addAction(copyAddressAction);
|
||||
contextMenu->addAction(copyLabelAction);
|
||||
contextMenu->addAction(copyAmountAction);
|
||||
contextMenu->addAction(copyTransactionHashAction);
|
||||
contextMenu->addAction(tr("Copy address"), this, &CoinControlDialog::copyAddress);
|
||||
contextMenu->addAction(tr("Copy label"), this, &CoinControlDialog::copyLabel);
|
||||
contextMenu->addAction(tr("Copy amount"), this, &CoinControlDialog::copyAmount);
|
||||
copyTransactionHashAction = contextMenu->addAction(tr("Copy transaction ID"), this, &CoinControlDialog::copyTransactionHash);
|
||||
contextMenu->addSeparator();
|
||||
contextMenu->addAction(lockAction);
|
||||
contextMenu->addAction(unlockAction);
|
||||
|
||||
// context menu signals
|
||||
lockAction = contextMenu->addAction(tr("Lock unspent"), this, &CoinControlDialog::lockCoin);
|
||||
unlockAction = contextMenu->addAction(tr("Unlock unspent"), this, &CoinControlDialog::unlockCoin);
|
||||
connect(ui->treeWidget, &QWidget::customContextMenuRequested, this, &CoinControlDialog::showMenu);
|
||||
connect(copyAddressAction, &QAction::triggered, this, &CoinControlDialog::copyAddress);
|
||||
connect(copyLabelAction, &QAction::triggered, this, &CoinControlDialog::copyLabel);
|
||||
connect(copyAmountAction, &QAction::triggered, this, &CoinControlDialog::copyAmount);
|
||||
connect(copyTransactionHashAction, &QAction::triggered, this, &CoinControlDialog::copyTransactionHash);
|
||||
connect(lockAction, &QAction::triggered, this, &CoinControlDialog::lockCoin);
|
||||
connect(unlockAction, &QAction::triggered, this, &CoinControlDialog::unlockCoin);
|
||||
|
||||
// clipboard actions
|
||||
QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this);
|
||||
|
@ -27,12 +27,8 @@ QRImageWidget::QRImageWidget(QWidget *parent):
|
||||
QLabel(parent), contextMenu(nullptr)
|
||||
{
|
||||
contextMenu = new QMenu(this);
|
||||
QAction *saveImageAction = new QAction(tr("&Save Image…"), this);
|
||||
connect(saveImageAction, &QAction::triggered, this, &QRImageWidget::saveImage);
|
||||
contextMenu->addAction(saveImageAction);
|
||||
QAction *copyImageAction = new QAction(tr("&Copy Image"), this);
|
||||
connect(copyImageAction, &QAction::triggered, this, &QRImageWidget::copyImage);
|
||||
contextMenu->addAction(copyImageAction);
|
||||
contextMenu->addAction(tr("Save Image…"), this, &QRImageWidget::saveImage);
|
||||
contextMenu->addAction(tr("Copy Image"), this, &QRImageWidget::copyImage);
|
||||
}
|
||||
|
||||
bool QRImageWidget::setQR(const QString& data, const QString& text)
|
||||
|
@ -31,28 +31,14 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget* parent) :
|
||||
ui->label_3}, GUIUtil::FontWeight::Normal, 15);
|
||||
GUIUtil::updateFonts();
|
||||
|
||||
// context menu actions
|
||||
QAction *copyURIAction = new QAction(tr("Copy URI"), this);
|
||||
QAction* copyAddressAction = new QAction(tr("Copy address"), this);
|
||||
copyLabelAction = new QAction(tr("Copy label"), this);
|
||||
copyMessageAction = new QAction(tr("Copy message"), this);
|
||||
copyAmountAction = new QAction(tr("Copy amount"), this);
|
||||
|
||||
// context menu
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->addAction(copyURIAction);
|
||||
contextMenu->addAction(copyAddressAction);
|
||||
contextMenu->addAction(copyLabelAction);
|
||||
contextMenu->addAction(copyMessageAction);
|
||||
contextMenu->addAction(copyAmountAction);
|
||||
|
||||
// context menu signals
|
||||
contextMenu->addAction(tr("Copy URI"), this, &ReceiveCoinsDialog::copyURI);
|
||||
contextMenu->addAction(tr("Copy address"), this, &ReceiveCoinsDialog::copyAddress);
|
||||
copyLabelAction = contextMenu->addAction(tr("Copy label"), this, &ReceiveCoinsDialog::copyLabel);
|
||||
copyMessageAction = contextMenu->addAction(tr("Copy message"), this, &ReceiveCoinsDialog::copyMessage);
|
||||
copyAmountAction = contextMenu->addAction(tr("Copy amount"), this, &ReceiveCoinsDialog::copyAmount);
|
||||
connect(ui->recentRequestsView, &QWidget::customContextMenuRequested, this, &ReceiveCoinsDialog::showMenu);
|
||||
connect(copyURIAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyURI);
|
||||
connect(copyAddressAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyAddress);
|
||||
connect(copyLabelAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyLabel);
|
||||
connect(copyMessageAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyMessage);
|
||||
connect(copyAmountAction, &QAction::triggered, this, &ReceiveCoinsDialog::copyAmount);
|
||||
|
||||
connect(ui->clearButton, &QPushButton::clicked, this, &ReceiveCoinsDialog::clear);
|
||||
}
|
||||
|
@ -705,29 +705,14 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
||||
ui->peerWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
ui->peerWidget->setItemDelegateForColumn(PeerTableModel::NetNodeId, new PeerIdViewDelegate(this));
|
||||
|
||||
// create peer table context menu actions
|
||||
QAction* disconnectAction = new QAction(tr("&Disconnect"), this);
|
||||
QAction* banAction1h = new QAction(ts.ban_for + " " + tr("1 &hour"), this);
|
||||
QAction* banAction24h = new QAction(ts.ban_for + " " + tr("1 &day"), this);
|
||||
QAction* banAction7d = new QAction(ts.ban_for + " " + tr("1 &week"), this);
|
||||
QAction* banAction365d = new QAction(ts.ban_for + " " + tr("1 &year"), this);
|
||||
|
||||
// create peer table context menu
|
||||
peersTableContextMenu = new QMenu(this);
|
||||
peersTableContextMenu->addAction(disconnectAction);
|
||||
peersTableContextMenu->addAction(banAction1h);
|
||||
peersTableContextMenu->addAction(banAction24h);
|
||||
peersTableContextMenu->addAction(banAction7d);
|
||||
peersTableContextMenu->addAction(banAction365d);
|
||||
|
||||
connect(banAction1h, &QAction::triggered, [this] { banSelectedNode(60 * 60); });
|
||||
connect(banAction24h, &QAction::triggered, [this] { banSelectedNode(60 * 60 * 24); });
|
||||
connect(banAction7d, &QAction::triggered, [this] { banSelectedNode(60 * 60 * 24 * 7); });
|
||||
connect(banAction365d, &QAction::triggered, [this] { banSelectedNode(60 * 60 * 24 * 365); });
|
||||
|
||||
// peer table context menu signals
|
||||
peersTableContextMenu->addAction(tr("Disconnect"), this, &RPCConsole::disconnectSelectedNode);
|
||||
peersTableContextMenu->addAction(ts.ban_for + " " + tr("1 hour"), [this] { banSelectedNode(60 * 60); });
|
||||
peersTableContextMenu->addAction(ts.ban_for + " " + tr("1 day"), [this] { banSelectedNode(60 * 60 * 24); });
|
||||
peersTableContextMenu->addAction(ts.ban_for + " " + tr("1 week"), [this] { banSelectedNode(60 * 60 * 24 * 7); });
|
||||
peersTableContextMenu->addAction(ts.ban_for + " " + tr("1 year"), [this] { banSelectedNode(60 * 60 * 24 * 365); });
|
||||
connect(ui->peerWidget, &QTableView::customContextMenuRequested, this, &RPCConsole::showPeersTableContextMenu);
|
||||
connect(disconnectAction, &QAction::triggered, this, &RPCConsole::disconnectSelectedNode);
|
||||
|
||||
// peer table signal handling - update peer details when selecting new node
|
||||
connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RPCConsole::updateDetailWidget);
|
||||
@ -746,16 +731,10 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_
|
||||
ui->banlistWidget->setColumnWidth(BanTableModel::Bantime, BANTIME_COLUMN_WIDTH);
|
||||
ui->banlistWidget->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
// create ban table context menu action
|
||||
QAction* unbanAction = new QAction(tr("&Unban"), this);
|
||||
|
||||
// create ban table context menu
|
||||
banTableContextMenu = new QMenu(this);
|
||||
banTableContextMenu->addAction(unbanAction);
|
||||
|
||||
// ban table context menu signals
|
||||
banTableContextMenu->addAction(tr("Unban"), this, &RPCConsole::unbanSelectedNode);
|
||||
connect(ui->banlistWidget, &QTableView::customContextMenuRequested, this, &RPCConsole::showBanTableContextMenu);
|
||||
connect(unbanAction, &QAction::triggered, this, &RPCConsole::unbanSelectedNode);
|
||||
|
||||
// ban table signal handling - clear peer details when clicking a peer in the ban table
|
||||
connect(ui->banlistWidget, &QTableView::clicked, this, &RPCConsole::clearSelectedNode);
|
||||
|
@ -145,37 +145,24 @@ TransactionView::TransactionView(QWidget* parent) :
|
||||
|
||||
transactionView->setObjectName("transactionView");
|
||||
|
||||
// Actions
|
||||
abandonAction = new QAction(tr("Abandon transaction"), this);
|
||||
resendAction = new QAction(tr("Resend transaction"), this);
|
||||
copyAddressAction = new QAction(tr("Copy address"), this);
|
||||
copyLabelAction = new QAction(tr("Copy label"), this);
|
||||
QAction *copyAmountAction = new QAction(tr("Copy amount"), this);
|
||||
QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this);
|
||||
QAction *copyTxHexAction = new QAction(tr("Copy raw transaction"), this);
|
||||
QAction *copyTxPlainText = new QAction(tr("Copy full transaction details"), this);
|
||||
QAction *editLabelAction = new QAction(tr("Edit address label"), this);
|
||||
QAction *showDetailsAction = new QAction(tr("Show transaction details"), this);
|
||||
QAction *showAddressQRCodeAction = new QAction(tr("Show address QR code"), this);
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->setObjectName("contextMenu");
|
||||
copyAddressAction = contextMenu->addAction(tr("Copy address"), this, &TransactionView::copyAddress);
|
||||
copyLabelAction = contextMenu->addAction(tr("Copy label"), this, &TransactionView::copyLabel);
|
||||
contextMenu->addAction(tr("Copy amount"), this, &TransactionView::copyAmount);
|
||||
contextMenu->addAction(tr("Copy transaction ID"), this, &TransactionView::copyTxID);
|
||||
contextMenu->addAction(tr("Copy raw transaction"), this, &TransactionView::copyTxHex);
|
||||
contextMenu->addAction(tr("Copy full transaction details"), this, &TransactionView::copyTxPlainText);
|
||||
contextMenu->addAction(tr("Show transaction details"), this, &TransactionView::showDetails);
|
||||
contextMenu->addSeparator();
|
||||
abandonAction = contextMenu->addAction(tr("Abandon transaction"), this, &TransactionView::abandonTx);
|
||||
resendAction = contextMenu->addAction(tr("Resend transaction"), this, &TransactionView::resendTx);
|
||||
contextMenu->addAction(tr("Edit address label"), this, &TransactionView::editLabel);
|
||||
[[maybe_unused]] QAction* showAddressQRCodeAction = contextMenu->addAction(tr("Show address QR code"), this, &TransactionView::showAddressQRCode);
|
||||
#ifndef USE_QRCODE
|
||||
showAddressQRCodeAction->setEnabled(false);
|
||||
#endif
|
||||
|
||||
contextMenu = new QMenu(this);
|
||||
contextMenu->setObjectName("contextMenu");
|
||||
contextMenu->addAction(copyAddressAction);
|
||||
contextMenu->addAction(copyLabelAction);
|
||||
contextMenu->addAction(copyAmountAction);
|
||||
contextMenu->addAction(copyTxIDAction);
|
||||
contextMenu->addAction(copyTxHexAction);
|
||||
contextMenu->addAction(copyTxPlainText);
|
||||
contextMenu->addAction(showDetailsAction);
|
||||
contextMenu->addAction(showAddressQRCodeAction);
|
||||
contextMenu->addSeparator();
|
||||
contextMenu->addAction(abandonAction);
|
||||
contextMenu->addAction(resendAction);
|
||||
contextMenu->addAction(editLabelAction);
|
||||
|
||||
connect(dateWidget, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &TransactionView::chooseDate);
|
||||
connect(typeWidget, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &TransactionView::chooseType);
|
||||
connect(watchOnlyWidget, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &TransactionView::chooseWatchonly);
|
||||
@ -188,17 +175,6 @@ TransactionView::TransactionView(QWidget* parent) :
|
||||
connect(transactionView, &QTableView::clicked, this, &TransactionView::computeSum);
|
||||
connect(transactionView, &QTableView::customContextMenuRequested, this, &TransactionView::contextualMenu);
|
||||
|
||||
connect(abandonAction, &QAction::triggered, this, &TransactionView::abandonTx);
|
||||
connect(resendAction, &QAction::triggered, this, &TransactionView::resendTx);
|
||||
connect(copyAddressAction, &QAction::triggered, this, &TransactionView::copyAddress);
|
||||
connect(copyLabelAction, &QAction::triggered, this, &TransactionView::copyLabel);
|
||||
connect(copyAmountAction, &QAction::triggered, this, &TransactionView::copyAmount);
|
||||
connect(copyTxIDAction, &QAction::triggered, this, &TransactionView::copyTxID);
|
||||
connect(copyTxHexAction, &QAction::triggered, this, &TransactionView::copyTxHex);
|
||||
connect(copyTxPlainText, &QAction::triggered, this, &TransactionView::copyTxPlainText);
|
||||
connect(editLabelAction, &QAction::triggered, this, &TransactionView::editLabel);
|
||||
connect(showDetailsAction, &QAction::triggered, this, &TransactionView::showDetails);
|
||||
connect(showAddressQRCodeAction, &QAction::triggered, this, &TransactionView::showAddressQRCode);
|
||||
// Double-clicking on a transaction on the transaction history page shows details
|
||||
connect(this, &TransactionView::doubleClicked, this, &TransactionView::showDetails);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user