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