diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-04-20 23:11:41 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-04-20 23:18:54 +0300 |
commit | f385ad765174afb02e60900581612a19c143cf83 (patch) | |
tree | 6f147fd60d1a3cebf91b87738486ace44fd0dd98 /src/qt/addressbookpage.cpp | |
parent | bca00942ed2734f2a6660fe951491825b88df176 (diff) | |
parent | 16c157de3c316517e095994fa8d526253225a672 (diff) |
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
Diffstat (limited to 'src/qt/addressbookpage.cpp')
-rw-r--r-- | src/qt/addressbookpage.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 059db9de8d..a816a0764c 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -112,29 +112,17 @@ AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode, 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); - deleteAction = new QAction(ui->deleteAddress->text(), this); - // Build context menu contextMenu = new QMenu(this); - contextMenu->addAction(copyAddressAction); - contextMenu->addAction(copyLabelAction); - contextMenu->addAction(editAction); - if(tab == SendingTab) - contextMenu->addAction(deleteAction); - contextMenu->addSeparator(); - - // 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); + 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); - connect(ui->tableView, &QWidget::customContextMenuRequested, this, &AddressBookPage::contextualMenu); + if (tab == SendingTab) { + contextMenu->addAction(tr("Delete"), this, &AddressBookPage::on_deleteAddress_clicked); + } + connect(ui->tableView, &QWidget::customContextMenuRequested, this, &AddressBookPage::contextualMenu); connect(ui->closeButton, &QPushButton::clicked, this, &QDialog::accept); GUIUtil::handleCloseWindowShortcut(this); @@ -249,13 +237,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); |