From 84b695cc9d4dc90b1ccb99e2d92e1e76e138d911 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Fri, 22 Nov 2013 13:53:05 +0100 Subject: [Qt] allow deletion of payment-requests in sendcoins - this adds a delete button for insecure and secure payment requests in the sendcoins dialog - it also enables the delete button even for single and empty entries, as this is much easier to handle and doesn't need to special case single entries - big parts of the ui file were changed, because I copied the delete button and had to delete the layout too and created it from scratch (which seems to cleanup the rows and colums in the layout also, which is nice IMHO) --- src/qt/sendcoinsdialog.cpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'src/qt/sendcoinsdialog.cpp') diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index fa8da1c8dd..6c3535b2fb 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -227,8 +227,8 @@ void SendCoinsDialog::on_sendButton_clicked() alternativeUnits.append(BitcoinUnits::formatWithUnit(u, totalAmount)); } questionString.append(tr("Total Amount %1 (= %2)") - .arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount)) - .arg(alternativeUnits.join(" "+tr("or")+" "))); + .arg(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), totalAmount)) + .arg(alternativeUnits.join(" " + tr("or") + " "))); QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), questionString.arg(formatted.join("
")), @@ -264,9 +264,7 @@ void SendCoinsDialog::clear() } addEntry(); - updateRemoveEnabled(); - - ui->sendButton->setDefault(true); + updateTabsAndLabels(); } void SendCoinsDialog::reject() @@ -287,7 +285,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry() connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*))); connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels())); - updateRemoveEnabled(); + updateTabsAndLabels(); // Focus the field, so that entry can start immediately entry->clear(); @@ -300,27 +298,21 @@ SendCoinsEntry *SendCoinsDialog::addEntry() return entry; } -void SendCoinsDialog::updateRemoveEnabled() +void SendCoinsDialog::updateTabsAndLabels() { - // Remove buttons are enabled as soon as there is more than one send-entry - bool enabled = (ui->entries->count() > 1); - for(int i = 0; i < ui->entries->count(); ++i) - { - SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - if(entry) - { - entry->setRemoveEnabled(enabled); - } - } setupTabChain(0); - coinControlUpdateLabels(); } void SendCoinsDialog::removeEntry(SendCoinsEntry* entry) { delete entry; - updateRemoveEnabled(); + + // If the last entry was removed add an empty one + if (!ui->entries->count()) + addEntry(); + + updateTabsAndLabels(); } QWidget *SendCoinsDialog::setupTabChain(QWidget *prev) @@ -379,7 +371,7 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) } entry->setValue(rv); - coinControlUpdateLabels(); + updateTabsAndLabels(); } bool SendCoinsDialog::handlePaymentRequest(const SendCoinsRecipient &rv) @@ -619,4 +611,3 @@ void SendCoinsDialog::coinControlUpdateLabels() ui->labelCoinControlInsuffFunds->hide(); } } - -- cgit v1.2.3