NavigationWidget.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef NAVIGATIONWIDGET_H
  2. #define NAVIGATIONWIDGET_H
  3. #include <QWidget>
  4. #include "Common/Icon.h"
  5. class NavigationWidget : public QWidget
  6. {
  7. Q_OBJECT
  8. public:
  9. static int EXPAND_WIDTH;
  10. explicit NavigationWidget(bool selectable, QWidget *parent = nullptr);
  11. virtual void setCompacted(bool compacted);
  12. void setSelected(bool selected);
  13. bool isCompacted;
  14. bool isSelected;
  15. bool isPressed;
  16. bool isEnter;
  17. bool isSelectable;
  18. // QWidget interface
  19. protected:
  20. void mousePressEvent(QMouseEvent *event) override;
  21. void mouseReleaseEvent(QMouseEvent *event) override;
  22. void enterEvent(QEvent *event) override;
  23. void leaveEvent(QEvent *event) override;
  24. signals:
  25. void clicked(bool);
  26. };
  27. class NavigationPushButton : public NavigationWidget
  28. {
  29. Q_OBJECT
  30. public:
  31. explicit NavigationPushButton(FluentIconBase *ficon, const QString &text, bool selectable,
  32. QWidget *parent = nullptr);
  33. QString text() const;
  34. // QWidget interface
  35. protected:
  36. void paintEvent(QPaintEvent *event) override;
  37. private:
  38. QScopedPointer<FluentIconBase> m_ficon;
  39. QString m_text;
  40. };
  41. class NavigationToolButton : public NavigationPushButton
  42. {
  43. Q_OBJECT
  44. public:
  45. explicit NavigationToolButton(FluentIconBase *ficon, QWidget *parent = nullptr);
  46. void setCompacted(bool compacted);
  47. };
  48. class NavigationSeparator : public NavigationWidget
  49. {
  50. Q_OBJECT
  51. public:
  52. explicit NavigationSeparator(QWidget *parent = nullptr);
  53. void setCompacted(bool compacted) override;
  54. // QWidget interface
  55. protected:
  56. void paintEvent(QPaintEvent *event) override;
  57. };
  58. #endif // NAVIGATIONWIDGET_H