MCPcopy Create free account
hub / github.com/ElyPrismLauncher/Launcher / execWithTask

Method execWithTask

launcher/ui/dialogs/ProgressDialog.cpp:131–170  ·  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 this->m_taskConnections.push_back(connect(task, &Task::abortButtonTextChanged, ui->skipButton, &QPushButton::setText));
156
157 m_is_multi_step = task->isMultiStep();
158 ui->taskProgressScrollArea->setHidden(!m_is_multi_step);
159 updateSize();
160
161 // It's a good idea to start the task after we entered the dialog's event loop :^)
162 if (!task->isRunning()) {
163 QMetaObject::invokeMethod(task, &Task::start, Qt::QueuedConnection);
164 } else {
165 changeStatus(task->getStatus());
166 changeProgress(task->getProgress(), task->getTotalProgress());
167 }
168
169 return QDialog::exec();
170}
171
172// TODO: only provide the unique_ptr overloads
173int ProgressDialog::execWithTask(std::unique_ptr<Task>&& task)

Callers 15

handleDataMigrationMethod · 0.80
decideLaunchModeMethod · 0.80
onProgressRequestedMethod · 0.80
downloadAssetMethod · 0.80
runModalTaskMethod · 0.80
processURLsMethod · 0.80
uploadPasteMethod · 0.80
updateStateMethod · 0.80
updateTexturePacksMethod · 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