Bitcoin Core  22.99.0
P2P Digital Currency
bitcoinamountfield.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_QT_BITCOINAMOUNTFIELD_H
6 #define BITCOIN_QT_BITCOINAMOUNTFIELD_H
7 
8 #include <amount.h>
9 
10 #include <QWidget>
11 
12 class AmountSpinBox;
13 
14 QT_BEGIN_NAMESPACE
15 class QValueComboBox;
16 QT_END_NAMESPACE
17 
20 class BitcoinAmountField: public QWidget
21 {
22  Q_OBJECT
23 
24  // ugly hack: for some unknown reason CAmount (instead of qint64) does not work here as expected
25  // discussion: https://github.com/bitcoin/bitcoin/pull/5117
26  Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY valueChanged USER true)
27 
28 public:
29  explicit BitcoinAmountField(QWidget *parent = nullptr);
30 
31  CAmount value(bool *value=nullptr) const;
32  void setValue(const CAmount& value);
33 
35  void SetAllowEmpty(bool allow);
36 
38  void SetMinValue(const CAmount& value);
39 
41  void SetMaxValue(const CAmount& value);
42 
44  void setSingleStep(const CAmount& step);
45 
47  void setReadOnly(bool fReadOnly);
48 
50  void setValid(bool valid);
52  bool validate();
53 
55  void setDisplayUnit(int unit);
56 
58  void clear();
59 
61  void setEnabled(bool fEnabled);
62 
66  QWidget *setupTabChain(QWidget *prev);
67 
68 Q_SIGNALS:
69  void valueChanged();
70 
71 protected:
73  bool eventFilter(QObject *object, QEvent *event) override;
74 
75 private:
78 
79 private Q_SLOTS:
80  void unitChanged(int idx);
81 
82 };
83 
84 #endif // BITCOIN_QT_BITCOINAMOUNTFIELD_H
BitcoinAmountField::SetAllowEmpty
void SetAllowEmpty(bool allow)
If allow empty is set to false the field will be set to the minimum allowed value if left empty.
Definition: bitcoinamountfield.cpp:303
BitcoinAmountField::unitChanged
void unitChanged(int idx)
Definition: bitcoinamountfield.cpp:323
BitcoinAmountField::valueChanged
void valueChanged()
BitcoinAmountField::setReadOnly
void setReadOnly(bool fReadOnly)
Make read-only.
Definition: bitcoinamountfield.cpp:318
BitcoinAmountField::unit
QValueComboBox * unit
Definition: bitcoinamountfield.h:77
BitcoinAmountField::setDisplayUnit
void setDisplayUnit(int unit)
Change unit used to display amount.
Definition: bitcoinamountfield.cpp:334
QValueComboBox
Definition: qvaluecombobox.h:12
BitcoinAmountField::SetMaxValue
void SetMaxValue(const CAmount &value)
Set the maximum value in satoshis.
Definition: bitcoinamountfield.cpp:313
BitcoinAmountField::value
qint64 value
Definition: bitcoinamountfield.h:26
BitcoinAmountField::setupTabChain
QWidget * setupTabChain(QWidget *prev)
Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project....
Definition: bitcoinamountfield.cpp:286
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
BitcoinAmountField::eventFilter
bool eventFilter(QObject *object, QEvent *event) override
Intercept focus-in event and ',' key presses.
Definition: bitcoinamountfield.cpp:276
AmountSpinBox
QSpinBox that uses fixed-point numbers internally and uses our own formatting/parsing functions.
Definition: bitcoinamountfield.cpp:21
BitcoinAmountField::setValue
void setValue(const CAmount &value)
Definition: bitcoinamountfield.cpp:298
BitcoinAmountField::clear
void clear()
Make field empty and ready for new input.
Definition: bitcoinamountfield.cpp:248
BitcoinAmountField::setSingleStep
void setSingleStep(const CAmount &step)
Set single step in satoshis.
Definition: bitcoinamountfield.cpp:339
BitcoinAmountField::amount
AmountSpinBox * amount
Definition: bitcoinamountfield.h:76
BitcoinAmountField::setValid
void setValid(bool valid)
Mark current value as invalid in UI.
Definition: bitcoinamountfield.cpp:268
BitcoinAmountField
Widget for entering bitcoin amounts.
Definition: bitcoinamountfield.h:20
BitcoinAmountField::BitcoinAmountField
BitcoinAmountField(QWidget *parent=nullptr)
Definition: bitcoinamountfield.cpp:218
BitcoinAmountField::SetMinValue
void SetMinValue(const CAmount &value)
Set the minimum value in satoshis.
Definition: bitcoinamountfield.cpp:308
amount.h
BitcoinAmountField::validate
bool validate()
Perform input validation, mark field as invalid if entered value is not valid.
Definition: bitcoinamountfield.cpp:260
BitcoinAmountField::setEnabled
void setEnabled(bool fEnabled)
Enable/Disable.
Definition: bitcoinamountfield.cpp:254