made env vars behave like the rest of the settings
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
e9fd02baca
commit
12d567a9b8
@ -188,9 +188,8 @@ void MinecraftInstance::loadSpecificSettings()
|
|||||||
auto legacySettings = m_settings->registerSetting("OverrideLegacySettings", false);
|
auto legacySettings = m_settings->registerSetting("OverrideLegacySettings", false);
|
||||||
m_settings->registerOverride(global_settings->getSetting("OnlineFixes"), legacySettings);
|
m_settings->registerOverride(global_settings->getSetting("OnlineFixes"), legacySettings);
|
||||||
|
|
||||||
m_settings->registerSetting("UseEnv", false);
|
auto envSetting = m_settings->registerSetting("OverrideEnv", false);
|
||||||
m_settings->registerSetting("OverrideEnv", false);
|
m_settings->registerOverride(global_settings->getSetting("Env"), envSetting);
|
||||||
m_settings->registerSetting("Env", QVariant(QMap<QString, QVariant>()));
|
|
||||||
|
|
||||||
m_settings->set("InstanceType", "OneSix");
|
m_settings->set("InstanceType", "OneSix");
|
||||||
}
|
}
|
||||||
@ -612,12 +611,11 @@ QProcessEnvironment MinecraftInstance::createLaunchEnvironment()
|
|||||||
env.insert(iter.key(), iter.value().toString());
|
env.insert(iter.key(), iter.value().toString());
|
||||||
};
|
};
|
||||||
|
|
||||||
bool useEnv = settings()->get("UseEnv").toBool();
|
bool overrideEnv = settings()->get("OverrideEnv").toBool();
|
||||||
bool overrideEnv = useEnv && settings()->get("OverrideEnv").toBool();
|
|
||||||
|
|
||||||
if (!overrideEnv)
|
if (!overrideEnv)
|
||||||
insertEnv(APPLICATION->settings()->get("Env").toMap());
|
insertEnv(APPLICATION->settings()->get("Env").toMap());
|
||||||
if (useEnv)
|
else
|
||||||
insertEnv(settings()->get("Env").toMap());
|
insertEnv(settings()->get("Env").toMap());
|
||||||
|
|
||||||
return env;
|
return env;
|
||||||
|
@ -29,7 +29,7 @@ EnvironmentVariablesPage::EnvironmentVariablesPage(QWidget* parent) : QWidget(pa
|
|||||||
variables->setContentsMargins(6, 6, 6, 6);
|
variables->setContentsMargins(6, 6, 6, 6);
|
||||||
verticalLayout->addWidget(variables);
|
verticalLayout->addWidget(variables);
|
||||||
|
|
||||||
variables->initialize(false, true, false, APPLICATION->settings()->get("Env").toMap());
|
variables->initialize(false, false, APPLICATION->settings()->get("Env").toMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString EnvironmentVariablesPage::displayName() const
|
QString EnvironmentVariablesPage::displayName() const
|
||||||
|
@ -203,9 +203,12 @@ void InstanceSettingsPage::applySettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Environment Variables
|
// Environment Variables
|
||||||
m_settings->set("UseEnv", ui->environmentVariables->checked());
|
auto env = ui->environmentVariables->override();
|
||||||
m_settings->set("OverrideEnv", ui->environmentVariables->override());
|
m_settings->set("OverrideEnv", env);
|
||||||
m_settings->set("Env", ui->environmentVariables->value());
|
if (env)
|
||||||
|
m_settings->set("Env", ui->environmentVariables->value());
|
||||||
|
else
|
||||||
|
m_settings->reset("Env");
|
||||||
|
|
||||||
// Workarounds
|
// Workarounds
|
||||||
bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked();
|
bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked();
|
||||||
@ -327,8 +330,7 @@ void InstanceSettingsPage::loadSettings()
|
|||||||
m_settings->get("WrapperCommand").toString(), m_settings->get("PostExitCommand").toString());
|
m_settings->get("WrapperCommand").toString(), m_settings->get("PostExitCommand").toString());
|
||||||
|
|
||||||
// Environment variables
|
// Environment variables
|
||||||
ui->environmentVariables->initialize(true, m_settings->get("UseEnv").toBool(), m_settings->get("OverrideEnv").toBool(),
|
ui->environmentVariables->initialize(true, m_settings->get("OverrideEnv").toBool(), m_settings->get("Env").toMap());
|
||||||
m_settings->get("Env").toMap());
|
|
||||||
|
|
||||||
// Workarounds
|
// Workarounds
|
||||||
ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool());
|
ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool());
|
||||||
|
@ -50,25 +50,6 @@ EnvironmentVariables::EnvironmentVariables(QWidget* parent) : QWidget(parent), u
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(ui->clear, &QPushButton::clicked, this, [this] { ui->list->clear(); });
|
connect(ui->clear, &QPushButton::clicked, this, [this] { ui->list->clear(); });
|
||||||
|
|
||||||
connect(ui->globalOverride, &QCheckBox::clicked, this, [this](bool state) {
|
|
||||||
if (!state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto global = APPLICATION->settings()->get("Env").toMap();
|
|
||||||
if (global.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto response = CustomMessageBox::selectable(
|
|
||||||
this, tr("Reset"),
|
|
||||||
tr("You have chosen to ignore global settings.\n\nWould you like to clear the current variables and copy "
|
|
||||||
"the global variables over?"),
|
|
||||||
QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
|
||||||
->exec();
|
|
||||||
|
|
||||||
if (response == QMessageBox::Yes)
|
|
||||||
initialize(true, checked(), override(), global);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EnvironmentVariables::~EnvironmentVariables()
|
EnvironmentVariables::~EnvironmentVariables()
|
||||||
@ -76,13 +57,11 @@ EnvironmentVariables::~EnvironmentVariables()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvironmentVariables::initialize(bool instance, bool checked, bool override, const QMap<QString, QVariant>& value)
|
void EnvironmentVariables::initialize(bool instance, bool override, const QMap<QString, QVariant>& value)
|
||||||
{
|
{
|
||||||
// update widgets to settings
|
// update widgets to settings
|
||||||
ui->groupBox->setCheckable(instance);
|
ui->groupBox->setCheckable(instance);
|
||||||
ui->groupBox->setChecked(checked);
|
ui->groupBox->setChecked(override);
|
||||||
ui->globalOverride->setVisible(instance);
|
|
||||||
ui->globalOverride->setChecked(override);
|
|
||||||
|
|
||||||
// populate
|
// populate
|
||||||
ui->list->clear();
|
ui->list->clear();
|
||||||
@ -113,18 +92,11 @@ void EnvironmentVariables::retranslate()
|
|||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EnvironmentVariables::checked() const
|
|
||||||
{
|
|
||||||
if (!ui->groupBox->isCheckable())
|
|
||||||
return true;
|
|
||||||
return ui->groupBox->isChecked();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EnvironmentVariables::override() const
|
bool EnvironmentVariables::override() const
|
||||||
{
|
{
|
||||||
if (!ui->globalOverride->isVisible())
|
if (!ui->groupBox->isCheckable())
|
||||||
return false;
|
return false;
|
||||||
return ui->globalOverride->isChecked();
|
return ui->groupBox->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QVariant> EnvironmentVariables::value() const
|
QMap<QString, QVariant> EnvironmentVariables::value() const
|
||||||
|
@ -31,11 +31,10 @@ class EnvironmentVariables : public QWidget {
|
|||||||
public:
|
public:
|
||||||
explicit EnvironmentVariables(QWidget* state = nullptr);
|
explicit EnvironmentVariables(QWidget* state = nullptr);
|
||||||
~EnvironmentVariables() override;
|
~EnvironmentVariables() override;
|
||||||
void initialize(bool instance, bool checked, bool override, const QMap<QString, QVariant>& value);
|
void initialize(bool instance, bool override, const QMap<QString, QVariant>& value);
|
||||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||||
|
|
||||||
void retranslate();
|
void retranslate();
|
||||||
bool checked() const;
|
|
||||||
bool override() const;
|
bool override() const;
|
||||||
QMap<QString, QVariant> value() const;
|
QMap<QString, QVariant> value() const;
|
||||||
|
|
||||||
|
@ -35,13 +35,6 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="globalOverride">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Ignore global settings</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeWidget" name="list">
|
<widget class="QTreeWidget" name="list">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
|
Loading…
Reference in New Issue
Block a user