2018-05-26 18:49:57 +00:00
|
|
|
|
|
|
|
#ifndef ASYNCTASKDIALOG_H
|
|
|
|
#define ASYNCTASKDIALOG_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2018-05-27 14:51:01 +00:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QTimer>
|
|
|
|
|
2018-05-28 14:19:04 +00:00
|
|
|
#include "utils/AsyncTask.h"
|
|
|
|
|
2018-05-26 18:49:57 +00:00
|
|
|
namespace Ui {
|
|
|
|
class AsyncTaskDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
class AsyncTaskDialog : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-05-28 14:19:04 +00:00
|
|
|
AsyncTaskDialog(AsyncTask::Ptr task, QWidget *parent = nullptr);
|
2018-05-26 18:49:57 +00:00
|
|
|
~AsyncTaskDialog();
|
|
|
|
|
2018-06-26 20:11:26 +00:00
|
|
|
void setInterruptOnClose(bool v) { interruptOnClose = v; }
|
|
|
|
bool getInterruptOnClose() { return interruptOnClose; }
|
|
|
|
|
2018-05-27 16:28:48 +00:00
|
|
|
public slots:
|
|
|
|
void reject() override;
|
|
|
|
|
2018-05-26 18:49:57 +00:00
|
|
|
private slots:
|
2018-05-27 19:57:37 +00:00
|
|
|
void updateLog(const QString &log);
|
2018-05-27 14:51:01 +00:00
|
|
|
void updateProgressTimer();
|
2018-05-26 18:49:57 +00:00
|
|
|
|
2018-05-27 16:28:48 +00:00
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *event) override;
|
|
|
|
|
2018-05-26 18:49:57 +00:00
|
|
|
private:
|
|
|
|
std::unique_ptr<Ui::AsyncTaskDialog> ui;
|
2018-05-28 14:19:04 +00:00
|
|
|
AsyncTask::Ptr task;
|
2018-05-27 14:51:01 +00:00
|
|
|
QTimer timer;
|
2018-05-27 16:28:48 +00:00
|
|
|
|
2018-06-26 20:11:26 +00:00
|
|
|
bool interruptOnClose = false;
|
2018-05-26 18:49:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //ASYNCTASKDIALOG_H
|