Skip to content

Commit

Permalink
Merge #408: Disable updating unspendable names
Browse files Browse the repository at this point in the history
b59ad07 Namecoin / Qt: Disable Renew/Configure for unspendable names (Jeremy Rand)

Pull request description:

  This PR disables the "Configure" and "Renew" options for names that are unspendable due to expiration or transfer.

ACKs for top commit:
  domob1812:
    ACK b59ad07.

Tree-SHA512: 56de9a7836f5ec285ad502c47e05903bef7d27275ba6cd217849310b5f77d835025376c2eee7dd62ff2cdcded28a2caf2f7991519381f599a00b67be9fa140ca
  • Loading branch information
domob1812 committed Aug 13, 2021
2 parents 6e0d254 + b59ad07 commit edbbdf1
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/qt/managenamespage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit edbbdf1

Please sign in to comment.