feat: use icons to show memory allocation state

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2022-11-11 15:22:16 +01:00
parent 863a168cb5
commit cabd887866
No known key found for this signature in database
GPG Key ID: C10411294912A422
2 changed files with 24 additions and 6 deletions

View File

@ -196,14 +196,23 @@ void JavaPage::updateThresholds()
auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
unsigned int maxMem = ui->maxMemSpinBox->value();
QString iconName;
if (maxMem >= sysMiB) {
ui->labelMaxMemIcon->setText(u8"");
iconName = "status-bad";
ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity."));
} else if (maxMem > (sysMiB * 0.9)) {
ui->labelMaxMemIcon->setText(u8"");
iconName = "status-yellow";
ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity."));
} else {
ui->labelMaxMemIcon->setText(u8"");
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);
}
}

View File

@ -458,14 +458,23 @@ void InstanceSettingsPage::updateThresholds()
auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
unsigned int maxMem = ui->maxMemSpinBox->value();
QString iconName;
if (maxMem >= sysMiB) {
ui->labelMaxMemIcon->setText(u8"");
iconName = "status-bad";
ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity."));
} else if (maxMem > (sysMiB * 0.9)) {
ui->labelMaxMemIcon->setText(u8"");
iconName = "status-yellow";
ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity."));
} else {
ui->labelMaxMemIcon->setText(u8"");
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);
}
}