Skip to content

Commit

Permalink
vkconfig3: Add applications tab
Browse files Browse the repository at this point in the history
Change-Id: I90efa861a5cf8656c3c0b165079236e653a4be6b
  • Loading branch information
christophe-lunarg committed Sep 12, 2024
1 parent 368a2d5 commit 3254bf4
Show file tree
Hide file tree
Showing 21 changed files with 728 additions and 775 deletions.
36 changes: 0 additions & 36 deletions vkconfig_core/application.cpp

This file was deleted.

45 changes: 0 additions & 45 deletions vkconfig_core/application.h

This file was deleted.

21 changes: 0 additions & 21 deletions vkconfig_core/application_manager.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions vkconfig_core/application_manager.h

This file was deleted.

28 changes: 16 additions & 12 deletions vkconfig_core/configuration_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ bool ConfigurationManager::Load(const QJsonObject &json_root_object) {
// configurations json object
if (json_root_object.value("configurations") != QJsonValue::Undefined) {
const QJsonObject &json_configurations_object = json_root_object.value("configurations").toObject();
this->use_per_application_configuration = json_configurations_object.value("use_per_application").toBool();
this->use_per_executable_configuration = json_configurations_object.value("use_per_executable").toBool();
this->use_system_tray = json_configurations_object.value("use_system_tray").toBool();
this->active_application = json_configurations_object.value("active_application").toString().toStdString();
this->active_executable = json_configurations_object.value("active_application").toString().toStdString();

if (json_configurations_object.value("infos") != QJsonValue::Undefined) {
this->configuration_infos.clear();
Expand Down Expand Up @@ -90,9 +90,9 @@ bool ConfigurationManager::Save(QJsonObject &json_root_object) const {
}

QJsonObject json_configurations_object;
json_configurations_object.insert("use_per_application", this->use_per_application_configuration);
json_configurations_object.insert("use_per_executable", this->use_per_executable_configuration);
json_configurations_object.insert("use_system_tray", this->use_system_tray);
json_configurations_object.insert("active_application", this->active_application.c_str());
json_configurations_object.insert("active_executable", this->active_executable.c_str());
json_configurations_object.insert("infos", json_infos_object);
json_configurations_object.insert("removed_builtin", json_removed_builtin_configurations_object);

Expand All @@ -103,9 +103,9 @@ bool ConfigurationManager::Save(QJsonObject &json_root_object) const {

void ConfigurationManager::Reset() {
this->removed_built_in_configuration.clear();
this->use_per_application_configuration = false;
this->use_per_executable_configuration = false;
this->use_system_tray = false;
this->active_application.clear();
this->active_executable.clear();
this->configuration_infos.clear();
this->available_configurations.clear();

Expand Down Expand Up @@ -212,16 +212,16 @@ void ConfigurationManager::SaveAllConfigurations() const {
}

const ConfigurationInfo *ConfigurationManager::GetActiveConfigurationInfo() const {
if (this->use_per_application_configuration) {
return &this->configuration_infos.find(this->active_application.c_str())->second;
if (this->use_per_executable_configuration) {
return &this->configuration_infos.find(this->active_executable.c_str())->second;
} else {
return &this->configuration_infos.find(GLOBAL_CONFIGURATION_TOKEN)->second;
}
}

ConfigurationInfo *ConfigurationManager::GetActiveConfigurationInfo() {
if (this->use_per_application_configuration) {
return &this->configuration_infos.find(this->active_application.c_str())->second;
if (this->use_per_executable_configuration) {
return &this->configuration_infos.find(this->active_executable.c_str())->second;
} else {
return &this->configuration_infos.find(GLOBAL_CONFIGURATION_TOKEN)->second;
}
Expand Down Expand Up @@ -376,6 +376,8 @@ const Configuration *ConfigurationManager::FindConfiguration(const std::string &
void ConfigurationManager::ImportConfiguration(const LayerManager &layers, const Path &full_import_path) {
assert(!full_import_path.Empty());

this->last_path_import = full_import_path;

Configuration configuration;
if (!configuration.Load(full_import_path, layers)) {
QMessageBox msg;
Expand All @@ -399,6 +401,8 @@ void ConfigurationManager::ExportConfiguration(const LayerManager &layers, const
assert(!configuration_name.empty());
assert(!full_export_path.Empty());

this->last_path_export = full_export_path;

Configuration *configuration = this->FindConfiguration(configuration_name);
assert(configuration);

Expand Down Expand Up @@ -460,9 +464,9 @@ bool ConfigurationManager::CompareLayersVersions(const std::vector<Layer> &avail
return result;
}

bool ConfigurationManager::GetPerApplicationConfig() const { return this->use_per_application_configuration; }
bool ConfigurationManager::GetPerExecutableConfig() const { return this->use_per_executable_configuration; }

void ConfigurationManager::SetPerApplicationConfig(bool enabled) { this->use_per_application_configuration = enabled; }
void ConfigurationManager::SetPerExecutableConfig(bool enabled) { this->use_per_executable_configuration = enabled; }

bool ConfigurationManager::GetUseSystemTray() const { return this->use_system_tray; }

Expand Down
10 changes: 6 additions & 4 deletions vkconfig_core/configuration_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ class ConfigurationManager : public Serialize {
bool HasFile(const Configuration& configuration) const;
void RemoveConfigurationFile(const std::string& key);

bool GetPerApplicationConfig() const;
void SetPerApplicationConfig(bool enabled);
bool GetPerExecutableConfig() const;
void SetPerExecutableConfig(bool enabled);

bool GetUseSystemTray() const;
void SetUseSystemTray(bool enabled);

std::vector<Configuration> available_configurations;
Path last_path_import;
Path last_path_export;

private:
bool CompareLayersVersions(const std::vector<Layer>& available_layers, Configuration* selected_configuration,
Expand All @@ -89,7 +91,7 @@ class ConfigurationManager : public Serialize {

std::map<std::string, int> removed_built_in_configuration;
bool use_system_tray = false;
bool use_per_application_configuration = false;
std::string active_application;
bool use_per_executable_configuration = false;
std::string active_executable;
std::map<std::string, ConfigurationInfo> configuration_infos;
};
15 changes: 7 additions & 8 deletions vkconfig_core/configurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ bool Configurator::WriteLoaderSettings(OverrideArea override_area, const Path& l

const std::map<std::string, ConfigurationInfo>& infos = this->configurations.GetConfigurationInfos();
for (auto it = infos.begin(), end = infos.end(); it != end; ++it) {
if (this->configurations.GetPerApplicationConfig()) {
if (this->configurations.GetPerExecutableConfig()) {
if (it->first == GLOBAL_CONFIGURATION_TOKEN) {
continue;
}
Expand Down Expand Up @@ -264,15 +264,14 @@ bool Configurator::WriteLayersSettings(OverrideArea override_area, const Path& l
if (override_area & OVERRIDE_AREA_LAYERS_SETTINGS_BIT) {
std::vector<LayersSettings> layers_settings_array;

if (this->configurations.GetPerApplicationConfig()) {
const std::vector<Application>& applications = this->environment.GetApplications();
if (this->configurations.GetPerExecutableConfig()) {
const std::vector<Executable>& executables = this->executables.GetExecutables();

for (std::size_t i = 0, n = applications.size(); i < n; ++i) {
for (std::size_t i = 0, n = executables.size(); i < n; ++i) {
LayersSettings settings;
settings.configuration_name =
this->configurations.FindConfigurationInfo(applications[i].executable_path.AbsolutePath())->name;
settings.executable_path = applications[i].executable_path;
settings.settings_path = applications[i].GetActiveOptions().working_folder;
settings.configuration_name = this->configurations.FindConfigurationInfo(executables[i].path.AbsolutePath())->name;
settings.executable_path = executables[i].path;
settings.settings_path = executables[i].GetActiveOptions().working_folder;
layers_settings_array.push_back(settings);
}
} else {
Expand Down
5 changes: 3 additions & 2 deletions vkconfig_core/configurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
#pragma once

#include "../vkconfig_core/version.h"
#include "../vkconfig_core/layer.h"
#include "../vkconfig_core/configuration_manager.h"
#include "../vkconfig_core/layer_manager.h"
#include "../vkconfig_core/executable_manager.h"
#include "../vkconfig_core/environment.h"
#include "../vkconfig_core/configuration_manager.h"
#include "../vkconfig_core/type_platform.h"
#include "../vkconfig_core/type_override_area.h"
#include "../vkconfig_core/vulkan_info.h"
Expand Down Expand Up @@ -85,5 +85,6 @@ class Configurator {
Environment environment;
LayerManager layers;
ConfigurationManager configurations;
ExecutableManager executables;
VulkanSystemInfo vulkan_system_info;
};
Loading

0 comments on commit 3254bf4

Please sign in to comment.