qt/LedOK/base/waitingdlg.h

51 lines
1.2 KiB
C
Raw Normal View History

2023-04-18 14:14:46 +08:00
#ifndef WAITINGDLG_H
#define WAITINGDLG_H
#include <QLabel>
2023-04-23 17:01:35 +08:00
#include <QNetworkReply>
2023-08-01 11:42:41 +08:00
#include <QDialog>
2023-04-18 14:14:46 +08:00
2023-08-01 11:42:41 +08:00
class WaitingIndicator : public QWidget {
Q_OBJECT
public:
using QWidget::QWidget;
QColor mColor{0x0088ff};
public slots:
void success();
protected:
void timerEvent(QTimerEvent * event) override;
void paintEvent(QPaintEvent * event) override;
int angle{0};
int timerId{0};
};
class WaitingDlg : public QDialog {
2023-04-18 14:14:46 +08:00
Q_OBJECT
public:
explicit WaitingDlg(QWidget *parent = nullptr, QString text = 0, QString sucText = 0);
2023-04-23 17:01:35 +08:00
inline void connAbort(QNetworkReply *reply) {
connect(this, &WaitingDlg::rejected, reply, [reply] {
reply->blockSignals(true);
reply->abort();
reply->blockSignals(false);
reply->deleteLater();
});
}
2023-04-18 14:14:46 +08:00
QLabel *fdText;
QString sucText;
2023-08-01 11:42:41 +08:00
WaitingIndicator *mIndicator;
2023-04-18 14:14:46 +08:00
public slots:
2023-08-01 11:42:41 +08:00
void show();
void showLater();
2023-04-18 14:14:46 +08:00
void success();
protected:
void timerEvent(QTimerEvent *) override;
2023-08-01 11:42:41 +08:00
void closeEvent(QCloseEvent *) override;
2023-04-18 14:14:46 +08:00
private:
2023-08-01 11:42:41 +08:00
int closeTimerId{0}, showTimerId{0};
2023-04-18 14:14:46 +08:00
};
#endif // WAITINGDLG_H