| 402 | } |
| 403 | |
| 404 | void ModFolderPage::changeModVersion() |
| 405 | { |
| 406 | if (m_instance->typeName() != "Minecraft") |
| 407 | return; // this is a null instance or a legacy instance |
| 408 | |
| 409 | auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile(); |
| 410 | if (!profile->getModLoaders().has_value()) { |
| 411 | QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!")); |
| 412 | return; |
| 413 | } |
| 414 | if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) { |
| 415 | QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!")); |
| 416 | return; |
| 417 | } |
| 418 | auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); |
| 419 | auto mods_list = m_model->selectedMods(selection); |
| 420 | if (mods_list.length() != 1 || mods_list[0]->metadata() == nullptr) |
| 421 | return; |
| 422 | |
| 423 | ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance); |
| 424 | mdownload.setModMetadata((*mods_list.begin())->metadata()); |
| 425 | if (mdownload.exec()) { |
| 426 | auto tasks = new ConcurrentTask("Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt()); |
| 427 | connect(tasks, &Task::failed, [this, tasks](QString reason) { |
| 428 | CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); |
| 429 | tasks->deleteLater(); |
| 430 | }); |
| 431 | connect(tasks, &Task::aborted, [this, tasks]() { |
| 432 | CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show(); |
| 433 | tasks->deleteLater(); |
| 434 | }); |
| 435 | connect(tasks, &Task::succeeded, [this, tasks]() { |
| 436 | QStringList warnings = tasks->warnings(); |
| 437 | if (warnings.count()) |
| 438 | CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show(); |
| 439 | |
| 440 | tasks->deleteLater(); |
| 441 | }); |
| 442 | |
| 443 | for (auto& task : mdownload.getTasks()) { |
| 444 | tasks->addTask(task); |
| 445 | } |
| 446 | |
| 447 | ProgressDialog loadDialog(this); |
| 448 | loadDialog.setSkipButton(true, tr("Abort")); |
| 449 | loadDialog.execWithTask(tasks); |
| 450 | |
| 451 | m_model->update(); |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | void ModFolderPage::exportModMetadata() |
| 456 | { |
nothing calls this directly
no test coverage detected