Merge pull request #436 from Scrumplex/feat-change-maxmem
Closes https://github.com/PrismLauncher/PrismLauncher/issues/426
This commit is contained in:
commit
9e1653ebb4
@ -58,9 +58,8 @@ JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage)
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->tabWidget->tabBar()->hide();
|
ui->tabWidget->tabBar()->hide();
|
||||||
|
|
||||||
auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
|
|
||||||
ui->maxMemSpinBox->setMaximum(sysMiB);
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
updateThresholds();
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaPage::~JavaPage()
|
JavaPage::~JavaPage()
|
||||||
@ -177,6 +176,11 @@ void JavaPage::on_javaTestBtn_clicked()
|
|||||||
checker->run();
|
checker->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JavaPage::on_maxMemSpinBox_valueChanged(int i)
|
||||||
|
{
|
||||||
|
updateThresholds();
|
||||||
|
}
|
||||||
|
|
||||||
void JavaPage::checkerFinished()
|
void JavaPage::checkerFinished()
|
||||||
{
|
{
|
||||||
checker.reset();
|
checker.reset();
|
||||||
@ -186,3 +190,29 @@ void JavaPage::retranslate()
|
|||||||
{
|
{
|
||||||
ui->retranslateUi(this);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -76,6 +76,8 @@ public:
|
|||||||
bool apply() override;
|
bool apply() override;
|
||||||
void retranslate() override;
|
void retranslate() override;
|
||||||
|
|
||||||
|
void updateThresholds();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void applySettings();
|
void applySettings();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
@ -85,6 +87,7 @@ slots:
|
|||||||
void on_javaDetectBtn_clicked();
|
void on_javaDetectBtn_clicked();
|
||||||
void on_javaTestBtn_clicked();
|
void on_javaTestBtn_clicked();
|
||||||
void on_javaBrowseBtn_clicked();
|
void on_javaBrowseBtn_clicked();
|
||||||
|
void on_maxMemSpinBox_valueChanged(int i);
|
||||||
void checkerFinished();
|
void checkerFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -44,39 +44,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Memory</string>
|
<string>Memory</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,0,0">
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QSpinBox" name="maxMemSpinBox">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>The maximum amount of memory Minecraft is allowed to use.</string>
|
|
||||||
</property>
|
|
||||||
<property name="suffix">
|
|
||||||
<string notr="true"> MiB</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>65536</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>1024</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="labelMinMem">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Minimum memory allocation:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>minMemSpinBox</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="labelMaxMem">
|
<widget class="QLabel" name="labelMaxMem">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -87,28 +55,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QSpinBox" name="minMemSpinBox">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>The amount of memory Minecraft is started with.</string>
|
|
||||||
</property>
|
|
||||||
<property name="suffix">
|
|
||||||
<string notr="true"> MiB</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>65536</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>256</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="labelPermGen">
|
<widget class="QLabel" name="labelPermGen">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -119,7 +65,61 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelMinMem">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Minimum memory allocation:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>minMemSpinBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QSpinBox" name="minMemSpinBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The amount of memory Minecraft is started with.</string>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string notr="true"> MiB</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1048576</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>256</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<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>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string notr="true"> MiB</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1048576</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1024</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
<widget class="QSpinBox" name="permGenSpinBox">
|
<widget class="QSpinBox" name="permGenSpinBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The amount of memory available to store loaded Java classes.</string>
|
<string>The amount of memory available to store loaded Java classes.</string>
|
||||||
@ -141,6 +141,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QLabel" name="labelMaxMemIcon">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>maxMemSpinBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -59,12 +59,12 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
|
|||||||
{
|
{
|
||||||
m_settings = inst->settings();
|
m_settings = inst->settings();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
auto sysMB = Sys::getSystemRam() / Sys::mebibyte;
|
|
||||||
ui->maxMemSpinBox->setMaximum(sysMB);
|
|
||||||
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
|
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
|
||||||
connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);
|
connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);
|
||||||
connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings);
|
connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings);
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
updateThresholds();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstanceSettingsPage::shouldDisplay() const
|
bool InstanceSettingsPage::shouldDisplay() const
|
||||||
@ -437,6 +437,11 @@ void InstanceSettingsPage::on_javaTestBtn_clicked()
|
|||||||
checker->run();
|
checker->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceSettingsPage::on_maxMemSpinBox_valueChanged(int i)
|
||||||
|
{
|
||||||
|
updateThresholds();
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceSettingsPage::checkerFinished()
|
void InstanceSettingsPage::checkerFinished()
|
||||||
{
|
{
|
||||||
checker.reset();
|
checker.reset();
|
||||||
@ -447,3 +452,29 @@ void InstanceSettingsPage::retranslate()
|
|||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
ui->customCommands->retranslate(); // TODO: why is this seperate from the others?
|
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();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -77,10 +77,13 @@ public:
|
|||||||
virtual bool shouldDisplay() const override;
|
virtual bool shouldDisplay() const override;
|
||||||
void retranslate() override;
|
void retranslate() override;
|
||||||
|
|
||||||
|
void updateThresholds();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_javaDetectBtn_clicked();
|
void on_javaDetectBtn_clicked();
|
||||||
void on_javaTestBtn_clicked();
|
void on_javaTestBtn_clicked();
|
||||||
void on_javaBrowseBtn_clicked();
|
void on_javaBrowseBtn_clicked();
|
||||||
|
void on_maxMemSpinBox_valueChanged(int i);
|
||||||
|
|
||||||
void applySettings();
|
void applySettings();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
@ -112,7 +112,14 @@
|
|||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,0,0">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="labelPermGen">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">PermGen:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="labelMinMem">
|
<widget class="QLabel" name="labelMinMem">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -120,29 +127,21 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="0">
|
||||||
<widget class="QSpinBox" name="maxMemSpinBox">
|
<widget class="QLabel" name="labelMaxMem">
|
||||||
<property name="toolTip">
|
<property name="text">
|
||||||
<string>The maximum amount of memory Minecraft is allowed to use.</string>
|
<string>Maximum memory allocation:</string>
|
||||||
</property>
|
|
||||||
<property name="suffix">
|
|
||||||
<string notr="true"> MiB</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>65536</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>128</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>1024</number>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="3" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="labelPermgenNote">
|
||||||
|
<property name="text">
|
||||||
|
<string>Note: Permgen is set automatically by Java 8 and later</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
<widget class="QSpinBox" name="minMemSpinBox">
|
<widget class="QSpinBox" name="minMemSpinBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The amount of memory Minecraft is started with.</string>
|
<string>The amount of memory Minecraft is started with.</string>
|
||||||
@ -154,7 +153,7 @@
|
|||||||
<number>128</number>
|
<number>128</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>65536</number>
|
<number>1048576</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="singleStep">
|
<property name="singleStep">
|
||||||
<number>128</number>
|
<number>128</number>
|
||||||
@ -164,7 +163,29 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<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>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string notr="true"> MiB</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>1048576</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>128</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>1024</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
<widget class="QSpinBox" name="permGenSpinBox">
|
<widget class="QSpinBox" name="permGenSpinBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The amount of memory available to store loaded Java classes.</string>
|
<string>The amount of memory available to store loaded Java classes.</string>
|
||||||
@ -186,24 +207,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="3">
|
||||||
<widget class="QLabel" name="labelPermGen">
|
<widget class="QLabel" name="labelMaxMemIcon">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string notr="true">PermGen:</string>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="alignment">
|
||||||
</item>
|
<set>Qt::AlignCenter</set>
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="labelMaxMem">
|
|
||||||
<property name="text">
|
|
||||||
<string>Maximum memory allocation:</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="buddy">
|
||||||
</item>
|
<cstring>maxMemSpinBox</cstring>
|
||||||
<item row="3" column="0" colspan="2">
|
|
||||||
<widget class="QLabel" name="labelPermgenNote">
|
|
||||||
<property name="text">
|
|
||||||
<string>Note: Permgen is set automatically by Java 8 and later</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -71,6 +71,7 @@ void JavaSettingsWidget::setupUi()
|
|||||||
m_memoryGroupBox->setObjectName(QStringLiteral("memoryGroupBox"));
|
m_memoryGroupBox->setObjectName(QStringLiteral("memoryGroupBox"));
|
||||||
m_gridLayout_2 = new QGridLayout(m_memoryGroupBox);
|
m_gridLayout_2 = new QGridLayout(m_memoryGroupBox);
|
||||||
m_gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
|
m_gridLayout_2->setObjectName(QStringLiteral("gridLayout_2"));
|
||||||
|
m_gridLayout_2->setColumnStretch(0, 1);
|
||||||
|
|
||||||
m_labelMinMem = new QLabel(m_memoryGroupBox);
|
m_labelMinMem = new QLabel(m_memoryGroupBox);
|
||||||
m_labelMinMem->setObjectName(QStringLiteral("labelMinMem"));
|
m_labelMinMem->setObjectName(QStringLiteral("labelMinMem"));
|
||||||
@ -80,7 +81,7 @@ void JavaSettingsWidget::setupUi()
|
|||||||
m_minMemSpinBox->setObjectName(QStringLiteral("minMemSpinBox"));
|
m_minMemSpinBox->setObjectName(QStringLiteral("minMemSpinBox"));
|
||||||
m_minMemSpinBox->setSuffix(QStringLiteral(" MiB"));
|
m_minMemSpinBox->setSuffix(QStringLiteral(" MiB"));
|
||||||
m_minMemSpinBox->setMinimum(128);
|
m_minMemSpinBox->setMinimum(128);
|
||||||
m_minMemSpinBox->setMaximum(m_availableMemory);
|
m_minMemSpinBox->setMaximum(1048576);
|
||||||
m_minMemSpinBox->setSingleStep(128);
|
m_minMemSpinBox->setSingleStep(128);
|
||||||
m_labelMinMem->setBuddy(m_minMemSpinBox);
|
m_labelMinMem->setBuddy(m_minMemSpinBox);
|
||||||
m_gridLayout_2->addWidget(m_minMemSpinBox, 0, 1, 1, 1);
|
m_gridLayout_2->addWidget(m_minMemSpinBox, 0, 1, 1, 1);
|
||||||
@ -93,11 +94,15 @@ void JavaSettingsWidget::setupUi()
|
|||||||
m_maxMemSpinBox->setObjectName(QStringLiteral("maxMemSpinBox"));
|
m_maxMemSpinBox->setObjectName(QStringLiteral("maxMemSpinBox"));
|
||||||
m_maxMemSpinBox->setSuffix(QStringLiteral(" MiB"));
|
m_maxMemSpinBox->setSuffix(QStringLiteral(" MiB"));
|
||||||
m_maxMemSpinBox->setMinimum(128);
|
m_maxMemSpinBox->setMinimum(128);
|
||||||
m_maxMemSpinBox->setMaximum(m_availableMemory);
|
m_maxMemSpinBox->setMaximum(1048576);
|
||||||
m_maxMemSpinBox->setSingleStep(128);
|
m_maxMemSpinBox->setSingleStep(128);
|
||||||
m_labelMaxMem->setBuddy(m_maxMemSpinBox);
|
m_labelMaxMem->setBuddy(m_maxMemSpinBox);
|
||||||
m_gridLayout_2->addWidget(m_maxMemSpinBox, 1, 1, 1, 1);
|
m_gridLayout_2->addWidget(m_maxMemSpinBox, 1, 1, 1, 1);
|
||||||
|
|
||||||
|
m_labelMaxMemIcon = new QLabel(m_memoryGroupBox);
|
||||||
|
m_labelMaxMemIcon->setObjectName(QStringLiteral("labelMaxMemIcon"));
|
||||||
|
m_gridLayout_2->addWidget(m_labelMaxMemIcon, 1, 2, 1, 1);
|
||||||
|
|
||||||
m_labelPermGen = new QLabel(m_memoryGroupBox);
|
m_labelPermGen = new QLabel(m_memoryGroupBox);
|
||||||
m_labelPermGen->setObjectName(QStringLiteral("labelPermGen"));
|
m_labelPermGen->setObjectName(QStringLiteral("labelPermGen"));
|
||||||
m_labelPermGen->setText(QStringLiteral("PermGen:"));
|
m_labelPermGen->setText(QStringLiteral("PermGen:"));
|
||||||
@ -108,7 +113,7 @@ void JavaSettingsWidget::setupUi()
|
|||||||
m_permGenSpinBox->setObjectName(QStringLiteral("permGenSpinBox"));
|
m_permGenSpinBox->setObjectName(QStringLiteral("permGenSpinBox"));
|
||||||
m_permGenSpinBox->setSuffix(QStringLiteral(" MiB"));
|
m_permGenSpinBox->setSuffix(QStringLiteral(" MiB"));
|
||||||
m_permGenSpinBox->setMinimum(64);
|
m_permGenSpinBox->setMinimum(64);
|
||||||
m_permGenSpinBox->setMaximum(m_availableMemory);
|
m_permGenSpinBox->setMaximum(1048576);
|
||||||
m_permGenSpinBox->setSingleStep(8);
|
m_permGenSpinBox->setSingleStep(8);
|
||||||
m_gridLayout_2->addWidget(m_permGenSpinBox, 2, 1, 1, 1);
|
m_gridLayout_2->addWidget(m_permGenSpinBox, 2, 1, 1, 1);
|
||||||
m_permGenSpinBox->setVisible(false);
|
m_permGenSpinBox->setVisible(false);
|
||||||
@ -130,6 +135,7 @@ void JavaSettingsWidget::initialize()
|
|||||||
m_minMemSpinBox->setValue(observedMinMemory);
|
m_minMemSpinBox->setValue(observedMinMemory);
|
||||||
m_maxMemSpinBox->setValue(observedMaxMemory);
|
m_maxMemSpinBox->setValue(observedMaxMemory);
|
||||||
m_permGenSpinBox->setValue(observedPermGenMemory);
|
m_permGenSpinBox->setValue(observedPermGenMemory);
|
||||||
|
updateThresholds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JavaSettingsWidget::refresh()
|
void JavaSettingsWidget::refresh()
|
||||||
@ -210,9 +216,9 @@ int JavaSettingsWidget::permGenSize() const
|
|||||||
void JavaSettingsWidget::memoryValueChanged(int)
|
void JavaSettingsWidget::memoryValueChanged(int)
|
||||||
{
|
{
|
||||||
bool actuallyChanged = false;
|
bool actuallyChanged = false;
|
||||||
int min = m_minMemSpinBox->value();
|
unsigned int min = m_minMemSpinBox->value();
|
||||||
int max = m_maxMemSpinBox->value();
|
unsigned int max = m_maxMemSpinBox->value();
|
||||||
int permgen = m_permGenSpinBox->value();
|
unsigned int permgen = m_permGenSpinBox->value();
|
||||||
QObject *obj = sender();
|
QObject *obj = sender();
|
||||||
if (obj == m_minMemSpinBox && min != observedMinMemory)
|
if (obj == m_minMemSpinBox && min != observedMinMemory)
|
||||||
{
|
{
|
||||||
@ -242,6 +248,7 @@ void JavaSettingsWidget::memoryValueChanged(int)
|
|||||||
if(actuallyChanged)
|
if(actuallyChanged)
|
||||||
{
|
{
|
||||||
checkJavaPathOnEdit(m_javaPathTextBox->text());
|
checkJavaPathOnEdit(m_javaPathTextBox->text());
|
||||||
|
updateThresholds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,3 +442,26 @@ void JavaSettingsWidget::retranslate()
|
|||||||
m_permGenSpinBox->setToolTip(tr("The amount of memory available to store loaded Java classes."));
|
m_permGenSpinBox->setToolTip(tr("The amount of memory available to store loaded Java classes."));
|
||||||
m_javaBrowseBtn->setText(tr("Browse"));
|
m_javaBrowseBtn->setText(tr("Browse"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JavaSettingsWidget::updateThresholds()
|
||||||
|
{
|
||||||
|
QString iconName;
|
||||||
|
|
||||||
|
if (observedMaxMemory >= m_availableMemory) {
|
||||||
|
iconName = "status-bad";
|
||||||
|
m_labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity."));
|
||||||
|
} else if (observedMaxMemory > (m_availableMemory * 0.9)) {
|
||||||
|
iconName = "status-yellow";
|
||||||
|
m_labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity."));
|
||||||
|
} else {
|
||||||
|
iconName = "status-good";
|
||||||
|
m_labelMaxMemIcon->setToolTip("");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto height = m_labelMaxMemIcon->fontInfo().pixelSize();
|
||||||
|
QIcon icon = APPLICATION->getThemedIcon(iconName);
|
||||||
|
QPixmap pix = icon.pixmap(height, height);
|
||||||
|
m_labelMaxMemIcon->setPixmap(pix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -56,6 +56,8 @@ public:
|
|||||||
int maxHeapSize() const;
|
int maxHeapSize() const;
|
||||||
QString javaPath() const;
|
QString javaPath() const;
|
||||||
|
|
||||||
|
void updateThresholds();
|
||||||
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void memoryValueChanged(int);
|
void memoryValueChanged(int);
|
||||||
@ -85,6 +87,7 @@ private: /* data */
|
|||||||
QSpinBox *m_maxMemSpinBox = nullptr;
|
QSpinBox *m_maxMemSpinBox = nullptr;
|
||||||
QLabel *m_labelMinMem = nullptr;
|
QLabel *m_labelMinMem = nullptr;
|
||||||
QLabel *m_labelMaxMem = nullptr;
|
QLabel *m_labelMaxMem = nullptr;
|
||||||
|
QLabel *m_labelMaxMemIcon = nullptr;
|
||||||
QSpinBox *m_minMemSpinBox = nullptr;
|
QSpinBox *m_minMemSpinBox = nullptr;
|
||||||
QLabel *m_labelPermGen = nullptr;
|
QLabel *m_labelPermGen = nullptr;
|
||||||
QSpinBox *m_permGenSpinBox = nullptr;
|
QSpinBox *m_permGenSpinBox = nullptr;
|
||||||
@ -92,9 +95,9 @@ private: /* data */
|
|||||||
QIcon yellowIcon;
|
QIcon yellowIcon;
|
||||||
QIcon badIcon;
|
QIcon badIcon;
|
||||||
|
|
||||||
int observedMinMemory = 0;
|
unsigned int observedMinMemory = 0;
|
||||||
int observedMaxMemory = 0;
|
unsigned int observedMaxMemory = 0;
|
||||||
int observedPermGenMemory = 0;
|
unsigned int observedPermGenMemory = 0;
|
||||||
QString queuedCheck;
|
QString queuedCheck;
|
||||||
uint64_t m_availableMemory = 0ull;
|
uint64_t m_availableMemory = 0ull;
|
||||||
shared_qobject_ptr<JavaChecker> m_checker;
|
shared_qobject_ptr<JavaChecker> m_checker;
|
||||||
|
Loading…
Reference in New Issue
Block a user