ExpandGroupSettingCard.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #ifndef EXPANDGROUPSETTINGCARD_H
  2. #define EXPANDGROUPSETTINGCARD_H
  3. #include <QAbstractButton>
  4. #include <QFrame>
  5. #include <QParallelAnimationGroup>
  6. #include <QPropertyAnimation>
  7. #include "Common/Icon.h"
  8. class VBoxLayout;
  9. class SettingCard;
  10. class ExpandButton : public QAbstractButton
  11. {
  12. Q_OBJECT
  13. Q_PROPERTY(float angle READ getAngle WRITE setAngle)
  14. public:
  15. explicit ExpandButton(QWidget *parent = nullptr);
  16. void setHover(bool hover);
  17. void setPressed(bool pressed);
  18. float getAngle() const;
  19. void setAngle(float angle);
  20. bool isHover;
  21. bool isPressed;
  22. protected:
  23. void mousePressEvent(QMouseEvent *event) override;
  24. void mouseReleaseEvent(QMouseEvent *event) override;
  25. void enterEvent(QEvent *event) override;
  26. void leaveEvent(QEvent *event) override;
  27. void paintEvent(QPaintEvent *event) override;
  28. private slots:
  29. void onClicked();
  30. private:
  31. float m_angle;
  32. QPropertyAnimation *m_rotateAni;
  33. };
  34. class ExpandSettingCard : public QFrame
  35. {
  36. Q_OBJECT
  37. public:
  38. explicit ExpandSettingCard(FluentIconBase *icon, const QString &title, const QString &content,
  39. QWidget *parent = nullptr);
  40. void addWidget(QWidget *widget);
  41. void setExpand(bool expand);
  42. virtual void setValue(const QVariant &value);
  43. QFrame *view() const;
  44. VBoxLayout *viewLayout;
  45. public slots:
  46. void toggleExpand();
  47. protected:
  48. void resizeEvent(QResizeEvent *event) override;
  49. bool eventFilter(QObject *watched, QEvent *event) override;
  50. void adjustViewSize();
  51. private:
  52. void initWidget();
  53. private slots:
  54. void onAniFinished();
  55. private:
  56. bool m_isExpand;
  57. ExpandButton *m_expandButton;
  58. QFrame *m_view;
  59. SettingCard *m_card;
  60. QParallelAnimationGroup *m_aniGroup;
  61. QPropertyAnimation *m_slideAni;
  62. QPropertyAnimation *m_expandAni;
  63. };
  64. class GroupSeparator : public QWidget
  65. {
  66. Q_OBJECT
  67. public:
  68. explicit GroupSeparator(QWidget *parent = nullptr);
  69. void paintEvent(QPaintEvent *event) override;
  70. };
  71. class ExpandGroupSettingCard : public ExpandSettingCard
  72. {
  73. Q_OBJECT
  74. public:
  75. explicit ExpandGroupSettingCard(FluentIconBase *icon, const QString &title, const QString &content,
  76. QWidget *parent = nullptr);
  77. void addGroupWidget(QWidget *widget);
  78. signals:
  79. };
  80. #endif // EXPANDGROUPSETTINGCARD_H