ThreeStateButton.h 731 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef THREESTATEBUTTON_H
  2. #define THREESTATEBUTTON_H
  3. #include <QMap>
  4. #include <QToolButton>
  5. enum ButtonState
  6. {
  7. NORMAL = 0,
  8. HOVER = 1,
  9. PRESSED = 2
  10. };
  11. class ThreeStateButton : public QToolButton
  12. {
  13. Q_OBJECT
  14. public:
  15. explicit ThreeStateButton(const QMap<ButtonState, QString> &iconPaths, QWidget *parent = nullptr,
  16. const QSize &buttonSize = QSize(40, 40), const QSize &iconSize = QSize());
  17. void setState(ButtonState state);
  18. // QObject interface
  19. public:
  20. virtual bool eventFilter(QObject *watched, QEvent *event) override;
  21. signals:
  22. private:
  23. QMap<ButtonState, QString> m_iconPaths;
  24. QSize m_buttonSize;
  25. QSize m_iconSize;
  26. };
  27. #endif // THREESTATEBUTTON_H