mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-03-14 13:20:59 +00:00
Merge 439669157b01df7a33a8a7aefa33b3a40d1c09ad into 9ec1d435655b76d5ddf56eee18d48bf853f135a9
This commit is contained in:
commit
07e59a9c43
@ -727,6 +727,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||
m_settings->registerSetting({"MinMemAlloc", "MinMemoryAlloc"}, 512);
|
||||
m_settings->registerSetting({"MaxMemAlloc", "MaxMemoryAlloc"}, 1024);
|
||||
m_settings->registerSetting("PermGen", 128);
|
||||
m_settings->registerSetting("AllowSwap", false);
|
||||
|
||||
// Java Settings
|
||||
m_settings->registerSetting("JavaPath", "");
|
||||
|
@ -37,9 +37,13 @@ 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);
|
||||
#if !defined(Q_OS_LINUX)
|
||||
ui->allowSwapCheckBox->setEnabled(false);
|
||||
ui->allowSwapCheckBox->setVisible(false);
|
||||
#endif
|
||||
|
||||
loadSettings();
|
||||
updateMemMax();
|
||||
}
|
||||
|
||||
JavaPage::~JavaPage()
|
||||
@ -71,6 +75,7 @@ void JavaPage::applySettings()
|
||||
s->set("MaxMemAlloc", min);
|
||||
}
|
||||
s->set("PermGen", ui->permGenSpinBox->value());
|
||||
s->set("AllowSwap", ui->allowSwapCheckBox->isChecked());
|
||||
|
||||
// Java Settings
|
||||
s->set("JavaPath", ui->javaPathTextBox->text());
|
||||
@ -94,12 +99,27 @@ void JavaPage::loadSettings()
|
||||
ui->maxMemSpinBox->setValue(min);
|
||||
}
|
||||
ui->permGenSpinBox->setValue(s->get("PermGen").toInt());
|
||||
ui->allowSwapCheckBox->setChecked(s->get("AllowSwap").toBool());
|
||||
|
||||
// Java Settings
|
||||
ui->javaPathTextBox->setText(s->get("JavaPath").toString());
|
||||
ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString());
|
||||
}
|
||||
|
||||
void JavaPage::updateMemMax() {
|
||||
auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
|
||||
|
||||
if (ui->allowSwapCheckBox->isChecked())
|
||||
sysMiB += Sys::getSystemSwap() / Sys::mebibyte;
|
||||
|
||||
ui->maxMemSpinBox->setMaximum(sysMiB);
|
||||
}
|
||||
|
||||
void JavaPage::on_allowSwapCheckBox_clicked(bool checked)
|
||||
{
|
||||
updateMemMax();
|
||||
}
|
||||
|
||||
void JavaPage::on_javaDetectBtn_clicked()
|
||||
{
|
||||
JavaInstallPtr java;
|
||||
|
@ -58,9 +58,11 @@ public:
|
||||
private:
|
||||
void applySettings();
|
||||
void loadSettings();
|
||||
void updateMemMax();
|
||||
|
||||
private
|
||||
slots:
|
||||
void on_allowSwapCheckBox_clicked(bool clicked);
|
||||
void on_javaDetectBtn_clicked();
|
||||
void on_javaTestBtn_clicked();
|
||||
void on_javaBrowseBtn_clicked();
|
||||
|
@ -132,6 +132,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="allowSwapCheckBox">
|
||||
<property name="text">
|
||||
<string>Allow use of swap</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Allows the usage of swap when specifying memory allocation.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -57,6 +57,8 @@ DistributionInfo getDistributionInfo();
|
||||
|
||||
uint64_t getSystemRam();
|
||||
|
||||
uint64_t getSystemSwap();
|
||||
|
||||
bool isSystem64bit();
|
||||
|
||||
bool isCPU64bit();
|
||||
|
@ -55,6 +55,11 @@ uint64_t Sys::getSystemRam()
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t Sys::getSystemSwap()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Sys::isCPU64bit()
|
||||
{
|
||||
// not even going to pretend I'm going to support anything else
|
||||
|
@ -82,6 +82,31 @@ uint64_t Sys::getSystemRam()
|
||||
return 0; // nothing found
|
||||
}
|
||||
|
||||
uint64_t Sys::getSystemSwap()
|
||||
{
|
||||
std::string token;
|
||||
#ifdef Q_OS_LINUX
|
||||
std::ifstream file("/proc/meminfo");
|
||||
while(file >> token)
|
||||
{
|
||||
if(token == "SwapTotal:")
|
||||
{
|
||||
uint64_t swap;
|
||||
if(file >> swap)
|
||||
{
|
||||
return swap * 1024ull;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Sys::isCPU64bit()
|
||||
{
|
||||
return isSystem64bit();
|
||||
|
@ -30,6 +30,11 @@ uint64_t Sys::getSystemRam()
|
||||
return (uint64_t)status.ullTotalPhys;
|
||||
}
|
||||
|
||||
uint64_t Sys::getSystemSwap()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Sys::isSystem64bit()
|
||||
{
|
||||
#if defined(_WIN64)
|
||||
|
Loading…
x
Reference in New Issue
Block a user