warning.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef WARNING_H
  2. #define WARNING_H
  3. #include <QDialog>
  4. class OneShadow;
  5. namespace Ui {
  6. class Warning;
  7. }
  8. class Warning : public QDialog
  9. {
  10. Q_OBJECT
  11. public:
  12. explicit Warning(QWidget *parent = nullptr);
  13. ~Warning();
  14. void setTitle(const QString& title);
  15. void setText(const QString& text);
  16. /* 只有一个确定按钮 */
  17. void setTextWithOneButton(const QString& text);
  18. /* 对调确定按钮和取消按钮 */
  19. void swapOkCancelButton();
  20. bool isOk() const { return m_isOk; }
  21. /* 设置QSS */
  22. void setQSS(const QString& qssPath);
  23. signals:
  24. void signal_ok();
  25. protected:
  26. // void paintEvent(QPaintEvent *event) override;
  27. /* 事件过滤器 */
  28. bool eventFilter(QObject *watched, QEvent *event) override;
  29. /* 鼠标点击事件 */
  30. void mousePressEvent(QMouseEvent *event) override;
  31. /* 鼠标移动事件 */
  32. void mouseMoveEvent(QMouseEvent *event) override;
  33. /* 鼠标释放事件 */
  34. void mouseReleaseEvent(QMouseEvent *event) override;
  35. private slots:
  36. void do_ok();
  37. private:
  38. /* 重新设置显示文字的区域大小 */
  39. void resetLabelSize();
  40. /* 移动警告图标 */
  41. void moveWarnICON();
  42. private:
  43. Ui::Warning *ui;
  44. // OneShadow* m_shadow = nullptr;
  45. const int SHADOW_W = 16; /* 阴影的大小 */
  46. bool m_isOk = false;
  47. QPoint m_lastPos;
  48. };
  49. #endif // WARNING_H