Bitcoin ABC  0.26.3
P2P Digital Currency
bitcoinamountfield.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 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 <consensus/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  Q_OBJECT
22 
23  Q_PROPERTY(
24  Amount value READ value WRITE setValue NOTIFY valueChanged USER true)
25 
26 public:
27  explicit BitcoinAmountField(QWidget *parent = nullptr);
28 
29  Amount value(bool *value = nullptr) const;
30  void setValue(const Amount value);
31 
36  void SetAllowEmpty(bool allow);
37 
39  void SetMinValue(const Amount &value);
40 
42  void SetMaxValue(const Amount &value);
43 
45  void setSingleStep(const Amount step);
46 
48  void setReadOnly(bool fReadOnly);
49 
51  void setValid(bool valid);
54  bool validate();
55 
57  void setDisplayUnit(int unit);
58 
60  void clear();
61 
63  void setEnabled(bool fEnabled);
64 
69  QWidget *setupTabChain(QWidget *prev);
70 
71 Q_SIGNALS:
72  void valueChanged();
73 
74 protected:
76  bool eventFilter(QObject *object, QEvent *event) override;
77 
78 private:
81 
82 private Q_SLOTS:
83  void unitChanged(int idx);
84 };
85 
86 #endif // BITCOIN_QT_BITCOINAMOUNTFIELD_H
QSpinBox that uses fixed-point numbers internally and uses our own formatting/parsing functions.
Widget for entering bitcoin amounts.
AmountSpinBox * amount
void setEnabled(bool fEnabled)
Enable/Disable.
void SetMaxValue(const Amount &value)
Set the maximum value in satoshis.
QValueComboBox * unit
bool eventFilter(QObject *object, QEvent *event) override
Intercept focus-in event and ',' key presses.
void setReadOnly(bool fReadOnly)
Make read-only.
BitcoinAmountField(QWidget *parent=nullptr)
void setDisplayUnit(int unit)
Change unit used to display amount.
void clear()
Make field empty and ready for new input.
bool validate()
Perform input validation, mark field as invalid if entered value is not valid.
QWidget * setupTabChain(QWidget *prev)
Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project....
void setValue(const Amount value)
void setValid(bool valid)
Mark current value as invalid in UI.
void SetAllowEmpty(bool allow)
If allow empty is set to false the field will be set to the minimum allowed value if left empty.
void setSingleStep(const Amount step)
Set single step in satoshis.
void SetMinValue(const Amount &value)
Set the minimum value in satoshis.
Definition: amount.h:19