Dialog.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef DIALOG_H
  2. #define DIALOG_H
  3. #include "MaskDialogBase.h"
  4. #include <QBoxLayout>
  5. #include <QDialog>
  6. #include <QLabel>
  7. #include <QObject>
  8. #include <QPushButton>
  9. class PrimaryPushButton;
  10. class MessageBoxBase
  11. {
  12. public:
  13. QLabel *titleLabel = nullptr;
  14. QLabel *contentLabel = nullptr;
  15. QFrame *buttonGroup = nullptr;
  16. PrimaryPushButton *yesButton = nullptr;
  17. QPushButton *cancelButton = nullptr;
  18. QVBoxLayout *vBoxLayout = nullptr;
  19. QVBoxLayout *textLayout = nullptr;
  20. QHBoxLayout *buttonLayout = nullptr;
  21. protected:
  22. void setUpUi(const QString &title, const QString &content, QWidget *parent);
  23. void adjustText();
  24. private:
  25. void initWidget();
  26. void setQss();
  27. void initLayout();
  28. private:
  29. QString m_content;
  30. QWidget *m_selfWidget = nullptr;
  31. };
  32. class Dialog : public QDialog, public MessageBoxBase
  33. {
  34. Q_OBJECT
  35. public:
  36. explicit Dialog(const QString &title, const QString &content, QWidget *parent = nullptr);
  37. void setTitleBarVisible(bool isVisible);
  38. signals:
  39. void yesSignal();
  40. void cancelSignal();
  41. private slots:
  42. void onYesButtonClicked();
  43. void onCancelButtonClicked();
  44. private:
  45. QLabel *m_windowTitleLabel;
  46. };
  47. class MessageBox : public MaskDialogBase, public MessageBoxBase
  48. {
  49. Q_OBJECT
  50. public:
  51. explicit MessageBox(const QString &title, const QString &content, QWidget *parent = nullptr);
  52. bool eventFilter(QObject *watched, QEvent *event) override;
  53. signals:
  54. void yesSignal();
  55. void cancelSignal();
  56. private slots:
  57. void onYesButtonClicked();
  58. void onCancelButtonClicked();
  59. };
  60. #endif // DIALOG_H