Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoinamountfield.cpp
Show All 21 Lines | class AmountSpinBox : public QAbstractSpinBox { | ||||
Q_OBJECT | Q_OBJECT | ||||
public: | public: | ||||
explicit AmountSpinBox(QWidget *parent) | explicit AmountSpinBox(QWidget *parent) | ||||
: QAbstractSpinBox(parent), currentUnit(BitcoinUnits::BCH), | : QAbstractSpinBox(parent), currentUnit(BitcoinUnits::BCH), | ||||
singleStep(100000 * SATOSHI) { | singleStep(100000 * SATOSHI) { | ||||
setAlignment(Qt::AlignRight); | setAlignment(Qt::AlignRight); | ||||
connect(lineEdit(), SIGNAL(textEdited(QString)), this, | connect(lineEdit(), &QLineEdit::textEdited, this, | ||||
SIGNAL(valueChanged())); | &AmountSpinBox::valueChanged); | ||||
} | } | ||||
QValidator::State validate(QString &text, int &pos) const override { | QValidator::State validate(QString &text, int &pos) const override { | ||||
if (text.isEmpty()) { | if (text.isEmpty()) { | ||||
return QValidator::Intermediate; | return QValidator::Intermediate; | ||||
} | } | ||||
bool valid = false; | bool valid = false; | ||||
parse(text, &valid); | parse(text, &valid); | ||||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | BitcoinAmountField::BitcoinAmountField(QWidget *parent) | ||||
layout->setContentsMargins(0, 0, 0, 0); | layout->setContentsMargins(0, 0, 0, 0); | ||||
setLayout(layout); | setLayout(layout); | ||||
setFocusPolicy(Qt::TabFocus); | setFocusPolicy(Qt::TabFocus); | ||||
setFocusProxy(amount); | setFocusProxy(amount); | ||||
// If one if the widgets changes, the combined content changes as well | // If one if the widgets changes, the combined content changes as well | ||||
connect(amount, SIGNAL(valueChanged()), this, SIGNAL(valueChanged())); | connect(amount, &AmountSpinBox::valueChanged, this, | ||||
connect(unit, SIGNAL(currentIndexChanged(int)), this, | &BitcoinAmountField::valueChanged); | ||||
SLOT(unitChanged(int))); | connect( | ||||
unit, | |||||
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | |||||
this, &BitcoinAmountField::unitChanged); | |||||
// Set default based on configuration | // Set default based on configuration | ||||
unitChanged(unit->currentIndex()); | unitChanged(unit->currentIndex()); | ||||
} | } | ||||
void BitcoinAmountField::clear() { | void BitcoinAmountField::clear() { | ||||
amount->clear(); | amount->clear(); | ||||
unit->setCurrentIndex(0); | unit->setCurrentIndex(0); | ||||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |