Replaces numbered place marker %2 with %1.
[bitcoinplatinum.git] / src / qt / bitcoinamountfield.h
blob8e2cceeb5e2e5a51c9f741bb25a713b1fa8d45a1
1 // Copyright (c) 2011-2017 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.
5 #ifndef BITCOIN_QT_BITCOINAMOUNTFIELD_H
6 #define BITCOIN_QT_BITCOINAMOUNTFIELD_H
8 #include <amount.h>
10 #include <QWidget>
12 class AmountSpinBox;
14 QT_BEGIN_NAMESPACE
15 class QValueComboBox;
16 QT_END_NAMESPACE
18 /** Widget for entering bitcoin amounts.
20 class BitcoinAmountField: public QWidget
22 Q_OBJECT
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)
28 public:
29 explicit BitcoinAmountField(QWidget *parent = 0);
31 CAmount value(bool *value=0) const;
32 void setValue(const CAmount& value);
34 /** Set single step in satoshis **/
35 void setSingleStep(const CAmount& step);
37 /** Make read-only **/
38 void setReadOnly(bool fReadOnly);
40 /** Mark current value as invalid in UI. */
41 void setValid(bool valid);
42 /** Perform input validation, mark field as invalid if entered value is not valid. */
43 bool validate();
45 /** Change unit used to display amount. */
46 void setDisplayUnit(int unit);
48 /** Make field empty and ready for new input. */
49 void clear();
51 /** Enable/Disable. */
52 void setEnabled(bool fEnabled);
54 /** Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907),
55 in these cases we have to set it up manually.
57 QWidget *setupTabChain(QWidget *prev);
59 Q_SIGNALS:
60 void valueChanged();
62 protected:
63 /** Intercept focus-in event and ',' key presses */
64 bool eventFilter(QObject *object, QEvent *event);
66 private:
67 AmountSpinBox *amount;
68 QValueComboBox *unit;
70 private Q_SLOTS:
71 void unitChanged(int idx);
75 #endif // BITCOIN_QT_BITCOINAMOUNTFIELD_H