qt: Use fixed-point arithmetic in amount spinbox
Fixes various issues and cleans up code - Fixes issue #4500: Amount widget +/- has floating point rounding artifacts - Amount box can now be emptied again, without clearing to 0 Also aligns the amount to the right, as in other places.
This commit is contained in:
@@ -8,17 +8,18 @@
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QDoubleSpinBox;
|
||||
class QValueComboBox;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class AmountSpinBox;
|
||||
|
||||
/** Widget for entering bitcoin amounts.
|
||||
*/
|
||||
class BitcoinAmountField: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true)
|
||||
Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY valueChanged USER true)
|
||||
|
||||
public:
|
||||
explicit BitcoinAmountField(QWidget *parent = 0);
|
||||
@@ -49,20 +50,15 @@ public:
|
||||
QWidget *setupTabChain(QWidget *prev);
|
||||
|
||||
signals:
|
||||
void textChanged();
|
||||
void valueChanged();
|
||||
|
||||
protected:
|
||||
/** Intercept focus-in event and ',' key presses */
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
private:
|
||||
QDoubleSpinBox *amount;
|
||||
AmountSpinBox *amount;
|
||||
QValueComboBox *unit;
|
||||
int currentUnit;
|
||||
qint64 nSingleStep;
|
||||
|
||||
void setText(const QString &text);
|
||||
QString text() const;
|
||||
|
||||
private slots:
|
||||
void unitChanged(int idx);
|
||||
|
||||
Reference in New Issue
Block a user