Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoinamountfield.cpp
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
void setDisplayUnit(int unit) { | void setDisplayUnit(int unit) { | ||||
bool valid = false; | bool valid = false; | ||||
Amount val(value(&valid)); | Amount val(value(&valid)); | ||||
currentUnit = unit; | currentUnit = unit; | ||||
if (valid) { | if (valid) { | ||||
setValue(val.GetSatoshis()); | setValue(val); | ||||
} else { | } else { | ||||
clear(); | clear(); | ||||
} | } | ||||
} | } | ||||
void setSingleStep(const Amount step) { singleStep = step; } | void setSingleStep(const Amount step) { singleStep = step; } | ||||
QSize minimumSizeHint() const override { | QSize minimumSizeHint() const override { | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | Amount parse(const QString &text, bool *valid_out = 0) const { | ||||
if (valid) { | if (valid) { | ||||
if (val < Amount(0) || val > BitcoinUnits::maxMoney()) { | if (val < Amount(0) || val > BitcoinUnits::maxMoney()) { | ||||
valid = false; | valid = false; | ||||
} | } | ||||
} | } | ||||
if (valid_out) { | if (valid_out) { | ||||
*valid_out = valid; | *valid_out = valid; | ||||
} | } | ||||
return valid ? val.GetSatoshis() : 0; | return valid ? val : Amount(0); | ||||
} | } | ||||
protected: | protected: | ||||
bool event(QEvent *event) override { | bool event(QEvent *event) override { | ||||
if (event->type() == QEvent::KeyPress || | if (event->type() == QEvent::KeyPress || | ||||
event->type() == QEvent::KeyRelease) { | event->type() == QEvent::KeyRelease) { | ||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); | QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); | ||||
if (keyEvent->key() == Qt::Key_Comma) { | if (keyEvent->key() == Qt::Key_Comma) { | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |