diff --git a/vkconfig_core/layer.cpp b/vkconfig_core/layer.cpp index eba7b9caca..9cde463285 100644 --- a/vkconfig_core/layer.cpp +++ b/vkconfig_core/layer.cpp @@ -49,6 +49,8 @@ const char* Layer::NO_PRESET = "User-Defined Settings"; +bool operator<(const LayersPathInfo& a, const LayersPathInfo& b) { return a.path.RelativePath() < b.path.RelativePath(); } + Layer::Layer() : status(STATUS_STABLE), platforms(PLATFORM_DESKTOP_BIT) {} Layer::Layer(const std::string& key) : key(key), status(STATUS_STABLE), platforms(PLATFORM_DESKTOP_BIT) {} diff --git a/vkconfig_core/layer.h b/vkconfig_core/layer.h index afc0e35d8d..16696bd0c1 100644 --- a/vkconfig_core/layer.h +++ b/vkconfig_core/layer.h @@ -40,6 +40,8 @@ struct LayersPathInfo { bool enabled = true; }; +bool operator<(const LayersPathInfo& a, const LayersPathInfo& b); + class Layer { public: static const char* NO_PRESET; diff --git a/vkconfig_core/layer_manager.cpp b/vkconfig_core/layer_manager.cpp index 4b813e588b..a09e2e4a98 100644 --- a/vkconfig_core/layer_manager.cpp +++ b/vkconfig_core/layer_manager.cpp @@ -276,6 +276,9 @@ 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) { + continue; + } if (this->selected_layers[i].key != layer_name) { continue; } @@ -359,6 +362,8 @@ void LayerManager::AddPath(const LayersPathInfo &info) { } else { this->paths[LAYERS_PATHS_GUI].push_back(info); } + + std::sort(this->paths[LAYERS_PATHS_GUI].begin(), this->paths[LAYERS_PATHS_GUI].end()); } void LayerManager::RemovePath(const LayersPathInfo &path_info) { diff --git a/vkconfig_core/type_tab.cpp b/vkconfig_core/type_tab.cpp index 82df19a0a1..00689e1aa3 100644 --- a/vkconfig_core/type_tab.cpp +++ b/vkconfig_core/type_tab.cpp @@ -26,9 +26,9 @@ const char* GetToken(TabType type) { static const char* TOKENS[]{ "DIAGNOSTIC", // TAB_DIAGNOSTIC - "APPLICATIONS", // TAB_APPLICATIONS - "LAYERS", // TAB_LAYERS "CONFIGURATIONS", // TAB_CONFIGURATIONS + "LAYERS", // TAB_LAYERS + "APPLICATIONS", // TAB_APPLICATIONS "PREFERENCES", // TAB_PREFERENCES "HELP" // TAB_HELP }; diff --git a/vkconfig_core/type_tab.h b/vkconfig_core/type_tab.h index b1bb250674..18c9e40b59 100644 --- a/vkconfig_core/type_tab.h +++ b/vkconfig_core/type_tab.h @@ -22,9 +22,9 @@ enum TabType { TAB_DIAGNOSTIC = 0, - TAB_APPLICATIONS, - TAB_LAYERS, TAB_CONFIGURATIONS, + TAB_LAYERS, + TAB_APPLICATIONS, TAB_PREFERENCES, TAB_HELP, diff --git a/vkconfig_gui/mainwindow.cpp b/vkconfig_gui/mainwindow.cpp index 6352426a2f..c7402c4405 100644 --- a/vkconfig_gui/mainwindow.cpp +++ b/vkconfig_gui/mainwindow.cpp @@ -481,7 +481,10 @@ QStringList MainWindow::BuildEnvVariables() const { return env; } -void MainWindow::on_tab_widget_currentChanged(int index) { this->tabs[index]->UpdateUI(UPDATE_REBUILD_UI); } +void MainWindow::on_tab_widget_currentChanged(int index) { + assert(index >= 0); + this->tabs[index]->UpdateUI(UPDATE_REBUILD_UI); +} void MainWindow::on_push_button_launcher_clicked() { // Are we already monitoring a running app? If so, terminate it diff --git a/vkconfig_gui/mainwindow.ui b/vkconfig_gui/mainwindow.ui index c3f12f9b96..e6e9aa9ed7 100644 --- a/vkconfig_gui/mainwindow.ui +++ b/vkconfig_gui/mainwindow.ui @@ -72,7 +72,7 @@ QTabWidget::Rounded - 2 + 1 @@ -104,752 +104,280 @@ - - - - 0 - 0 - - + - Applications + Configurations - - - 6 + + + 5 - 6 + 5 - 6 + 5 - 6 + 0 - - - + + 0 + + + + 0 - - 0 + + Qt::Horizontal - - - - QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked - - - - - - - 0 - - - 0 - - - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 32 - 16777215 - - - - + - - - - - - - - 0 - 0 - - - - - 32 - 0 - - - - - 32 - 16777215 - - - - - - - - - .. - - - false - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 7 - - - 0 - - - - - Layers Mode: + + true + + + 5 + + + false + + + + 0 + + + Qt::Vertical + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + + 1 + 0 + + + + + + + + 6 - - - - - - Arguments: + + 0 - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + 0 - - - - - + 0 - - - - - - - - 32 - 16777215 - - - - ... - - - - - - - - + 0 - - - - - - - 32 - 16777215 - + + + 0 - - ... + + 0 - - - - - - - - - - - - - - Output Log: - - - - - - - Env Variables: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Working Dir: - - - - - - - 0 - - - - - - Layers Controlled by Vulkan Applications - + + + + + 0 + 0 + + + - - - Layers Controlled by Vulkan Configurator - + + + + + 0 + 0 + + + + Per-Application: + + - - - Layers Disabled by Vulkan Configurator - + + + + + 0 + 0 + + + + Layers Mode: + + - + + + + + 0 + 0 + + + + + Layers Controlled by Vulkan Applications + + + + + Layers Controlled by Vulkan Configurator + + + + + Layers Disabled by Vulkan Configurator + + + + + - + + + 0 + + + + + + Arial + 10 + + + + false + + + QFrame::Box + + + QFrame::Sunken + + + 0 + + + Qt::ScrollBarAlwaysOn + + + QAbstractItemView::NoEditTriggers + + + false + + + + - - - - - - - - - - - - 0 - 0 - - - - - 16777215 - 32 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - Arial - 10 - + + + + + + + false + + + + 0 + 0 + + + + + 0 - - Clear + + 0 - - - - - - - Arial - 10 - + + 0 - - Clear log at launch + + 0 - - true + + 0 - - - - - - - Arial - 10 - - - - Launch - - - - - - - - - - - 0 - 0 - - - - - Consolas - 9 - - - - 1 - - - - - - - - Layers - - - - 5 - - - 5 - - - 5 - - - 0 - - - - - - - 0 - - - 0 - - - 0 - - - - - - - - - 32 - 16777215 - - - - ... - - - - - - - - 32 - 16777215 - - - - + - - - - - - - - - - 0 - 0 - - - - Qt::ScrollBarAlwaysOn - - - true - - - false - - - - 1 - - - - - - - - - - - Configurations - - - - 5 - - - 5 - - - 5 - - - 0 - - - 0 - - - - - 0 - - - Qt::Horizontal - - - true - - - 5 - - - false - - - - 0 - - - Qt::Vertical - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - + + + + + 0 + 0 + + + + + Arial + 9 + true + + + true + + 0 + + + Execute Closer to the Vulkan Application + + + Qt::AlignBottom|Qt::AlignHCenter + + + + + - - 1 + + 0 0 - - - - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Per-Application: - - - - - - - - 0 - 0 - - - - Layers Mode: - - - - - - - - 0 - 0 - - - - - Layers Controlled by Vulkan Applications - - - - - Layers Controlled by Vulkan Configurator - - - - - Layers Disabled by Vulkan Configurator - - - - - - - - - - 0 - - - - - - Arial - 10 - - - - false - - - QFrame::Box - - - QFrame::Sunken - - - 0 - - - Qt::ScrollBarAlwaysOn - - - QAbstractItemView::NoEditTriggers - - - false - - - - - - - - - - - - - false - - - - 0 - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - Arial - 9 - true - - - - true - - - 0 - - - Execute Closer to the Vulkan Application - - - Qt::AlignBottom|Qt::AlignHCenter - - - - - - - - 0 - 0 - - - - - Arial - 9 - true - + + + Arial + 9 + true + true @@ -1020,128 +548,600 @@ 0 - + + 0 + + + Qt::Vertical + + + + false + + + + 0 + 1 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 400 + 0 + + + + + + + false + + + false + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + Arial + 10 + + + + QFrame::Box + + + QFrame::Plain + + + 0 + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + + + 0 + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + false + + + 1 + + + false + + + 160 + + + 200 + + + + + + + + + + + + + + + + + + + + + Layers + + + + 5 + + + 5 + + + 5 + + + 0 + + + + + + + 0 + + + 0 + + + 0 + + + + + + + + + 32 + 16777215 + + + + ... + + + + + + + + 32 + 16777215 + + + + + + + + + + + + + + + 0 + 0 + + + + Qt::ScrollBarAlwaysOn + + + true + + + false + + + + 1 + + + + + + + + + + + + 0 + 0 + + + + Applications + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + 0 + + + 0 + + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked + + + + + + + 0 + + + 0 + + + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 32 + 16777215 + + + + + + + + + + + + + 0 + 0 + + + + + 32 + 0 + + + + + 32 + 16777215 + + + + - + + + + .. + + + false + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 7 + + + 0 + + + + + Layers Mode: + + + + + + + Arguments: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + 0 + + + + + + + + + 32 + 16777215 + + + + ... + + + + + + + + + 0 + + + + + + + + + 32 + 16777215 + + + + ... + + + + + + + + + + + + + + + Output Log: + + + + + + + Env Variables: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Working Dir: + + + + + + + 0 + + + + + + Layers Controlled by Vulkan Applications + + + + + Layers Controlled by Vulkan Configurator + + + + + Layers Disabled by Vulkan Configurator + + + + + + + + + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 32 + + + + + + + + 0 + + 0 - - Qt::Vertical + + 0 - - - false - - - - 0 - 1 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 400 - 0 - - - - - - - false - - - false - - - - 0 + + 0 + + + + + Qt::Horizontal - - 0 + + + 40 + 20 + - - 0 + + + + + + + Arial + 10 + - - 0 + + Clear - - 0 + + + + + + + Arial + 10 + - - - - - Arial - 10 - - - - QFrame::Box - - - QFrame::Plain - - - 0 - - - Qt::ScrollBarAlwaysOff - - - QAbstractScrollArea::AdjustToContentsOnFirstShow - - - 0 - - - QAbstractItemView::NoEditTriggers - - - true - - - false - - - false - - - 1 - - - false - - - 160 - - - 200 - - - - - - - - - - - - - - + + Clear log at launch + + + true + + + + + + + + Arial + 10 + + + + Launch + + + + + + + + + + + 0 + 0 + + + + + Consolas + 9 + + + + 1 + diff --git a/vkconfig_gui/settings_tree.cpp b/vkconfig_gui/settings_tree.cpp index 72e43c4c68..f708a8608f 100644 --- a/vkconfig_gui/settings_tree.cpp +++ b/vkconfig_gui/settings_tree.cpp @@ -139,9 +139,14 @@ void SettingsTreeManager::CreateGUI(QComboBox *preset_combobox, QTreeWidget *bui layer_item->setExpanded(parameter.control == LAYER_CONTROL_ON); */ if (layer == nullptr) { + preset_combobox->setVisible(false); continue; } + if (layer->api_version != this->parameter->api_version) { + configuration->SwitchLayerVersion(configurator.layers, layer->key, layer->api_version); + } + preset_combobox->blockSignals(true); preset_combobox->clear(); preset_labels.clear(); @@ -163,9 +168,6 @@ void SettingsTreeManager::CreateGUI(QComboBox *preset_combobox, QTreeWidget *bui preset_labels.push_back(layer_preset.label); } - // QTreeWidgetItem *presets_item = new QTreeWidgetItem(); - // this->tree->addTopLevelItem(presets_item); - // WidgetPreset *presets_combobox = new WidgetPreset(this->tree, presets_item, *layer, parameter); this->connect(preset_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnPresetChanged(int))); preset_combobox->setVisible(true); } else { diff --git a/vkconfig_gui/settings_tree.h b/vkconfig_gui/settings_tree.h index 602d3beb61..0a23bd8a9c 100644 --- a/vkconfig_gui/settings_tree.h +++ b/vkconfig_gui/settings_tree.h @@ -23,11 +23,11 @@ #include "widget_setting_flags.h" #include "widget_setting_filesystem.h" -#include "widget_preset.h" #include "../vkconfig_core/configuration.h" #include +#include #include #include diff --git a/vkconfig_gui/tab_layers.cpp b/vkconfig_gui/tab_layers.cpp index 18e4552b14..da37364063 100644 --- a/vkconfig_gui/tab_layers.cpp +++ b/vkconfig_gui/tab_layers.cpp @@ -109,6 +109,7 @@ void TabLayers::on_layers_add_pushButton_pressed() { LayersPathInfo info; info.path = ui->layers_lineEdit->text().toStdString(); configurator.layers.AddPath(info); + configurator.layers.LoadLayersFromPath(info.path); this->UpdateUI_LayersPaths(UPDATE_REBUILD_UI); } @@ -118,13 +119,14 @@ void TabLayers::on_layers_browse_pushButton_pressed() { this->ui->layers_lineEdit->text()); if (!selected_path.isEmpty()) { - this->ui->layers_lineEdit->setText(selected_path); + this->ui->layers_lineEdit->setText(Path(selected_path.toStdString()).AbsolutePath().c_str()); LayersPathInfo info; info.path = selected_path.toStdString(); Configurator &configurator = Configurator::Get(); configurator.layers.AddPath(info); + configurator.layers.LoadLayersFromPath(info.path); this->UpdateUI_LayersPaths(UPDATE_REBUILD_UI); } diff --git a/vkconfig_gui/vkconfig.pro b/vkconfig_gui/vkconfig.pro index 576febeaa6..687b0fae62 100644 --- a/vkconfig_gui/vkconfig.pro +++ b/vkconfig_gui/vkconfig.pro @@ -78,7 +78,6 @@ SOURCES += \ widget_tab_configurations_layer.cpp \ widget_tab_layers_path.cpp \ widget_tree_friendly_combobox.cpp \ - widget_preset.cpp \ widget_setting.cpp \ widget_setting_bool.cpp \ widget_setting_enum.cpp \ @@ -155,7 +154,6 @@ HEADERS += \ widget_tab_configurations_layer.h \ widget_tab_layers_path.h \ widget_tree_friendly_combobox.h \ - widget_preset.h \ widget_setting.h \ widget_setting_bool.h \ widget_setting_enum.h \ diff --git a/vkconfig_gui/widget_preset.cpp b/vkconfig_gui/widget_preset.cpp deleted file mode 100644 index 3bf4bfdc23..0000000000 --- a/vkconfig_gui/widget_preset.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 "widget_preset.h" - -#include - -WidgetPreset::WidgetPreset(QTreeWidget* tree, QTreeWidgetItem* item, const Layer& layer, Parameter& parameter) - : WidgetSettingBase(tree, item), layer(layer), parameter(parameter), field(new ComboBox(this)) { - this->field->setFocusPolicy(Qt::StrongFocus); - this->field->addItem(Layer::NO_PRESET); - - preset_labels.push_back(Layer::NO_PRESET); - - for (std::size_t i = 0, n = layer.presets.size(); i < n; ++i) { - const LayerPreset& layer_preset = layer.presets[i]; - - if (!IsPlatformSupported(layer_preset.platform_flags)) continue; - if (layer_preset.view == SETTING_VIEW_HIDDEN) continue; - - this->field->addItem((layer_preset.label + " Preset").c_str()); - preset_labels.push_back(layer_preset.label); - } - - // 'Refresh' need to be called before 'connect' to avoid triggering 'currentIndexChanged' in an infinite loop - this->Refresh(REFRESH_ENABLE_AND_STATE); - this->connect(this->field, SIGNAL(currentIndexChanged(int)), this, SLOT(OnPresetChanged(int))); - - this->item->setSizeHint(0, QSize(0, ITEM_HEIGHT)); - this->tree->setItemWidget(this->item, 0, this); -} - -void WidgetPreset::Refresh(RefreshAreas refresh_areas) { - (void)refresh_areas; - - const std::string& preset_label = layer.FindPresetLabel(parameter.settings); - - this->field->blockSignals(true); - this->field->setCurrentIndex(GetComboBoxIndex(preset_label.c_str())); - this->field->blockSignals(false); - - if (preset_label != Layer::NO_PRESET) { - const LayerPreset* preset = GetPreset(layer.presets, preset_label.c_str()); - assert(preset != nullptr); - this->setToolTip(preset->description.c_str()); - } -} - -void WidgetPreset::resizeEvent(QResizeEvent* event) { - const QRect button_rect = QRect(0, 0, event->size().width(), event->size().height()); - this->field->setGeometry(button_rect); -} - -int WidgetPreset::GetComboBoxIndex(const char* preset_label) const { - for (std::size_t i = 0, n = preset_labels.size(); i < n; ++i) { - if (preset_labels[i] == preset_label) return static_cast(i); - } - - assert(0); - return -1; -} - -void WidgetPreset::OnPresetChanged(int combox_preset_index) { - assert(combox_preset_index >= 0 && static_cast(combox_preset_index) < preset_labels.size()); - const std::string& preset_label = preset_labels[combox_preset_index]; - - if (preset_label == Layer::NO_PRESET) return; - - const LayerPreset* preset = GetPreset(layer.presets, preset_label.c_str()); - assert(preset != nullptr); - parameter.ApplyPresetSettings(*preset); - - emit itemChanged(); -} diff --git a/vkconfig_gui/widget_preset.h b/vkconfig_gui/widget_preset.h deleted file mode 100644 index b7dcc5c6b3..0000000000 --- a/vkconfig_gui/widget_preset.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2020-2021 Valve Corporation - * Copyright (c) 2020-2021 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 "../vkconfig_core/layer.h" -#include "../vkconfig_core/parameter.h" - -#include "widget_setting.h" -#include "combo_box.h" - -#include - -#include - -class WidgetPreset : public WidgetSettingBase { - Q_OBJECT - - public: - explicit WidgetPreset(QTreeWidget* tree, QTreeWidgetItem* item, const Layer& layer, Parameter& parameter); - - void Refresh(RefreshAreas refresh_areas) override; - - public Q_SLOTS: - void OnPresetChanged(int combox_preset_index); - - Q_SIGNALS: - void itemChanged(); - - protected: - void resizeEvent(QResizeEvent* event) override; - - private: - int GetComboBoxIndex(const char* preset_label) const; - - std::vector preset_labels; // The preset in the combobox - const Layer& layer; - Parameter& parameter; - ComboBox* field; -}; diff --git a/vkconfig_gui/widget_tab_configurations_layer.cpp b/vkconfig_gui/widget_tab_configurations_layer.cpp index ce42789dbd..150f312a78 100644 --- a/vkconfig_gui/widget_tab_configurations_layer.cpp +++ b/vkconfig_gui/widget_tab_configurations_layer.cpp @@ -102,10 +102,11 @@ ConfigurationLayerWidget::ConfigurationLayerWidget(TabConfigurations *tab, const const Layer *layer = configurator.layers.Find(parameter.key, parameter.api_version); if (parameter.control != LAYER_CONTROL_APPLICATIONS_API && parameter.control != LAYER_CONTROL_APPLICATIONS_ENV) { - assert(layer != nullptr); + this->setEnabled(layer != nullptr); this->layer_version = new QComboBox(this); this->layer_version->setVisible(advanced_view); + this->layer_version->setEnabled(layer != nullptr); this->layer_version->addItem("Latest"); int version_index = 0; @@ -113,7 +114,9 @@ ConfigurationLayerWidget::ConfigurationLayerWidget(TabConfigurations *tab, const if (layer_versions[i] == parameter.api_version) { version_index = this->layer_version->count(); - this->layer_version->setToolTip(layer->manifest_path.AbsolutePath().c_str()); + if (layer != nullptr) { + this->layer_version->setToolTip(layer->manifest_path.AbsolutePath().c_str()); + } } this->layer_version->addItem(layer_versions[i].str().c_str()); @@ -130,6 +133,7 @@ ConfigurationLayerWidget::ConfigurationLayerWidget(TabConfigurations *tab, const } this->layer_state->setEnabled(!layer_versions.empty()); this->layer_state->setCurrentIndex(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); }