[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)
This commit is contained in:
Philip Kaufmann
2013-11-22 13:53:05 +01:00
parent d4cda964d2
commit 84b695cc9d
5 changed files with 162 additions and 134 deletions

View File

@@ -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("<br />")),
@@ -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<SendCoinsEntry*>(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();
}
}