53 lines
1.2 KiB
C++
53 lines
1.2 KiB
C++
#ifndef WAIT_DIALOG_H
|
|
#define WAIT_DIALOG_H
|
|
|
|
#include <QDialog>
|
|
#include <QGraphicsDropShadowEffect>
|
|
#include <QLabel>
|
|
#include <QMovie>
|
|
#include <QPainter>
|
|
#include <QPushButton>
|
|
#include <functional>
|
|
|
|
|
|
class CWaitDialog : public QDialog {
|
|
Q_OBJECT
|
|
public:
|
|
explicit CWaitDialog(QWidget *parent = nullptr);
|
|
~CWaitDialog();
|
|
|
|
public:
|
|
// 给定 gif 图和对话框的大小
|
|
void Init(const QString &gif, int size = 120);
|
|
// 设定提示信息(建议简短一些)
|
|
void setTipsText(QString strTipsText);
|
|
// 是否显示取消按钮
|
|
void setCanCancel(bool show);
|
|
// 移动对话框到指定窗口中间
|
|
void moveToCenter(QWidget *pParent);
|
|
// 注册用户点击取消后的回调函数
|
|
void registerFunc(std::function<void()> call);
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
Q_SIGNALS:
|
|
void cancelWaiting();
|
|
|
|
public:
|
|
void StopWait();
|
|
|
|
private:
|
|
QFrame *frame_center_;
|
|
QLabel *movie_lable_;
|
|
QMovie *load_movie_;
|
|
QLabel *tip_lable_;
|
|
QPushButton *cancel_btn_;
|
|
int margin_{3};
|
|
int base_size{120};
|
|
int base_heigh_{};
|
|
|
|
private:
|
|
std::function<void()> stopCall_{};
|
|
};
|
|
#endif // LOADINGDIALOG_H
|