aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCelil <celil.kj@gmail.com>2011-07-22 16:55:50 -0700
committerCelil <celil.kj@gmail.com>2011-07-22 16:55:50 -0700
commit2eac3a6decf3353e5db8a8b07f3307d04e77d329 (patch)
treea6785cb89fd591a2b2352ff6f71102c9231d5070 /src
parent64c991da2a235ae8d6544ed5cce01c24b233b929 (diff)
Allow ammount field to be empty so that one can specify .05 instead of
having to type the leading zero as in 0.05
Diffstat (limited to 'src')
-rw-r--r--src/qt/bitcoinamountfield.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp
index f9df91b333..ea0a98b7f2 100644
--- a/src/qt/bitcoinamountfield.cpp
+++ b/src/qt/bitcoinamountfield.cpp
@@ -11,7 +11,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);
@@ -64,11 +64,6 @@ void BitcoinAmountField::clear()
bool BitcoinAmountField::validate()
{
bool valid = true;
- if(amount->text().isEmpty())
- {
- amount->setValid(false);
- valid = false;
- }
if(decimals->text().isEmpty())
{
decimals->setValid(false);
@@ -79,10 +74,14 @@ bool BitcoinAmountField::validate()
QString BitcoinAmountField::text() const
{
- if(amount->text().isEmpty() || decimals->text().isEmpty())
+ if(decimals->text().isEmpty())
{
return QString();
}
+ if(amount->text().isEmpty())
+ {
+ return QString("0.") + decimals->text();
+ }
return amount->text() + QString(".") + decimals->text();
}