From b59ad07c1c183111c2614b3f9c43853e864108ed Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Sat, 30 Jan 2021 13:30:23 +0000 Subject: [PATCH] Namecoin / Qt: Disable Renew/Configure for unspendable names --- src/qt/managenamespage.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/qt/managenamespage.cpp b/src/qt/managenamespage.cpp index db891b0797..377b881a0a 100644 --- a/src/qt/managenamespage.cpp +++ b/src/qt/managenamespage.cpp @@ -107,18 +107,30 @@ void ManageNamesPage::selectionChanged() QModelIndexList indexes = GUIUtil::getEntryData(ui->tableView, NameTableModel::Name); + bool anyUnspendableSelected = false; + for (const QModelIndex& index : indexes) + { + const std::string &status = index.sibling(index.row(), NameTableModel::NameStatus).data(Qt::EditRole).toString().toStdString(); + + if (status == NameTableEntry::NAME_STATUS_EXPIRED || status == NameTableEntry::NAME_STATUS_TRANSFERRED_OUT) + { + anyUnspendableSelected = true; + break; + } + } + const bool singleNameSelected = indexes.size() == 1; const bool anyNamesSelected = indexes.size() >= 1; // Context menu copyNameAction->setEnabled(singleNameSelected); copyValueAction->setEnabled(singleNameSelected); - configureNameAction->setEnabled(singleNameSelected); - renewNameAction->setEnabled(anyNamesSelected); + configureNameAction->setEnabled(singleNameSelected && !anyUnspendableSelected); + renewNameAction->setEnabled(anyNamesSelected && !anyUnspendableSelected); // Buttons - ui->configureNameButton->setEnabled(singleNameSelected); - ui->renewNameButton->setEnabled(anyNamesSelected); + ui->configureNameButton->setEnabled(configureNameAction->isEnabled()); + ui->renewNameButton->setEnabled(renewNameAction->isEnabled()); } void ManageNamesPage::contextualMenu(const QPoint &point)