aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoinamountfield.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-07-25 21:35:45 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-07-25 21:38:54 +0200
commite285ffcd052a42a6e870f093e7663671a2a3b147 (patch)
treed9c5237ba0d2c6617d6202cbf1fda666a0b33d78 /src/qt/bitcoinamountfield.cpp
parentbbae0fc9efa6eb7155d679a1cc3eeb451d594d14 (diff)
preparations for multiple unit (uBTC, mBTC, BTC) support, fix amount entry issue
Diffstat (limited to 'src/qt/bitcoinamountfield.cpp')
-rw-r--r--src/qt/bitcoinamountfield.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp
index b312b9792e..330a7bfdef 100644
--- a/src/qt/bitcoinamountfield.cpp
+++ b/src/qt/bitcoinamountfield.cpp
@@ -1,5 +1,6 @@
#include "bitcoinamountfield.h"
#include "qvalidatedlineedit.h"
+#include "bitcoinunits.h"
#include <QLabel>
#include <QLineEdit>
@@ -11,7 +12,7 @@ BitcoinAmountField::BitcoinAmountField(QWidget *parent):
QWidget(parent), amount(0), decimals(0)
{
amount = new QValidatedLineEdit(this);
- amount->setValidator(new QRegExpValidator(QRegExp("[0-9]?"), this));
+ amount->setValidator(new QRegExpValidator(QRegExp("[0-9]*"), this));
amount->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
amount->installEventFilter(this);
amount->setMaximumWidth(100);
@@ -26,7 +27,7 @@ BitcoinAmountField::BitcoinAmountField(QWidget *parent):
layout->addWidget(amount);
layout->addWidget(new QLabel(QString(".")));
layout->addWidget(decimals);
- layout->addWidget(new QLabel(QString(" BTC")));
+ layout->addWidget(new QLabel(QString(" ") + BitcoinUnits::name(BitcoinUnits::BTC)));
layout->addStretch(1);
layout->setContentsMargins(0,0,0,0);
@@ -69,6 +70,13 @@ bool BitcoinAmountField::validate()
decimals->setValid(false);
valid = false;
}
+ if(!BitcoinUnits::parse(BitcoinUnits::BTC, text(), 0))
+ {
+ amount->setValid(false);
+ decimals->setValid(false);
+ valid = false;
+ }
+
return valid;
}