Added auto java options to the java wizzard page
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
4c76f7afe0
commit
2f489d1aec
3 changed files with 48 additions and 0 deletions
|
@ -57,6 +57,8 @@ bool JavaWizardPage::validatePage()
|
||||||
{
|
{
|
||||||
auto settings = APPLICATION->settings();
|
auto settings = APPLICATION->settings();
|
||||||
auto result = m_java_widget->validate();
|
auto result = m_java_widget->validate();
|
||||||
|
settings->set("AutomaticJavaSwitch", m_java_widget->autodetectJava());
|
||||||
|
settings->set("AutomaticJavaDownload", m_java_widget->autodownloadJava());
|
||||||
switch (result) {
|
switch (result) {
|
||||||
default:
|
default:
|
||||||
case JavaSettingsWidget::ValidationStatus::Bad: {
|
case JavaSettingsWidget::ValidationStatus::Bad: {
|
||||||
|
|
|
@ -136,6 +136,26 @@ void JavaSettingsWidget::setupUi()
|
||||||
|
|
||||||
m_verticalLayout->addLayout(m_horizontalBtnLayout);
|
m_verticalLayout->addLayout(m_horizontalBtnLayout);
|
||||||
|
|
||||||
|
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_veriticalJavaLayout->addWidget(m_autodetectJavaCheckBox);
|
||||||
|
|
||||||
|
m_autodownloadCheckBox = new QCheckBox(m_autoJavaGroupBox);
|
||||||
|
m_autodownloadCheckBox->setObjectName("autodownloadCheckBox");
|
||||||
|
m_autodownloadCheckBox->setEnabled(false);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
m_verticalLayout->addWidget(m_autoJavaGroupBox);
|
||||||
|
|
||||||
retranslate();
|
retranslate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +173,9 @@ void JavaSettingsWidget::initialize()
|
||||||
m_maxMemSpinBox->setValue(observedMaxMemory);
|
m_maxMemSpinBox->setValue(observedMaxMemory);
|
||||||
m_permGenSpinBox->setValue(observedPermGenMemory);
|
m_permGenSpinBox->setValue(observedPermGenMemory);
|
||||||
updateThresholds();
|
updateThresholds();
|
||||||
|
|
||||||
|
m_autodetectJavaCheckBox->setChecked(s->get("AutomaticJavaSwitch").toBool());
|
||||||
|
m_autodownloadCheckBox->setChecked(s->get("AutomaticJavaSwitch").toBool() && s->get("AutomaticJavaDownload").toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaSettingsWidget::refresh()
|
void JavaSettingsWidget::refresh()
|
||||||
|
@ -280,11 +303,13 @@ void JavaSettingsWidget::on_javaBrowseBtn_clicked()
|
||||||
m_javaPathTextBox->setText(cooked_path);
|
m_javaPathTextBox->setText(cooked_path);
|
||||||
checkJavaPath(cooked_path);
|
checkJavaPath(cooked_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaSettingsWidget::on_javaDownloadBtn_clicked()
|
void JavaSettingsWidget::on_javaDownloadBtn_clicked()
|
||||||
{
|
{
|
||||||
auto jdialog = new Java::Downloader(this);
|
auto jdialog = new Java::Downloader(this);
|
||||||
jdialog->exec();
|
jdialog->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaSettingsWidget::on_javaStatusBtn_clicked()
|
void JavaSettingsWidget::on_javaStatusBtn_clicked()
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
|
@ -418,6 +443,9 @@ void JavaSettingsWidget::retranslate()
|
||||||
m_minMemSpinBox->setToolTip(tr("The amount of memory Minecraft is started with."));
|
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_permGenSpinBox->setToolTip(tr("The amount of memory available to store loaded Java classes."));
|
||||||
m_javaBrowseBtn->setText(tr("Browse"));
|
m_javaBrowseBtn->setText(tr("Browse"));
|
||||||
|
m_autodownloadCheckBox->setText(tr("Autodownload Mojang Java"));
|
||||||
|
m_autodetectJavaCheckBox->setText(tr("Autodetect Java version"));
|
||||||
|
m_autoJavaGroupBox->setTitle(tr("Autodetect Java"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaSettingsWidget::updateThresholds()
|
void JavaSettingsWidget::updateThresholds()
|
||||||
|
@ -464,3 +492,13 @@ void JavaSettingsWidget::on_addJavaPathBtn_clicked()
|
||||||
APPLICATION->settings()->set("JavaExtraSearchPaths", currentList);
|
APPLICATION->settings()->set("JavaExtraSearchPaths", currentList);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JavaSettingsWidget::autodownloadJava() const
|
||||||
|
{
|
||||||
|
return m_autodetectJavaCheckBox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JavaSettingsWidget::autodetectJava() const
|
||||||
|
{
|
||||||
|
return m_autodownloadCheckBox->isChecked();
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <BaseVersion.h>
|
#include <BaseVersion.h>
|
||||||
#include <QObjectPtr.h>
|
#include <QObjectPtr.h>
|
||||||
#include <java/JavaChecker.h>
|
#include <java/JavaChecker.h>
|
||||||
|
#include <qcheckbox.h>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
|
@ -41,6 +42,8 @@ class JavaSettingsWidget : public QWidget {
|
||||||
int minHeapSize() const;
|
int minHeapSize() const;
|
||||||
int maxHeapSize() const;
|
int maxHeapSize() const;
|
||||||
QString javaPath() const;
|
QString javaPath() const;
|
||||||
|
bool autodetectJava() const;
|
||||||
|
bool autodownloadJava() const;
|
||||||
|
|
||||||
void updateThresholds();
|
void updateThresholds();
|
||||||
|
|
||||||
|
@ -86,6 +89,11 @@ class JavaSettingsWidget : public QWidget {
|
||||||
QIcon yellowIcon;
|
QIcon yellowIcon;
|
||||||
QIcon badIcon;
|
QIcon badIcon;
|
||||||
|
|
||||||
|
QGroupBox* m_autoJavaGroupBox = nullptr;
|
||||||
|
QVBoxLayout* m_veriticalJavaLayout = nullptr;
|
||||||
|
QCheckBox* m_autodetectJavaCheckBox = nullptr;
|
||||||
|
QCheckBox* m_autodownloadCheckBox = nullptr;
|
||||||
|
|
||||||
unsigned int observedMinMemory = 0;
|
unsigned int observedMinMemory = 0;
|
||||||
unsigned int observedMaxMemory = 0;
|
unsigned int observedMaxMemory = 0;
|
||||||
unsigned int observedPermGenMemory = 0;
|
unsigned int observedPermGenMemory = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue