FolderListSettingCard.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef FOLDERLISTSETTINGCARD_H
  2. #define FOLDERLISTSETTINGCARD_H
  3. #include "Common/Icon.h"
  4. #include "ExpandGroupSettingCard.h"
  5. #include <QBoxLayout>
  6. #include <QLabel>
  7. #include <QPushButton>
  8. #include <QToolButton>
  9. class FToolButton : public QToolButton
  10. {
  11. Q_OBJECT
  12. public:
  13. explicit FToolButton(FluentIconBase *icon, const QSize &size, const QSize &iconSize, QWidget *parent = nullptr);
  14. // QWidget interface
  15. protected:
  16. void mousePressEvent(QMouseEvent *event) override;
  17. void mouseReleaseEvent(QMouseEvent *event) override;
  18. void paintEvent(QPaintEvent *event) override;
  19. private:
  20. bool m_isPressed;
  21. QScopedPointer<FluentIconBase> m_icon;
  22. QSize m_iconSize;
  23. };
  24. class FPushButton : public QPushButton
  25. {
  26. Q_OBJECT
  27. public:
  28. explicit FPushButton(FluentIconBase *icon, const QString &text, QWidget *parent = nullptr);
  29. // QWidget interface
  30. protected:
  31. void mousePressEvent(QMouseEvent *event) override;
  32. void mouseReleaseEvent(QMouseEvent *event) override;
  33. void paintEvent(QPaintEvent *event) override;
  34. private:
  35. bool m_isPressed;
  36. QScopedPointer<FluentIconBase> m_icon;
  37. };
  38. class FolderItem : public QWidget
  39. {
  40. Q_OBJECT
  41. public:
  42. explicit FolderItem(const QString &folder, QWidget *parent = nullptr);
  43. QString folder() const;
  44. QHBoxLayout *hBoxLayout;
  45. signals:
  46. void removed(FolderItem *);
  47. private:
  48. QString m_folder;
  49. QLabel *m_folderLabel;
  50. FToolButton *m_removeButton;
  51. };
  52. class FolderListSettingCard : public ExpandSettingCard
  53. {
  54. Q_OBJECT
  55. public:
  56. explicit FolderListSettingCard(const QVariant &configItem, const QString &title, const QString &content = "",
  57. const QString &directory = "./", QWidget *parent = nullptr);
  58. private:
  59. void initWidget();
  60. void addFolderItem(const QString &folder);
  61. private slots:
  62. void showFolderDialog();
  63. void showConfirmDialog(FolderItem *item);
  64. void removeFolder(FolderItem *item);
  65. signals:
  66. void folderChanged(const QStringList &);
  67. private:
  68. QVariant m_configItem;
  69. QString m_dialogDirectory;
  70. FPushButton *m_addFolderButton;
  71. QStringList m_folders;
  72. };
  73. #endif // FOLDERLISTSETTINGCARD_H