diff options
Diffstat (limited to 'src/qt/bitcoinamountfield.cpp')
-rw-r--r-- | src/qt/bitcoinamountfield.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index b12e296f99..eeb6fe89bb 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -4,10 +4,11 @@ #include "bitcoinunits.h" #include "guiconstants.h" +#include <QApplication> #include <QHBoxLayout> #include <QKeyEvent> #include <QDoubleSpinBox> -#include <QApplication> + #include <qmath.h> // for qPow() BitcoinAmountField::BitcoinAmountField(QWidget *parent): @@ -60,7 +61,9 @@ bool BitcoinAmountField::validate() bool valid = true; if (amount->value() == 0.0) valid = false; - if (valid && !BitcoinUnits::parse(currentUnit, text(), 0)) + else if (!BitcoinUnits::parse(currentUnit, text(), 0)) + valid = false; + else if (amount->value() > BitcoinUnits::maxAmount(currentUnit)) valid = false; setValid(valid); @@ -115,7 +118,7 @@ qint64 BitcoinAmountField::value(bool *valid_out) const { qint64 val_out = 0; bool valid = BitcoinUnits::parse(currentUnit, text(), &val_out); - if(valid_out) + if (valid_out) { *valid_out = valid; } @@ -145,12 +148,12 @@ void BitcoinAmountField::unitChanged(int idx) amount->setDecimals(BitcoinUnits::decimals(currentUnit)); amount->setMaximum(qPow(10, BitcoinUnits::amountDigits(currentUnit)) - qPow(10, -amount->decimals())); - if(currentUnit == BitcoinUnits::uBTC) + if (currentUnit == BitcoinUnits::uBTC) amount->setSingleStep(0.01); else amount->setSingleStep(0.001); - if(valid) + if (valid) { // If value was valid, re-place it in the widget with the new unit setValue(currentValue); |