summaryrefslogtreecommitdiff
path: root/archived/projt-launcher/launcher/ui/widgets/JavaWizardWidget.cpp
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 18:51:45 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 18:51:45 +0300
commitd3261e64152397db2dca4d691a990c6bc2a6f4dd (patch)
treefac2f7be638651181a72453d714f0f96675c2b8b /archived/projt-launcher/launcher/ui/widgets/JavaWizardWidget.cpp
parent31b9a8949ed0a288143e23bf739f2eb64fdc63be (diff)
downloadProject-Tick-d3261e64152397db2dca4d691a990c6bc2a6f4dd.tar.gz
Project-Tick-d3261e64152397db2dca4d691a990c6bc2a6f4dd.zip
NOISSUE add archived projects
Signed-off-by: Mehmet Samet Duman <yongdohyun@projecttick.org>
Diffstat (limited to 'archived/projt-launcher/launcher/ui/widgets/JavaWizardWidget.cpp')
-rw-r--r--archived/projt-launcher/launcher/ui/widgets/JavaWizardWidget.cpp645
1 files changed, 645 insertions, 0 deletions
diff --git a/archived/projt-launcher/launcher/ui/widgets/JavaWizardWidget.cpp b/archived/projt-launcher/launcher/ui/widgets/JavaWizardWidget.cpp
new file mode 100644
index 0000000000..126736cbf2
--- /dev/null
+++ b/archived/projt-launcher/launcher/ui/widgets/JavaWizardWidget.cpp
@@ -0,0 +1,645 @@
+// SPDX-License-Identifier: GPL-3.0-only
+// SPDX-FileCopyrightText: 2026 Project Tick
+// SPDX-FileContributor: Project Tick Team
+/*
+ * ProjT Launcher - Minecraft Launcher
+ * Copyright (C) 2026 Project Tick
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#include "JavaWizardWidget.h"
+
+#include <QFileDialog>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayoutItem>
+#include <QLineEdit>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QSizePolicy>
+#include <QSpinBox>
+#include <QToolButton>
+#include <QVBoxLayout>
+
+#include "DesktopServices.h"
+#include "FileSystem.h"
+#include "JavaCommon.h"
+#include "java/core/RuntimeInstall.hpp"
+#include "java/services/RuntimeCatalog.hpp"
+#include "java/services/RuntimeProbeTask.hpp"
+#include "java/services/RuntimeScanner.hpp"
+
+#include "ui/dialogs/CustomMessageBox.h"
+#include "ui/java/InstallJavaDialog.h"
+#include "ui/widgets/VersionSelectWidget.h"
+
+#include "Application.h"
+#include "BuildConfig.h"
+#include "HardwareInfo.h"
+
+JavaWizardWidget::JavaWizardWidget(QWidget* parent) : QWidget(parent)
+{
+ m_availableMemory = HardwareInfo::totalRamMiB();
+
+ goodIcon = QIcon::fromTheme("status-good");
+ yellowIcon = QIcon::fromTheme("status-yellow");
+ badIcon = QIcon::fromTheme("status-bad");
+ m_memoryTimer = new QTimer(this);
+ setupUi();
+
+ connect(m_minMemSpinBox, &QSpinBox::valueChanged, this, &JavaWizardWidget::onSpinBoxValueChanged);
+ connect(m_maxMemSpinBox, &QSpinBox::valueChanged, this, &JavaWizardWidget::onSpinBoxValueChanged);
+ connect(m_permGenSpinBox, &QSpinBox::valueChanged, this, &JavaWizardWidget::onSpinBoxValueChanged);
+ connect(m_memoryTimer, &QTimer::timeout, this, &JavaWizardWidget::memoryValueChanged);
+ connect(m_versionWidget,
+ &VersionSelectWidget::selectedVersionChanged,
+ this,
+ &JavaWizardWidget::javaVersionSelected);
+ connect(m_javaBrowseBtn, &QPushButton::clicked, this, &JavaWizardWidget::on_javaBrowseBtn_clicked);
+ connect(m_javaPathTextBox, &QLineEdit::textEdited, this, &JavaWizardWidget::javaPathEdited);
+ connect(m_javaStatusBtn, &QToolButton::clicked, this, &JavaWizardWidget::on_javaStatusBtn_clicked);
+ if (BuildConfig.JAVA_DOWNLOADER_ENABLED)
+ {
+ connect(m_javaDownloadBtn, &QPushButton::clicked, this, &JavaWizardWidget::javaDownloadBtn_clicked);
+ }
+}
+
+void JavaWizardWidget::setupUi()
+{
+ setObjectName(QStringLiteral("javaSettingsWidget"));
+ m_verticalLayout = new QVBoxLayout(this);
+ m_verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
+
+ m_versionWidget = new VersionSelectWidget(this);
+
+ m_horizontalLayout = new QHBoxLayout();
+ m_horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
+ m_javaPathTextBox = new QLineEdit(this);
+ m_javaPathTextBox->setObjectName(QStringLiteral("javaPathTextBox"));
+
+ m_horizontalLayout->addWidget(m_javaPathTextBox);
+
+ m_javaBrowseBtn = new QPushButton(this);
+ m_javaBrowseBtn->setObjectName(QStringLiteral("javaBrowseBtn"));
+
+ m_horizontalLayout->addWidget(m_javaBrowseBtn);
+
+ m_javaStatusBtn = new QToolButton(this);
+ m_javaStatusBtn->setIcon(yellowIcon);
+ m_horizontalLayout->addWidget(m_javaStatusBtn);
+
+ m_memoryGroupBox = new QGroupBox(this);
+ m_memoryGroupBox->setObjectName(QStringLiteral("memoryGroupBox"));
+ m_gridLayout_2 = new QGridLayout(m_memoryGroupBox);
+ m_gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
+ m_gridLayout_2->setColumnStretch(0, 1);
+
+ m_labelMinMem = new QLabel(m_memoryGroupBox);
+ m_labelMinMem->setObjectName(QStringLiteral("labelMinMem"));
+ m_gridLayout_2->addWidget(m_labelMinMem, 0, 0, 1, 1);
+
+ m_minMemSpinBox = new QSpinBox(m_memoryGroupBox);
+ m_minMemSpinBox->setObjectName(QStringLiteral("minMemSpinBox"));
+ m_minMemSpinBox->setSuffix(QStringLiteral(" MiB"));
+ m_minMemSpinBox->setMinimum(8);
+ m_minMemSpinBox->setMaximum(1048576);
+ m_minMemSpinBox->setSingleStep(128);
+ m_labelMinMem->setBuddy(m_minMemSpinBox);
+ m_gridLayout_2->addWidget(m_minMemSpinBox, 0, 1, 1, 1);
+
+ m_labelMaxMem = new QLabel(m_memoryGroupBox);
+ m_labelMaxMem->setObjectName(QStringLiteral("labelMaxMem"));
+ m_gridLayout_2->addWidget(m_labelMaxMem, 1, 0, 1, 1);
+
+ m_maxMemSpinBox = new QSpinBox(m_memoryGroupBox);
+ m_maxMemSpinBox->setObjectName(QStringLiteral("maxMemSpinBox"));
+ m_maxMemSpinBox->setSuffix(QStringLiteral(" MiB"));
+ m_maxMemSpinBox->setMinimum(8);
+ m_maxMemSpinBox->setMaximum(1048576);
+ m_maxMemSpinBox->setSingleStep(128);
+ m_labelMaxMem->setBuddy(m_maxMemSpinBox);
+ m_gridLayout_2->addWidget(m_maxMemSpinBox, 1, 1, 1, 1);
+
+ m_labelMaxMemIcon = new QLabel(m_memoryGroupBox);
+ m_labelMaxMemIcon->setObjectName(QStringLiteral("labelMaxMemIcon"));
+ m_gridLayout_2->addWidget(m_labelMaxMemIcon, 1, 2, 1, 1);
+
+ m_labelPermGen = new QLabel(m_memoryGroupBox);
+ m_labelPermGen->setObjectName(QStringLiteral("labelPermGen"));
+ m_labelPermGen->setText(QStringLiteral("PermGen:"));
+ m_gridLayout_2->addWidget(m_labelPermGen, 2, 0, 1, 1);
+ m_labelPermGen->setVisible(false);
+
+ m_permGenSpinBox = new QSpinBox(m_memoryGroupBox);
+ m_permGenSpinBox->setObjectName(QStringLiteral("permGenSpinBox"));
+ m_permGenSpinBox->setSuffix(QStringLiteral(" MiB"));
+ m_permGenSpinBox->setMinimum(4);
+ m_permGenSpinBox->setMaximum(1048576);
+ m_permGenSpinBox->setSingleStep(8);
+ m_gridLayout_2->addWidget(m_permGenSpinBox, 2, 1, 1, 1);
+ m_permGenSpinBox->setVisible(false);
+
+ m_verticalLayout->addWidget(m_memoryGroupBox);
+
+ m_horizontalBtnLayout = new QHBoxLayout();
+ m_horizontalBtnLayout->setObjectName(QStringLiteral("horizontalBtnLayout"));
+
+ if (BuildConfig.JAVA_DOWNLOADER_ENABLED)
+ {
+ m_javaDownloadBtn = new QPushButton(tr("Download Java"), this);
+ m_horizontalBtnLayout->addWidget(m_javaDownloadBtn);
+ }
+
+ m_autoJavaGroupBox = new QGroupBox(this);
+ m_autoJavaGroupBox->setObjectName(QStringLiteral("autoJavaGroupBox"));
+ m_veriticalJavaLayout = new QVBoxLayout(m_autoJavaGroupBox);
+ m_veriticalJavaLayout->setObjectName(QStringLiteral("veriticalJavaLayout"));
+
+ m_autodetectJavaCheckBox = new QCheckBox(m_autoJavaGroupBox);
+ m_autodetectJavaCheckBox->setObjectName("autodetectJavaCheckBox");
+ m_autodetectJavaCheckBox->setChecked(true);
+ m_veriticalJavaLayout->addWidget(m_autodetectJavaCheckBox);
+
+ if (BuildConfig.JAVA_DOWNLOADER_ENABLED)
+ {
+ m_autodownloadCheckBox = new QCheckBox(m_autoJavaGroupBox);
+ m_autodownloadCheckBox->setObjectName("autodownloadCheckBox");
+ m_autodownloadCheckBox->setEnabled(m_autodetectJavaCheckBox->isChecked());
+ m_veriticalJavaLayout->addWidget(m_autodownloadCheckBox);
+ connect(m_autodetectJavaCheckBox,
+ &QCheckBox::stateChanged,
+ this,
+ [this]
+ {
+ m_autodownloadCheckBox->setEnabled(m_autodetectJavaCheckBox->isChecked());
+ if (!m_autodetectJavaCheckBox->isChecked())
+ m_autodownloadCheckBox->setChecked(false);
+ });
+
+ connect(m_autodownloadCheckBox,
+ &QCheckBox::stateChanged,
+ this,
+ [this]
+ {
+ auto isChecked = m_autodownloadCheckBox->isChecked();
+ m_versionWidget->setVisible(!isChecked);
+ m_javaStatusBtn->setVisible(!isChecked);
+ m_javaBrowseBtn->setVisible(!isChecked);
+ m_javaPathTextBox->setVisible(!isChecked);
+ m_javaDownloadBtn->setVisible(!isChecked);
+ if (!isChecked)
+ {
+ m_verticalLayout->removeItem(m_verticalSpacer);
+ }
+ else
+ {
+ m_verticalLayout->addSpacerItem(m_verticalSpacer);
+ }
+ });
+ }
+ m_verticalLayout->addWidget(m_autoJavaGroupBox);
+
+ m_verticalLayout->addLayout(m_horizontalBtnLayout);
+
+ m_verticalLayout->addWidget(m_versionWidget);
+ m_verticalLayout->addLayout(m_horizontalLayout);
+ m_verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
+
+ retranslate();
+}
+
+void JavaWizardWidget::initialize()
+{
+ m_versionWidget->initialize(APPLICATION->runtimeCatalog().get());
+ m_versionWidget->selectSearch();
+ m_versionWidget->setResizeOn(2);
+ auto s = APPLICATION->settings();
+ // Memory
+ observedMinMemory = s->get("MinMemAlloc").toInt();
+ observedMaxMemory = s->get("MaxMemAlloc").toInt();
+ observedPermGenMemory = s->get("PermGen").toInt();
+ m_minMemSpinBox->setValue(observedMinMemory);
+ m_maxMemSpinBox->setValue(observedMaxMemory);
+ m_permGenSpinBox->setValue(observedPermGenMemory);
+ updateThresholds();
+ if (BuildConfig.JAVA_DOWNLOADER_ENABLED)
+ {
+ m_autodownloadCheckBox->setChecked(true);
+ }
+}
+
+void JavaWizardWidget::refresh()
+{
+ if (BuildConfig.JAVA_DOWNLOADER_ENABLED && m_autodownloadCheckBox->isChecked())
+ {
+ return;
+ }
+ if (projt::java::RuntimeProbeTask::probeJarPath().isEmpty())
+ {
+ JavaCommon::javaCheckNotFound(this);
+ return;
+ }
+ m_versionWidget->loadList();
+}
+
+JavaWizardWidget::ValidationStatus JavaWizardWidget::validate()
+{
+ switch (javaStatus)
+ {
+ default:
+ case JavaStatus::NotSet:
+ /* fallthrough */
+ case JavaStatus::DoesNotExist:
+ /* fallthrough */
+ case JavaStatus::DoesNotStart:
+ /* fallthrough */
+ case JavaStatus::ReturnedInvalidData:
+ {
+ if (!(BuildConfig.JAVA_DOWNLOADER_ENABLED && m_autodownloadCheckBox->isChecked()))
+ { // the java will not be autodownloaded
+ int button = QMessageBox::No;
+ if (m_result.platformTag == "32" && maxHeapSize() > 2048)
+ {
+ button = CustomMessageBox::selectable(this,
+ tr("32-bit Java detected"),
+ tr("You selected a 32-bit installation of Java, but "
+ "allocated more than 2048MiB as maximum memory.\n"
+ "%1 will not be able to start Minecraft.\n"
+ "Do you wish to proceed?"
+ "\n\n"
+ "You can change the Java version in the settings later.\n")
+ .arg(BuildConfig.LAUNCHER_DISPLAYNAME),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::No | QMessageBox::Help,
+ QMessageBox::NoButton)
+ ->exec();
+ }
+ else
+ {
+ button = CustomMessageBox::selectable(
+ this,
+ tr("No Java version selected"),
+ tr("You either didn't select a Java version or selected one that does not work.\n"
+ "%1 will not be able to start Minecraft.\n"
+ "Do you wish to proceed without a functional version of Java?"
+ "\n\n"
+ "You can change the Java version in the settings later.\n")
+ .arg(BuildConfig.LAUNCHER_DISPLAYNAME),
+ QMessageBox::Warning,
+ QMessageBox::Yes | QMessageBox::No | QMessageBox::Help,
+ QMessageBox::NoButton)
+ ->exec();
+ }
+ switch (button)
+ {
+ case QMessageBox::Yes: return ValidationStatus::JavaBad;
+ case QMessageBox::Help:
+ DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg("java-wizard")));
+ [[fallthrough]];
+ case QMessageBox::No:
+ /* fallthrough */
+ default: return ValidationStatus::Bad;
+ }
+ }
+ return ValidationStatus::JavaBad;
+ }
+ break;
+ case JavaStatus::Pending:
+ {
+ return ValidationStatus::Bad;
+ }
+ case JavaStatus::Good:
+ {
+ return ValidationStatus::AllOK;
+ }
+ }
+}
+
+QString JavaWizardWidget::javaPath() const
+{
+ return m_javaPathTextBox->text();
+}
+
+int JavaWizardWidget::maxHeapSize() const
+{
+ auto min = m_minMemSpinBox->value();
+ auto max = m_maxMemSpinBox->value();
+ if (max < min)
+ max = min;
+ return max;
+}
+
+int JavaWizardWidget::minHeapSize() const
+{
+ auto min = m_minMemSpinBox->value();
+ auto max = m_maxMemSpinBox->value();
+ if (min > max)
+ min = max;
+ return min;
+}
+
+bool JavaWizardWidget::permGenEnabled() const
+{
+ return m_permGenSpinBox->isVisible();
+}
+
+int JavaWizardWidget::permGenSize() const
+{
+ return m_permGenSpinBox->value();
+}
+
+void JavaWizardWidget::memoryValueChanged()
+{
+ bool actuallyChanged = false;
+ unsigned int min = m_minMemSpinBox->value();
+ unsigned int max = m_maxMemSpinBox->value();
+ unsigned int permgen = m_permGenSpinBox->value();
+ if (min != observedMinMemory)
+ {
+ observedMinMemory = min;
+ actuallyChanged = true;
+ }
+ if (max != observedMaxMemory)
+ {
+ observedMaxMemory = max;
+ actuallyChanged = true;
+ }
+ if (permgen != observedPermGenMemory)
+ {
+ observedPermGenMemory = permgen;
+ actuallyChanged = true;
+ }
+ if (actuallyChanged)
+ {
+ checkJavaPathOnEdit(m_javaPathTextBox->text());
+ updateThresholds();
+ }
+}
+
+void JavaWizardWidget::javaVersionSelected(BaseVersion::Ptr version)
+{
+ auto java = std::dynamic_pointer_cast<projt::java::RuntimeInstall>(version);
+ if (!java)
+ {
+ return;
+ }
+ auto visible = java->version.needsPermGen();
+ m_labelPermGen->setVisible(visible);
+ m_permGenSpinBox->setVisible(visible);
+ m_javaPathTextBox->setText(java->path);
+ checkJavaPath(java->path);
+}
+
+void JavaWizardWidget::on_javaBrowseBtn_clicked()
+{
+ auto filter = QString("Java (%1)").arg(projt::java::RuntimeScanner::executableName());
+ auto raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"), QString(), filter);
+ if (raw_path.isEmpty())
+ {
+ return;
+ }
+ auto cooked_path = FS::NormalizePath(raw_path);
+ m_javaPathTextBox->setText(cooked_path);
+ checkJavaPath(cooked_path);
+}
+
+void JavaWizardWidget::javaDownloadBtn_clicked()
+{
+ auto jdialog = new Java::InstallDialog({}, nullptr, this);
+ jdialog->exec();
+}
+
+void JavaWizardWidget::on_javaStatusBtn_clicked()
+{
+ QString text;
+ bool failed = false;
+ switch (javaStatus)
+ {
+ case JavaStatus::NotSet: checkJavaPath(m_javaPathTextBox->text()); return;
+ case JavaStatus::DoesNotExist:
+ text += QObject::tr("The specified file either doesn't exist or is not a proper executable.");
+ failed = true;
+ break;
+ case JavaStatus::DoesNotStart:
+ {
+ text += QObject::tr("The specified Java binary didn't start properly.<br />");
+ auto htmlError = m_result.stderrLog;
+ if (!htmlError.isEmpty())
+ {
+ htmlError.replace('\n', "<br />");
+ text += QString("<font color=\"red\">%1</font>").arg(htmlError);
+ }
+ failed = true;
+ break;
+ }
+ case JavaStatus::ReturnedInvalidData:
+ {
+ text += QObject::tr("The specified Java binary returned unexpected results:<br />");
+ auto htmlOut = m_result.stdoutLog;
+ if (!htmlOut.isEmpty())
+ {
+ htmlOut.replace('\n', "<br />");
+ text += QString("<font color=\"red\">%1</font>").arg(htmlOut);
+ }
+ failed = true;
+ break;
+ }
+ case JavaStatus::Good:
+ text += QObject::tr("Java test succeeded!<br />Platform reported: %1<br />Java version "
+ "reported: %2<br />")
+ .arg(m_result.platformArch, m_result.version.toString());
+ break;
+ case JavaStatus::Pending:
+ CustomMessageBox::selectable(this,
+ QObject::tr("Java test pending"),
+ QObject::tr("The Java check is still in progress. Please wait."),
+ QMessageBox::Information)
+ ->show();
+ return;
+ }
+ CustomMessageBox::selectable(this,
+ failed ? QObject::tr("Java test failure") : QObject::tr("Java test success"),
+ text,
+ failed ? QMessageBox::Critical : QMessageBox::Information)
+ ->show();
+}
+
+void JavaWizardWidget::setJavaStatus(JavaWizardWidget::JavaStatus status)
+{
+ javaStatus = status;
+ switch (javaStatus)
+ {
+ case JavaStatus::Good: m_javaStatusBtn->setIcon(goodIcon); break;
+ case JavaStatus::NotSet:
+ case JavaStatus::Pending: m_javaStatusBtn->setIcon(yellowIcon); break;
+ default: m_javaStatusBtn->setIcon(badIcon); break;
+ }
+}
+
+void JavaWizardWidget::javaPathEdited(const QString& path)
+{
+ checkJavaPathOnEdit(path);
+}
+
+void JavaWizardWidget::checkJavaPathOnEdit(const QString& path)
+{
+ auto realPath = FS::ResolveExecutable(path);
+ QFileInfo pathInfo(realPath);
+ if (pathInfo.baseName().toLower().contains("java"))
+ {
+ checkJavaPath(path);
+ }
+ else
+ {
+ if (!m_checker)
+ {
+ setJavaStatus(JavaStatus::NotSet);
+ }
+ }
+}
+
+void JavaWizardWidget::checkJavaPath(const QString& path)
+{
+ if (m_checker)
+ {
+ queuedCheck = path;
+ return;
+ }
+ auto realPath = FS::ResolveExecutable(path);
+ if (realPath.isNull())
+ {
+ setJavaStatus(JavaStatus::DoesNotExist);
+ return;
+ }
+ setJavaStatus(JavaStatus::Pending);
+ projt::java::RuntimeProbeTask::ProbeSettings settings;
+ settings.binaryPath = path;
+ settings.minMem = minHeapSize();
+ settings.maxMem = maxHeapSize();
+ settings.permGen = m_permGenSpinBox->isVisible() ? m_permGenSpinBox->value() : 0;
+ m_checker.reset(new projt::java::RuntimeProbeTask(settings));
+ connect(m_checker.get(), &projt::java::RuntimeProbeTask::probeFinished, this, &JavaWizardWidget::checkFinished);
+ m_checker->start();
+}
+
+void JavaWizardWidget::checkFinished(const projt::java::RuntimeProbeTask::ProbeReport& result)
+{
+ m_result = result;
+ switch (result.status)
+ {
+ case projt::java::RuntimeProbeTask::ProbeReport::Status::Valid:
+ {
+ setJavaStatus(JavaStatus::Good);
+ break;
+ }
+ case projt::java::RuntimeProbeTask::ProbeReport::Status::InvalidData:
+ {
+ setJavaStatus(JavaStatus::ReturnedInvalidData);
+ break;
+ }
+ case projt::java::RuntimeProbeTask::ProbeReport::Status::Errored:
+ {
+ setJavaStatus(JavaStatus::DoesNotStart);
+ break;
+ }
+ }
+ updateThresholds();
+ m_checker.reset();
+ if (!queuedCheck.isNull())
+ {
+ checkJavaPath(queuedCheck);
+ queuedCheck.clear();
+ }
+}
+
+void JavaWizardWidget::retranslate()
+{
+ m_memoryGroupBox->setTitle(tr("Memory"));
+ m_maxMemSpinBox->setToolTip(tr("The maximum amount of memory Minecraft is allowed to use."));
+ m_labelMinMem->setText(tr("Minimum memory allocation:"));
+ m_labelMaxMem->setText(tr("Maximum memory allocation:"));
+ m_minMemSpinBox->setToolTip(tr("The amount of memory Minecraft is started with."));
+ m_permGenSpinBox->setToolTip(tr("The amount of memory available to store loaded Java classes."));
+ m_javaBrowseBtn->setText(tr("Browse"));
+ if (BuildConfig.JAVA_DOWNLOADER_ENABLED)
+ {
+ m_autodownloadCheckBox->setText(tr("Auto-download Mojang Java"));
+ }
+ m_autodetectJavaCheckBox->setText(tr("Auto-detect Java version"));
+ m_autoJavaGroupBox->setTitle(tr("Autodetect Java"));
+}
+
+void JavaWizardWidget::updateThresholds()
+{
+ QString iconName;
+
+ if (observedMaxMemory >= m_availableMemory)
+ {
+ iconName = "status-bad";
+ m_labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity."));
+ }
+ else if (observedMaxMemory > (m_availableMemory * 0.9))
+ {
+ iconName = "status-yellow";
+ m_labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity."));
+ }
+ else if (observedMaxMemory < observedMinMemory)
+ {
+ iconName = "status-yellow";
+ m_labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation is smaller than the minimum value"));
+ }
+ else if (BuildConfig.JAVA_DOWNLOADER_ENABLED && m_autodownloadCheckBox->isChecked())
+ {
+ iconName = "status-good";
+ m_labelMaxMemIcon->setToolTip("");
+ }
+ else if (observedMaxMemory > 2048 && !m_result.is_64bit)
+ {
+ iconName = "status-bad";
+ m_labelMaxMemIcon->setToolTip(
+ tr("You are exceeding the maximum allocation supported by 32-bit installations of Java."));
+ }
+ else
+ {
+ iconName = "status-good";
+ m_labelMaxMemIcon->setToolTip("");
+ }
+
+ {
+ auto height = m_labelMaxMemIcon->fontInfo().pixelSize();
+ QIcon icon = QIcon::fromTheme(iconName);
+ QPixmap pix = icon.pixmap(height, height);
+ m_labelMaxMemIcon->setPixmap(pix);
+ }
+}
+
+bool JavaWizardWidget::autoDownloadJava() const
+{
+ return m_autodownloadCheckBox && m_autodownloadCheckBox->isChecked();
+}
+
+bool JavaWizardWidget::autoDetectJava() const
+{
+ return m_autodetectJavaCheckBox->isChecked();
+}
+
+void JavaWizardWidget::onSpinBoxValueChanged(int)
+{
+ m_memoryTimer->start(500);
+}
+
+JavaWizardWidget::~JavaWizardWidget()
+{
+ delete m_verticalSpacer;
+};