|
|
@ -60,7 +60,9 @@ bool BitcoinAmountField::validate()
|
|
|
|
bool valid = true;
|
|
|
|
bool valid = true;
|
|
|
|
if (amount->value() == 0.0)
|
|
|
|
if (amount->value() == 0.0)
|
|
|
|
valid = false;
|
|
|
|
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;
|
|
|
|
valid = false;
|
|
|
|
|
|
|
|
|
|
|
|
setValid(valid);
|
|
|
|
setValid(valid);
|
|
|
@ -115,7 +117,7 @@ qint64 BitcoinAmountField::value(bool *valid_out) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
qint64 val_out = 0;
|
|
|
|
qint64 val_out = 0;
|
|
|
|
bool valid = BitcoinUnits::parse(currentUnit, text(), &val_out);
|
|
|
|
bool valid = BitcoinUnits::parse(currentUnit, text(), &val_out);
|
|
|
|
if(valid_out)
|
|
|
|
if (valid_out)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
*valid_out = valid;
|
|
|
|
*valid_out = valid;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -145,12 +147,12 @@ void BitcoinAmountField::unitChanged(int idx)
|
|
|
|
amount->setDecimals(BitcoinUnits::decimals(currentUnit));
|
|
|
|
amount->setDecimals(BitcoinUnits::decimals(currentUnit));
|
|
|
|
amount->setMaximum(qPow(10, BitcoinUnits::amountDigits(currentUnit)) - qPow(10, -amount->decimals()));
|
|
|
|
amount->setMaximum(qPow(10, BitcoinUnits::amountDigits(currentUnit)) - qPow(10, -amount->decimals()));
|
|
|
|
|
|
|
|
|
|
|
|
if(currentUnit == BitcoinUnits::uBTC)
|
|
|
|
if (currentUnit == BitcoinUnits::uBTC)
|
|
|
|
amount->setSingleStep(0.01);
|
|
|
|
amount->setSingleStep(0.01);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
amount->setSingleStep(0.001);
|
|
|
|
amount->setSingleStep(0.001);
|
|
|
|
|
|
|
|
|
|
|
|
if(valid)
|
|
|
|
if (valid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// If value was valid, re-place it in the widget with the new unit
|
|
|
|
// If value was valid, re-place it in the widget with the new unit
|
|
|
|
setValue(currentValue);
|
|
|
|
setValue(currentValue);
|
|
|
|