mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-09 10:43:19 -05:00
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)
This commit is contained in:
commit
eec81cbb80
1 changed files with 22 additions and 17 deletions
|
@ -20,6 +20,7 @@
|
|||
class AmountSpinBox: public QAbstractSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AmountSpinBox(QWidget *parent):
|
||||
QAbstractSpinBox(parent),
|
||||
|
@ -72,23 +73,6 @@ public:
|
|||
setValue(val);
|
||||
}
|
||||
|
||||
StepEnabled stepEnabled() const
|
||||
{
|
||||
StepEnabled rv = 0;
|
||||
if(text().isEmpty()) // Allow step-up with empty field
|
||||
return StepUpEnabled;
|
||||
bool valid = false;
|
||||
CAmount val = value(&valid);
|
||||
if(valid)
|
||||
{
|
||||
if(val > 0)
|
||||
rv |= StepDownEnabled;
|
||||
if(val < BitcoinUnits::maxMoney())
|
||||
rv |= StepUpEnabled;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
void setDisplayUnit(int unit)
|
||||
{
|
||||
bool valid = false;
|
||||
|
@ -139,6 +123,7 @@ public:
|
|||
}
|
||||
return cachedMinimumSizeHint;
|
||||
}
|
||||
|
||||
private:
|
||||
int currentUnit;
|
||||
CAmount singleStep;
|
||||
|
@ -179,6 +164,26 @@ protected:
|
|||
return QAbstractSpinBox::event(event);
|
||||
}
|
||||
|
||||
StepEnabled stepEnabled() const
|
||||
{
|
||||
if (isReadOnly()) // Disable steps when AmountSpinBox is read-only
|
||||
return StepNone;
|
||||
if (text().isEmpty()) // Allow step-up with empty field
|
||||
return StepUpEnabled;
|
||||
|
||||
StepEnabled rv = 0;
|
||||
bool valid = false;
|
||||
CAmount val = value(&valid);
|
||||
if(valid)
|
||||
{
|
||||
if(val > 0)
|
||||
rv |= StepDownEnabled;
|
||||
if(val < BitcoinUnits::maxMoney())
|
||||
rv |= StepUpEnabled;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
signals:
|
||||
void valueChanged();
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue