aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoinamountfield.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-02-17 12:30:21 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-02-17 12:30:30 +0100
commit7abcd1a1c9c24489ee58d9a3f5846458e8b9c72e (patch)
tree38693c24daa180264fe302ce6aaa616b0540891d /src/qt/bitcoinamountfield.cpp
parent129429dd8f6dfcb76fa1a481b91c06e36808523d (diff)
parentb920148258ac78d975ded66eebfa8c0c89de3b9b (diff)
Merge pull request #3614
b920148 [Qt] Improve single step in bitcoinamountfield (Cozz Lovan)
Diffstat (limited to 'src/qt/bitcoinamountfield.cpp')
-rw-r--r--src/qt/bitcoinamountfield.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp
index 923b17e66d..25ad0c66af 100644
--- a/src/qt/bitcoinamountfield.cpp
+++ b/src/qt/bitcoinamountfield.cpp
@@ -19,12 +19,12 @@ BitcoinAmountField::BitcoinAmountField(QWidget *parent) :
amount(0),
currentUnit(-1)
{
+ nSingleStep = 100000; // satoshis
+
amount = new QDoubleSpinBox(this);
amount->setLocale(QLocale::c());
- amount->setDecimals(8);
amount->installEventFilter(this);
amount->setMaximumWidth(170);
- amount->setSingleStep(0.001);
QHBoxLayout *layout = new QHBoxLayout(this);
layout->addWidget(amount);
@@ -159,11 +159,7 @@ void BitcoinAmountField::unitChanged(int idx)
// Set max length after retrieving the value, to prevent truncation
amount->setDecimals(BitcoinUnits::decimals(currentUnit));
amount->setMaximum(qPow(10, BitcoinUnits::amountDigits(currentUnit)) - qPow(10, -amount->decimals()));
-
- if (currentUnit == BitcoinUnits::uBTC)
- amount->setSingleStep(0.01);
- else
- amount->setSingleStep(0.001);
+ amount->setSingleStep((double)nSingleStep / (double)BitcoinUnits::factor(currentUnit));
if (valid)
{
@@ -182,3 +178,9 @@ void BitcoinAmountField::setDisplayUnit(int newUnit)
{
unit->setValue(newUnit);
}
+
+void BitcoinAmountField::setSingleStep(qint64 step)
+{
+ nSingleStep = step;
+ unitChanged(unit->currentIndex());
+}