|
|
@ -20,6 +20,7 @@ |
|
|
|
class AmountSpinBox: public QAbstractSpinBox |
|
|
|
class AmountSpinBox: public QAbstractSpinBox |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_OBJECT |
|
|
|
Q_OBJECT |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
explicit AmountSpinBox(QWidget *parent): |
|
|
|
explicit AmountSpinBox(QWidget *parent): |
|
|
|
QAbstractSpinBox(parent), |
|
|
|
QAbstractSpinBox(parent), |
|
|
@ -72,23 +73,6 @@ public: |
|
|
|
setValue(val); |
|
|
|
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) |
|
|
|
void setDisplayUnit(int unit) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool valid = false; |
|
|
|
bool valid = false; |
|
|
@ -139,6 +123,7 @@ public: |
|
|
|
} |
|
|
|
} |
|
|
|
return cachedMinimumSizeHint; |
|
|
|
return cachedMinimumSizeHint; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
int currentUnit; |
|
|
|
int currentUnit; |
|
|
|
CAmount singleStep; |
|
|
|
CAmount singleStep; |
|
|
@ -179,6 +164,26 @@ protected: |
|
|
|
return QAbstractSpinBox::event(event); |
|
|
|
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: |
|
|
|
signals: |
|
|
|
void valueChanged(); |
|
|
|
void valueChanged(); |
|
|
|
}; |
|
|
|
}; |
|
|
|