MCPcopy Create free account
hub / github.com/PrismLauncher/PrismLauncher / done

Method done

launcher/ui/java/InstallJavaDialog.cpp:309–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

307}
308
309void InstallDialog::done(int result)
310{
311 if (result == Accepted) {
312 auto* page = pageCast(container->selectedPage());
313 if (page->selectedVersion()) {
314 auto meta = std::dynamic_pointer_cast<Java::Metadata>(page->selectedVersion());
315 if (meta) {
316 Task::Ptr task;
317 auto final_path = FS::PathCombine(APPLICATION->javaPath(), meta->m_name);
318 auto deletePath = [final_path] { FS::deletePath(final_path); };
319 switch (meta->downloadType) {
320 case Java::DownloadType::Manifest:
321 task = makeShared<ManifestDownloadTask>(meta->url, final_path, meta->checksumType, meta->checksumHash);
322 break;
323 case Java::DownloadType::Archive:
324 task = makeShared<ArchiveDownloadTask>(meta->url, final_path, meta->checksumType, meta->checksumHash);
325 break;
326 case Java::DownloadType::Unknown:
327 QString error = QString(tr("Could not determine Java download type!"));
328 CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show();
329 deletePath();
330 return;
331 }
332#if defined(Q_OS_MACOS)
333 auto seq = makeShared<SequentialTask>(tr("Install Java"));
334 seq->addTask(task);
335 seq->addTask(makeShared<Java::SymlinkTask>(final_path));
336 task = seq;
337#endif
338 connect(task.get(), &Task::failed, this, [this, &deletePath](QString reason) {
339 QString error = QString("Java download failed: %1").arg(reason);
340 CustomMessageBox::selectable(this, tr("Error"), error, QMessageBox::Warning)->show();
341 deletePath();
342 });
343 connect(task.get(), &Task::aborted, this, deletePath);
344 ProgressDialog pg(this);
345 pg.setSkipButton(true, tr("Abort"));
346 pg.execWithTask(task.get());
347 } else {
348 return;
349 }
350 } else {
351 return;
352 }
353 }
354
355 QDialog::done(result);
356}
357
358} // namespace Java
359

Callers

nothing calls this directly

Calls 13

PathCombineFunction · 0.85
deletePathFunction · 0.85
selectableFunction · 0.85
showMethod · 0.80
addTaskMethod · 0.80
setSkipButtonMethod · 0.80
execWithTaskMethod · 0.80
pageCastFunction · 0.70
QStringClass · 0.50
selectedPageMethod · 0.45
selectedVersionMethod · 0.45
javaPathMethod · 0.45

Tested by

no test coverage detected