Skip to content

Commit eec81cb

Browse files
committed
Merge pull request #5637
80dd50c [Qt] group variables below initial if-clauses in AmountSpinBox::stepEnabled (Philip Kaufmann) 0fd9e2b [Qt] don't allow amount changes when AmountSpinBox is read-only (Philip Kaufmann)
2 parents ddb512a + 80dd50c commit eec81cb

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/qt/bitcoinamountfield.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
class AmountSpinBox: public QAbstractSpinBox
2121
{
2222
Q_OBJECT
23+
2324
public:
2425
explicit AmountSpinBox(QWidget *parent):
2526
QAbstractSpinBox(parent),
@@ -72,23 +73,6 @@ class AmountSpinBox: public QAbstractSpinBox
7273
setValue(val);
7374
}
7475

75-
StepEnabled stepEnabled() const
76-
{
77-
StepEnabled rv = 0;
78-
if(text().isEmpty()) // Allow step-up with empty field
79-
return StepUpEnabled;
80-
bool valid = false;
81-
CAmount val = value(&valid);
82-
if(valid)
83-
{
84-
if(val > 0)
85-
rv |= StepDownEnabled;
86-
if(val < BitcoinUnits::maxMoney())
87-
rv |= StepUpEnabled;
88-
}
89-
return rv;
90-
}
91-
9276
void setDisplayUnit(int unit)
9377
{
9478
bool valid = false;
@@ -139,6 +123,7 @@ class AmountSpinBox: public QAbstractSpinBox
139123
}
140124
return cachedMinimumSizeHint;
141125
}
126+
142127
private:
143128
int currentUnit;
144129
CAmount singleStep;
@@ -179,6 +164,26 @@ class AmountSpinBox: public QAbstractSpinBox
179164
return QAbstractSpinBox::event(event);
180165
}
181166

167+
StepEnabled stepEnabled() const
168+
{
169+
if (isReadOnly()) // Disable steps when AmountSpinBox is read-only
170+
return StepNone;
171+
if (text().isEmpty()) // Allow step-up with empty field
172+
return StepUpEnabled;
173+
174+
StepEnabled rv = 0;
175+
bool valid = false;
176+
CAmount val = value(&valid);
177+
if(valid)
178+
{
179+
if(val > 0)
180+
rv |= StepDownEnabled;
181+
if(val < BitcoinUnits::maxMoney())
182+
rv |= StepUpEnabled;
183+
}
184+
return rv;
185+
}
186+
182187
signals:
183188
void valueChanged();
184189
};

0 commit comments

Comments
 (0)