warning.h 983 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. signals:
  18. void signal_ok();
  19. protected:
  20. void paintEvent(QPaintEvent *event) override;
  21. /* 鼠标点击事件 */
  22. void mousePressEvent(QMouseEvent *event) override;
  23. /* 鼠标移动事件 */
  24. void mouseMoveEvent(QMouseEvent *event) override;
  25. /* 鼠标释放事件 */
  26. void mouseReleaseEvent(QMouseEvent *event) override;
  27. private slots:
  28. void do_ok();
  29. private:
  30. Ui::Warning *ui;
  31. OneShadow* m_shadow = nullptr;
  32. const int SHADOW_W = 16; /* 阴影的大小 */
  33. bool m_isOk = false;
  34. QPoint m_lastPos;
  35. };
  36. #endif // WARNING_H