Skip to content

Commit

Permalink
vkconfig3: Layer tabs UI improvements
Browse files Browse the repository at this point in the history
Change-Id: I6d060eb988c538badc08a207f2455f4e5248296c
  • Loading branch information
christophe-lunarg committed Oct 9, 2024
1 parent 6023e20 commit 1fed9d8
Show file tree
Hide file tree
Showing 10 changed files with 248 additions and 65 deletions.
2 changes: 1 addition & 1 deletion vkconfig_core/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Layer {
std::string enable_env;
bool disable_value;
bool enable_value;
bool visible = true;
bool enabled = true;

std::vector<SettingMeta*> settings;
std::vector<LayerPreset> presets;
Expand Down
56 changes: 35 additions & 21 deletions vkconfig_core/layer_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,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<LayersPathViewType>(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();
Expand Down Expand Up @@ -175,6 +183,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);

Expand Down Expand Up @@ -239,7 +249,7 @@ std::vector<Version> LayerManager::GatherVersions(const std::string &layer_name)
std::vector<Version> 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;
}

Expand Down Expand Up @@ -274,7 +284,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) {
Expand Down Expand Up @@ -330,26 +340,30 @@ void LayerManager::LoadLayersFromPath(const Path &layers_path, LayerType type) {
const std::vector<Path> &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);
}
}
}

Expand All @@ -373,7 +387,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) {
Expand Down Expand Up @@ -407,7 +421,7 @@ void LayerManager::UpdatePathEnabled(const LayersPathInfo &path_info) {
continue;
}

layer->visible = path_info.enabled;
layer->enabled = path_info.enabled;
}
}

Expand Down
4 changes: 4 additions & 0 deletions vkconfig_core/layer_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "layer.h"
#include "path.h"
#include "serialization.h"
#include "type_layer_path_view.h"

#include <string>
#include <vector>
Expand Down Expand Up @@ -61,6 +62,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);
Expand All @@ -70,6 +72,8 @@ class LayerManager : public Serialize {

std::vector<Layer> selected_layers;
std::array<std::vector<LayersPathInfo>, LAYERS_PATHS_COUNT> paths;
Path last_layers_path = Get(Path::HOME);
LayersPathViewType paths_view = LAYERS_PATH_ONLY_USER_DEFINED;

private:
void InitSystemPaths();
Expand Down
21 changes: 21 additions & 0 deletions vkconfig_core/type_layer_path_view.cpp
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*/

#include "type_layer_path_view.h"
31 changes: 31 additions & 0 deletions vkconfig_core/type_layer_path_view.h
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*/

#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 };
67 changes: 55 additions & 12 deletions vkconfig_gui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>6</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab_diagnostic">
<attribute name="title">
Expand Down Expand Up @@ -698,31 +698,74 @@
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="layers_lineEdit"/>
<widget class="QComboBox" name="layers_paths_view_comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToContents</enum>
</property>
<item>
<property name="text">
<string>Show Only User-Defined Layers Paths</string>
</property>
</item>
<item>
<property name="text">
<string>Show Only Active SDK Layers Paths</string>
</property>
</item>
<item>
<property name="text">
<string>Show All Layers</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="layers_browse_pushButton">
<property name="maximumSize">
<size>
<width>32</width>
<height>16777215</height>
</size>
<widget class="QProgressBar" name="layers_progress">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>...</string>
<property name="value">
<number>24</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textVisible">
<bool>true</bool>
</property>
<property name="invertedAppearance">
<bool>false</bool>
</property>
<property name="format">
<string>Loading layers... %p%</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="layers_add_pushButton">
<widget class="QLineEdit" name="layers_path_lineedit"/>
</item>
<item>
<widget class="QPushButton" name="layers_browse_pushButton">
<property name="maximumSize">
<size>
<width>32</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Add user-defined layers path</string>
</property>
<property name="text">
<string>+</string>
<string>...</string>
</property>
</widget>
</item>
Expand Down
Loading

0 comments on commit 1fed9d8

Please sign in to comment.