MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / execWithTask

Method execWithTask

launcher/ui/dialogs/ProgressDialog.cpp:61–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61int ProgressDialog::execWithTask(Task* task)
62{
63 this->task = task;
64
65 if (!task) {
66 qDebug() << "Programmer error: Progress dialog created with null task.";
67 return QDialog::DialogCode::Accepted;
68 }
69
70 QDialog::DialogCode result;
71 if (handleImmediateResult(result)) {
72 return result;
73 }
74
75 // Connect signals.
76 connect(task, &Task::started, this, &ProgressDialog::onTaskStarted);
77 connect(task, &Task::failed, this, &ProgressDialog::onTaskFailed);
78 connect(task, &Task::succeeded, this, &ProgressDialog::onTaskSucceeded);
79 connect(task, &Task::status, this, &ProgressDialog::changeStatus);
80 connect(task, &Task::stepStatus, this, &ProgressDialog::changeStatus);
81 connect(task, &Task::progress, this, &ProgressDialog::changeProgress);
82
83 connect(task, &Task::aborted, [this] { QDialog::reject(); });
84 connect(task, &Task::abortStatusChanged, ui->skipButton, &QPushButton::setEnabled);
85
86 m_is_multi_step = task->isMultiStep();
87 if (!m_is_multi_step) {
88 ui->globalStatusLabel->setHidden(true);
89 ui->globalProgressBar->setHidden(true);
90 }
91
92 // It's a good idea to start the task after we entered the dialog's event loop :^)
93 if (!task->isRunning()) {
94 QMetaObject::invokeMethod(task, &Task::start, Qt::QueuedConnection);
95 } else {
96 changeStatus(task->getStatus());
97 changeProgress(task->getProgress(), task->getTotalProgress());
98 }
99
100 return QDialog::exec();
101}
102
103// TODO: only provide the unique_ptr overloads
104int ProgressDialog::execWithTask(std::unique_ptr<Task>&& task)

Callers 15

loginMethod · 0.80
onProgressRequestedMethod · 0.80
downloadUpdatesMethod · 0.80
runModalTaskMethod · 0.80
finalizeInstanceMethod · 0.80
fetchFlameKeyMethod · 0.80
uploadPasteMethod · 0.80
installModsMethod · 0.80
updateModsMethod · 0.80

Calls 6

getStatusMethod · 0.80
getProgressMethod · 0.80
getTotalProgressMethod · 0.80
isMultiStepMethod · 0.45
isRunningMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected