aboutsummaryrefslogtreecommitdiff
path: root/src/qt/sendcoinsentry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/sendcoinsentry.cpp')
-rw-r--r--src/qt/sendcoinsentry.cpp66
1 files changed, 43 insertions, 23 deletions
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index b7f684c483..490b9caf5e 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -22,7 +22,7 @@ SendCoinsEntry::SendCoinsEntry(QWidget *parent) :
{
ui->setupUi(this);
- setCurrentWidget(ui->SendCoinsInsecure);
+ setCurrentWidget(ui->SendCoins);
#ifdef Q_OS_MAC
ui->payToLayout->setSpacing(4);
@@ -32,10 +32,12 @@ SendCoinsEntry::SendCoinsEntry(QWidget *parent) :
ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book"));
ui->payTo->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)"));
#endif
- setFocusPolicy(Qt::TabFocus);
setFocusProxy(ui->payTo);
+ // normal bitcoin address field
GUIUtil::setupAddressWidget(ui->payTo, this);
+ // just a label for displaying bitcoin address(es)
+ ui->payTo_is->setFont(GUIUtil::bitcoinAddressFont());
}
SendCoinsEntry::~SendCoinsEntry()
@@ -71,7 +73,7 @@ void SendCoinsEntry::setModel(WalletModel *model)
{
this->model = model;
- if(model && model->getOptionsModel())
+ if (model && model->getOptionsModel())
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
clear();
@@ -84,11 +86,15 @@ void SendCoinsEntry::setRemoveEnabled(bool enabled)
void SendCoinsEntry::clear()
{
- // clear UI elements for insecure payments
+ // clear UI elements for normal payment
ui->payTo->clear();
ui->addAsLabel->clear();
ui->payAmount->clear();
- // and the ones for secure payments just to be sure
+ // clear UI elements for insecure payment request
+ ui->payTo_is->clear();
+ ui->memoTextLabel_is->clear();
+ ui->payAmount_is->clear();
+ // clear UI elements for secure payment request
ui->payTo_s->clear();
ui->memoTextLabel_s->clear();
ui->payAmount_s->clear();
@@ -106,20 +112,23 @@ void SendCoinsEntry::on_deleteButton_clicked()
bool SendCoinsEntry::validate()
{
+ if (!model)
+ return false;
+
// Check input validity
bool retval = true;
- if (!recipient.authenticatedMerchant.isEmpty())
+ // Skip checks for payment request
+ if (recipient.paymentRequest.IsInitialized())
return retval;
- if (!ui->payTo->hasAcceptableInput() ||
- (model && !model->validateAddress(ui->payTo->text())))
+ if (!ui->payTo->hasAcceptableInput() || !model->validateAddress(ui->payTo->text()))
{
ui->payTo->setValid(false);
retval = false;
}
- if(!ui->payAmount->validate())
+ if (!ui->payAmount->validate())
{
retval = false;
}
@@ -135,10 +144,11 @@ bool SendCoinsEntry::validate()
SendCoinsRecipient SendCoinsEntry::getValue()
{
- if (!recipient.authenticatedMerchant.isEmpty())
+ // Payment request
+ if (recipient.paymentRequest.IsInitialized())
return recipient;
- // User-entered or non-authenticated:
+ // Normal payment
recipient.address = ui->payTo->text();
recipient.label = ui->addAsLabel->text();
recipient.amount = ui->payAmount->value();
@@ -160,22 +170,31 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value)
{
recipient = value;
- if (recipient.authenticatedMerchant.isEmpty())
+ if (recipient.paymentRequest.IsInitialized()) // payment request
+ {
+ if (recipient.authenticatedMerchant.isEmpty()) // insecure
+ {
+ ui->payTo_is->setText(recipient.address);
+ ui->memoTextLabel_is->setText(recipient.message);
+ ui->payAmount_is->setValue(recipient.amount);
+ ui->payAmount_is->setReadOnly(true);
+ setCurrentWidget(ui->SendCoins_InsecurePaymentRequest);
+ }
+ else // secure
+ {
+ ui->payTo_s->setText(recipient.authenticatedMerchant);
+ ui->memoTextLabel_s->setText(recipient.message);
+ ui->payAmount_s->setValue(recipient.amount);
+ ui->payAmount_s->setReadOnly(true);
+ setCurrentWidget(ui->SendCoins_SecurePaymentRequest);
+ }
+ }
+ else // normal payment
{
ui->payTo->setText(recipient.address);
ui->addAsLabel->setText(recipient.label);
ui->payAmount->setValue(recipient.amount);
}
- else
- {
- const payments::PaymentDetails& details = recipient.paymentRequest.getDetails();
-
- ui->payTo_s->setText(recipient.authenticatedMerchant);
- ui->memoTextLabel_s->setText(QString::fromStdString(details.memo()));
- ui->payAmount_s->setValue(recipient.amount);
- ui->payAmount_s->setReadOnly(true);
- setCurrentWidget(ui->SendCoinsSecure);
- }
}
void SendCoinsEntry::setAddress(const QString &address)
@@ -186,7 +205,7 @@ void SendCoinsEntry::setAddress(const QString &address)
bool SendCoinsEntry::isClear()
{
- return ui->payTo->text().isEmpty() && ui->payTo_s->text().isEmpty();
+ return ui->payTo->text().isEmpty() && ui->payTo_is->text().isEmpty() && ui->payTo_s->text().isEmpty();
}
void SendCoinsEntry::setFocus()
@@ -200,6 +219,7 @@ void SendCoinsEntry::updateDisplayUnit()
{
// Update payAmount with the current unit
ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
+ ui->payAmount_is->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
ui->payAmount_s->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
}
}