mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
qt: Disable requests context menu actions when appropriate
The recent requests table will allow you to copy data points even if they do not exist. This PR implements checks to disable the 'copy label', 'copy message', and 'copy amount' context menu action if the respective fields are empty.
This commit is contained in:
parent
78effb37f3
commit
bb3da8fe41
2 changed files with 16 additions and 4 deletions
|
@ -45,9 +45,9 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(const PlatformStyle *_platformStyle, QWid
|
|||
// context menu actions
|
||||
QAction *copyURIAction = new QAction(tr("Copy URI"), this);
|
||||
QAction* copyAddressAction = new QAction(tr("Copy address"), this);
|
||||
QAction *copyLabelAction = new QAction(tr("Copy label"), this);
|
||||
QAction *copyMessageAction = new QAction(tr("Copy message"), this);
|
||||
QAction *copyAmountAction = new QAction(tr("Copy amount"), 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);
|
||||
|
@ -269,9 +269,18 @@ void ReceiveCoinsDialog::copyColumnToClipboard(int column)
|
|||
// context menu
|
||||
void ReceiveCoinsDialog::showMenu(const QPoint &point)
|
||||
{
|
||||
if (!selectedRow().isValid()) {
|
||||
const QModelIndex sel = selectedRow();
|
||||
if (!sel.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// disable context menu actions when appropriate
|
||||
const RecentRequestsTableModel* const submodel = model->getRecentRequestsTableModel();
|
||||
const RecentRequestEntry& req = submodel->entry(sel.row());
|
||||
copyLabelAction->setDisabled(req.recipient.label.isEmpty());
|
||||
copyMessageAction->setDisabled(req.recipient.message.isEmpty());
|
||||
copyAmountAction->setDisabled(req.recipient.amount == 0);
|
||||
|
||||
contextMenu->exec(QCursor::pos());
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ private:
|
|||
Ui::ReceiveCoinsDialog *ui;
|
||||
WalletModel *model;
|
||||
QMenu *contextMenu;
|
||||
QAction* copyLabelAction;
|
||||
QAction* copyMessageAction;
|
||||
QAction* copyAmountAction;
|
||||
const PlatformStyle *platformStyle;
|
||||
|
||||
QModelIndex selectedRow();
|
||||
|
|
Loading…
Add table
Reference in a new issue