warning.h 1.3 KB

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