Skip to content

Commit be60c03

Browse files
vkconfig: Add layer settings override
1 parent ac9b0b4 commit be60c03

7 files changed

Lines changed: 214 additions & 33 deletions

File tree

vkconfig_core/configuration.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ bool Configuration::Load(const Path& full_path, const LayerManager& layers) {
126126
this->default_control = ::GetLayerControl(ReadString(json_configuration_object, "default_layer_control").c_str());
127127
}
128128

129+
if (json_configuration_object.value("override_settings") != QJsonValue::Undefined) {
130+
this->override_settings = ReadBoolValue(json_configuration_object, "override_settings");
131+
}
132+
133+
if (json_configuration_object.value("override_settings_path") != QJsonValue::Undefined) {
134+
this->override_settings_path = ReadString(json_configuration_object, "override_settings_path");
135+
}
136+
129137
if (json_configuration_object.value("override_layers") != QJsonValue::Undefined) {
130138
this->override_layers = ReadBoolValue(json_configuration_object, "override_layers");
131139
}
@@ -300,6 +308,8 @@ bool Configuration::Save(const Path& full_path, bool export_mode) const {
300308
json_configuration.insert("version", this->version);
301309
SaveStringArray(json_configuration, "platforms", GetPlatformTokens(this->platform_flags));
302310
json_configuration.insert("default_layer_control", ::GetToken(this->default_control));
311+
json_configuration.insert("override_settings", this->override_settings);
312+
json_configuration.insert("override_settings_path", this->override_settings_path.RelativePath().c_str());
303313
json_configuration.insert("override_layers", this->override_layers);
304314
json_configuration.insert("override_loader", this->override_loader);
305315
SaveStringArray(json_configuration, "loader_message_types", GetLogTokens(this->loader_log_messages_flags));

vkconfig_core/configuration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ class Configuration {
6060
int version = 1;
6161
int platform_flags = PLATFORM_DESKTOP_BIT;
6262
LayerControl default_control = LAYER_CONTROL_AUTO;
63+
bool override_settings = false;
64+
Path override_settings_path;
6365
bool override_layers = true;
6466
bool override_loader = true;
6567
int loader_log_messages_flags = GetBit(LOG_ERROR);

vkconfig_gui/mainwindow.ui

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<enum>QTabWidget::TabShape::Rounded</enum>
9292
</property>
9393
<property name="currentIndex">
94-
<number>5</number>
94+
<number>0</number>
9595
</property>
9696
<widget class="QWidget" name="tab_configurations">
9797
<property name="autoFillBackground">
@@ -418,6 +418,91 @@
418418
</property>
419419
</widget>
420420
</item>
421+
<item>
422+
<layout class="QHBoxLayout" name="horizontalLayout_14">
423+
<property name="spacing">
424+
<number>0</number>
425+
</property>
426+
<property name="topMargin">
427+
<number>0</number>
428+
</property>
429+
<item>
430+
<widget class="QCheckBox" name="configuration_settings_file_enable">
431+
<property name="font">
432+
<font>
433+
<family>Arial</family>
434+
<pointsize>10</pointsize>
435+
<bold>false</bold>
436+
<kerning>true</kerning>
437+
</font>
438+
</property>
439+
<property name="text">
440+
<string>Override Layer Settings:</string>
441+
</property>
442+
</widget>
443+
</item>
444+
<item>
445+
<widget class="QLineEdit" name="configuration_settings_file_path">
446+
<property name="maximumSize">
447+
<size>
448+
<width>16777215</width>
449+
<height>24</height>
450+
</size>
451+
</property>
452+
</widget>
453+
</item>
454+
<item>
455+
<widget class="QPushButton" name="configuration_settings_file_search">
456+
<property name="sizePolicy">
457+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
458+
<horstretch>0</horstretch>
459+
<verstretch>0</verstretch>
460+
</sizepolicy>
461+
</property>
462+
<property name="minimumSize">
463+
<size>
464+
<width>24</width>
465+
<height>24</height>
466+
</size>
467+
</property>
468+
<property name="maximumSize">
469+
<size>
470+
<width>24</width>
471+
<height>24</height>
472+
</size>
473+
</property>
474+
<property name="text">
475+
<string/>
476+
</property>
477+
</widget>
478+
</item>
479+
<item>
480+
<widget class="QPushButton" name="configuration_settings_file_remove">
481+
<property name="sizePolicy">
482+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
483+
<horstretch>0</horstretch>
484+
<verstretch>0</verstretch>
485+
</sizepolicy>
486+
</property>
487+
<property name="minimumSize">
488+
<size>
489+
<width>24</width>
490+
<height>24</height>
491+
</size>
492+
</property>
493+
<property name="maximumSize">
494+
<size>
495+
<width>24</width>
496+
<height>24</height>
497+
</size>
498+
</property>
499+
<property name="text">
500+
<string/>
501+
</property>
502+
</widget>
503+
</item>
504+
</layout>
505+
</item>
421506
</layout>
422507
</widget>
423508
</item>
@@ -2627,8 +2712,11 @@
26272712
<bold>false</bold>
26282713
</font>
26292714
</property>
2715+
<property name="toolTip">
2716+
<string>Show debug layer settings</string>
2717+
</property>
26302718
<property name="text">
2631-
<string>Layer Developer Mode</string>
2719+
<string>Layer Debugging Mode</string>
26322720
</property>
26332721
</widget>
26342722
</item>

vkconfig_gui/settings_tree.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ void SettingsTreeManager::CreateGUI() {
8888
this->ui->configurations_group_box_settings->blockSignals(true);
8989
this->ui->configurations_group_box_settings->setTitle(format("%s:", title.c_str()).c_str());
9090
this->ui->configurations_group_box_settings->setEnabled(configurator.HasEnabledUI(ENABLE_UI_SETTINGS));
91-
this->ui->configurations_group_box_settings->setCheckable(true);
91+
this->ui->configurations_group_box_settings->setCheckable(!configurator.GetActiveConfiguration()->override_settings);
9292
this->ui->configurations_group_box_settings->setChecked(parameter->override_settings);
9393
this->ui->configurations_group_box_settings->blockSignals(false);
9494
this->ui->configurations_presets->setVisible(!layer->presets.empty());
95+
this->ui->configurations_presets->setEnabled(!configurator.GetActiveConfiguration()->override_settings);
96+
this->ui->configurations_settings->setEnabled(!configurator.GetActiveConfiguration()->override_settings);
9597

9698
const std::vector<Path> &layer_versions = configurator.layers.GatherManifests(parameter->key);
9799
this->ui->configurations_versions->setEnabled(true);

vkconfig_gui/tab_configurations.cpp

Lines changed: 83 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ TabConfigurations::TabConfigurations(MainWindow &window, std::shared_ptr<Ui::Mai
117117
this->connect(this->ui->configurations_list, SIGNAL(currentRowChanged(int)), this,
118118
SLOT(on_configurations_list_currentRowChanged(int)));
119119

120+
this->connect(this->ui->configuration_settings_file_enable, SIGNAL(toggled(bool)), this,
121+
SLOT(on_configuration_settings_file_enable_toggled(bool)));
122+
this->connect(this->ui->configuration_settings_file_search, SIGNAL(clicked()), this,
123+
SLOT(on_configuration_settings_file_search_pressed()));
124+
this->connect(this->ui->configuration_settings_file_remove, SIGNAL(clicked()), this,
125+
SLOT(on_configuration_settings_file_remove_pressed()));
126+
120127
this->connect(this->ui->configurations_layers_list, SIGNAL(currentRowChanged(int)), this,
121128
SLOT(on_configurations_layers_list_currentRowChanged(int)));
122129

@@ -166,13 +173,12 @@ void TabConfigurations::UpdateUI_Configurations(UpdateUIMode mode) {
166173

167174
Configurator &configurator = Configurator::Get();
168175

169-
ui->configurations_executable_scope->blockSignals(true);
170-
ui->configurations_executable_scope->setCurrentIndex(configurator.GetExecutableScope());
171-
ui->configurations_executable_scope->blockSignals(false);
172-
173-
ui->configurations_list->blockSignals(true);
176+
this->ui->configurations_executable_scope->blockSignals(true);
177+
this->ui->configurations_executable_scope->setCurrentIndex(configurator.GetExecutableScope());
178+
this->ui->configurations_executable_scope->blockSignals(false);
174179

175-
ui->configurations_list->clear();
180+
this->ui->configurations_list->blockSignals(true);
181+
this->ui->configurations_list->clear();
176182

177183
int current_row = -1;
178184

@@ -223,10 +229,25 @@ void TabConfigurations::UpdateUI_Configurations(UpdateUIMode mode) {
223229
}
224230

225231
if (current_row != -1) {
226-
ui->configurations_list->setCurrentRow(current_row);
232+
this->ui->configurations_list->setCurrentRow(current_row);
227233
}
228234

229-
ui->configurations_list->blockSignals(false);
235+
this->ui->configurations_list->blockSignals(false);
236+
237+
const Configuration *configuration = configurator.GetActiveConfiguration();
238+
this->ui->configuration_settings_file_enable->setEnabled(configuration != nullptr);
239+
this->ui->configuration_settings_file_path->setEnabled(configuration != nullptr);
240+
this->ui->configuration_settings_file_search->setEnabled(configuration != nullptr);
241+
242+
if (configuration == nullptr) {
243+
this->ui->configuration_settings_file_enable->setChecked(false);
244+
this->ui->configuration_settings_file_path->clear();
245+
this->ui->configuration_settings_file_remove->setEnabled(false);
246+
} else {
247+
this->ui->configuration_settings_file_enable->setChecked(configuration->override_settings);
248+
this->ui->configuration_settings_file_path->setText(configuration->override_settings_path.RelativePath().c_str());
249+
this->ui->configuration_settings_file_remove->setEnabled(!configuration->override_settings_path.Empty());
250+
}
230251
}
231252

232253
void TabConfigurations::UpdateUI_Applications(UpdateUIMode ui_update_mode) {
@@ -358,10 +379,14 @@ void TabConfigurations::UpdateUI_Settings(UpdateUIMode mode) {
358379

359380
const Parameter *parameter = configurator.GetActiveParameter();
360381
if (parameter != nullptr) {
361-
const std::string state = parameter->override_settings ? "Uncheck to disable" : "Check to enable";
362-
const std::string tooltip = format("%s '%s' layer settings", state.c_str(), parameter->key.c_str());
382+
if (configurator.GetActiveConfiguration()->override_settings) {
383+
this->ui->configurations_group_box_settings->setToolTip("Override Layer Settings is enabled");
384+
} else {
385+
const std::string state = parameter->override_settings ? "Uncheck to disable" : "Check to enable";
386+
const std::string tooltip = format("%s '%s' layer settings", state.c_str(), parameter->key.c_str());
363387

364-
this->ui->configurations_group_box_settings->setToolTip(tooltip.c_str());
388+
this->ui->configurations_group_box_settings->setToolTip(tooltip.c_str());
389+
}
365390
}
366391
}
367392

@@ -1296,6 +1321,53 @@ void TabConfigurations::on_configurations_list_currentRowChanged(int currentRow)
12961321
}
12971322
}
12981323

1324+
void TabConfigurations::on_configuration_settings_file_enable_toggled(bool checked) {
1325+
Configurator &configurator = Configurator::Get();
1326+
Configuration *configuration = configurator.GetActiveConfiguration();
1327+
1328+
if (checked && configuration->override_settings_path.Empty()) {
1329+
this->on_configuration_settings_file_search_pressed();
1330+
} else {
1331+
configuration->override_settings = checked;
1332+
1333+
this->UpdateUI_Configurations(UPDATE_REFRESH_UI);
1334+
this->UpdateUI_Settings(UPDATE_REFRESH_UI);
1335+
}
1336+
}
1337+
1338+
void TabConfigurations::on_configuration_settings_file_search_pressed() {
1339+
Configurator &configurator = Configurator::Get();
1340+
Configuration *configuration = configurator.GetActiveConfiguration();
1341+
assert(configuration != nullptr);
1342+
1343+
const std::string selected_path =
1344+
QFileDialog::getOpenFileName(&this->window, "Locate Layers Settings File",
1345+
configuration->override_settings_path.AbsolutePath().c_str(), "vk_layer_settings.txt(*.txt)")
1346+
.toStdString();
1347+
1348+
if (selected_path.empty()) {
1349+
return;
1350+
}
1351+
1352+
configurator.GetActiveConfiguration()->override_settings = true;
1353+
configurator.GetActiveConfiguration()->override_settings_path = selected_path;
1354+
1355+
this->UpdateUI_Configurations(UPDATE_REFRESH_UI);
1356+
this->UpdateUI_Settings(UPDATE_REFRESH_UI);
1357+
}
1358+
1359+
void TabConfigurations::on_configuration_settings_file_remove_pressed() {
1360+
Configurator &configurator = Configurator::Get();
1361+
Configuration *configuration = configurator.GetActiveConfiguration();
1362+
if (configuration != nullptr) {
1363+
configurator.GetActiveConfiguration()->override_settings = false;
1364+
configurator.GetActiveConfiguration()->override_settings_path.Clear();
1365+
}
1366+
1367+
this->UpdateUI_Configurations(UPDATE_REFRESH_UI);
1368+
this->UpdateUI_Settings(UPDATE_REFRESH_UI);
1369+
}
1370+
12991371
void TabConfigurations::on_configurations_layers_list_currentRowChanged(int currentRow) {
13001372
this->_settings_tree_manager.CleanupGUI();
13011373

vkconfig_gui/tab_configurations.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class TabConfigurations : public Tab {
7171
void on_configurations_list_itemDoubleClicked(QListWidgetItem *item);
7272
void on_configurations_list_itemChanged(QListWidgetItem *item);
7373
void on_configurations_list_currentRowChanged(int currentRow);
74+
75+
void on_configuration_settings_file_enable_toggled(bool checked);
76+
void on_configuration_settings_file_search_pressed();
77+
void on_configuration_settings_file_remove_pressed();
78+
7479
void on_configurations_layers_list_currentRowChanged(int currentRow);
7580

7681
void on_configurations_layerVersionChanged();

vkconfig_gui/tab_preferences.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ void TabPreferences::on_theme_mode_changed() {
113113
// Configurations
114114
this->ui->configurations_executable_append->setIcon(::Get(::ICON_FILE_SEARCH));
115115
this->ui->configurations_executable_remove->setIcon(::Get(::ICON_FILE_REMOVE));
116+
this->ui->configuration_settings_file_search->setIcon(::Get(::ICON_FILE_SEARCH));
117+
this->ui->configuration_settings_file_remove->setIcon(::Get(::ICON_FILE_REMOVE));
116118

117119
// Layers
118120
this->ui->layers_browse_button->setIcon(::Get(::ICON_FOLDER_SEARCH));
@@ -145,25 +147,25 @@ void TabPreferences::on_theme_mode_changed() {
145147

146148
this->current_theme_mode = mew_theme_mode;
147149

148-
//this->window.update();
149-
//this->window.app.styleHints()->setColorScheme(Qt::ColorScheme::Light);
150-
/*
151-
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
152-
switch (mew_theme_mode) {
153-
default:
154-
case THEME_MODE_FORCE_LIGHT:
155-
//if (this->window.app.styleHints()->colorScheme() != Qt::ColorScheme::Light) {
156-
this->window.app.styleHints()->setColorScheme(Qt::ColorScheme::Light);
157-
//}
158-
break;
159-
case THEME_MODE_FORCE_DARK:
160-
//if (this->window.app.styleHints()->colorScheme() != Qt::ColorScheme::Dark) {
161-
this->window.app.styleHints()->setColorScheme(Qt::ColorScheme::Dark);
162-
//}
163-
break;
164-
}
165-
#endif
166-
*/
150+
// this->window.update();
151+
// this->window.app.styleHints()->setColorScheme(Qt::ColorScheme::Light);
152+
/*
153+
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
154+
switch (mew_theme_mode) {
155+
default:
156+
case THEME_MODE_FORCE_LIGHT:
157+
//if (this->window.app.styleHints()->colorScheme() != Qt::ColorScheme::Light) {
158+
this->window.app.styleHints()->setColorScheme(Qt::ColorScheme::Light);
159+
//}
160+
break;
161+
case THEME_MODE_FORCE_DARK:
162+
//if (this->window.app.styleHints()->colorScheme() != Qt::ColorScheme::Dark) {
163+
this->window.app.styleHints()->setColorScheme(Qt::ColorScheme::Dark);
164+
//}
165+
break;
166+
}
167+
#endif
168+
*/
167169
}
168170

169171
void TabPreferences::on_keep_running_toggled(bool checked) {

0 commit comments

Comments
 (0)