Skip to content

Commit 0ed717a

Browse files
vkconfig: Add preferences tab
Change-Id: Ib931952683592ad9e64a001d26692c5830fb9cd2
1 parent 5622f10 commit 0ed717a

8 files changed

+32
-36
lines changed

vkconfig_core/configurator.cpp

+10-14
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,6 @@ bool Configurator::Load() {
804804
// TAB_CONFIGURATIONS
805805
if (json_interface_object.value(GetToken(TAB_CONFIGURATIONS)) != QJsonValue::Undefined) {
806806
const QJsonObject& json_object = json_interface_object.value(GetToken(TAB_CONFIGURATIONS)).toObject();
807-
this->use_system_tray = json_object.value("use_system_tray").toBool();
808-
if (json_object.value("use_layer_dev_mode") != QJsonValue::Undefined) {
809-
this->use_layer_dev_mode = json_object.value("use_layer_dev_mode").toBool();
810-
}
811807
this->advanced = json_object.value("advanced").toBool();
812808
this->executable_scope = ::GetExecutableScope(json_object.value("executable_scope").toString().toStdString().c_str());
813809
this->selected_global_configuration = json_object.value("selected_global_configuration").toString().toStdString();
@@ -823,13 +819,13 @@ bool Configurator::Load() {
823819
const QJsonObject& json_object = json_interface_object.value(GetToken(TAB_APPLICATIONS)).toObject();
824820
}
825821

826-
// TAB_DIAGNOSTIC
827-
if (json_interface_object.value(GetToken(TAB_DIAGNOSTIC)) != QJsonValue::Undefined) {
828-
const QJsonObject& json_object = json_interface_object.value(GetToken(TAB_DIAGNOSTIC)).toObject();
822+
// TAB_PREFERENCES
823+
if (json_interface_object.value(GetToken(TAB_PREFERENCES)) != QJsonValue::Undefined) {
824+
const QJsonObject& json_object = json_interface_object.value(GetToken(TAB_PREFERENCES)).toObject();
829825

830-
if (json_object.value("VK_HOME") != QJsonValue::Undefined) {
831-
::SetHomePath(json_object.value("VK_HOME").toString().toStdString());
832-
}
826+
this->use_layer_dev_mode = json_object.value("use_layer_dev_mode").toBool();
827+
this->use_system_tray = json_object.value("use_system_tray").toBool();
828+
::SetHomePath(json_object.value("VK_HOME").toString().toStdString());
833829
}
834830

835831
this->executables.Load(json_root_object);
@@ -854,8 +850,6 @@ bool Configurator::Save() const {
854850
// TAB_CONFIGURATIONS
855851
{
856852
QJsonObject json_object;
857-
json_object.insert("use_system_tray", this->use_system_tray);
858-
json_object.insert("use_layer_dev_mode", this->use_layer_dev_mode);
859853
json_object.insert("advanced", this->advanced);
860854
json_object.insert("executable_scope", ::GetToken(this->executable_scope));
861855
json_object.insert("selected_global_configuration", this->selected_global_configuration.c_str());
@@ -874,11 +868,13 @@ bool Configurator::Save() const {
874868
json_interface_object.insert(GetToken(TAB_APPLICATIONS), json_object);
875869
}
876870

877-
// TAB_DIAGNOSTIC
871+
// TAB_PREFERENCES
878872
{
879873
QJsonObject json_object;
874+
json_object.insert("use_system_tray", this->use_system_tray);
875+
json_object.insert("use_layer_dev_mode", this->use_layer_dev_mode);
880876
json_object.insert("VK_HOME", ::Path(Path::HOME).RelativePath().c_str());
881-
json_interface_object.insert(GetToken(TAB_DIAGNOSTIC), json_object);
877+
json_interface_object.insert(GetToken(TAB_PREFERENCES), json_object);
882878
}
883879

884880
// interface json object

vkconfig_core/type_tab.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const char* GetLabel(TabType type) {
3030
"Application Launcher", // TAB_APPLICATIONS
3131
"System Diagnostic", // TAB_DIAGNOSTIC
3232
"Documentation", // TAB_DOCUMENTATION
33-
"Settings", // TAB_SETTINGS
33+
"Preferences", // TAB_PREFERENCES
3434
"About" // TAB_ABOUT
3535
};
3636

@@ -46,7 +46,7 @@ const char* GetToken(TabType type) {
4646
"APPLICATIONS", // TAB_APPLICATIONS
4747
"DIAGNOSTIC", // TAB_DIAGNOSTIC
4848
"DOCUMENTATION", // TAB_DOCUMENTATION
49-
"SETTINGS", // TAB_SETTINGS
49+
"PREFERENCES", // TAB_PREFERENCES
5050
"ABOUT" // TAB_ABOUT
5151
};
5252

vkconfig_core/type_tab.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ enum TabType {
2626
TAB_APPLICATIONS,
2727
TAB_DIAGNOSTIC,
2828
TAB_DOCUMENTATION,
29-
TAB_SETTINGS,
29+
TAB_PREFERENCES,
3030
TAB_ABOUT,
3131

3232
TAB_FIRST = TAB_CONFIGURATIONS,

vkconfig_gui/mainwindow.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ MainWindow::MainWindow(QWidget *parent)
6464
this->tabs[TAB_LAYERS].reset(new TabLayers(*this, ui));
6565
this->tabs[TAB_CONFIGURATIONS].reset(new TabConfigurations(*this, ui));
6666
this->tabs[TAB_DOCUMENTATION].reset(new TabDocumentation(*this, ui));
67-
this->tabs[TAB_SETTINGS].reset(new TabSettings(*this, ui));
67+
this->tabs[TAB_PREFERENCES].reset(new TabPreferences(*this, ui));
6868
this->tabs[TAB_ABOUT].reset(new TabAbout(*this, ui));
6969

7070
this->connect(qApp, &QGuiApplication::commitDataRequest, this, &MainWindow::commitDataRequest);
@@ -292,7 +292,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
292292
palette.setColor(QPalette::WindowText, QColor(Qt::red));
293293
this->ui->settings_keep_running->setPalette(palette);
294294

295-
this->ui->tab_widget->setCurrentIndex(TAB_SETTINGS);
295+
this->ui->tab_widget->setCurrentIndex(TAB_PREFERENCES);
296296

297297
int ret_val = alert.exec();
298298
if (alert.checkBox()->isChecked()) {

vkconfig_gui/mainwindow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "tab_applications.h"
2929
#include "tab_diagnostics.h"
3030
#include "tab_documentation.h"
31-
#include "tab_settings.h"
31+
#include "tab_preferences.h"
3232
#include "tab_about.h"
3333
#include "ui_mainwindow.h"
3434

vkconfig_gui/tab_settings.cpp vkconfig_gui/tab_preferences.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
* - Christophe Riccio <[email protected]>
1919
*/
2020

21-
#include "tab_settings.h"
21+
#include "tab_preferences.h"
2222
#include "style.h"
2323

2424
#include "../vkconfig_core/configurator.h"
2525

2626
#include <QFileDialog>
2727
#include <QMessageBox>
2828

29-
TabSettings::TabSettings(MainWindow &window, std::shared_ptr<Ui::MainWindow> ui) : Tab(TAB_DIAGNOSTIC, window, ui) {
29+
TabPreferences::TabPreferences(MainWindow &window, std::shared_ptr<Ui::MainWindow> ui) : Tab(TAB_DIAGNOSTIC, window, ui) {
3030
this->ui->settings_reset->setIcon(::Get(::ICON_RESET));
3131
this->ui->settings_vk_home_browse->setIcon(::Get(::ICON_FOLDER_SEARCH));
3232

@@ -37,9 +37,9 @@ TabSettings::TabSettings(MainWindow &window, std::shared_ptr<Ui::MainWindow> ui)
3737
this->connect(this->ui->settings_layer_dev_mode, SIGNAL(toggled(bool)), this, SLOT(on_layer_dev_mode_toggled(bool)));
3838
}
3939

40-
TabSettings::~TabSettings() {}
40+
TabPreferences::~TabPreferences() {}
4141

42-
void TabSettings::UpdateUI(UpdateUIMode mode) {
42+
void TabPreferences::UpdateUI(UpdateUIMode mode) {
4343
(void)mode;
4444

4545
Configurator &configurator = Configurator::Get();
@@ -58,21 +58,21 @@ void TabSettings::UpdateUI(UpdateUIMode mode) {
5858
this->ui->settings_layer_dev_mode->blockSignals(false);
5959
}
6060

61-
void TabSettings::CleanUI() {}
61+
void TabPreferences::CleanUI() {}
6262

63-
bool TabSettings::EventFilter(QObject *target, QEvent *event) {
63+
bool TabPreferences::EventFilter(QObject *target, QEvent *event) {
6464
(void)target;
6565
(void)event;
6666

6767
return false;
6868
}
6969

70-
void TabSettings::on_keep_running_toggled(bool checked) {
70+
void TabPreferences::on_keep_running_toggled(bool checked) {
7171
Configurator &configurator = Configurator::Get();
7272
configurator.SetUseSystemTray(checked);
7373
}
7474

75-
void TabSettings::on_vk_home_text_pressed() {
75+
void TabPreferences::on_vk_home_text_pressed() {
7676
Path path(this->ui->settings_vk_home_text->text().toStdString());
7777
if (path.Exists()) {
7878
::SetHomePath(this->ui->settings_vk_home_text->text().toStdString());
@@ -90,7 +90,7 @@ void TabSettings::on_vk_home_text_pressed() {
9090
}
9191
}
9292

93-
void TabSettings::on_vk_home_browse_pressed() {
93+
void TabPreferences::on_vk_home_browse_pressed() {
9494
const QString selected_path = QFileDialog::getExistingDirectory(
9595
this->ui->settings_vk_home_browse, "Select the Vulkan Home Default Working Folder (Set ${VK_HOME} value)...",
9696
::Path(Path::HOME).AbsolutePath().c_str());
@@ -102,7 +102,7 @@ void TabSettings::on_vk_home_browse_pressed() {
102102
}
103103
}
104104

105-
void TabSettings::on_reset_hard_pressed() {
105+
void TabPreferences::on_reset_hard_pressed() {
106106
QMessageBox message;
107107
message.setIcon(QMessageBox::Critical);
108108
message.setWindowTitle(format("Restoring and Resetting %s to default...", VKCONFIG_NAME).c_str());
@@ -118,7 +118,7 @@ void TabSettings::on_reset_hard_pressed() {
118118
}
119119
}
120120

121-
void TabSettings::on_layer_dev_mode_toggled(bool checked) {
121+
void TabPreferences::on_layer_dev_mode_toggled(bool checked) {
122122
Configurator &configurator = Configurator::Get();
123123
configurator.SetUseLayerDevMode(checked);
124124
}

vkconfig_gui/tab_settings.h vkconfig_gui/tab_preferences.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
#include "tab.h"
2424

25-
class TabSettings : public Tab {
25+
class TabPreferences : public Tab {
2626
Q_OBJECT
2727

2828
public:
29-
TabSettings(MainWindow &window, std::shared_ptr<Ui::MainWindow> ui);
30-
virtual ~TabSettings();
29+
TabPreferences(MainWindow &window, std::shared_ptr<Ui::MainWindow> ui);
30+
virtual ~TabPreferences();
3131

3232
virtual void UpdateUI(UpdateUIMode mode) override;
3333
virtual void CleanUI() override;

vkconfig_gui/vkconfig.pro

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ SOURCES += \
104104
tab_configurations.cpp \
105105
tab_diagnostics.cpp \
106106
tab_documentation.cpp \
107-
tab_settings.cpp \
107+
tab_preferences.cpp \
108108
tab_layers.cpp \
109109
settings_tree.cpp \
110110
style.cpp
@@ -185,7 +185,7 @@ HEADERS += \
185185
tab_configurations.h \
186186
tab_diagnostics.h \
187187
tab_documentation.h \
188-
tab_settings.h \
188+
tab_preferences.h \
189189
tab_layers.h \
190190
settings_tree.h \
191191
style.h

0 commit comments

Comments
 (0)