2 #include "ui_sendcoinsdialog.h"
16 #include <QMessageBox>
17 #include <QTextDocument>
31 #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
32 ui->addButton->setIcon(QIcon());
33 ui->clearButton->setIcon(QIcon());
34 ui->sendButton->setIcon(QIcon());
35 ui->sendQRButton->setIcon(QIcon());
37 #if QT_VERSION >= 0x040700
39 ui->lineEditCoinControlChange->setPlaceholderText(tr(
"Enter a Feathercoin address (e.g. 6nqmPL9tX4Uz3uQhbz8GrgLfXQNQEXstVu)"));
43 this->
ui->sendQRButton->hide();
47 connect(
ui->addButton, SIGNAL(clicked()),
this, SLOT(
addEntry()));
48 connect(
ui->clearButton, SIGNAL(clicked()),
this, SLOT(
clear()));
54 connect(
ui->lineEditCoinControlChange, SIGNAL(textEdited(
const QString &)),
this, SLOT(
coinControlChangeEdited(
const QString &)));
57 QAction *clipboardQuantityAction =
new QAction(tr(
"Copy quantity"),
this);
58 QAction *clipboardAmountAction =
new QAction(tr(
"Copy amount"),
this);
59 QAction *clipboardFeeAction =
new QAction(tr(
"Copy fee"),
this);
60 QAction *clipboardAfterFeeAction =
new QAction(tr(
"Copy after fee"),
this);
61 QAction *clipboardBytesAction =
new QAction(tr(
"Copy bytes"),
this);
62 QAction *clipboardPriorityAction =
new QAction(tr(
"Copy priority"),
this);
63 QAction *clipboardLowOutputAction =
new QAction(tr(
"Copy low output"),
this);
64 QAction *clipboardChangeAction =
new QAction(tr(
"Copy change"),
this);
73 ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
74 ui->labelCoinControlAmount->addAction(clipboardAmountAction);
75 ui->labelCoinControlFee->addAction(clipboardFeeAction);
76 ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
77 ui->labelCoinControlBytes->addAction(clipboardBytesAction);
78 ui->labelCoinControlPriority->addAction(clipboardPriorityAction);
79 ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
80 ui->labelCoinControlChange->addAction(clipboardChangeAction);
89 for(
int i = 0; i <
ui->entries->count(); ++i)
100 connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)),
this, SLOT(
setBalance(qint64, qint64, qint64)));
121 connect(snap, SIGNAL(finished(QString)),
this, SLOT(
onSnapClosed(QString)));
132 QList<SendCoinsRecipient> recipients;
138 for(
int i = 0; i <
ui->entries->count(); ++i)
145 recipients.append(entry->
getValue());
154 if(!valid || recipients.isEmpty())
160 QStringList formatted;
163 #if QT_VERSION < 0x050000
172 QMessageBox::StandardButton retval = QMessageBox::question(
this, tr(
"Confirm send coins"),
173 tr(
"Are you sure you want to send %1?").
arg(formatted.join(tr(
" and "))),
174 QMessageBox::Yes|QMessageBox::Cancel,
175 QMessageBox::Cancel);
177 if(retval != QMessageBox::Yes)
199 QMessageBox::warning(
this, tr(
"Send Coins"),
200 tr(
"The recipient address is not valid, please recheck."),
201 QMessageBox::Ok, QMessageBox::Ok);
204 QMessageBox::warning(
this, tr(
"Send Coins"),
205 tr(
"The amount to pay must be larger than 0."),
206 QMessageBox::Ok, QMessageBox::Ok);
209 QMessageBox::warning(
this, tr(
"Send Coins"),
210 tr(
"The amount exceeds your balance."),
211 QMessageBox::Ok, QMessageBox::Ok);
214 QMessageBox::warning(
this, tr(
"Send Coins"),
215 tr(
"The total exceeds your balance when the %1 transaction fee is included.").
217 QMessageBox::Ok, QMessageBox::Ok);
220 QMessageBox::warning(
this, tr(
"Send Coins"),
221 tr(
"Duplicate address found, can only send to each address once per send operation."),
222 QMessageBox::Ok, QMessageBox::Ok);
225 QMessageBox::warning(
this, tr(
"Send Coins"),
226 tr(
"Error: Transaction creation failed!"),
227 QMessageBox::Ok, QMessageBox::Ok);
230 QMessageBox::warning(
this, tr(
"Send Coins"),
231 tr(
"Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."),
232 QMessageBox::Ok, QMessageBox::Ok);
248 while(
ui->entries->count())
250 ui->entries->takeAt(0)->widget()->deleteLater();
256 ui->sendButton->setDefault(
true);
273 ui->entries->addWidget(entry);
282 ui->scrollAreaWidgetContents->resize(
ui->scrollAreaWidgetContents->sizeHint());
283 qApp->processEvents();
284 QScrollBar* bar =
ui->scrollArea->verticalScrollBar();
286 bar->setSliderPosition(bar->maximum());
293 bool enabled = (
ui->entries->count() > 1);
294 for(
int i = 0; i <
ui->entries->count(); ++i)
309 entry->deleteLater();
315 for(
int i = 0; i <
ui->entries->count(); ++i)
323 QWidget::setTabOrder(prev,
ui->addButton);
324 QWidget::setTabOrder(
ui->addButton,
ui->sendButton);
325 return ui->sendButton;
332 if(
ui->entries->count() == 1)
355 if(
ui->entries->count() == 1)
378 if (!address.IsValid())
389 Q_UNUSED(unconfirmedBalance);
390 Q_UNUSED(immatureBalance);
458 ui->frameCoinControl->setVisible(checked);
460 if (!checked &&
model)
478 if (state == Qt::Checked)
484 ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
485 ui->labelCoinControlChangeLabel->setVisible((state == Qt::Checked));
496 ui->labelCoinControlChangeLabel->setStyleSheet(
"QLabel{color:black;}");
498 ui->labelCoinControlChangeLabel->setText(
"");
501 ui->labelCoinControlChangeLabel->setStyleSheet(
"QLabel{color:red;}");
502 ui->labelCoinControlChangeLabel->setText(tr(
"Warning: Invalid Bitcoin address"));
507 if (!associatedLabel.isEmpty())
508 ui->labelCoinControlChangeLabel->setText(associatedLabel);
515 ui->labelCoinControlChangeLabel->setText(tr(
"(no label)"));
518 ui->labelCoinControlChangeLabel->setStyleSheet(
"QLabel{color:red;}");
519 ui->labelCoinControlChangeLabel->setText(tr(
"Warning: Unknown change address"));
534 for(
int i = 0; i <
ui->entries->count(); ++i)
547 ui->labelCoinControlAutomaticallySelected->hide();
548 ui->widgetCoinControl->show();
553 ui->labelCoinControlAutomaticallySelected->show();
554 ui->widgetCoinControl->hide();
555 ui->labelCoinControlInsuffFunds->hide();
void removeEntry(SendCoinsEntry *entry)
void setValue(const SendCoinsRecipient &value)
SendCoinsReturn sendCoins(const QList< SendCoinsRecipient > &recipients, const CCoinControl *coinControl=NULL)
static QString formatWithUnit(int unit, qint64 amount, bool plussign=false)
Format as string (with unit)
void coinControlClipboardPriority()
qint64 getImmatureBalance() const
static CCoinControl * coinControl
SendCoinsRecipient getValue()
UnlockContext requestUnlock()
SendCoinsDialog(QWidget *parent=0)
void coinControlClipboardQuantity()
void coinControlClipboardAfterFee()
void setAddress(const QString &address)
void updateRemoveEnabled()
AddressTableModel * getAddressTableModel()
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
A single entry in the dialog for sending bitcoins.
void coinControlFeatureChanged(bool)
QWidget * setupTabChain(QWidget *prev)
Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://...
bool getCoinControlFeatures()
void onSnapClosed(QString s)
Scan of QR code finished.
QWidget * setupTabChain(QWidget *prev)
Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://...
void on_sendButton_clicked()
SendCoinsEntry * addEntry()
void on_sendQRButton_clicked()
void setAddress(const QString &address)
void coinControlClipboardChange()
void setClipboard(const QString &str)
CTxDestination destChange
qint64 getUnconfirmedBalance() const
An encapsulated public key.
bool getPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
bool handleURI(const QString &uri)
Dialog for sending bitcoins.
void coinControlChangeEdited(const QString &)
static void updateLabels(WalletModel *, QDialog *)
void coinControlUpdateLabels()
void setModel(WalletModel *model)
void setRemoveEnabled(bool enabled)
bool isClear()
Return whether the entry is still empty and unedited.
void coinControlClipboardLowOutput()
void setModel(WalletModel *model)
QString labelForAddress(const QString &address) const
Interface to Bitcoin wallet from Qt view code.
A reference to a CKey: the Hash160 of its serialized public key.
qint64 getBalance(const CCoinControl *coinControl=NULL) const
void setModel(WalletModel *model)
static QList< qint64 > payAmounts
void coinControlClipboardBytes()
void coinControlClipboardAmount()
void sendCoins(QString addr)
void pasteEntry(const SendCoinsRecipient &rv)
bool fNewRecipientAllowed
void coinControlButtonClicked()
void coinControlClipboardFee()
QFont bitcoinAddressFont()
OptionsModel * getOptionsModel()
void setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
void coinControlChangeChecked(int)