made env vars behave like the rest of the settings
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -50,25 +50,6 @@ EnvironmentVariables::EnvironmentVariables(QWidget* parent) : QWidget(parent), u
|
||||
});
|
||||
|
||||
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()
|
||||
@ -76,13 +57,11 @@ EnvironmentVariables::~EnvironmentVariables()
|
||||
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
|
||||
ui->groupBox->setCheckable(instance);
|
||||
ui->groupBox->setChecked(checked);
|
||||
ui->globalOverride->setVisible(instance);
|
||||
ui->globalOverride->setChecked(override);
|
||||
ui->groupBox->setChecked(override);
|
||||
|
||||
// populate
|
||||
ui->list->clear();
|
||||
@ -113,18 +92,11 @@ void EnvironmentVariables::retranslate()
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
bool EnvironmentVariables::checked() const
|
||||
{
|
||||
if (!ui->groupBox->isCheckable())
|
||||
return true;
|
||||
return ui->groupBox->isChecked();
|
||||
}
|
||||
|
||||
bool EnvironmentVariables::override() const
|
||||
{
|
||||
if (!ui->globalOverride->isVisible())
|
||||
if (!ui->groupBox->isCheckable())
|
||||
return false;
|
||||
return ui->globalOverride->isChecked();
|
||||
return ui->groupBox->isChecked();
|
||||
}
|
||||
|
||||
QMap<QString, QVariant> EnvironmentVariables::value() const
|
||||
|
@ -31,11 +31,10 @@ class EnvironmentVariables : public QWidget {
|
||||
public:
|
||||
explicit EnvironmentVariables(QWidget* state = nullptr);
|
||||
~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;
|
||||
|
||||
void retranslate();
|
||||
bool checked() const;
|
||||
bool override() const;
|
||||
QMap<QString, QVariant> value() const;
|
||||
|
||||
|
@ -35,13 +35,6 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="globalOverride">
|
||||
<property name="text">
|
||||
<string>&Ignore global settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="list">
|
||||
<property name="alternatingRowColors">
|
||||
|
Reference in New Issue
Block a user