QSpinBox that uses fixed-point numbers internally and uses our own * formatting/parsing functions. */
| 18 | * formatting/parsing functions. |
| 19 | */ |
| 20 | class AmountSpinBox: public QAbstractSpinBox |
| 21 | { |
| 22 | Q_OBJECT |
| 23 | |
| 24 | public: |
| 25 | explicit AmountSpinBox(QWidget *parent): |
| 26 | QAbstractSpinBox(parent), |
| 27 | currentUnit(BitcoinUnits::BTG), |
| 28 | singleStep(100000) // satoshis |
| 29 | { |
| 30 | setAlignment(Qt::AlignRight); |
| 31 | |
| 32 | connect(lineEdit(), SIGNAL(textEdited(QString)), this, SIGNAL(valueChanged())); |
| 33 | } |
| 34 | |
| 35 | QValidator::State validate(QString &text, int &pos) const |
| 36 | { |
| 37 | if(text.isEmpty()) |
| 38 | return QValidator::Intermediate; |
| 39 | bool valid = false; |
| 40 | parse(text, &valid); |
| 41 | /* Make sure we return Intermediate so that fixup() is called on defocus */ |
| 42 | return valid ? QValidator::Intermediate : QValidator::Invalid; |
| 43 | } |
| 44 | |
| 45 | void fixup(QString &input) const |
| 46 | { |