| 197 | } |
| 198 | |
| 199 | void ModFolderPage::installMods() |
| 200 | { |
| 201 | if (m_instance->typeName() != "Minecraft") |
| 202 | return; // this is a null instance or a legacy instance |
| 203 | |
| 204 | auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile(); |
| 205 | if (!profile->getModLoaders().has_value()) { |
| 206 | QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!")); |
| 207 | return; |
| 208 | } |
| 209 | |
| 210 | ResourceDownload::ModDownloadDialog mdownload(this, m_model, m_instance); |
| 211 | if (mdownload.exec()) { |
| 212 | auto tasks = new ConcurrentTask("Download Mods", APPLICATION->settings()->get("NumberOfConcurrentDownloads").toInt()); |
| 213 | connect(tasks, &Task::failed, [this, tasks](QString reason) { |
| 214 | CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); |
| 215 | tasks->deleteLater(); |
| 216 | }); |
| 217 | connect(tasks, &Task::aborted, [this, tasks]() { |
| 218 | CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show(); |
| 219 | tasks->deleteLater(); |
| 220 | }); |
| 221 | connect(tasks, &Task::succeeded, [this, tasks]() { |
| 222 | QStringList warnings = tasks->warnings(); |
| 223 | if (warnings.count()) |
| 224 | CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show(); |
| 225 | |
| 226 | tasks->deleteLater(); |
| 227 | }); |
| 228 | |
| 229 | for (auto& task : mdownload.getTasks()) { |
| 230 | tasks->addTask(task); |
| 231 | } |
| 232 | |
| 233 | ProgressDialog loadDialog(this); |
| 234 | loadDialog.setSkipButton(true, tr("Abort")); |
| 235 | loadDialog.execWithTask(tasks); |
| 236 | |
| 237 | m_model->update(); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | void ModFolderPage::updateMods(bool includeDeps) |
| 242 | { |
nothing calls this directly
no test coverage detected