Pharao Release
Version 4.0.0.4 - refactored code - migrated vom Qt4 to Qt5 - added secure messaging
This commit is contained in:
+188
-179
@@ -1,15 +1,18 @@
|
||||
#include "sendcoinsdialog.h"
|
||||
#include "ui_sendcoinsdialog.h"
|
||||
|
||||
#include "init.h"
|
||||
#include "walletmodel.h"
|
||||
#include "addresstablemodel.h"
|
||||
#include "addressbookpage.h"
|
||||
#include "bitcoinunits.h"
|
||||
|
||||
#include "trianglesunits.h"
|
||||
#include "addressbookpage.h"
|
||||
#include "optionsmodel.h"
|
||||
#include "sendcoinsentry.h"
|
||||
#include "guiutil.h"
|
||||
#include "askpassphrasedialog.h"
|
||||
|
||||
#include "coincontrol.h"
|
||||
#include "coincontroldialog.h"
|
||||
|
||||
@@ -33,47 +36,47 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
|
||||
#endif
|
||||
|
||||
#if QT_VERSION >= 0x040700
|
||||
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
|
||||
ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a Triangles address (e.g. TrXW1RKLDe8VMNwTwLwSiKuATN5M74EL85)"));
|
||||
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
|
||||
ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a TRI address (e.g. TXc7mPCNFFpinDonuSH5PNVY9S8nBcvGQm)"));
|
||||
#endif
|
||||
|
||||
addEntry();
|
||||
|
||||
connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry()));
|
||||
connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
|
||||
// Coin Control
|
||||
ui->lineEditCoinControlChange->setFont(GUIUtil::bitcoinAddressFont());
|
||||
connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked()));
|
||||
connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int)));
|
||||
connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &)));
|
||||
|
||||
// Coin Control: clipboard actions
|
||||
QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this);
|
||||
QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this);
|
||||
QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this);
|
||||
QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this);
|
||||
QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this);
|
||||
QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this);
|
||||
QAction *clipboardLowOutputAction = new QAction(tr("Copy low output"), this);
|
||||
QAction *clipboardChangeAction = new QAction(tr("Copy change"), this);
|
||||
connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity()));
|
||||
connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount()));
|
||||
connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee()));
|
||||
connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee()));
|
||||
connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes()));
|
||||
connect(clipboardPriorityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardPriority()));
|
||||
connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput()));
|
||||
connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange()));
|
||||
ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
|
||||
ui->labelCoinControlAmount->addAction(clipboardAmountAction);
|
||||
ui->labelCoinControlFee->addAction(clipboardFeeAction);
|
||||
ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
|
||||
ui->labelCoinControlBytes->addAction(clipboardBytesAction);
|
||||
ui->labelCoinControlPriority->addAction(clipboardPriorityAction);
|
||||
ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
|
||||
ui->labelCoinControlChange->addAction(clipboardChangeAction);
|
||||
|
||||
|
||||
// Coin Control
|
||||
ui->lineEditCoinControlChange->setFont(GUIUtil::trianglesAddressFont());
|
||||
connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked()));
|
||||
connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int)));
|
||||
connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &)));
|
||||
|
||||
// Coin Control: clipboard actions
|
||||
QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this);
|
||||
QAction *clipboardAmountAction = new QAction(tr("Copy amount"), this);
|
||||
QAction *clipboardFeeAction = new QAction(tr("Copy fee"), this);
|
||||
QAction *clipboardAfterFeeAction = new QAction(tr("Copy after fee"), this);
|
||||
QAction *clipboardBytesAction = new QAction(tr("Copy bytes"), this);
|
||||
QAction *clipboardPriorityAction = new QAction(tr("Copy priority"), this);
|
||||
QAction *clipboardLowOutputAction = new QAction(tr("Copy low output"), this);
|
||||
QAction *clipboardChangeAction = new QAction(tr("Copy change"), this);
|
||||
connect(clipboardQuantityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardQuantity()));
|
||||
connect(clipboardAmountAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAmount()));
|
||||
connect(clipboardFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardFee()));
|
||||
connect(clipboardAfterFeeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardAfterFee()));
|
||||
connect(clipboardBytesAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardBytes()));
|
||||
connect(clipboardPriorityAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardPriority()));
|
||||
connect(clipboardLowOutputAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardLowOutput()));
|
||||
connect(clipboardChangeAction, SIGNAL(triggered()), this, SLOT(coinControlClipboardChange()));
|
||||
ui->labelCoinControlQuantity->addAction(clipboardQuantityAction);
|
||||
ui->labelCoinControlAmount->addAction(clipboardAmountAction);
|
||||
ui->labelCoinControlFee->addAction(clipboardFeeAction);
|
||||
ui->labelCoinControlAfterFee->addAction(clipboardAfterFeeAction);
|
||||
ui->labelCoinControlBytes->addAction(clipboardBytesAction);
|
||||
ui->labelCoinControlPriority->addAction(clipboardPriorityAction);
|
||||
ui->labelCoinControlLowOutput->addAction(clipboardLowOutputAction);
|
||||
ui->labelCoinControlChange->addAction(clipboardChangeAction);
|
||||
|
||||
fNewRecipientAllowed = true;
|
||||
}
|
||||
|
||||
@@ -94,7 +97,7 @@ void SendCoinsDialog::setModel(WalletModel *model)
|
||||
setBalance(model->getBalance(), model->getStake(), model->getUnconfirmedBalance(), model->getImmatureBalance());
|
||||
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64, qint64)));
|
||||
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
|
||||
|
||||
|
||||
// Coin Control
|
||||
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(coinControlUpdateLabels()));
|
||||
connect(model->getOptionsModel(), SIGNAL(coinControlFeaturesChanged(bool)), this, SLOT(coinControlFeatureChanged(bool)));
|
||||
@@ -116,7 +119,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||
|
||||
if(!model)
|
||||
return;
|
||||
|
||||
|
||||
for(int i = 0; i < ui->entries->count(); ++i)
|
||||
{
|
||||
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
|
||||
@@ -142,7 +145,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||
QStringList formatted;
|
||||
foreach(const SendCoinsRecipient &rcp, recipients)
|
||||
{
|
||||
formatted.append(tr("<b>%1</b> to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address));
|
||||
formatted.append(tr("<b>%1</b> to %2 (%3)").arg(TrianglesUnits::formatWithUnit(TrianglesUnits::TRI, rcp.amount), Qt::escape(rcp.label), rcp.address));
|
||||
}
|
||||
|
||||
fNewRecipientAllowed = false;
|
||||
@@ -166,7 +169,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||
return;
|
||||
}
|
||||
|
||||
WalletModel::SendCoinsReturn sendstatus;
|
||||
WalletModel::SendCoinsReturn sendstatus;
|
||||
|
||||
if (!model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures())
|
||||
sendstatus = model->sendCoins(recipients);
|
||||
@@ -193,7 +196,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||
case WalletModel::AmountWithFeeExceedsBalance:
|
||||
QMessageBox::warning(this, tr("Send Coins"),
|
||||
tr("The total exceeds your balance when the %1 transaction fee is included.").
|
||||
arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, sendstatus.fee)),
|
||||
arg(TrianglesUnits::formatWithUnit(TrianglesUnits::TRI, sendstatus.fee)),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
break;
|
||||
case WalletModel::DuplicateAddress:
|
||||
@@ -211,11 +214,16 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||
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."),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
break;
|
||||
case WalletModel::Aborted: // User aborted, nothing to do
|
||||
case WalletModel::NarrationTooLong:
|
||||
QMessageBox::warning(this, tr("Send Coins"),
|
||||
tr("Error: Narration is too long."),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
break;
|
||||
case WalletModel::Aborted: // User aborted, nothing to do
|
||||
break;
|
||||
case WalletModel::OK:
|
||||
accept();
|
||||
CoinControlDialog::coinControl->UnSelectAll();
|
||||
CoinControlDialog::coinControl->UnSelectAll();
|
||||
coinControlUpdateLabels();
|
||||
break;
|
||||
}
|
||||
@@ -252,7 +260,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
|
||||
entry->setModel(model);
|
||||
ui->entries->addWidget(entry);
|
||||
connect(entry, SIGNAL(removeEntry(SendCoinsEntry*)), this, SLOT(removeEntry(SendCoinsEntry*)));
|
||||
connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels()));
|
||||
connect(entry, SIGNAL(payAmountChanged()), this, SLOT(coinControlUpdateLabels()));
|
||||
|
||||
updateRemoveEnabled();
|
||||
|
||||
@@ -280,7 +288,7 @@ void SendCoinsDialog::updateRemoveEnabled()
|
||||
}
|
||||
}
|
||||
setupTabChain(0);
|
||||
coinControlUpdateLabels();
|
||||
coinControlUpdateLabels();
|
||||
}
|
||||
|
||||
void SendCoinsDialog::removeEntry(SendCoinsEntry* entry)
|
||||
@@ -331,9 +339,9 @@ bool SendCoinsDialog::handleURI(const QString &uri)
|
||||
{
|
||||
SendCoinsRecipient rv;
|
||||
// URI has to be valid
|
||||
if (GUIUtil::parseBitcoinURI(uri, &rv))
|
||||
if (GUIUtil::parseTrianglesURI(uri, &rv))
|
||||
{
|
||||
CBitcoinAddress address(rv.address.toStdString());
|
||||
CTrianglesAddress address(rv.address.toStdString());
|
||||
if (!address.IsValid())
|
||||
return false;
|
||||
pasteEntry(rv);
|
||||
@@ -352,7 +360,7 @@ void SendCoinsDialog::setBalance(qint64 balance, qint64 stake, qint64 unconfirme
|
||||
return;
|
||||
|
||||
int unit = model->getOptionsModel()->getDisplayUnit();
|
||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance));
|
||||
ui->labelBalance->setText(TrianglesUnits::formatWithUnit(unit, balance));
|
||||
}
|
||||
|
||||
void SendCoinsDialog::updateDisplayUnit()
|
||||
@@ -360,135 +368,136 @@ void SendCoinsDialog::updateDisplayUnit()
|
||||
if(model && model->getOptionsModel())
|
||||
{
|
||||
// Update labelBalance with the current balance and the current unit
|
||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance()));
|
||||
ui->labelBalance->setText(TrianglesUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance()));
|
||||
}
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Quantity" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardQuantity()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlQuantity->text());
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Amount" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardAmount()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Fee" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardFee()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")));
|
||||
}
|
||||
|
||||
// Coin Control: copy label "After fee" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardAfterFee()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")));
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Bytes" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardBytes()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlBytes->text());
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Priority" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardPriority()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlPriority->text());
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Low output" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardLowOutput()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlLowOutput->text());
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Change" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardChange()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")));
|
||||
}
|
||||
|
||||
// Coin Control: settings menu - coin control enabled/disabled by user
|
||||
void SendCoinsDialog::coinControlFeatureChanged(bool checked)
|
||||
{
|
||||
ui->frameCoinControl->setVisible(checked);
|
||||
|
||||
if (!checked && model) // coin control features disabled
|
||||
CoinControlDialog::coinControl->SetNull();
|
||||
}
|
||||
|
||||
// Coin Control: button inputs -> show actual coin control dialog
|
||||
void SendCoinsDialog::coinControlButtonClicked()
|
||||
{
|
||||
CoinControlDialog dlg;
|
||||
dlg.setModel(model);
|
||||
dlg.exec();
|
||||
coinControlUpdateLabels();
|
||||
}
|
||||
|
||||
// Coin Control: checkbox custom change address
|
||||
void SendCoinsDialog::coinControlChangeChecked(int state)
|
||||
{
|
||||
if (model)
|
||||
{
|
||||
if (state == Qt::Checked)
|
||||
CoinControlDialog::coinControl->destChange = CBitcoinAddress(ui->lineEditCoinControlChange->text().toStdString()).Get();
|
||||
else
|
||||
CoinControlDialog::coinControl->destChange = CNoDestination();
|
||||
}
|
||||
|
||||
ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
|
||||
ui->labelCoinControlChangeLabel->setEnabled((state == Qt::Checked));
|
||||
}
|
||||
|
||||
// Coin Control: custom change address changed
|
||||
void SendCoinsDialog::coinControlChangeEdited(const QString & text)
|
||||
{
|
||||
if (model)
|
||||
{
|
||||
CoinControlDialog::coinControl->destChange = CBitcoinAddress(text.toStdString()).Get();
|
||||
|
||||
// label for the change address
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
|
||||
if (text.isEmpty())
|
||||
ui->labelCoinControlChangeLabel->setText("");
|
||||
else if (!CBitcoinAddress(text.toStdString()).IsValid())
|
||||
{
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
|
||||
ui->labelCoinControlChangeLabel->setText(tr("WARNING: Invalid Triangle address"));
|
||||
}
|
||||
else
|
||||
{
|
||||
QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
|
||||
if (!associatedLabel.isEmpty())
|
||||
ui->labelCoinControlChangeLabel->setText(associatedLabel);
|
||||
else
|
||||
{
|
||||
CPubKey pubkey;
|
||||
CKeyID keyid;
|
||||
CBitcoinAddress(text.toStdString()).GetKeyID(keyid);
|
||||
if (model->getPubKey(keyid, pubkey))
|
||||
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
|
||||
else
|
||||
{
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
|
||||
ui->labelCoinControlChangeLabel->setText(tr("WARNING: unknown change address"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Coin Control: update labels
|
||||
void SendCoinsDialog::coinControlUpdateLabels()
|
||||
{
|
||||
if (!model || !model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures())
|
||||
return;
|
||||
// set pay amounts
|
||||
// Coin Control: copy label "Quantity" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardQuantity()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlQuantity->text());
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Amount" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardAmount()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Fee" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardFee()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")));
|
||||
}
|
||||
|
||||
// Coin Control: copy label "After fee" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardAfterFee()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")));
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Bytes" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardBytes()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlBytes->text());
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Priority" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardPriority()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlPriority->text());
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Low output" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardLowOutput()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlLowOutput->text());
|
||||
}
|
||||
|
||||
// Coin Control: copy label "Change" to clipboard
|
||||
void SendCoinsDialog::coinControlClipboardChange()
|
||||
{
|
||||
QApplication::clipboard()->setText(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")));
|
||||
}
|
||||
|
||||
// Coin Control: settings menu - coin control enabled/disabled by user
|
||||
void SendCoinsDialog::coinControlFeatureChanged(bool checked)
|
||||
{
|
||||
ui->frameCoinControl->setVisible(checked);
|
||||
|
||||
if (!checked && model) // coin control features disabled
|
||||
CoinControlDialog::coinControl->SetNull();
|
||||
}
|
||||
|
||||
// Coin Control: button inputs -> show actual coin control dialog
|
||||
void SendCoinsDialog::coinControlButtonClicked()
|
||||
{
|
||||
CoinControlDialog dlg;
|
||||
dlg.setModel(model);
|
||||
dlg.exec();
|
||||
coinControlUpdateLabels();
|
||||
}
|
||||
|
||||
// Coin Control: checkbox custom change address
|
||||
void SendCoinsDialog::coinControlChangeChecked(int state)
|
||||
{
|
||||
if (model)
|
||||
{
|
||||
if (state == Qt::Checked)
|
||||
CoinControlDialog::coinControl->destChange = CTrianglesAddress(ui->lineEditCoinControlChange->text().toStdString()).Get();
|
||||
else
|
||||
CoinControlDialog::coinControl->destChange = CNoDestination();
|
||||
}
|
||||
|
||||
ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
|
||||
ui->labelCoinControlChangeLabel->setEnabled((state == Qt::Checked));
|
||||
}
|
||||
|
||||
// Coin Control: custom change address changed
|
||||
void SendCoinsDialog::coinControlChangeEdited(const QString & text)
|
||||
{
|
||||
if (model)
|
||||
{
|
||||
CoinControlDialog::coinControl->destChange = CTrianglesAddress(text.toStdString()).Get();
|
||||
|
||||
// label for the change address
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
|
||||
if (text.isEmpty())
|
||||
ui->labelCoinControlChangeLabel->setText("");
|
||||
else if (!CTrianglesAddress(text.toStdString()).IsValid())
|
||||
{
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
|
||||
ui->labelCoinControlChangeLabel->setText(tr("WARNING: Invalid TRI address"));
|
||||
}
|
||||
else
|
||||
{
|
||||
QString associatedLabel = model->getAddressTableModel()->labelForAddress(text);
|
||||
if (!associatedLabel.isEmpty())
|
||||
ui->labelCoinControlChangeLabel->setText(associatedLabel);
|
||||
else
|
||||
{
|
||||
CPubKey pubkey;
|
||||
CKeyID keyid;
|
||||
CTrianglesAddress(text.toStdString()).GetKeyID(keyid);
|
||||
if (model->getPubKey(keyid, pubkey))
|
||||
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
|
||||
else
|
||||
{
|
||||
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
|
||||
ui->labelCoinControlChangeLabel->setText(tr("WARNING: unknown change address"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Coin Control: update labels
|
||||
void SendCoinsDialog::coinControlUpdateLabels()
|
||||
{
|
||||
if (!model || !model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures())
|
||||
return;
|
||||
|
||||
// set pay amounts
|
||||
CoinControlDialog::payAmounts.clear();
|
||||
for(int i = 0; i < ui->entries->count(); ++i)
|
||||
{
|
||||
@@ -496,10 +505,12 @@ void SendCoinsDialog::updateDisplayUnit()
|
||||
if(entry)
|
||||
CoinControlDialog::payAmounts.append(entry->getValue().amount);
|
||||
}
|
||||
if (CoinControlDialog::coinControl->HasSelected())
|
||||
|
||||
if (CoinControlDialog::coinControl->HasSelected())
|
||||
{
|
||||
// actual coin control calculation
|
||||
CoinControlDialog::updateLabels(model, this);
|
||||
CoinControlDialog::updateLabels(model, this);
|
||||
|
||||
// show coin control stats
|
||||
ui->labelCoinControlAutomaticallySelected->hide();
|
||||
ui->widgetCoinControl->show();
|
||||
@@ -511,6 +522,4 @@ void SendCoinsDialog::updateDisplayUnit()
|
||||
ui->widgetCoinControl->hide();
|
||||
ui->labelCoinControlInsuffFunds->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user