summaryrefslogtreecommitdiffstats
path: root/application/pages/global/JavaPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'application/pages/global/JavaPage.cpp')
-rw-r--r--application/pages/global/JavaPage.cpp52
1 files changed, 30 insertions, 22 deletions
diff --git a/application/pages/global/JavaPage.cpp b/application/pages/global/JavaPage.cpp
index 543cc11f..57250c79 100644
--- a/application/pages/global/JavaPage.cpp
+++ b/application/pages/global/JavaPage.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2013-2017 MultiMC Contributors
+/* Copyright 2013-2018 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
#include <QDir>
#include "dialogs/VersionSelectDialog.h"
-#include <ColumnResizer.h>
#include "java/JavaUtils.h"
#include "java/JavaInstallList.h"
@@ -30,16 +29,15 @@
#include "settings/SettingsObject.h"
#include <FileSystem.h>
#include "MultiMC.h"
+#include <sys.h>
JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage)
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
- auto resizer = new ColumnResizer(this);
- resizer->addWidgetsFromLayout(ui->javaSettingsGroupBox->layout(), 0);
- resizer->addWidgetsFromLayout(ui->customCommandsGroupBox->layout(), 0);
-
+ auto sysMB = Sys::getSystemRam() / Sys::megabyte;
+ ui->maxMemSpinBox->setMaximum(sysMB);
loadSettings();
}
@@ -59,36 +57,46 @@ void JavaPage::applySettings()
auto s = MMC->settings();
// Memory
- s->set("MinMemAlloc", ui->minMemSpinBox->value());
- s->set("MaxMemAlloc", ui->maxMemSpinBox->value());
+ int min = ui->minMemSpinBox->value();
+ int max = ui->maxMemSpinBox->value();
+ if(min < max)
+ {
+ s->set("MinMemAlloc", min);
+ s->set("MaxMemAlloc", max);
+ }
+ else
+ {
+ s->set("MinMemAlloc", max);
+ s->set("MaxMemAlloc", min);
+ }
s->set("PermGen", ui->permGenSpinBox->value());
// Java Settings
s->set("JavaPath", ui->javaPathTextBox->text());
s->set("JvmArgs", ui->jvmArgsTextBox->text());
JavaCommon::checkJVMArgs(s->get("JvmArgs").toString(), this->parentWidget());
-
- // Custom Commands
- s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text());
- s->set("WrapperCommand", ui->wrapperCmdTextBox->text());
- s->set("PostExitCommand", ui->postExitCmdTextBox->text());
}
void JavaPage::loadSettings()
{
auto s = MMC->settings();
// Memory
- ui->minMemSpinBox->setValue(s->get("MinMemAlloc").toInt());
- ui->maxMemSpinBox->setValue(s->get("MaxMemAlloc").toInt());
+ int min = s->get("MinMemAlloc").toInt();
+ int max = s->get("MaxMemAlloc").toInt();
+ if(min < max)
+ {
+ ui->minMemSpinBox->setValue(min);
+ ui->maxMemSpinBox->setValue(max);
+ }
+ else
+ {
+ ui->minMemSpinBox->setValue(max);
+ ui->maxMemSpinBox->setValue(min);
+ }
ui->permGenSpinBox->setValue(s->get("PermGen").toInt());
// Java Settings
ui->javaPathTextBox->setText(s->get("JavaPath").toString());
ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString());
-
- // Custom Commands
- ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString());
- ui->wrapperCmdTextBox->setText(s->get("WrapperCommand").toString());
- ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString());
}
void JavaPage::on_javaDetectBtn_clicked()
@@ -108,14 +116,14 @@ void JavaPage::on_javaDetectBtn_clicked()
void JavaPage::on_javaBrowseBtn_clicked()
{
QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
- QString cooked_path = FS::NormalizePath(raw_path);
// do not allow current dir - it's dirty. Do not allow dirs that don't exist
- if(cooked_path.isEmpty())
+ if(raw_path.isEmpty())
{
return;
}
+ QString cooked_path = FS::NormalizePath(raw_path);
QFileInfo javaInfo(cooked_path);;
if(!javaInfo.exists() || !javaInfo.isExecutable())
{