1 #include "sendcoinsdialog.h"
2 #include "ui_sendcoinsdialog.h"
4 #include "addressbookdialog.h"
5 #include "bitcoinaddressvalidator.h"
7 #include <QApplication>
16 SendCoinsDialog::SendCoinsDialog(QWidget *parent, const QString &address) :
18 ui(new Ui::SendCoinsDialog)
22 /* Set up validators */
23 ui->payTo->setMaxLength(BitcoinAddressValidator::MaxAddressLength);
24 ui->payTo->setValidator(new BitcoinAddressValidator(this));
25 QDoubleValidator *amountValidator = new QDoubleValidator(this);
26 amountValidator->setDecimals(8);
27 amountValidator->setBottom(0.0);
28 ui->payAmount->setValidator(amountValidator);
30 /* Set initial address if provided */
31 if(!address.isEmpty())
33 ui->payTo->setText(address);
34 ui->payAmount->setFocus();
38 SendCoinsDialog::~SendCoinsDialog()
43 void SendCoinsDialog::on_sendButton_clicked()
45 QByteArray payTo = ui->payTo->text().toUtf8();
46 uint160 payToHash = 0;
47 int64 payAmount = 0.0;
50 if(!AddressToHash160(payTo.constData(), payToHash))
52 QMessageBox::warning(this, tr("Warning"),
53 tr("The recepient address is not valid, please recheck."),
56 ui->payTo->setFocus();
59 valid = ParseMoney(ui->payAmount->text().toStdString(), payAmount);
61 if(!valid || payAmount <= 0)
63 QMessageBox::warning(this, tr("Warning"),
64 tr("The amount to pay must be a valid number larger than 0."),
67 ui->payAmount->setFocus();
70 qDebug() << "Pay " << payAmount;
72 /* TODO: send command to core, once this succeeds do accept() */
76 void SendCoinsDialog::on_pasteButton_clicked()
78 /* Paste text from clipboard into recipient field */
79 ui->payTo->setText(QApplication::clipboard()->text());
82 void SendCoinsDialog::on_addressBookButton_clicked()
84 AddressBookDialog dlg;
86 ui->payTo->setText(dlg.getReturnValue());
89 void SendCoinsDialog::on_buttonBox_rejected()