GUI: Disable "Subtract fee from amount" checkbox when a non-pegged asset is selected

Fixes: https://github.com/greenaddress/elements/issues/4
This commit is contained in:
Luke Dashjr 2019-02-22 22:54:51 +00:00 committed by Gregory Sanders
parent 1f0b6886b7
commit 36ebb131dc
2 changed files with 13 additions and 0 deletions

View file

@ -44,6 +44,7 @@ SendCoinsEntry::SendCoinsEntry(const PlatformStyle *_platformStyle, QWidget *par
// Connect signals
connect(ui->payAmount, &BitcoinAmountField::valueChanged, this, &SendCoinsEntry::payAmountChanged);
connect(ui->checkboxSubtractFeeFromAmount, &QCheckBox::toggled, this, &SendCoinsEntry::subtractFeeFromAmountChanged);
connect(ui->payAmount, SIGNAL(valueChanged()), this, SLOT(payAmountChangedInternal()));
connect(ui->deleteButton, &QPushButton::clicked, this, &SendCoinsEntry::deleteClicked);
connect(ui->deleteButton_is, &QPushButton::clicked, this, &SendCoinsEntry::deleteClicked);
connect(ui->deleteButton_s, &QPushButton::clicked, this, &SendCoinsEntry::deleteClicked);
@ -115,6 +116,17 @@ void SendCoinsEntry::clear()
updateDisplayUnit();
}
void SendCoinsEntry::payAmountChangedInternal()
{
const auto send_assets = ui->payAmount->fullValue();
if (send_assets.first == Params().GetConsensus().pegged_asset) {
ui->checkboxSubtractFeeFromAmount->setEnabled(true);
} else {
ui->checkboxSubtractFeeFromAmount->setCheckState(Qt::Unchecked);
ui->checkboxSubtractFeeFromAmount->setEnabled(false);
}
}
void SendCoinsEntry::checkSubtractFeeFromAmount()
{
ui->checkboxSubtractFeeFromAmount->setChecked(true);

View file

@ -58,6 +58,7 @@ Q_SIGNALS:
void subtractFeeFromAmountChanged();
private Q_SLOTS:
void payAmountChangedInternal();
void deleteClicked();
void useAvailableBalanceClicked();
void on_payTo_textChanged(const QString &address);