diff options
| author | Wladimir J. van der Laan <[email protected]> | 2011-05-15 19:31:20 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2011-05-15 19:31:20 +0200 |
| commit | 992ff49b43cd9110fc8ce41151f7555458dcf4dc (patch) | |
| tree | 589c25b9608f671e9ca4be7f32e384c931ab19a7 /gui/src | |
| parent | update to bitcoin-git (diff) | |
| download | discoin-992ff49b43cd9110fc8ce41151f7555458dcf4dc.tar.xz discoin-992ff49b43cd9110fc8ce41151f7555458dcf4dc.zip | |
make send coins dialog more user friendly (better checking)
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/addressbookdialog.cpp | 10 | ||||
| -rw-r--r-- | gui/src/bitcoingui.cpp | 7 | ||||
| -rw-r--r-- | gui/src/sendcoinsdialog.cpp | 43 |
3 files changed, 51 insertions, 9 deletions
diff --git a/gui/src/addressbookdialog.cpp b/gui/src/addressbookdialog.cpp index 71543f11a..9ad18f1cd 100644 --- a/gui/src/addressbookdialog.cpp +++ b/gui/src/addressbookdialog.cpp @@ -127,6 +127,12 @@ void AddressBookDialog::on_buttonBox_accepted() QVariant address = table->model()->data(index); returnValue = address.toString(); } - - accept(); + if(!returnValue.isEmpty()) + { + accept(); + } + else + { + reject(); + } } diff --git a/gui/src/bitcoingui.cpp b/gui/src/bitcoingui.cpp index 4af703cf8..760789a01 100644 --- a/gui/src/bitcoingui.cpp +++ b/gui/src/bitcoingui.cpp @@ -211,7 +211,12 @@ void BitcoinGUI::addressbookClicked() qDebug() << "Address book clicked"; AddressBookDialog dlg; dlg.setTab(AddressBookDialog::SendingTab); - dlg.exec(); + /* if an address accepted, do a 'send' to specified address */ + if(dlg.exec()) + { + SendCoinsDialog send(0, dlg.getReturnValue()); + send.exec(); + } } void BitcoinGUI::receivingAddressesClicked() diff --git a/gui/src/sendcoinsdialog.cpp b/gui/src/sendcoinsdialog.cpp index ce95244dc..3907b4bc5 100644 --- a/gui/src/sendcoinsdialog.cpp +++ b/gui/src/sendcoinsdialog.cpp @@ -6,17 +6,31 @@ #include <QApplication> #include <QClipboard> +#include <QMessageBox> +#include <QLocale> #include "base58.h" -SendCoinsDialog::SendCoinsDialog(QWidget *parent) : +SendCoinsDialog::SendCoinsDialog(QWidget *parent, const QString &address) : QDialog(parent), ui(new Ui::SendCoinsDialog) { ui->setupUi(this); + + /* Set up validators */ ui->payTo->setMaxLength(BitcoinAddressValidator::MaxAddressLength); ui->payTo->setValidator(new BitcoinAddressValidator(this)); - ui->payAmount->setValidator(new QDoubleValidator(this)); + QDoubleValidator *amountValidator = new QDoubleValidator(this); + amountValidator->setDecimals(8); + amountValidator->setBottom(0.0); + ui->payAmount->setValidator(amountValidator); + + /* Set initial address if provided */ + if(!address.isEmpty()) + { + ui->payTo->setText(address); + ui->payAmount->setFocus(); + } } SendCoinsDialog::~SendCoinsDialog() @@ -28,14 +42,31 @@ void SendCoinsDialog::on_sendButton_clicked() { QByteArray payTo = ui->payTo->text().toUtf8(); uint160 payToHash = 0; - if(AddressToHash160(payTo.constData(), payToHash)) + double payAmount = 0.0; + bool valid = false; + + if(!AddressToHash160(payTo.constData(), payToHash)) { - accept(); + QMessageBox::warning(this, tr("Warning"), + tr("The recepient address is not valid, please recheck."), + QMessageBox::Ok, + QMessageBox::Ok); + ui->payTo->setFocus(); + return; } - else + payAmount = QLocale::system().toDouble(ui->payAmount->text(), &valid); + if(!valid || payAmount <= 0.0) { - + QMessageBox::warning(this, tr("Warning"), + tr("The amount to pay must be a valid number larger than 0."), + QMessageBox::Ok, + QMessageBox::Ok); + ui->payAmount->setFocus(); + return; } + + /* TODO: send command to core, once this succeeds do accept() */ + accept(); } void SendCoinsDialog::on_pasteButton_clicked() |