diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-03-30 02:49:03 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-04-14 18:51:26 +0300 |
commit | 16c157de3c316517e095994fa8d526253225a672 (patch) | |
tree | d8aff58cc7d8a9f9c121e8bb1beec054dacca385 /src/qt/addressbookpage.cpp | |
parent | 79311750b58d650d49a3f0edd59d31dd132ab8c0 (diff) |
qt, refactor: Use better QMenu::addAction overloaded function
This overloaded function was introduced in Qt 5.6 and makes code more
concise.
Diffstat (limited to 'src/qt/addressbookpage.cpp')
-rw-r--r-- | src/qt/addressbookpage.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 858350c287..c2ea99b7c8 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -112,27 +112,16 @@ 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); - // Build context menu contextMenu = new QMenu(this); - contextMenu->addAction(copyAddressAction); - contextMenu->addAction(copyLabelAction); - contextMenu->addAction(editAction); + 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); + if (tab == SendingTab) { - QAction* deleteAction = new QAction(tr("Delete"), this); - contextMenu->addAction(deleteAction); - connect(deleteAction, &QAction::triggered, this, &AddressBookPage::on_deleteAddress_clicked); + 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(ui->tableView, &QWidget::customContextMenuRequested, this, &AddressBookPage::contextualMenu); connect(ui->closeButton, &QPushButton::clicked, this, &QDialog::accept); |