mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01: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:
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user