Merge branch 'master' of https://github.com/bitcoin/bitcoin
[novacoin.git] / src / qt / bitcoinamountfield.h
1 #ifndef BITCOINFIELD_H
2 #define BITCOINFIELD_H
3
4 #include <QWidget>
5
6 QT_BEGIN_NAMESPACE
7 class QValidatedLineEdit;
8 class QComboBox;
9 QT_END_NAMESPACE
10
11 // Coin amount entry widget with separate parts for whole
12 // coins and decimals.
13 class BitcoinAmountField: public QWidget
14 {
15     Q_OBJECT
16     //Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true);
17     Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true);
18 public:
19     explicit BitcoinAmountField(QWidget *parent = 0);
20
21     qint64 value(bool *valid=0) const;
22     void setValue(qint64 value);
23
24     // Mark current valid as invalid in UI
25     void setValid(bool valid);
26     bool validate();
27
28     // Make field empty and ready for new input
29     void clear();
30
31     // Qt messes up the tab chain by default in some cases (issue http://bugreports.qt.nokia.com/browse/QTBUG-10907)
32     // Hence we have to set it up manually
33     QWidget *setupTabChain(QWidget *prev);
34
35 signals:
36     void textChanged();
37
38 protected:
39     // Intercept '.' and ',' keys, if pressed focus a specified widget
40     bool eventFilter(QObject *object, QEvent *event);
41
42 private:
43     QValidatedLineEdit *amount;
44     QValidatedLineEdit *decimals;
45     QComboBox *unit;
46     int currentUnit;
47
48     void setText(const QString &text);
49     QString text() const;
50
51 private slots:
52     void unitChanged(int idx);
53
54 };
55
56
57 #endif // BITCOINFIELD_H