| 202 | } |
| 203 | |
| 204 | void AutoInstallJava::tryNextMajorJava() |
| 205 | { |
| 206 | if (!isRunning()) |
| 207 | return; |
| 208 | auto versionList = APPLICATION->metadataIndex()->get("net.minecraft.java"); |
| 209 | auto packProfile = m_instance->getPackProfile(); |
| 210 | auto wantedJavaName = packProfile->getProfile()->getCompatibleJavaName(); |
| 211 | auto majorJavaVersions = packProfile->getProfile()->getCompatibleJavaMajors(); |
| 212 | if (m_majorJavaVersionIndex >= majorJavaVersions.length()) { |
| 213 | emit logLine( |
| 214 | tr("No versions of Java were found for your operating system: %1-%2").arg(SysInfo::currentSystem(), SysInfo::useQTForArch()), |
| 215 | MessageLevel::Warning); |
| 216 | emit logLine(tr("No compatible version of Java was found. Using the default one."), MessageLevel::Warning); |
| 217 | emitSucceeded(); |
| 218 | return; |
| 219 | } |
| 220 | auto majorJavaVersion = majorJavaVersions[m_majorJavaVersionIndex]; |
| 221 | m_majorJavaVersionIndex++; |
| 222 | |
| 223 | auto javaMajor = versionList->getVersion(QString("java%1").arg(majorJavaVersion)); |
| 224 | |
| 225 | if (javaMajor->isLoaded()) { |
| 226 | downloadJava(javaMajor, wantedJavaName); |
| 227 | } else { |
| 228 | m_current_task = APPLICATION->metadataIndex()->loadVersion("net.minecraft.java", javaMajor->version(), Net::Mode::Online); |
| 229 | connect(m_current_task.get(), &Task::succeeded, this, |
| 230 | [this, javaMajor, wantedJavaName] { downloadJava(javaMajor, wantedJavaName); }); |
| 231 | connect(m_current_task.get(), &Task::failed, this, &AutoInstallJava::tryNextMajorJava); |
| 232 | connect(m_current_task.get(), &Task::progress, this, &AutoInstallJava::setProgress); |
| 233 | connect(m_current_task.get(), &Task::stepProgress, this, &AutoInstallJava::propagateStepProgress); |
| 234 | connect(m_current_task.get(), &Task::status, this, &AutoInstallJava::setStatus); |
| 235 | connect(m_current_task.get(), &Task::details, this, &AutoInstallJava::setDetails); |
| 236 | if (!m_current_task->isRunning()) { |
| 237 | m_current_task->start(); |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | bool AutoInstallJava::abort() |
| 242 | { |
| 243 | if (m_current_task && m_current_task->canAbort()) { |
nothing calls this directly
no test coverage detected