Skip to content

Commit 7abcd1a

Browse files
committed
Merge pull request #3614
b920148 [Qt] Improve single step in bitcoinamountfield (Cozz Lovan)
2 parents 129429d + b920148 commit 7abcd1a

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/qt/bitcoinamountfield.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ BitcoinAmountField::BitcoinAmountField(QWidget *parent) :
1919
amount(0),
2020
currentUnit(-1)
2121
{
22+
nSingleStep = 100000; // satoshis
23+
2224
amount = new QDoubleSpinBox(this);
2325
amount->setLocale(QLocale::c());
24-
amount->setDecimals(8);
2526
amount->installEventFilter(this);
2627
amount->setMaximumWidth(170);
27-
amount->setSingleStep(0.001);
2828

2929
QHBoxLayout *layout = new QHBoxLayout(this);
3030
layout->addWidget(amount);
@@ -159,11 +159,7 @@ void BitcoinAmountField::unitChanged(int idx)
159159
// Set max length after retrieving the value, to prevent truncation
160160
amount->setDecimals(BitcoinUnits::decimals(currentUnit));
161161
amount->setMaximum(qPow(10, BitcoinUnits::amountDigits(currentUnit)) - qPow(10, -amount->decimals()));
162-
163-
if (currentUnit == BitcoinUnits::uBTC)
164-
amount->setSingleStep(0.01);
165-
else
166-
amount->setSingleStep(0.001);
162+
amount->setSingleStep((double)nSingleStep / (double)BitcoinUnits::factor(currentUnit));
167163

168164
if (valid)
169165
{
@@ -182,3 +178,9 @@ void BitcoinAmountField::setDisplayUnit(int newUnit)
182178
{
183179
unit->setValue(newUnit);
184180
}
181+
182+
void BitcoinAmountField::setSingleStep(qint64 step)
183+
{
184+
nSingleStep = step;
185+
unitChanged(unit->currentIndex());
186+
}

src/qt/bitcoinamountfield.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class BitcoinAmountField: public QWidget
2626
qint64 value(bool *valid=0) const;
2727
void setValue(qint64 value);
2828

29+
/** Set single step in satoshis **/
30+
void setSingleStep(qint64 step);
31+
2932
/** Make read-only **/
3033
void setReadOnly(bool fReadOnly);
3134

@@ -56,6 +59,7 @@ class BitcoinAmountField: public QWidget
5659
QDoubleSpinBox *amount;
5760
QValueComboBox *unit;
5861
int currentUnit;
62+
qint64 nSingleStep;
5963

6064
void setText(const QString &text);
6165
QString text() const;

src/qt/optionsdialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "optionsmodel.h"
1616

1717
#include "netbase.h"
18+
#include "main.h"
1819

1920
#include <QDir>
2021
#include <QIntValidator>
@@ -93,6 +94,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
9394
}
9495

9596
ui->unit->setModel(new BitcoinUnits(this));
97+
ui->transactionFee->setSingleStep(CTransaction::nMinTxFee);
9698

9799
/* Widget-to-option mapper */
98100
mapper = new MonitoredDataMapper(this);

0 commit comments

Comments
 (0)