MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / execWithTask

Method execWithTask

launcher/ui/dialogs/ProgressDialog.cpp:131–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131int ProgressDialog::execWithTask(Task* task)
132{
133 this->m_task = task;
134
135 if (!task) {
136 qDebug() << "Programmer error: Progress dialog created with null task.";
137 return QDialog::DialogCode::Accepted;
138 }
139
140 QDialog::DialogCode result{};
141 if (handleImmediateResult(result)) {
142 return result;
143 }
144
145 // Connect signals.
146 this->m_taskConnections.push_back(connect(task, &Task::started, this, &ProgressDialog::onTaskStarted));
147 this->m_taskConnections.push_back(connect(task, &Task::failed, this, &ProgressDialog::onTaskFailed));
148 this->m_taskConnections.push_back(connect(task, &Task::succeeded, this, &ProgressDialog::onTaskSucceeded));
149 this->m_taskConnections.push_back(connect(task, &Task::status, this, &ProgressDialog::changeStatus));
150 this->m_taskConnections.push_back(connect(task, &Task::details, this, &ProgressDialog::changeStatus));
151 this->m_taskConnections.push_back(connect(task, &Task::stepProgress, this, &ProgressDialog::changeStepProgress));
152 this->m_taskConnections.push_back(connect(task, &Task::progress, this, &ProgressDialog::changeProgress));
153 this->m_taskConnections.push_back(connect(task, &Task::aborted, this, &ProgressDialog::hide));
154 this->m_taskConnections.push_back(connect(task, &Task::abortStatusChanged, ui->skipButton, &QPushButton::setEnabled));
155
156 m_is_multi_step = task->isMultiStep();
157 ui->taskProgressScrollArea->setHidden(!m_is_multi_step);
158 updateSize();
159
160 // It's a good idea to start the task after we entered the dialog's event loop :^)
161 if (!task->isRunning()) {
162 QMetaObject::invokeMethod(task, &Task::start, Qt::QueuedConnection);
163 } else {
164 changeStatus(task->getStatus());
165 changeProgress(task->getProgress(), task->getTotalProgress());
166 }
167
168 return QDialog::exec();
169}
170
171// TODO: only provide the unique_ptr overloads
172int ProgressDialog::execWithTask(std::unique_ptr<Task>&& task)

Callers 15

handleDataMigrationMethod · 0.80
loginMethod · 0.80
onProgressRequestedMethod · 0.80
downloadAssetMethod · 0.80
runModalTaskMethod · 0.80
processURLsMethod · 0.80
uploadPasteMethod · 0.80
updateStateMethod · 0.80
downloadTPsMethod · 0.80
installModsMethod · 0.80
updateModsMethod · 0.80
changeModVersionMethod · 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