summaryrefslogtreecommitdiffstats
path: root/application/pages/InstanceSettingsPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'application/pages/InstanceSettingsPage.cpp')
-rw-r--r--application/pages/InstanceSettingsPage.cpp57
1 files changed, 42 insertions, 15 deletions
diff --git a/application/pages/InstanceSettingsPage.cpp b/application/pages/InstanceSettingsPage.cpp
index 82438583..71e90a32 100644
--- a/application/pages/InstanceSettingsPage.cpp
+++ b/application/pages/InstanceSettingsPage.cpp
@@ -11,12 +11,16 @@
#include <java/JavaInstallList.h>
#include <FileSystem.h>
+#include <sys.h>
+#include <widgets/CustomCommands.h>
InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
: QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst)
{
m_settings = inst->settings();
ui->setupUi(this);
+ auto sysMB = Sys::getSystemRam() / Sys::megabyte;
+ ui->maxMemSpinBox->setMaximum(sysMB);
loadSettings();
}
@@ -77,8 +81,18 @@ void InstanceSettingsPage::applySettings()
m_settings->set("OverrideMemory", memory);
if (memory)
{
- m_settings->set("MinMemAlloc", ui->minMemSpinBox->value());
- m_settings->set("MaxMemAlloc", ui->maxMemSpinBox->value());
+ int min = ui->minMemSpinBox->value();
+ int max = ui->maxMemSpinBox->value();
+ if(min < max)
+ {
+ m_settings->set("MinMemAlloc", min);
+ m_settings->set("MaxMemAlloc", max);
+ }
+ else
+ {
+ m_settings->set("MinMemAlloc", max);
+ m_settings->set("MaxMemAlloc", min);
+ }
m_settings->set("PermGen", ui->permGenSpinBox->value());
}
else
@@ -117,13 +131,13 @@ void InstanceSettingsPage::applySettings()
m_settings->reset("OverrideJava");
// Custom Commands
- bool custcmd = ui->customCommandsGroupBox->isChecked();
+ bool custcmd = ui->customCommands->checked();
m_settings->set("OverrideCommands", custcmd);
if (custcmd)
{
- m_settings->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text());
- m_settings->set("WrapperCommand", ui->wrapperCmdTextBox->text());
- m_settings->set("PostExitCommand", ui->postExitCmdTextBox->text());
+ m_settings->set("PreLaunchCommand", ui->customCommands->prelaunchCommand());
+ m_settings->set("WrapperCommand", ui->customCommands->wrapperCommand());
+ m_settings->set("PostExitCommand", ui->customCommands->postexitCommand());
}
else
{
@@ -149,8 +163,18 @@ void InstanceSettingsPage::loadSettings()
// Memory
ui->memoryGroupBox->setChecked(m_settings->get("OverrideMemory").toBool());
- ui->minMemSpinBox->setValue(m_settings->get("MinMemAlloc").toInt());
- ui->maxMemSpinBox->setValue(m_settings->get("MaxMemAlloc").toInt());
+ int min = m_settings->get("MinMemAlloc").toInt();
+ int max = m_settings->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(m_settings->get("PermGen").toInt());
// Java Settings
@@ -164,11 +188,14 @@ void InstanceSettingsPage::loadSettings()
ui->javaArgumentsGroupBox->setChecked(overrideArgs);
ui->jvmArgsTextBox->setPlainText(m_settings->get("JvmArgs").toString());
- // Custom Commands
- ui->customCommandsGroupBox->setChecked(m_settings->get("OverrideCommands").toBool());
- ui->preLaunchCmdTextBox->setText(m_settings->get("PreLaunchCommand").toString());
- ui->wrapperCmdTextBox->setText(m_settings->get("WrapperCommand").toString());
- ui->postExitCmdTextBox->setText(m_settings->get("PostExitCommand").toString());
+ // Custom commands
+ ui->customCommands->initialize(
+ true,
+ m_settings->get("OverrideCommands").toBool(),
+ m_settings->get("PreLaunchCommand").toString(),
+ m_settings->get("WrapperCommand").toString(),
+ m_settings->get("PostExitCommand").toString()
+ );
}
void InstanceSettingsPage::on_javaDetectBtn_clicked()
@@ -189,13 +216,13 @@ void InstanceSettingsPage::on_javaDetectBtn_clicked()
void InstanceSettingsPage::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())