diff --git a/vkconfig_core/layer.h b/vkconfig_core/layer.h index 16696bd0c1..2d115b41cb 100644 --- a/vkconfig_core/layer.h +++ b/vkconfig_core/layer.h @@ -80,7 +80,7 @@ class Layer { std::string enable_env; bool disable_value; bool enable_value; - bool visible = true; + bool enabled = true; std::vector settings; std::vector presets; diff --git a/vkconfig_core/layer_manager.cpp b/vkconfig_core/layer_manager.cpp index 6efdccca64..7fc2058f17 100644 --- a/vkconfig_core/layer_manager.cpp +++ b/vkconfig_core/layer_manager.cpp @@ -25,14 +25,6 @@ #include -LayerType GetLayerType(LayersPaths Layers_paths_type) { - if (Layers_paths_type == LAYERS_PATHS_IMPLICIT) { - return LAYER_TYPE_IMPLICIT; - } else { - return LAYER_TYPE_EXPLICIT; - } -} - std::vector GetImplicitLayerPaths() { std::vector result; @@ -128,6 +120,14 @@ bool LayerManager::Load(const QJsonObject &json_root_object) { if (json_root_object.value("layers") != QJsonValue::Undefined) { const QJsonObject &json_layers_object = json_root_object.value("layers").toObject(); + if (json_layers_object.value("last_layers_path") != QJsonValue::Undefined) { + this->last_layers_path = json_layers_object.value("last_layers_path").toString().toStdString(); + } + + if (json_layers_object.value("paths_view") != QJsonValue::Undefined) { + this->paths_view = static_cast(json_layers_object.value("paths_view").toInt()); + } + if (json_layers_object.value("validated") != QJsonValue::Undefined) { const QJsonObject &json_layers_validated_object = json_layers_object.value("validated").toObject(); const QStringList &json_layers_validated_keys = json_layers_validated_object.keys(); @@ -175,6 +175,8 @@ bool LayerManager::Save(QJsonObject &json_root_object) const { } QJsonObject json_layers_object; + json_layers_object.insert("last_layers_path", this->last_layers_path.RelativePath().c_str()); + json_layers_object.insert("paths_view", this->paths_view); json_layers_object.insert("validated", json_layers_paths_object); json_layers_object.insert("paths", json_paths_object); @@ -239,7 +241,7 @@ std::vector LayerManager::GatherVersions(const std::string &layer_name) std::vector result; for (std::size_t i = 0, n = this->selected_layers.size(); i < n; ++i) { - if (!this->selected_layers[i].visible) { + if (!this->selected_layers[i].enabled) { continue; } @@ -274,7 +276,7 @@ const Layer *LayerManager::Find(const std::string &layer_name, const Version &la return this->Find(layer_name, latest); } else { for (std::size_t i = 0, n = this->selected_layers.size(); i < n; ++i) { - if (this->selected_layers[i].visible == false) { + if (this->selected_layers[i].enabled == false) { continue; } if (this->selected_layers[i].key != layer_name) { @@ -330,26 +332,30 @@ void LayerManager::LoadLayersFromPath(const Path &layers_path, LayerType type) { const std::vector &layers_paths = CollectFilePaths(layers_path); for (std::size_t i = 0, n = layers_paths.size(); i < n; ++i) { - const std::string &last_modified = layers_paths[i].LastModified(); - - Layer *already_loaded_layer = this->FindFromManifest(layers_paths[i]); - if (already_loaded_layer != nullptr) { - // Already loaded - auto it = this->layers_validated.find(layers_paths[i]); - if (it != layers_validated.end()) { - if (last_modified == it->second) { - continue; // Already loaded and up to date - } - } + this->LoadLayer(layers_paths[i], type); + } +} + +void LayerManager::LoadLayer(const Path &layer_path, LayerType type) { + const std::string &last_modified = layer_path.LastModified(); - // Reload - already_loaded_layer->Load(layers_paths[i], this->layers_validated, type); - } else { - Layer layer; - if (layer.Load(layers_paths[i], this->layers_validated, type)) { - this->selected_layers.push_back(layer); + Layer *already_loaded_layer = this->FindFromManifest(layer_path); + if (already_loaded_layer != nullptr) { + // Already loaded + auto it = this->layers_validated.find(layer_path); + if (it != layers_validated.end()) { + if (last_modified == it->second) { + return; } } + + // Modified to reload + already_loaded_layer->Load(layer_path, this->layers_validated, type); + } else { + Layer layer; + if (layer.Load(layer_path, this->layers_validated, type)) { + this->selected_layers.push_back(layer); + } } } @@ -373,7 +379,7 @@ void LayerManager::RemovePath(const LayersPathInfo &path_info) { continue; } - layer->visible = false; + layer->enabled = false; } for (int paths_type_index = LAYERS_PATHS_FIRST; paths_type_index <= LAYERS_PATHS_LAST; ++paths_type_index) { @@ -407,7 +413,7 @@ void LayerManager::UpdatePathEnabled(const LayersPathInfo &path_info) { continue; } - layer->visible = path_info.enabled; + layer->enabled = path_info.enabled; } } diff --git a/vkconfig_core/layer_manager.h b/vkconfig_core/layer_manager.h index 25011170c7..4f9b97baee 100644 --- a/vkconfig_core/layer_manager.h +++ b/vkconfig_core/layer_manager.h @@ -23,27 +23,13 @@ #include "layer.h" #include "path.h" #include "serialization.h" +#include "type_layer_path_view.h" +#include "type_layers_paths.h" #include #include #include -enum LayersPaths { - LAYERS_PATHS_IMPLICIT = 0, - LAYERS_PATHS_EXPLICIT, - LAYERS_PATHS_ENV_SET, // From $VK_LAYER_PATH - LAYERS_PATHS_ENV_ADD, // from $VK_ADD_LAYER_PATH - LAYERS_PATHS_GUI, - LAYERS_PATHS_SDK, - - LAYERS_PATHS_FIRST = LAYERS_PATHS_IMPLICIT, - LAYERS_PATHS_LAST = LAYERS_PATHS_SDK, -}; - -enum { LAYERS_PATHS_COUNT = LAYERS_PATHS_LAST - LAYERS_PATHS_FIRST + 1 }; - -LayerType GetLayerType(LayersPaths Layers_paths_type); - class LayerManager : public Serialize { public: bool Load(const QJsonObject& json_root_object) override; @@ -61,6 +47,7 @@ class LayerManager : public Serialize { void LoadAllInstalledLayers(); void LoadLayersFromPath(const Path& layers_path, LayerType type = LAYER_TYPE_EXPLICIT); + void LoadLayer(const Path& layer_path, LayerType type = LAYER_TYPE_EXPLICIT); void AppendPath(const LayersPathInfo& path_info); void RemovePath(const LayersPathInfo& path_info); @@ -70,6 +57,8 @@ class LayerManager : public Serialize { std::vector selected_layers; std::array, LAYERS_PATHS_COUNT> paths; + Path last_layers_path = Get(Path::HOME); + LayersPathViewType paths_view = LAYERS_PATH_ONLY_USER_DEFINED; private: void InitSystemPaths(); diff --git a/vkconfig_core/test/test_layer_manager.cpp b/vkconfig_core/test/test_layer_manager.cpp index adb9634ed0..9563ff44ed 100644 --- a/vkconfig_core/test/test_layer_manager.cpp +++ b/vkconfig_core/test/test_layer_manager.cpp @@ -191,7 +191,7 @@ TEST(test_layer_manager, GatherVersions) { EXPECT_TRUE(layer193 != nullptr); Layer* layer_edit = layer_manager.FindFromManifest(layer193->manifest_path); - layer_edit->visible = false; + layer_edit->enabled = false; const std::vector& versions_found_b = layer_manager.GatherVersions("VK_LAYER_LUNARG_version"); EXPECT_FALSE(versions_found_b.empty()); @@ -272,21 +272,21 @@ TEST(test_layer_manager, custom_path_update_layers) { EXPECT_EQ(layer_manager.paths[LAYERS_PATHS_GUI].size(), 1); EXPECT_EQ(layer_manager.paths[LAYERS_PATHS_GUI][0].enabled, true); for (std::size_t i = 0, n = layer_manager.selected_layers.size(); i < n; ++i) { - EXPECT_TRUE(layer_manager.selected_layers[i].visible); + EXPECT_TRUE(layer_manager.selected_layers[i].enabled); } info.enabled = false; layer_manager.UpdatePathEnabled(info); EXPECT_EQ(layer_manager.paths[LAYERS_PATHS_GUI][0].enabled, false); for (std::size_t i = 0, n = layer_manager.selected_layers.size(); i < n; ++i) { - EXPECT_FALSE(layer_manager.selected_layers[i].visible); + EXPECT_FALSE(layer_manager.selected_layers[i].enabled); } info.enabled = true; layer_manager.UpdatePathEnabled(info); EXPECT_EQ(layer_manager.paths[LAYERS_PATHS_GUI][0].enabled, true); for (std::size_t i = 0, n = layer_manager.selected_layers.size(); i < n; ++i) { - EXPECT_TRUE(layer_manager.selected_layers[i].visible); + EXPECT_TRUE(layer_manager.selected_layers[i].enabled); } EXPECT_EQ(layer_manager.paths[LAYERS_PATHS_GUI].size(), 1); diff --git a/vkconfig_core/type_layer_control.cpp b/vkconfig_core/type_layer_control.cpp index 607127c1ea..99077becfc 100644 --- a/vkconfig_core/type_layer_control.cpp +++ b/vkconfig_core/type_layer_control.cpp @@ -30,8 +30,21 @@ const char* GetToken(LayerControl control) { "Auto", // LAYER_CONTROL_AUTO "Off", // LAYER_CONTROL_OFF "On", // LAYER_CONTROL_ON - "application_enabled_layers", // LAYER_CONTROL_APPLICATIONS - "unordered_layer_location" // LAYER_CONTROL_UNORDERED + "application_enabled_layers", // LAYER_CONTROL_APPLICATIONS_API + "unordered_layer_location" // LAYER_CONTROL_APPLICATIONS_ENV + }; + static_assert(std::size(TOKENS) == LAYER_CONTROL_COUNT); + + return TOKENS[control]; +} + +const char* GetDescription(LayerControl control) { + static const char* TOKENS[] = { + "Auto, let Vulkan applications or environment variables to enable or disable the layer", // LAYER_CONTROL_AUTO + "Force Off the layer, preventing its execution", // LAYER_CONTROL_OFF + "Force On the layer, insuring its execution", // LAYER_CONTROL_ON + "Located and Enabled Layers using the Vulkan API by the Vulkan Application", // LAYER_CONTROL_APPLICATIONS_API + "Located and Enabled Layers using Environment Variables by the Vulkan Application" // LAYER_CONTROL_APPLICATIONS_ENV }; static_assert(std::size(TOKENS) == LAYER_CONTROL_COUNT); diff --git a/vkconfig_core/type_layer_control.h b/vkconfig_core/type_layer_control.h index 0150b7f26f..f1bf1c8b71 100644 --- a/vkconfig_core/type_layer_control.h +++ b/vkconfig_core/type_layer_control.h @@ -41,4 +41,6 @@ enum { LAYER_CONTROL_COUNT = LAYER_CONTROL_LAST - LAYER_CONTROL_FIRST + 1 }; const char* GetToken(LayerControl control); +const char* GetDescription(LayerControl control); + LayerControl GetLayerControl(const char* token); diff --git a/vkconfig_core/type_layer_path_view.cpp b/vkconfig_core/type_layer_path_view.cpp new file mode 100644 index 0000000000..9c96851a94 --- /dev/null +++ b/vkconfig_core/type_layer_path_view.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020-2024 Valve Corporation + * Copyright (c) 2020-2024 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Authors: + * - Christophe Riccio + */ + +#include "type_layer_path_view.h" diff --git a/vkconfig_core/type_layer_path_view.h b/vkconfig_core/type_layer_path_view.h new file mode 100644 index 0000000000..7f64e3881b --- /dev/null +++ b/vkconfig_core/type_layer_path_view.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020-2024 Valve Corporation + * Copyright (c) 2020-2024 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Authors: + * - Christophe Riccio + */ + +#pragma once + +enum LayersPathViewType { + LAYERS_PATH_ONLY_USER_DEFINED = 0, + LAYERS_PATH_ONLY_ACTIVE_SDK, + LAYERS_PATH_ALL, + + LAYERS_PATH_FIRST = LAYERS_PATH_ONLY_USER_DEFINED, + LAYERS_PATH_LAST = LAYERS_PATH_ALL, +}; +enum { LAYERS_PATH_COUNT = LAYERS_PATH_LAST - LAYERS_PATH_FIRST + 1 }; diff --git a/vkconfig_core/type_layers_paths.cpp b/vkconfig_core/type_layers_paths.cpp new file mode 100644 index 0000000000..b6185bcae3 --- /dev/null +++ b/vkconfig_core/type_layers_paths.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020-2024 Valve Corporation + * Copyright (c) 2020-2024 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Authors: + * - Christophe Riccio + */ + +#include "type_layers_paths.h" + +#include + +LayerType GetLayerType(LayersPaths Layers_paths_type) { + if (Layers_paths_type == LAYERS_PATHS_IMPLICIT) { + return LAYER_TYPE_IMPLICIT; + } else { + return LAYER_TYPE_EXPLICIT; + } +} + +const char* GetLabel(LayersPaths Layers_paths_type) { + static const char* TABLE[] = { + "Implicit Layers", // LAYERS_PATHS_IMPLICIT + "Explicit Layers", // LAYERS_PATHS_EXPLICIT + "$VK_LAYER_PATH Layers", // LAYERS_PATHS_ENV_SET + "$VK_ADD_LAYER_PATH Layers", // LAYERS_PATHS_ENV_ADD + "Vulkan Configurator Layers", // LAYERS_PATHS_GUI + "Vulkan SDK Layers", // LAYERS_PATHS_SDK + }; + static_assert(std::size(TABLE) == LAYERS_PATHS_COUNT, "The tranlation table size doesn't match the enum number of elements"); + + return TABLE[Layers_paths_type]; +} diff --git a/vkconfig_core/type_layers_paths.h b/vkconfig_core/type_layers_paths.h new file mode 100644 index 0000000000..3cbe3b87e8 --- /dev/null +++ b/vkconfig_core/type_layers_paths.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2020-2024 Valve Corporation + * Copyright (c) 2020-2024 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Authors: + * - Christophe Riccio + */ + +#pragma once + +#include "type_layer_type.h" + +enum LayersPaths { + LAYERS_PATHS_IMPLICIT = 0, + LAYERS_PATHS_EXPLICIT, + LAYERS_PATHS_ENV_SET, // From $VK_LAYER_PATH + LAYERS_PATHS_ENV_ADD, // from $VK_ADD_LAYER_PATH + LAYERS_PATHS_GUI, + LAYERS_PATHS_SDK, + + LAYERS_PATHS_FIRST = LAYERS_PATHS_IMPLICIT, + LAYERS_PATHS_LAST = LAYERS_PATHS_SDK, +}; + +enum { LAYERS_PATHS_COUNT = LAYERS_PATHS_LAST - LAYERS_PATHS_FIRST + 1 }; + +LayerType GetLayerType(LayersPaths Layers_paths_type); + +const char* GetLabel(LayersPaths Layers_paths_type); diff --git a/vkconfig_gui/mainwindow.ui b/vkconfig_gui/mainwindow.ui index b23dac46a1..d14dfd2f81 100644 --- a/vkconfig_gui/mainwindow.ui +++ b/vkconfig_gui/mainwindow.ui @@ -75,7 +75,7 @@ QTabWidget::Rounded - 6 + 2 @@ -698,31 +698,74 @@ 0 - + + + + 0 + 0 + + + + QComboBox::AdjustToContents + + + + Show Only User-Defined Layers Paths + + + + + Show Only Active SDK Layers Paths + + + + + Show All Layers + + + - - - - 32 - 16777215 - + + + + 0 + 0 + - - ... + + 24 + + + Qt::AlignCenter + + + true + + + false + + + Loading layers... %p% - + + + + 32 16777215 + + Add user-defined layers path + - + + ... diff --git a/vkconfig_gui/tab_configurations.cpp b/vkconfig_gui/tab_configurations.cpp index e2153ea6a9..9bd3d81ece 100644 --- a/vkconfig_gui/tab_configurations.cpp +++ b/vkconfig_gui/tab_configurations.cpp @@ -229,11 +229,8 @@ void TabConfigurations::UpdateUI_Layers(UpdateUIMode mode) { new ConfigurationLayerWidget(this, parameter, layer_versions, configuration->view_advanced_layers); item_state->widget = layer_widget; - if (parameter.control == LAYER_CONTROL_APPLICATIONS_API) { - item_state->widget->setToolTip("Located and Enabled Layers using the Vulkan API by the Vulkan Application"); - } else if (parameter.control == LAYER_CONTROL_APPLICATIONS_ENV) { - item_state->widget->setToolTip( - "Located and Enabled Layers using Environment Variables by the Vulkan Application"); + if (parameter.control == LAYER_CONTROL_APPLICATIONS_API || parameter.control == LAYER_CONTROL_APPLICATIONS_ENV) { + item_state->widget->setToolTip(GetDescription(parameter.control)); } ui->configurations_layers_list->setItemWidget(item_state, layer_widget); @@ -619,6 +616,9 @@ void TabConfigurations::OnContextMenuImportClicked(ConfigurationListItem *item) if (result) { configurator.Override(OVERRIDE_AREA_ALL); this->UpdateUI_Configurations(UPDATE_REBUILD_UI); + this->UpdateUI_LoaderMessages(); + this->UpdateUI_Layers(UPDATE_REBUILD_UI); + this->UpdateUI_Settings(UPDATE_REBUILD_UI); } else { QMessageBox msg; msg.setIcon(QMessageBox::Critical); diff --git a/vkconfig_gui/tab_layers.cpp b/vkconfig_gui/tab_layers.cpp index d6e2bbc798..742e1808ce 100644 --- a/vkconfig_gui/tab_layers.cpp +++ b/vkconfig_gui/tab_layers.cpp @@ -23,16 +23,24 @@ #include "mainwindow.h" #include "../vkconfig_core/configurator.h" +#include "../vkconfig_core/type_layer_path_view.h" #include TabLayers::TabLayers(MainWindow &window, std::shared_ptr ui) : Tab(TAB_LAYERS, window, ui) { - this->connect(this->ui->layers_lineEdit, SIGNAL(textEdited(QString)), this, SLOT(on_layers_lineEdit_textEdited(QString))); - this->connect(this->ui->layers_lineEdit, SIGNAL(returnPressed()), this, SLOT(on_layers_add_pushButton_pressed())); - this->connect(this->ui->layers_add_pushButton, SIGNAL(pressed()), this, SLOT(on_layers_add_pushButton_pressed())); - this->connect(this->ui->layers_browse_pushButton, SIGNAL(pressed()), this, SLOT(on_layers_browse_pushButton_pressed())); + Configurator &configurator = Configurator::Get(); + + this->ui->layers_progress->setValue(0); + this->ui->layers_progress->setVisible(false); + this->ui->layers_path_lineedit->setVisible(true); + this->ui->layers_path_lineedit->setText(configurator.layers.last_layers_path.RelativePath().c_str()); + + this->ui->layers_paths_view_comboBox->setCurrentIndex(configurator.layers.paths_view); - this->on_layers_lineEdit_textEdited(""); + this->connect(this->ui->layers_browse_pushButton, SIGNAL(pressed()), this, SLOT(on_layers_browse_pushButton_pressed())); + this->connect(this->ui->layers_path_lineedit, SIGNAL(returnPressed()), this, SLOT(on_layers_add_pushButton_pressed())); + this->connect(this->ui->layers_paths_view_comboBox, SIGNAL(currentIndexChanged(int)), this, + SLOT(on_layers_paths_view_comboBox_currentIndexChanged(int))); } TabLayers::~TabLayers() {} @@ -40,10 +48,22 @@ TabLayers::~TabLayers() {} void TabLayers::UpdateUI_LayersPaths(UpdateUIMode ui_update_mode) { Configurator &configurator = Configurator::Get(); - ui->layers_paths_tree->blockSignals(true); - ui->layers_paths_tree->clear(); + this->ui->layers_paths_tree->blockSignals(true); + this->ui->layers_paths_tree->clear(); + + LayersPathViewType view = static_cast(this->ui->layers_paths_view_comboBox->currentIndex()); for (std::size_t group_index = 0, group_count = configurator.layers.paths.size(); group_index < group_count; ++group_index) { + if (view == LAYERS_PATH_ONLY_USER_DEFINED) { + if (group_index != LAYERS_PATHS_GUI) { + continue; + } + } else if (view == LAYERS_PATH_ONLY_ACTIVE_SDK) { + if (group_index != LAYERS_PATHS_SDK) { + continue; + } + } + const LayerType layer_type = ::GetLayerType(static_cast(group_index)); std::vector &paths_group = configurator.layers.paths[group_index]; @@ -51,7 +71,7 @@ void TabLayers::UpdateUI_LayersPaths(UpdateUIMode ui_update_mode) { QTreeWidgetItem *item_state = new QTreeWidgetItem; item_state->setFlags(item_state->flags() | Qt::ItemIsSelectable); item_state->setSizeHint(0, QSize(0, ITEM_HEIGHT)); - LayersPathWidget *layer_path_widget = new LayersPathWidget(&paths_group[i]); + LayersPathWidget *layer_path_widget = new LayersPathWidget(&paths_group[i], static_cast(group_index)); this->connect(layer_path_widget, SIGNAL(toggled(bool)), this, SLOT(on_check_box_paths_toggled(bool))); ui->layers_paths_tree->addTopLevelItem(item_state); @@ -67,8 +87,7 @@ void TabLayers::UpdateUI_LayersPaths(UpdateUIMode ui_update_mode) { continue; // When the directory has JSON files that are not layer manifest } - std::string label = - layer->key + " - " + layer->api_version.str() + " - " + format("%s layer", GetToken(layer->type)); + std::string label = layer->key + " - " + layer->api_version.str(); if (layer->status != STATUS_STABLE) { label += format(" (%s)", GetToken(layer->status)); } @@ -76,17 +95,21 @@ void TabLayers::UpdateUI_LayersPaths(UpdateUIMode ui_update_mode) { QTreeWidgetItem *item = new QTreeWidgetItem; item->setText(0, label.c_str()); item->setToolTip(0, layer->manifest_path.AbsolutePath().c_str()); - item->setDisabled(!layer_path_widget->isChecked()); + item->setDisabled(!layer->enabled); item_state->addChild(item); } } } - ui->layers_paths_tree->expandAll(); - ui->layers_paths_tree->blockSignals(false); + this->ui->layers_paths_tree->expandAll(); + this->ui->layers_paths_tree->blockSignals(false); } -void TabLayers::UpdateUI(UpdateUIMode ui_update_mode) { this->UpdateUI_LayersPaths(ui_update_mode); } +void TabLayers::UpdateUI(UpdateUIMode ui_update_mode) { + this->ui->layers_progress->resetFormat(); + this->ui->layers_progress->setValue(0); + this->UpdateUI_LayersPaths(ui_update_mode); +} void TabLayers::CleanUI() {} @@ -98,36 +121,71 @@ void TabLayers::on_check_box_paths_toggled(bool checked) { this->UpdateUI_LayersPaths(UPDATE_REBUILD_UI); } -void TabLayers::on_layers_lineEdit_textEdited(const QString &text) { - // Path new_path(ui->layers_lineEdit->text().toStdString()); - Path new_path(text.toStdString()); - ui->layers_add_pushButton->setEnabled(new_path.Exists()); +void TabLayers::on_layers_browse_pushButton_pressed() { + Configurator &configurator = Configurator::Get(); + + this->ui->layers_paths_view_comboBox->setVisible(false); + this->ui->layers_path_lineedit->setVisible(false); + this->ui->layers_browse_pushButton->setVisible(false); + this->ui->layers_progress->setVisible(true); + + const QString selected_path = + QFileDialog::getExistingDirectory(this->ui->layers_browse_pushButton, "Select Layers Manifest Folder...", + configurator.layers.last_layers_path.AbsolutePath().c_str()); + + this->LoadLayersManifest(selected_path); } void TabLayers::on_layers_add_pushButton_pressed() { + this->ui->layers_paths_view_comboBox->setVisible(false); + this->ui->layers_path_lineedit->setVisible(false); + this->ui->layers_browse_pushButton->setVisible(false); + this->ui->layers_progress->setVisible(true); + + this->LoadLayersManifest(this->ui->layers_path_lineedit->text()); +} + +void TabLayers::on_layers_paths_view_comboBox_currentIndexChanged(int index) { Configurator &configurator = Configurator::Get(); - LayersPathInfo info; - info.path = ui->layers_lineEdit->text().toStdString(); - configurator.layers.AppendPath(info); - configurator.layers.LoadLayersFromPath(info.path); + configurator.layers.paths_view = static_cast(index); this->UpdateUI_LayersPaths(UPDATE_REBUILD_UI); } -void TabLayers::on_layers_browse_pushButton_pressed() { - const QString selected_path = QFileDialog::getExistingDirectory(this->ui->layers_browse_pushButton, "Select Folder...", - this->ui->layers_lineEdit->text()); +void TabLayers::LoadLayersManifest(const QString &selected_path) { + Configurator &configurator = Configurator::Get(); if (!selected_path.isEmpty()) { - this->ui->layers_lineEdit->setText(Path(selected_path.toStdString()).AbsolutePath().c_str()); + configurator.layers.last_layers_path = selected_path.toStdString(); + this->ui->layers_path_lineedit->setText(configurator.layers.last_layers_path.AbsolutePath().c_str()); LayersPathInfo info; info.path = selected_path.toStdString(); - Configurator &configurator = Configurator::Get(); + const std::vector &layers_paths = CollectFilePaths(info.path); + + this->ui->layers_progress->setMaximum(layers_paths.size()); + this->ui->layers_progress->setValue(0); + configurator.layers.AppendPath(info); - configurator.layers.LoadLayersFromPath(info.path); + for (std::size_t i = 0, n = layers_paths.size(); i < n; ++i) { + this->ui->layers_progress->setFormat( + format("Validating %s... - %d/%d", layers_paths[i].AbsolutePath().c_str(), i, layers_paths.size()).c_str()); + this->ui->layers_progress->setValue(i); + configurator.layers.LoadLayer(layers_paths[i]); + this->UpdateUI_LayersPaths(UPDATE_REBUILD_UI); + } + + configurator.layers.UpdatePathEnabled(info); this->UpdateUI_LayersPaths(UPDATE_REBUILD_UI); + + this->ui->layers_progress->setFormat("Layers validated!"); + this->ui->layers_progress->setValue(layers_paths.size()); } + + this->ui->layers_paths_view_comboBox->setVisible(true); + this->ui->layers_path_lineedit->setVisible(true); + this->ui->layers_browse_pushButton->setVisible(true); + this->ui->layers_progress->setVisible(false); } diff --git a/vkconfig_gui/tab_layers.h b/vkconfig_gui/tab_layers.h index 065feda5e4..55ad16dfb3 100644 --- a/vkconfig_gui/tab_layers.h +++ b/vkconfig_gui/tab_layers.h @@ -37,7 +37,10 @@ struct TabLayers : public Tab { public Q_SLOTS: void on_check_box_paths_toggled(bool checked); - void on_layers_lineEdit_textEdited(const QString &text); - void on_layers_add_pushButton_pressed(); void on_layers_browse_pushButton_pressed(); + void on_layers_add_pushButton_pressed(); + void on_layers_paths_view_comboBox_currentIndexChanged(int index); + + private: + void LoadLayersManifest(const QString &selected_path); }; diff --git a/vkconfig_gui/vkconfig.pro b/vkconfig_gui/vkconfig.pro index 08e9634938..f41cf1845e 100644 --- a/vkconfig_gui/vkconfig.pro +++ b/vkconfig_gui/vkconfig.pro @@ -62,8 +62,10 @@ SOURCES += \ ../vkconfig_core/setting_string.cpp \ ../vkconfig_core/type_hide_message.cpp \ ../vkconfig_core/type_layer_control.cpp \ + ../vkconfig_core/type_layer_path_view.cpp \ ../vkconfig_core/type_layer_type.cpp \ ../vkconfig_core/type_layers_mode.cpp \ + ../vkconfig_core/type_layers_paths.cpp \ ../vkconfig_core/type_log.cpp \ ../vkconfig_core/type_platform.cpp \ ../vkconfig_core/type_status.cpp \ @@ -138,8 +140,10 @@ HEADERS += \ ../vkconfig_core/setting_string.h \ ../vkconfig_core/type_hide_message.h \ ../vkconfig_core/type_layer_control.h \ + ../vkconfig_core/type_layer_path_view.h \ ../vkconfig_core/type_layer_type.h \ ../vkconfig_core/type_layers_mode.h \ + ../vkconfig_core/type_layers_paths.h \ ../vkconfig_core/type_log.h \ ../vkconfig_core/type_platform.h \ ../vkconfig_core/type_status.h \ diff --git a/vkconfig_gui/widget_tab_configurations_layer.cpp b/vkconfig_gui/widget_tab_configurations_layer.cpp index 3958c58acf..caf47b6d18 100644 --- a/vkconfig_gui/widget_tab_configurations_layer.cpp +++ b/vkconfig_gui/widget_tab_configurations_layer.cpp @@ -113,15 +113,15 @@ ConfigurationLayerWidget::ConfigurationLayerWidget(TabConfigurations *tab, const for (std::size_t i = 0, n = layer_versions.size(); i < n; ++i) { if (layer_versions[i] == parameter.api_version) { version_index = this->layer_version->count(); - - if (layer != nullptr) { - this->layer_version->setToolTip(layer->manifest_path.AbsolutePath().c_str()); - } } this->layer_version->addItem(layer_versions[i].str().c_str()); } this->layer_version->setCurrentIndex(version_index); + if (layer != nullptr) { + this->layer_version->setToolTip(layer->manifest_path.AbsolutePath().c_str()); + this->setToolTip(layer->description.c_str()); + } // this->layer_version->setEnabled(layers.size() > 1); this->connect(this->layer_version, SIGNAL(currentIndexChanged(int)), this, SLOT(on_layer_version_currentIndexChanged(int))); @@ -141,6 +141,7 @@ ConfigurationLayerWidget::ConfigurationLayerWidget(TabConfigurations *tab, const } this->layer_state->setEnabled(!layer_versions.empty()); this->layer_state->setCurrentIndex(parameter.control); + this->layer_state->setToolTip(GetDescription(parameter.control)); this->layer_state->setEnabled(layer != nullptr); this->connect(this->layer_state, SIGNAL(currentIndexChanged(int)), this, SLOT(on_layer_state_currentIndexChanged(int))); // this->layer_state->installEventFilter(this); @@ -218,6 +219,12 @@ void ConfigurationLayerWidget::on_layer_version_currentIndexChanged(int index) { Configuration *configuration = configurator.GetActiveConfiguration(); configuration->SwitchLayerVersion(configurator.layers, this->layer_name, version); + const Layer *layer = configurator.layers.Find(this->layer_name, version); + if (layer != nullptr) { + this->layer_version->setToolTip(layer->manifest_path.AbsolutePath().c_str()); + this->setToolTip(layer->description.c_str()); + } + this->tab->UpdateUI_Settings(UPDATE_REBUILD_UI); } @@ -229,5 +236,7 @@ void ConfigurationLayerWidget::on_layer_state_currentIndexChanged(int index) { Parameter *parameter = configuration->Find(this->layer_name); parameter->control = GetLayerControl(text.c_str()); + this->layer_state->setToolTip(GetDescription(parameter->control)); + this->tab->UpdateUI_Settings(UPDATE_REFRESH_UI); } diff --git a/vkconfig_gui/widget_tab_layers_path.cpp b/vkconfig_gui/widget_tab_layers_path.cpp index 1a71c8c5f8..472144f225 100644 --- a/vkconfig_gui/widget_tab_layers_path.cpp +++ b/vkconfig_gui/widget_tab_layers_path.cpp @@ -24,7 +24,7 @@ #include -LayersPathWidget::LayersPathWidget(LayersPathInfo* path_info) : path_info(path_info) { +LayersPathWidget::LayersPathWidget(LayersPathInfo* path_info, LayersPaths layers_path) : path_info(path_info) { this->setChecked(this->path_info->enabled); this->buttom_remove = new QPushButton(this); @@ -32,7 +32,7 @@ LayersPathWidget::LayersPathWidget(LayersPathInfo* path_info) : path_info(path_i this->buttom_remove->show(); this->setText(path_info->path.RelativePath().c_str()); - this->setToolTip("Load layers in this location"); + this->setToolTip(GetLabel(layers_path)); this->connect(this, SIGNAL(toggled(bool)), this, SLOT(on_toggled(bool))); this->connect(this->buttom_remove, SIGNAL(clicked(bool)), this, SLOT(on_buttom_remove_clicked(bool))); @@ -52,12 +52,17 @@ void LayersPathWidget::on_buttom_remove_clicked(bool checked) { Configurator& configurator = Configurator::Get(); configurator.layers.RemovePath(*this->path_info); + this->path_info = nullptr; + emit toggled(checked); } void LayersPathWidget::on_toggled(bool checked) { - this->path_info->enabled = checked; + // Check the path is not removed + if (this->path_info != nullptr) { + this->path_info->enabled = checked; - Configurator& configurator = Configurator::Get(); - configurator.layers.UpdatePathEnabled(*this->path_info); + Configurator& configurator = Configurator::Get(); + configurator.layers.UpdatePathEnabled(*this->path_info); + } } diff --git a/vkconfig_gui/widget_tab_layers_path.h b/vkconfig_gui/widget_tab_layers_path.h index 77fcbb64dc..2eabd2f416 100644 --- a/vkconfig_gui/widget_tab_layers_path.h +++ b/vkconfig_gui/widget_tab_layers_path.h @@ -21,6 +21,7 @@ #pragma once #include "../vkconfig_core/layer.h" +#include "../vkconfig_core/type_layers_paths.h" #include #include @@ -30,7 +31,7 @@ class LayersPathWidget : public QCheckBox { Q_OBJECT public: - LayersPathWidget(LayersPathInfo *path_info); + LayersPathWidget(LayersPathInfo *path_info, LayersPaths layers_path); protected: void resizeEvent(QResizeEvent *event) override;