123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #ifndef TIPWIDGET_H
- #define TIPWIDGET_H
- #include <QWidget>
- class QPropertyAnimation;
- namespace Ui {
- class TipWidget;
- }
- class TipWidget : public QWidget
- {
- Q_OBJECT
- public:
- enum FormType
- {
- OPERATOR_OK = 0, // 操作成功!
- OPERATOR_FAIL, // 操作失败!
- OPERATOR_TIP, // 普通提示!
- OPERATOR_WARN, // 需注意!
- };
- public:
- static const int WIDTH = 168;
- static const int HEIGHT = 56;
- static void display(FormType type, QWidget* parent = Q_NULLPTR, int nTitleHeight = 48);
- static void display(FormType type, QString text, QWidget* parent = Q_NULLPTR, int nTitleHeight = 48);
- explicit TipWidget(FormType type, QWidget *parent = 0);
- TipWidget(FormType type, QString& text, QWidget *parent = 0);
- ~TipWidget();
- void setEndPos(int x, int y);
- void run();
- public slots:
- void onBtnClose();
- void onFadeOut();
- protected:
- void paintEvent(QPaintEvent *event) override;
- private:
- void setFormType(FormType type);
- private:
- Ui::TipWidget *ui;
- QColor _backgroundColor{246, 255, 237};
- QColor _borderColor{183, 235, 143};
- QRect _endRect;
- QTimer* _pKillTimer{nullptr};
- QPropertyAnimation* _animation{nullptr};
- QPropertyAnimation* _animFadeOut{nullptr};
- QString m_tipText; /* 提示文本 */
- bool m_customText; /* 自定义文本标志 */
- };
- #endif // TIPWIDGET_H
|