diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-07-29 14:36:35 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-07-29 14:36:35 +0200 |
commit | ee014e5b10f5f65820ff056311051ff49813b294 (patch) | |
tree | d9c0dd04b021c2c828bf55ba6ff33d93d07b5276 /src/qt/bitcoinamountfield.cpp | |
parent | b5b1d1a66b9f418c9fb293cb1cc3eac09a711c4e (diff) |
Full support for other units, add configuration option for default unit (used when displaying amounts)
Diffstat (limited to 'src/qt/bitcoinamountfield.cpp')
-rw-r--r-- | src/qt/bitcoinamountfield.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index f1b4e9fdc3..73498050ad 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -1,5 +1,6 @@ #include "bitcoinamountfield.h" #include "qvalidatedlineedit.h" +#include "qvaluecombobox.h" #include "bitcoinunits.h" #include <QLabel> @@ -8,6 +9,7 @@ #include <QHBoxLayout> #include <QKeyEvent> #include <QComboBox> +#include <QDebug> BitcoinAmountField::BitcoinAmountField(QWidget *parent): QWidget(parent), amount(0), decimals(0), currentUnit(-1) @@ -27,7 +29,7 @@ BitcoinAmountField::BitcoinAmountField(QWidget *parent): layout->addWidget(amount); layout->addWidget(new QLabel(QString("."))); layout->addWidget(decimals); - unit = new QComboBox(this); + unit = new QValueComboBox(this); unit->setModel(new BitcoinUnits(this)); layout->addWidget(unit); layout->addStretch(1); @@ -78,7 +80,7 @@ bool BitcoinAmountField::validate() decimals->setValid(false); valid = false; } - if(!BitcoinUnits::parse(BitcoinUnits::BTC, text(), 0)) + if(!BitcoinUnits::parse(currentUnit, text(), 0)) { setValid(false); valid = false; @@ -169,6 +171,9 @@ void BitcoinAmountField::unitChanged(int idx) setText(""); } setValid(true); +} - +void BitcoinAmountField::setDisplayUnit(int newUnit) +{ + unit->setValue(newUnit); } |