summaryrefslogtreecommitdiffstats
path: root/application/dialogs
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-07-26 17:55:29 +0200
committerPetr Mrázek <peterix@gmail.com>2015-07-26 17:55:29 +0200
commitd8caab515aa641ec901592d40b5d30c6dfd282f5 (patch)
tree612b322374083309027204b656d4dc0a78780de8 /application/dialogs
parent6310f6569c2630f27ad72dc0a5fef9f9fec5a88c (diff)
downloadMultiMC-d8caab515aa641ec901592d40b5d30c6dfd282f5.tar
MultiMC-d8caab515aa641ec901592d40b5d30c6dfd282f5.tar.gz
MultiMC-d8caab515aa641ec901592d40b5d30c6dfd282f5.tar.lz
MultiMC-d8caab515aa641ec901592d40b5d30c6dfd282f5.tar.xz
MultiMC-d8caab515aa641ec901592d40b5d30c6dfd282f5.zip
GH-1053 add back update progress dialog
Diffstat (limited to 'application/dialogs')
-rw-r--r--application/dialogs/ProgressDialog.cpp37
-rw-r--r--application/dialogs/ProgressDialog.h3
2 files changed, 39 insertions, 1 deletions
diff --git a/application/dialogs/ProgressDialog.cpp b/application/dialogs/ProgressDialog.cpp
index 9a437d7a..939c5870 100644
--- a/application/dialogs/ProgressDialog.cpp
+++ b/application/dialogs/ProgressDialog.cpp
@@ -57,6 +57,12 @@ void ProgressDialog::updateSize()
int ProgressDialog::exec(Task *task)
{
this->task = task;
+ QDialog::DialogCode result;
+
+ if(handleImmediateResult(result))
+ {
+ return result;
+ }
// Connect signals.
connect(task, SIGNAL(started()), SLOT(onTaskStarted()));
@@ -67,11 +73,40 @@ int ProgressDialog::exec(Task *task)
// if this didn't connect to an already running task, invoke start
if(!task->isRunning())
+ {
task->start();
+ }
if(task->isRunning())
+ {
+ changeProgress(task->getProgress(), task->getTotalProgress());
+ changeStatus(task->getStatus());
return QDialog::exec();
+ }
+ else if(handleImmediateResult(result))
+ {
+ return result;
+ }
else
- return QDialog::Accepted;
+ {
+ return QDialog::Rejected;
+ }
+}
+
+bool ProgressDialog::handleImmediateResult(QDialog::DialogCode &result)
+{
+ if(task->isFinished())
+ {
+ if(task->successful())
+ {
+ result = QDialog::Accepted;
+ }
+ else
+ {
+ result = QDialog::Rejected;
+ }
+ return true;
+ }
+ return false;
}
Task *ProgressDialog::getTask()
diff --git a/application/dialogs/ProgressDialog.h b/application/dialogs/ProgressDialog.h
index fb80d0ce..44cbbe88 100644
--- a/application/dialogs/ProgressDialog.h
+++ b/application/dialogs/ProgressDialog.h
@@ -59,6 +59,9 @@ protected:
virtual void closeEvent(QCloseEvent *e);
private:
+ bool handleImmediateResult(QDialog::DialogCode &result);
+
+private:
Ui::ProgressDialog *ui;
Task *task;