diff options
author | Philip Kaufmann <phil.kaufmann@t-online.de> | 2015-01-10 15:02:12 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-01-30 15:12:05 +0100 |
commit | 6a02ef8bdb07ef42bdac0511b7f897d49f69f7eb (patch) | |
tree | 12ea158faa37e5a1ff0aabacd91f57072ce69b08 /src | |
parent | b61940b3a15a9776878b0affdd04e72d6b6dcc55 (diff) |
[Qt] don't allow amount changes when AmountSpinBox is read-only
- before it was possible to use the steps to change e.g. amouns of
authenticated or unauthenticated payment requests (AmountSpinBox is
already set to read-only here) - this is now fixed
- also move the reimplemented stepEnabled() function to the
protected section of our class, where it belongs (see Qt doc)
Github-Pull: #5637
Rebased-From: 0fd9e2bf43d217d9a76003476661c8ab53606548
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/bitcoinamountfield.cpp | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index 5b8ab23b26..4373357e44 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -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,25 @@ protected: return QAbstractSpinBox::event(event); } + StepEnabled stepEnabled() const + { + StepEnabled rv = 0; + if (isReadOnly()) // Disable steps when AmountSpinBox is read-only + return StepNone; + 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; + } + signals: void valueChanged(); }; |