Raven Core  3.0.0
P2P Digital Currency
ravenamountfield.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef RAVEN_QT_RAVENAMOUNTFIELD_H
7 #define RAVEN_QT_RAVENAMOUNTFIELD_H
8 
9 #include "amount.h"
10 
11 #include <QWidget>
12 
13 class AmountSpinBox;
14 
15 QT_BEGIN_NAMESPACE
16 class QValueComboBox;
17 QT_END_NAMESPACE
18 
21 class RavenAmountField: public QWidget
22 {
23  Q_OBJECT
24 
25  // ugly hack: for some unknown reason CAmount (instead of qint64) does not work here as expected
26  // discussion: https://github.com/RavenProject/Ravencoin/pull/5117
27  Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY valueChanged USER true)
28 
29 public:
30  explicit RavenAmountField(QWidget *parent = 0);
31 
32  CAmount value(bool *value=0) const;
33  void setValue(const CAmount& value);
34 
36  void setSingleStep(const CAmount& step);
37 
39  void setReadOnly(bool fReadOnly);
40 
42  void setValid(bool valid);
44  bool validate();
45 
47  void setDisplayUnit(int unit);
48 
50  void clear();
51 
53  void setEnabled(bool fEnabled);
54 
58  QWidget *setupTabChain(QWidget *prev);
59 
60 Q_SIGNALS:
61  void valueChanged();
62 
63 protected:
65  bool eventFilter(QObject *object, QEvent *event);
66 
67 private:
70 
71 private Q_SLOTS:
72  void unitChanged(int idx);
73 
74 };
75 
76 
77 
78 
79 class AssetAmountField: public QWidget
80 {
81 Q_OBJECT
82 
83  // ugly hack: for some unknown reason CAmount (instead of qint64) does not work here as expected
84  // discussion: https://github.com/RavenProject/Ravencoin/pull/5117
85  Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY valueChanged USER true)
86 
87 public:
88  explicit AssetAmountField(QWidget *parent = 0);
89 
90  CAmount value(bool *value=0) const;
91  void setValue(const CAmount& value);
92 
94  void setSingleStep(const CAmount& step);
95 
97  void setReadOnly(bool fReadOnly);
98 
100  void setValid(bool valid);
102  bool validate();
103 
105  void setDisplayUnit(int unit);
106 
108  void clear();
109 
111  void setEnabled(bool fEnabled);
112 
113  void setUnit(int unit);
114  void setMaxAmount(CAmount& max);
115 
116 Q_SIGNALS:
117  void valueChanged();
118 
119 protected:
121  bool eventFilter(QObject *object, QEvent *event);
122 
123 private:
126 
127 };
128 
129 
130 #endif // RAVEN_QT_RAVENAMOUNTFIELD_H
AmountSpinBox * amount
AmountSpinBox * amount
bool validate()
Perform input validation, mark field as invalid if entered value is not valid.
void setEnabled(bool fEnabled)
Enable/Disable.
void unitChanged(int idx)
QSpinBox that uses fixed-point numbers internally and uses our own formatting/parsing functions...
QWidget * setupTabChain(QWidget *prev)
Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907), in these cases we have to set it up manually.
RavenAmountField(QWidget *parent=0)
void setSingleStep(const CAmount &step)
Set single step in satoshis.
int64_t CAmount
Amount in corbies (Can be negative)
Definition: amount.h:13
void setValue(const CAmount &value)
bool eventFilter(QObject *object, QEvent *event)
Intercept focus-in event and &#39;,&#39; key presses.
void setDisplayUnit(int unit)
Change unit used to display amount.
void setReadOnly(bool fReadOnly)
Make read-only.
Widget for entering raven amounts.
void clear()
Make field empty and ready for new input.
QValueComboBox * unit
void setValid(bool valid)
Mark current value as invalid in UI.