You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bitcoinamountfield.h 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #ifndef BITCOINAMOUNTFIELD_H
  5. #define BITCOINAMOUNTFIELD_H
  6. #include <QWidget>
  7. QT_BEGIN_NAMESPACE
  8. class QDoubleSpinBox;
  9. class QValueComboBox;
  10. QT_END_NAMESPACE
  11. /** Widget for entering bitcoin amounts.
  12. */
  13. class BitcoinAmountField: public QWidget
  14. {
  15. Q_OBJECT
  16. Q_PROPERTY(qint64 value READ value WRITE setValue NOTIFY textChanged USER true)
  17. public:
  18. explicit BitcoinAmountField(QWidget *parent = 0);
  19. qint64 value(bool *valid=0) const;
  20. void setValue(qint64 value);
  21. /** Set single step in satoshis **/
  22. void setSingleStep(qint64 step);
  23. /** Make read-only **/
  24. void setReadOnly(bool fReadOnly);
  25. /** Mark current value as invalid in UI. */
  26. void setValid(bool valid);
  27. /** Perform input validation, mark field as invalid if entered value is not valid. */
  28. bool validate();
  29. /** Change unit used to display amount. */
  30. void setDisplayUnit(int unit);
  31. /** Make field empty and ready for new input. */
  32. void clear();
  33. /** Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907),
  34. in these cases we have to set it up manually.
  35. */
  36. QWidget *setupTabChain(QWidget *prev);
  37. signals:
  38. void textChanged();
  39. protected:
  40. /** Intercept focus-in event and ',' key presses */
  41. bool eventFilter(QObject *object, QEvent *event);
  42. private:
  43. QDoubleSpinBox *amount;
  44. QValueComboBox *unit;
  45. int currentUnit;
  46. qint64 nSingleStep;
  47. void setText(const QString &text);
  48. QString text() const;
  49. private slots:
  50. void unitChanged(int idx);
  51. };
  52. #endif // BITCOINAMOUNTFIELD_H