warning.h 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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);
  23. /* 事件过滤器 */
  24. bool eventFilter(QObject *watched, QEvent *event);
  25. private slots:
  26. void do_ok();
  27. private:
  28. /* 重新设置显示文字的区域大小 */
  29. void resetLabelSize();
  30. /* 移动警告图标 */
  31. void moveWarnICON();
  32. private:
  33. Ui::Warning *ui;
  34. OneShadow* m_shadow = nullptr;
  35. const int SHADOW_W = 16; /* 阴影的大小 */
  36. bool m_isOk = false;
  37. };
  38. #endif // WARNING_H