]>
Commit | Line | Data |
---|---|---|
e592d43f WL |
1 | // Copyright (c) 2011-2013 The Bitcoin developers |
2 | // Distributed under the MIT/X11 software license, see the accompanying | |
3 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | |
4 | ||
128eefa0 PK |
5 | #ifndef BITCOINAMOUNTFIELD_H |
6 | #define BITCOINAMOUNTFIELD_H | |
f193c57a | 7 | |
a372168e MF |
8 | #include "amount.h" |
9 | ||
f193c57a WL |
10 | #include <QWidget> |
11 | ||
5e83bc40 PK |
12 | class AmountSpinBox; |
13 | ||
f193c57a | 14 | QT_BEGIN_NAMESPACE |
ee014e5b | 15 | class QValueComboBox; |
f193c57a WL |
16 | QT_END_NAMESPACE |
17 | ||
af836ad5 WL |
18 | /** Widget for entering bitcoin amounts. |
19 | */ | |
f193c57a WL |
20 | class BitcoinAmountField: public QWidget |
21 | { | |
22 | Q_OBJECT | |
32af5266 | 23 | |
a372168e | 24 | Q_PROPERTY(CAmount value READ value WRITE setValue NOTIFY valueChanged USER true) |
32af5266 | 25 | |
f193c57a WL |
26 | public: |
27 | explicit BitcoinAmountField(QWidget *parent = 0); | |
28 | ||
a372168e MF |
29 | CAmount value(bool *value=0) const; |
30 | void setValue(const CAmount& value); | |
73cd5e52 | 31 | |
b9201482 | 32 | /** Set single step in satoshis **/ |
a372168e | 33 | void setSingleStep(const CAmount& step); |
b9201482 | 34 | |
a41d5fe0 GA |
35 | /** Make read-only **/ |
36 | void setReadOnly(bool fReadOnly); | |
37 | ||
af836ad5 | 38 | /** Mark current value as invalid in UI. */ |
587e5285 | 39 | void setValid(bool valid); |
af836ad5 | 40 | /** Perform input validation, mark field as invalid if entered value is not valid. */ |
a5e6d723 | 41 | bool validate(); |
587e5285 | 42 | |
af836ad5 | 43 | /** Change unit used to display amount. */ |
ee014e5b WL |
44 | void setDisplayUnit(int unit); |
45 | ||
af836ad5 | 46 | /** Make field empty and ready for new input. */ |
587e5285 WL |
47 | void clear(); |
48 | ||
e1eb3d44 | 49 | /** Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907), |
af836ad5 WL |
50 | in these cases we have to set it up manually. |
51 | */ | |
a5e6d723 | 52 | QWidget *setupTabChain(QWidget *prev); |
f193c57a WL |
53 | |
54 | signals: | |
91cce173 | 55 | void valueChanged(); |
f193c57a WL |
56 | |
57 | protected: | |
814efd6f | 58 | /** Intercept focus-in event and ',' key presses */ |
f193c57a WL |
59 | bool eventFilter(QObject *object, QEvent *event); |
60 | ||
61 | private: | |
91cce173 | 62 | AmountSpinBox *amount; |
ee014e5b | 63 | QValueComboBox *unit; |
587e5285 WL |
64 | |
65 | private slots: | |
66 | void unitChanged(int idx); | |
67 | ||
f193c57a WL |
68 | }; |
69 | ||
128eefa0 | 70 | #endif // BITCOINAMOUNTFIELD_H |