qt/ledset/waitingdlg.h

51 lines
1.1 KiB
C
Raw Normal View History

2023-06-06 12:13:33 +08:00
#ifndef WAITINGDLG_H
#define WAITINGDLG_H
#include <QLabel>
#include <QNetworkReply>
#include <QDialog>
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 {
Q_OBJECT
public:
explicit WaitingDlg(QWidget *parent = nullptr, QString text = 0, QString sucText = 0);
inline void connAbort(QNetworkReply *reply) {
connect(this, &WaitingDlg::rejected, reply, [reply] {
reply->blockSignals(true);
reply->abort();
reply->blockSignals(false);
reply->deleteLater();
});
}
QPushButton *btnAbort;
QLabel *fdText;
QString sucText;
WaitingIndicator *mIndicator;
public slots:
void showLater();
void success();
protected:
void timerEvent(QTimerEvent *) override;
2023-06-07 19:11:03 +08:00
void closeEvent(QCloseEvent *) override;
2023-06-06 12:13:33 +08:00
private:
int closeTimerId{0}, showTimerId{0};
};
#endif // WAITINGDLG_H