initial commit
This commit is contained in:
35
client/gui/dialogs/CancelableTaskDialog.h
Normal file
35
client/gui/dialogs/CancelableTaskDialog.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
|
||||
class QLabel;
|
||||
class QProgressBar;
|
||||
class QPushButton;
|
||||
|
||||
// 可复用的“长任务提示框”:显示提示文本 + 不定进度条 + 取消按钮。
|
||||
// - 任务本身由调用方启动(例如网络请求/后台线程)
|
||||
// - 调用方在取消时应中止任务,并调用 reject()/close()
|
||||
class CancelableTaskDialog final : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CancelableTaskDialog(const QString& title,
|
||||
const QString& message,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
void setMessage(const QString& message);
|
||||
bool wasCanceled() const { return m_canceled; }
|
||||
|
||||
signals:
|
||||
void canceled();
|
||||
|
||||
private slots:
|
||||
void onCancel();
|
||||
|
||||
private:
|
||||
QLabel* m_label = nullptr;
|
||||
QProgressBar* m_bar = nullptr;
|
||||
QPushButton* m_btnCancel = nullptr;
|
||||
bool m_canceled = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user