diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-11-11 15:02:08 +0100 |
---|---|---|
committer | Sefa Eyeoglu <contact@scrumplex.net> | 2022-11-11 15:04:05 +0100 |
commit | 5ee4fb3522ea2bb66ad49e1cdd91140b8d5c6a00 (patch) | |
tree | ce1d95fc90e427cb9cb08da413a40027dd254f0b /launcher/ui/pages/instance/InstanceSettingsPage.cpp | |
parent | 46a8e18841f398a3735e7ca4310c317e3dacc474 (diff) | |
download | PrismLauncher-5ee4fb3522ea2bb66ad49e1cdd91140b8d5c6a00.tar.gz PrismLauncher-5ee4fb3522ea2bb66ad49e1cdd91140b8d5c6a00.tar.bz2 PrismLauncher-5ee4fb3522ea2bb66ad49e1cdd91140b8d5c6a00.zip |
feat: validate maximum memory allocation
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'launcher/ui/pages/instance/InstanceSettingsPage.cpp')
-rw-r--r-- | launcher/ui/pages/instance/InstanceSettingsPage.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index 5da7f19f..50039e87 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -59,12 +59,12 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent) { m_settings = inst->settings(); ui->setupUi(this); - auto sysMB = Sys::getSystemRam() / Sys::mebibyte; - ui->maxMemSpinBox->setMaximum(sysMB); + connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked); connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings); connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings); loadSettings(); + updateThresholds(); } bool InstanceSettingsPage::shouldDisplay() const @@ -437,6 +437,11 @@ void InstanceSettingsPage::on_javaTestBtn_clicked() checker->run(); } +void InstanceSettingsPage::on_maxMemSpinBox_valueChanged(int i) +{ + updateThresholds(); +} + void InstanceSettingsPage::checkerFinished() { checker.reset(); @@ -447,3 +452,20 @@ void InstanceSettingsPage::retranslate() ui->retranslateUi(this); ui->customCommands->retranslate(); // TODO: why is this seperate from the others? } + +void InstanceSettingsPage::updateThresholds() +{ + auto sysMiB = Sys::getSystemRam() / Sys::mebibyte; + unsigned int maxMem = ui->maxMemSpinBox->value(); + + if (maxMem >= sysMiB) { + ui->labelMaxMemIcon->setText(u8"✘"); + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity.")); + } else if (maxMem > (sysMiB * 0.9)) { + ui->labelMaxMemIcon->setText(u8"⚠"); + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity.")); + } else { + ui->labelMaxMemIcon->setText(u8"✔"); + ui->labelMaxMemIcon->setToolTip(""); + } +} |