warning.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. void setTextWithOneButton(const QString& text); /* 只有一个确定按钮 */
  17. bool isOk() const { return m_isOk; }
  18. /* 设置QSS */
  19. void setQSS(const QString& qssPath);
  20. signals:
  21. void signal_ok();
  22. protected:
  23. // void paintEvent(QPaintEvent *event) override;
  24. /* 事件过滤器 */
  25. bool eventFilter(QObject *watched, QEvent *event) override;
  26. /* 鼠标点击事件 */
  27. void mousePressEvent(QMouseEvent *event) override;
  28. /* 鼠标移动事件 */
  29. void mouseMoveEvent(QMouseEvent *event) override;
  30. /* 鼠标释放事件 */
  31. void mouseReleaseEvent(QMouseEvent *event) override;
  32. private slots:
  33. void do_ok();
  34. private:
  35. /* 重新设置显示文字的区域大小 */
  36. void resetLabelSize();
  37. /* 移动警告图标 */
  38. void moveWarnICON();
  39. private:
  40. Ui::Warning *ui;
  41. // OneShadow* m_shadow = nullptr;
  42. const int SHADOW_W = 16; /* 阴影的大小 */
  43. bool m_isOk = false;
  44. QPoint m_lastPos;
  45. };
  46. #endif // WARNING_H