| 152 | } |
| 153 | |
| 154 | void ModFolderPage::installMods() |
| 155 | { |
| 156 | if (!m_controlsEnabled) |
| 157 | return; |
| 158 | if (m_instance->typeName() != "Minecraft") |
| 159 | return; // this is a null instance or a legacy instance |
| 160 | |
| 161 | auto profile = static_cast<MinecraftInstance*>(m_instance)->getPackProfile(); |
| 162 | if (profile->getModLoaders() == ModAPI::Unspecified) { |
| 163 | QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!")); |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | ModDownloadDialog mdownload(m_model, this, m_instance); |
| 168 | if (mdownload.exec()) { |
| 169 | ConcurrentTask* tasks = new ConcurrentTask(this); |
| 170 | connect(tasks, &Task::failed, [this, tasks](QString reason) { |
| 171 | CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); |
| 172 | tasks->deleteLater(); |
| 173 | }); |
| 174 | connect(tasks, &Task::aborted, [this, tasks]() { |
| 175 | CustomMessageBox::selectable(this, tr("Aborted"), tr("Download stopped by user."), QMessageBox::Information)->show(); |
| 176 | tasks->deleteLater(); |
| 177 | }); |
| 178 | connect(tasks, &Task::succeeded, [this, tasks]() { |
| 179 | QStringList warnings = tasks->warnings(); |
| 180 | if (warnings.count()) |
| 181 | CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show(); |
| 182 | |
| 183 | tasks->deleteLater(); |
| 184 | }); |
| 185 | |
| 186 | for (auto& task : mdownload.getTasks()) { |
| 187 | tasks->addTask(task); |
| 188 | } |
| 189 | |
| 190 | ProgressDialog loadDialog(this); |
| 191 | loadDialog.setSkipButton(true, tr("Abort")); |
| 192 | loadDialog.execWithTask(tasks); |
| 193 | |
| 194 | m_model->update(); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | void ModFolderPage::updateMods() |
| 199 | { |
nothing calls this directly
no test coverage detected