aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/global
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2022-11-11 15:02:08 +0100
committerSefa Eyeoglu <contact@scrumplex.net>2022-11-11 15:04:05 +0100
commit5ee4fb3522ea2bb66ad49e1cdd91140b8d5c6a00 (patch)
treece1d95fc90e427cb9cb08da413a40027dd254f0b /launcher/ui/pages/global
parent46a8e18841f398a3735e7ca4310c317e3dacc474 (diff)
downloadPrismLauncher-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/global')
-rw-r--r--launcher/ui/pages/global/JavaPage.cpp25
-rw-r--r--launcher/ui/pages/global/JavaPage.h3
-rw-r--r--launcher/ui/pages/global/JavaPage.ui54
3 files changed, 58 insertions, 24 deletions
diff --git a/launcher/ui/pages/global/JavaPage.cpp b/launcher/ui/pages/global/JavaPage.cpp
index 2cee15bf..00c06cff 100644
--- a/launcher/ui/pages/global/JavaPage.cpp
+++ b/launcher/ui/pages/global/JavaPage.cpp
@@ -58,9 +58,8 @@ JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage)
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
- auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
- ui->maxMemSpinBox->setMaximum(sysMiB);
loadSettings();
+ updateThresholds();
}
JavaPage::~JavaPage()
@@ -177,6 +176,11 @@ void JavaPage::on_javaTestBtn_clicked()
checker->run();
}
+void JavaPage::on_maxMemSpinBox_valueChanged(int i)
+{
+ updateThresholds();
+}
+
void JavaPage::checkerFinished()
{
checker.reset();
@@ -186,3 +190,20 @@ void JavaPage::retranslate()
{
ui->retranslateUi(this);
}
+
+void JavaPage::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("");
+ }
+}
diff --git a/launcher/ui/pages/global/JavaPage.h b/launcher/ui/pages/global/JavaPage.h
index 64d4098e..2ef6d749 100644
--- a/launcher/ui/pages/global/JavaPage.h
+++ b/launcher/ui/pages/global/JavaPage.h
@@ -76,6 +76,8 @@ public:
bool apply() override;
void retranslate() override;
+ void updateThresholds();
+
private:
void applySettings();
void loadSettings();
@@ -85,6 +87,7 @@ slots:
void on_javaDetectBtn_clicked();
void on_javaTestBtn_clicked();
void on_javaBrowseBtn_clicked();
+ void on_maxMemSpinBox_valueChanged(int i);
void checkerFinished();
private:
diff --git a/launcher/ui/pages/global/JavaPage.ui b/launcher/ui/pages/global/JavaPage.ui
index 6ccffed4..19e23eba 100644
--- a/launcher/ui/pages/global/JavaPage.ui
+++ b/launcher/ui/pages/global/JavaPage.ui
@@ -44,8 +44,8 @@
<property name="title">
<string>Memory</string>
</property>
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="1" column="1">
+ <layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,0">
+ <item row="1" column="2">
<widget class="QSpinBox" name="maxMemSpinBox">
<property name="toolTip">
<string>The maximum amount of memory Minecraft is allowed to use.</string>
@@ -67,27 +67,17 @@
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="labelMinMem">
- <property name="text">
- <string>&amp;Minimum memory allocation:</string>
- </property>
- <property name="buddy">
- <cstring>minMemSpinBox</cstring>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="labelMaxMem">
+ <item row="2" column="0">
+ <widget class="QLabel" name="labelPermGen">
<property name="text">
- <string>Ma&amp;ximum memory allocation:</string>
+ <string notr="true">&amp;PermGen:</string>
</property>
<property name="buddy">
- <cstring>maxMemSpinBox</cstring>
+ <cstring>permGenSpinBox</cstring>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="0" column="2">
<widget class="QSpinBox" name="minMemSpinBox">
<property name="toolTip">
<string>The amount of memory Minecraft is started with.</string>
@@ -109,17 +99,27 @@
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="labelPermGen">
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelMaxMem">
<property name="text">
- <string notr="true">&amp;PermGen:</string>
+ <string>Ma&amp;ximum memory allocation:</string>
</property>
<property name="buddy">
- <cstring>permGenSpinBox</cstring>
+ <cstring>maxMemSpinBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelMinMem">
+ <property name="text">
+ <string>&amp;Minimum memory allocation:</string>
+ </property>
+ <property name="buddy">
+ <cstring>minMemSpinBox</cstring>
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="2" column="2">
<widget class="QSpinBox" name="permGenSpinBox">
<property name="toolTip">
<string>The amount of memory available to store loaded Java classes.</string>
@@ -141,6 +141,16 @@
</property>
</widget>
</item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="labelMaxMemIcon">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="buddy">
+ <cstring>maxMemSpinBox</cstring>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>