Changeset View
Changeset View
Standalone View
Standalone View
src/qt/sendcoinsentry.cpp
Show All 35 Lines | ui->messageTextLabel->setToolTip( | ||||
tr("A message that was attached to the %1 URI which will be" | tr("A message that was attached to the %1 URI which will be" | ||||
" stored with the transaction for your reference. Note: " | " stored with the transaction for your reference. Note: " | ||||
"This message will not be sent over the Bitcoin network.") | "This message will not be sent over the Bitcoin network.") | ||||
.arg(QString::fromStdString( | .arg(QString::fromStdString( | ||||
model->getChainParams().CashAddrPrefix()))); | model->getChainParams().CashAddrPrefix()))); | ||||
setCurrentWidget(ui->SendCoins); | setCurrentWidget(ui->SendCoins); | ||||
if (platformStyle->getUseExtraSpacing()) ui->payToLayout->setSpacing(4); | if (platformStyle->getUseExtraSpacing()) { | ||||
ui->payToLayout->setSpacing(4); | |||||
} | |||||
ui->addAsLabel->setPlaceholderText( | ui->addAsLabel->setPlaceholderText( | ||||
tr("Enter a label for this address to add it to your address book")); | tr("Enter a label for this address to add it to your address book")); | ||||
// normal bitcoin address field | // normal bitcoin address field | ||||
GUIUtil::setupAddressWidget(ui->payTo, this); | GUIUtil::setupAddressWidget(ui->payTo, this); | ||||
// just a label for displaying bitcoin address(es) | // just a label for displaying bitcoin address(es) | ||||
ui->payTo_is->setFont(GUIUtil::fixedPitchFont()); | ui->payTo_is->setFont(GUIUtil::fixedPitchFont()); | ||||
Show All 15 Lines | |||||
} | } | ||||
void SendCoinsEntry::on_pasteButton_clicked() { | void SendCoinsEntry::on_pasteButton_clicked() { | ||||
// Paste text from clipboard into recipient field | // Paste text from clipboard into recipient field | ||||
ui->payTo->setText(QApplication::clipboard()->text()); | ui->payTo->setText(QApplication::clipboard()->text()); | ||||
} | } | ||||
void SendCoinsEntry::on_addressBookButton_clicked() { | void SendCoinsEntry::on_addressBookButton_clicked() { | ||||
if (!model) return; | if (!model) { | ||||
return; | |||||
} | |||||
AddressBookPage dlg(platformStyle, AddressBookPage::ForSelection, | AddressBookPage dlg(platformStyle, AddressBookPage::ForSelection, | ||||
AddressBookPage::SendingTab, this); | AddressBookPage::SendingTab, this); | ||||
dlg.setModel(model->getAddressTableModel()); | dlg.setModel(model->getAddressTableModel()); | ||||
if (dlg.exec()) { | if (dlg.exec()) { | ||||
ui->payTo->setText(dlg.getReturnValue()); | ui->payTo->setText(dlg.getReturnValue()); | ||||
ui->payAmount->setFocus(); | ui->payAmount->setFocus(); | ||||
} | } | ||||
} | } | ||||
void SendCoinsEntry::on_payTo_textChanged(const QString &address) { | void SendCoinsEntry::on_payTo_textChanged(const QString &address) { | ||||
updateLabel(address); | updateLabel(address); | ||||
} | } | ||||
void SendCoinsEntry::setModel(WalletModel *_model) { | void SendCoinsEntry::setModel(WalletModel *_model) { | ||||
this->model = _model; | this->model = _model; | ||||
if (_model && _model->getOptionsModel()) | if (_model && _model->getOptionsModel()) { | ||||
connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), | connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), | ||||
this, SLOT(updateDisplayUnit())); | this, SLOT(updateDisplayUnit())); | ||||
} | |||||
clear(); | clear(); | ||||
} | } | ||||
void SendCoinsEntry::clear() { | void SendCoinsEntry::clear() { | ||||
// clear UI elements for normal payment | // clear UI elements for normal payment | ||||
ui->payTo->clear(); | ui->payTo->clear(); | ||||
ui->addAsLabel->clear(); | ui->addAsLabel->clear(); | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | if (retval && | ||||
retval = false; | retval = false; | ||||
} | } | ||||
return retval; | return retval; | ||||
} | } | ||||
SendCoinsRecipient SendCoinsEntry::getValue() { | SendCoinsRecipient SendCoinsEntry::getValue() { | ||||
// Payment request | // Payment request | ||||
if (recipient.paymentRequest.IsInitialized()) return recipient; | if (recipient.paymentRequest.IsInitialized()) { | ||||
return recipient; | |||||
} | |||||
// Normal payment | // Normal payment | ||||
recipient.address = ui->payTo->text(); | recipient.address = ui->payTo->text(); | ||||
recipient.label = ui->addAsLabel->text(); | recipient.label = ui->addAsLabel->text(); | ||||
recipient.amount = ui->payAmount->value(); | recipient.amount = ui->payAmount->value(); | ||||
recipient.message = ui->messageTextLabel->text(); | recipient.message = ui->messageTextLabel->text(); | ||||
recipient.fSubtractFeeFromAmount = | recipient.fSubtractFeeFromAmount = | ||||
(ui->checkboxSubtractFeeFromAmount->checkState() == Qt::Checked); | (ui->checkboxSubtractFeeFromAmount->checkState() == Qt::Checked); | ||||
Show All 11 Lines | QWidget *SendCoinsEntry::setupTabChain(QWidget *prev) { | ||||
QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton); | QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton); | ||||
QWidget::setTabOrder(ui->pasteButton, ui->deleteButton); | QWidget::setTabOrder(ui->pasteButton, ui->deleteButton); | ||||
return ui->deleteButton; | return ui->deleteButton; | ||||
} | } | ||||
void SendCoinsEntry::setValue(const SendCoinsRecipient &value) { | void SendCoinsEntry::setValue(const SendCoinsRecipient &value) { | ||||
recipient = value; | recipient = value; | ||||
if (recipient.paymentRequest.IsInitialized()) // payment request | // payment request | ||||
{ | if (recipient.paymentRequest.IsInitialized()) { | ||||
if (recipient.authenticatedMerchant.isEmpty()) // unauthenticated | // unauthenticated | ||||
{ | if (recipient.authenticatedMerchant.isEmpty()) { | ||||
ui->payTo_is->setText(recipient.address); | ui->payTo_is->setText(recipient.address); | ||||
ui->memoTextLabel_is->setText(recipient.message); | ui->memoTextLabel_is->setText(recipient.message); | ||||
ui->payAmount_is->setValue(recipient.amount); | ui->payAmount_is->setValue(recipient.amount); | ||||
ui->payAmount_is->setReadOnly(true); | ui->payAmount_is->setReadOnly(true); | ||||
setCurrentWidget(ui->SendCoins_UnauthenticatedPaymentRequest); | setCurrentWidget(ui->SendCoins_UnauthenticatedPaymentRequest); | ||||
} else // authenticated | } | ||||
{ | |||||
// authenticated | |||||
else { | |||||
ui->payTo_s->setText(recipient.authenticatedMerchant); | ui->payTo_s->setText(recipient.authenticatedMerchant); | ||||
ui->memoTextLabel_s->setText(recipient.message); | ui->memoTextLabel_s->setText(recipient.message); | ||||
ui->payAmount_s->setValue(recipient.amount); | ui->payAmount_s->setValue(recipient.amount); | ||||
ui->payAmount_s->setReadOnly(true); | ui->payAmount_s->setReadOnly(true); | ||||
setCurrentWidget(ui->SendCoins_AuthenticatedPaymentRequest); | setCurrentWidget(ui->SendCoins_AuthenticatedPaymentRequest); | ||||
} | } | ||||
} else // normal payment | } | ||||
{ | |||||
// normal payment | |||||
else { | |||||
// message | // message | ||||
ui->messageTextLabel->setText(recipient.message); | ui->messageTextLabel->setText(recipient.message); | ||||
ui->messageTextLabel->setVisible(!recipient.message.isEmpty()); | ui->messageTextLabel->setVisible(!recipient.message.isEmpty()); | ||||
ui->messageLabel->setVisible(!recipient.message.isEmpty()); | ui->messageLabel->setVisible(!recipient.message.isEmpty()); | ||||
ui->addAsLabel->clear(); | ui->addAsLabel->clear(); | ||||
ui->payTo->setText( | // this may set a label from addressbook | ||||
recipient.address); // this may set a label from addressbook | ui->payTo->setText(recipient.address); | ||||
if (!recipient.label.isEmpty()) // if a label had been set from the | // if a label had been set from the addressbook, don't overwrite with an | ||||
// addressbook, don't overwrite with an | |||||
// empty label | // empty label | ||||
if (!recipient.label.isEmpty()) { | |||||
ui->addAsLabel->setText(recipient.label); | ui->addAsLabel->setText(recipient.label); | ||||
} | |||||
ui->payAmount->setValue(recipient.amount); | ui->payAmount->setValue(recipient.amount); | ||||
} | } | ||||
} | } | ||||
void SendCoinsEntry::setAddress(const QString &address) { | void SendCoinsEntry::setAddress(const QString &address) { | ||||
ui->payTo->setText(address); | ui->payTo->setText(address); | ||||
ui->payAmount->setFocus(); | ui->payAmount->setFocus(); | ||||
} | } | ||||
Show All 19 Lines | if (model && model->getOptionsModel()) { | ||||
ui->payAmount_is->setDisplayUnit( | ui->payAmount_is->setDisplayUnit( | ||||
model->getOptionsModel()->getDisplayUnit()); | model->getOptionsModel()->getDisplayUnit()); | ||||
ui->payAmount_s->setDisplayUnit( | ui->payAmount_s->setDisplayUnit( | ||||
model->getOptionsModel()->getDisplayUnit()); | model->getOptionsModel()->getDisplayUnit()); | ||||
} | } | ||||
} | } | ||||
bool SendCoinsEntry::updateLabel(const QString &address) { | bool SendCoinsEntry::updateLabel(const QString &address) { | ||||
if (!model) return false; | if (!model) { | ||||
return false; | |||||
} | |||||
// Fill in label from address book, if address has an associated label | // Fill in label from address book, if address has an associated label | ||||
QString associatedLabel = | QString associatedLabel = | ||||
model->getAddressTableModel()->labelForAddress(address); | model->getAddressTableModel()->labelForAddress(address); | ||||
if (!associatedLabel.isEmpty()) { | if (!associatedLabel.isEmpty()) { | ||||
ui->addAsLabel->setText(associatedLabel); | ui->addAsLabel->setText(associatedLabel); | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } |