FolderListDialog.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef FOLDERLISTDIALOG_H
  2. #define FOLDERLISTDIALOG_H
  3. #include "MaskDialogBase.h"
  4. #include <QLabel>
  5. class ScrollArea;
  6. class AddFolderCard;
  7. class FolderCard;
  8. class FolderListDialog : public MaskDialogBase
  9. {
  10. Q_OBJECT
  11. public:
  12. FolderListDialog(const QStringList &folderList, const QString &title, const QString &content,
  13. QWidget *parent = nullptr);
  14. ~FolderListDialog();
  15. signals:
  16. void folderChanged(const QStringList &list);
  17. private:
  18. void initWidget();
  19. void setQss();
  20. void initLayout();
  21. void adjustWidgetSize();
  22. void deleteFolderCard(FolderCard *card);
  23. private slots:
  24. void showFileDialog();
  25. void onButtonClicked();
  26. void showDeleteFolderCardDialog();
  27. private:
  28. QStringList m_folderPaths;
  29. QStringList m_originalPaths;
  30. QString m_title;
  31. QString m_content;
  32. QVBoxLayout *m_vBoxLayout;
  33. QLabel *m_titleLabel;
  34. QLabel *m_contentLabel;
  35. ScrollArea *m_scrollArea;
  36. QWidget *m_scrollWidget;
  37. QPushButton *m_completeButton;
  38. AddFolderCard *m_addFolderCard;
  39. QList<FolderCard *> m_folderCards;
  40. QVBoxLayout *m_scrollLayout;
  41. };
  42. class ClickableWindow : public QWidget
  43. {
  44. Q_OBJECT
  45. public:
  46. explicit ClickableWindow(QWidget *parent = nullptr);
  47. // QWidget interface
  48. bool isPressed() const;
  49. bool isEnter() const;
  50. protected:
  51. void mousePressEvent(QMouseEvent *event) override;
  52. void mouseReleaseEvent(QMouseEvent *event) override;
  53. void enterEvent(QEvent *event) override;
  54. void leaveEvent(QEvent *event) override;
  55. void paintEvent(QPaintEvent *event) override;
  56. signals:
  57. void clicked();
  58. private:
  59. bool m_isPressed;
  60. bool m_isEnter;
  61. };
  62. class FolderCard : public ClickableWindow
  63. {
  64. Q_OBJECT
  65. public:
  66. explicit FolderCard(const QString &folderPath, QWidget *parent = nullptr);
  67. QString folderName() const;
  68. protected:
  69. void paintEvent(QPaintEvent *event) override;
  70. private:
  71. void drawText(QPainter *painter, int x1, int fontSize1, int x2, int fontSize2);
  72. private:
  73. QString m_folderPath;
  74. QString m_folderName;
  75. QPixmap m_closeIcon;
  76. };
  77. class AddFolderCard : public ClickableWindow
  78. {
  79. Q_OBJECT
  80. public:
  81. explicit AddFolderCard(QWidget *parent = nullptr);
  82. protected:
  83. void paintEvent(QPaintEvent *event) override;
  84. private:
  85. QPixmap m_iconPix;
  86. };
  87. #endif // FOLDERLISTDIALOG_H