diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-11-30 18:22:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-30 18:22:55 +0100 |
commit | 9e1653ebb471d4d96efda85cbde128c59fe3686a (patch) | |
tree | 5eb71805fc8fa97252c2aaf19b927e6481298184 /launcher/ui/pages/global/JavaPage.cpp | |
parent | 42c00213ce97e51cdf9c0a9d3ddb235e64567994 (diff) | |
parent | 884fe0d5741de2a8a78f48c5d37274d8f174ba3a (diff) | |
download | PrismLauncher-9e1653ebb471d4d96efda85cbde128c59fe3686a.tar.gz PrismLauncher-9e1653ebb471d4d96efda85cbde128c59fe3686a.tar.bz2 PrismLauncher-9e1653ebb471d4d96efda85cbde128c59fe3686a.zip |
Merge pull request #436 from Scrumplex/feat-change-maxmem
Closes https://github.com/PrismLauncher/PrismLauncher/issues/426
Diffstat (limited to 'launcher/ui/pages/global/JavaPage.cpp')
-rw-r--r-- | launcher/ui/pages/global/JavaPage.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/launcher/ui/pages/global/JavaPage.cpp b/launcher/ui/pages/global/JavaPage.cpp index 2cee15bf..81dd4cc1 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,29 @@ void JavaPage::retranslate() { ui->retranslateUi(this); } + +void JavaPage::updateThresholds() +{ + auto sysMiB = Sys::getSystemRam() / Sys::mebibyte; + unsigned int maxMem = ui->maxMemSpinBox->value(); + + QString iconName; + + if (maxMem >= sysMiB) { + iconName = "status-bad"; + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity.")); + } else if (maxMem > (sysMiB * 0.9)) { + iconName = "status-yellow"; + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity.")); + } else { + iconName = "status-good"; + ui->labelMaxMemIcon->setToolTip(""); + } + + { + auto height = ui->labelMaxMemIcon->fontInfo().pixelSize(); + QIcon icon = APPLICATION->getThemedIcon(iconName); + QPixmap pix = icon.pixmap(height, height); + ui->labelMaxMemIcon->setPixmap(pix); + } +} |