aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/dialogs/ProgressDialog.cpp
diff options
context:
space:
mode:
authorkumquat-ir <66188216+kumquat-ir@users.noreply.github.com>2022-07-18 14:05:23 -0400
committerkumquat-ir <66188216+kumquat-ir@users.noreply.github.com>2022-07-18 14:05:23 -0400
commit20b1723e78149c1f2ac4072cbd46997e9c5160fa (patch)
tree7d97c8bc2edfe5cb41b91e6d04ba36da8aa163e6 /launcher/ui/dialogs/ProgressDialog.cpp
parentbe78afeee54a19cd0115e1d2ec63f3a3201a3940 (diff)
parentdec81c4f274dd8388d442062cf9fa18600aa850d (diff)
downloadPrismLauncher-20b1723e78149c1f2ac4072cbd46997e9c5160fa.tar.gz
PrismLauncher-20b1723e78149c1f2ac4072cbd46997e9c5160fa.tar.bz2
PrismLauncher-20b1723e78149c1f2ac4072cbd46997e9c5160fa.zip
merge origin/develop
Signed-off-by: kumquat-ir <66188216+kumquat-ir@users.noreply.github.com>
Diffstat (limited to 'launcher/ui/dialogs/ProgressDialog.cpp')
-rw-r--r--launcher/ui/dialogs/ProgressDialog.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index e5226016..a79bc837 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -62,24 +62,24 @@ void ProgressDialog::updateSize()
int ProgressDialog::execWithTask(Task* task)
{
this->task = task;
- QDialog::DialogCode result;
if (!task) {
- qDebug() << "Programmer error: progress dialog created with null task.";
- return Accepted;
+ qDebug() << "Programmer error: Progress dialog created with null task.";
+ return QDialog::DialogCode::Accepted;
}
+ QDialog::DialogCode result;
if (handleImmediateResult(result)) {
return result;
}
// Connect signals.
- connect(task, SIGNAL(started()), SLOT(onTaskStarted()));
- connect(task, SIGNAL(failed(QString)), SLOT(onTaskFailed(QString)));
- connect(task, SIGNAL(succeeded()), SLOT(onTaskSucceeded()));
- connect(task, SIGNAL(status(QString)), SLOT(changeStatus(const QString&)));
- connect(task, SIGNAL(stepStatus(QString)), SLOT(changeStatus(const QString&)));
- connect(task, SIGNAL(progress(qint64, qint64)), SLOT(changeProgress(qint64, qint64)));
+ connect(task, &Task::started, this, &ProgressDialog::onTaskStarted);
+ connect(task, &Task::failed, this, &ProgressDialog::onTaskFailed);
+ connect(task, &Task::succeeded, this, &ProgressDialog::onTaskSucceeded);
+ connect(task, &Task::status, this, &ProgressDialog::changeStatus);
+ connect(task, &Task::stepStatus, this, &ProgressDialog::changeStatus);
+ connect(task, &Task::progress, this, &ProgressDialog::changeProgress);
connect(task, &Task::aborted, [this] { onTaskFailed(tr("Aborted by user")); });
@@ -89,19 +89,15 @@ int ProgressDialog::execWithTask(Task* task)
ui->globalProgressBar->setHidden(true);
}
- // if this didn't connect to an already running task, invoke start
+ // It's a good idea to start the task after we entered the dialog's event loop :^)
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;
+ QMetaObject::invokeMethod(task, &Task::start, Qt::QueuedConnection);
} else {
- return QDialog::Rejected;
+ changeStatus(task->getStatus());
+ changeProgress(task->getProgress(), task->getTotalProgress());
}
+
+ return QDialog::exec();
}
// TODO: only provide the unique_ptr overloads