12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #ifndef WARNING_H
- #define WARNING_H
- #include <QDialog>
- class OneShadow;
- namespace Ui {
- class Warning;
- }
- class Warning : public QDialog
- {
- Q_OBJECT
- public:
- explicit Warning(QWidget *parent = nullptr);
- ~Warning();
- /* 设置标题 */
- void setTitle(const QString& title, const QSize& size = QSize(120, 18));
- void setText(const QString& text);
- void setTextWithOneButton(const QString& text); /* 只有一个确定按钮 */
- bool isOk() const { return m_isOk; }
- /* 设置QSS */
- void setQSS(const QString& qssPath);
- signals:
- void signal_ok();
- protected:
- // void paintEvent(QPaintEvent *event) override;
- /* 事件过滤器 */
- bool eventFilter(QObject *watched, QEvent *event) override;
- /* 鼠标点击事件 */
- void mousePressEvent(QMouseEvent *event) override;
- /* 鼠标移动事件 */
- void mouseMoveEvent(QMouseEvent *event) override;
- /* 鼠标释放事件 */
- void mouseReleaseEvent(QMouseEvent *event) override;
- private slots:
- void do_ok();
- private:
- /* 重新设置显示文字的区域大小 */
- void resetLabelSize();
- /* 移动警告图标 */
- void moveWarnICON();
- private:
- Ui::Warning *ui;
- // OneShadow* m_shadow = nullptr;
- const int SHADOW_W = 16; /* 阴影的大小 */
- bool m_isOk = false;
- QPoint m_lastPos;
- };
- #endif // WARNING_H
|