From 426c4a2a5b65ce04a767e4c514aafc182b8d5a56 Mon Sep 17 00:00:00 2001 From: LittleWhite Date: Sun, 24 Jan 2016 18:34:05 +0100 Subject: [PATCH 1/3] Add Configure widget --- src/citra_qt/CMakeLists.txt | 15 +++- src/citra_qt/configure.ui | 109 +++++++++++++++++++++++++++++ src/citra_qt/configure_debug.cpp | 33 +++++++++ src/citra_qt/configure_debug.h | 31 ++++++++ src/citra_qt/configure_debug.ui | 76 ++++++++++++++++++++ src/citra_qt/configure_dialog.cpp | 32 +++++++++ src/citra_qt/configure_dialog.h | 31 ++++++++ src/citra_qt/configure_general.cpp | 40 +++++++++++ src/citra_qt/configure_general.h | 31 ++++++++ src/citra_qt/configure_general.ui | 96 +++++++++++++++++++++++++ src/citra_qt/hotkeys.cpp | 2 +- src/citra_qt/hotkeys.h | 2 +- src/citra_qt/hotkeys.ui | 47 +------------ src/citra_qt/main.cpp | 48 +++---------- src/citra_qt/main.h | 4 -- src/citra_qt/main.ui | 51 +------------- src/citra_qt/ui_settings.cpp | 11 +++ src/citra_qt/ui_settings.h | 16 +++++ 18 files changed, 533 insertions(+), 142 deletions(-) create mode 100644 src/citra_qt/configure.ui create mode 100644 src/citra_qt/configure_debug.cpp create mode 100644 src/citra_qt/configure_debug.h create mode 100644 src/citra_qt/configure_debug.ui create mode 100644 src/citra_qt/configure_dialog.cpp create mode 100644 src/citra_qt/configure_dialog.h create mode 100644 src/citra_qt/configure_general.cpp create mode 100644 src/citra_qt/configure_general.h create mode 100644 src/citra_qt/configure_general.ui create mode 100644 src/citra_qt/ui_settings.cpp create mode 100644 src/citra_qt/ui_settings.h diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 9b3eb2cd6..6660d9879 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -17,12 +17,16 @@ set(SRCS debugger/profiler.cpp debugger/ramview.cpp debugger/registers.cpp - game_list.cpp util/spinbox.cpp util/util.cpp bootmanager.cpp + configure_debug.cpp + configure_dialog.cpp + configure_general.cpp + game_list.cpp hotkeys.cpp main.cpp + ui_settings.cpp citra-qt.rc Info.plist ) @@ -44,12 +48,16 @@ set(HEADERS debugger/profiler.h debugger/ramview.h debugger/registers.h - game_list.h util/spinbox.h util/util.h bootmanager.h + configure_debug.h + configure_dialog.h + configure_general.h + game_list.h hotkeys.h main.h + ui_settings.h version.h ) @@ -59,6 +67,9 @@ set(UIS debugger/disassembler.ui debugger/profiler.ui debugger/registers.ui + configure.ui + configure_debug.ui + configure_general.ui hotkeys.ui main.ui ) diff --git a/src/citra_qt/configure.ui b/src/citra_qt/configure.ui new file mode 100644 index 000000000..e4ac9a7d8 --- /dev/null +++ b/src/citra_qt/configure.ui @@ -0,0 +1,109 @@ + + + ConfigureDialog + + + + 0 + 0 + 441 + 401 + + + + + 370 + 219 + + + + Dialog + + + + + + + 371 + 221 + + + + 0 + + + + General + + + + + Input + + + + + Debug + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + ConfigureGeneral + QWidget +
configure_general.h
+ 1 +
+ + ConfigureDebug + QWidget +
configure_debug.h
+ 1 +
+
+ + + + buttonBox + accepted() + ConfigureDialog + accept() + + + 220 + 380 + + + 220 + 200 + + + + + buttonBox + rejected() + ConfigureDialog + reject() + + + 220 + 380 + + + 220 + 200 + + + + +
diff --git a/src/citra_qt/configure_debug.cpp b/src/citra_qt/configure_debug.cpp new file mode 100644 index 000000000..f8ff804b2 --- /dev/null +++ b/src/citra_qt/configure_debug.cpp @@ -0,0 +1,33 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/core.h" +#include "core/gdbstub/gdbstub.h" // TODO: can't include gdbstub without core.h +#include "core/settings.h" + +#include "configure_debug.h" +#include "ui_configure_debug.h" + +ConfigureDebug::ConfigureDebug(QWidget *parent) : + QWidget(parent), + ui(new Ui::ConfigureDebug) +{ + ui->setupUi(this); + this->setConfiguration(); +} + +ConfigureDebug::~ConfigureDebug() { + delete ui; +} + +void ConfigureDebug::setConfiguration() { + ui->toogleGDBStub->setChecked(Settings::values.use_gdbstub); + ui->GDBPortSpinBox->setValue(Settings::values.gdbstub_port); +} + +void ConfigureDebug::applyConfiguration() { + GDBStub::ToggleServer(ui->toogleGDBStub->isChecked()); + Settings::values.use_gdbstub = ui->toogleGDBStub->isChecked(); + Settings::values.gdbstub_port = ui->GDBPortSpinBox->value(); +} diff --git a/src/citra_qt/configure_debug.h b/src/citra_qt/configure_debug.h new file mode 100644 index 000000000..9b7080d92 --- /dev/null +++ b/src/citra_qt/configure_debug.h @@ -0,0 +1,31 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#ifndef CONFIGURE_DEBUG_H +#define CONFIGURE_DEBUG_H + +#include + +namespace Ui { +class ConfigureDebug; +} + +class ConfigureDebug : public QWidget +{ + Q_OBJECT + +public: + explicit ConfigureDebug(QWidget *parent = 0); + ~ConfigureDebug(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + Ui::ConfigureDebug *ui; +}; + +#endif // CONFIGURE_DEBUG_H diff --git a/src/citra_qt/configure_debug.ui b/src/citra_qt/configure_debug.ui new file mode 100644 index 000000000..80acf6e31 --- /dev/null +++ b/src/citra_qt/configure_debug.ui @@ -0,0 +1,76 @@ + + + ConfigureDebug + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + GDB + + + + + + + + + + Enable GDB Stub + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Port: + + + + + + + 65536 + + + + + + + + + + + + + + + + + diff --git a/src/citra_qt/configure_dialog.cpp b/src/citra_qt/configure_dialog.cpp new file mode 100644 index 000000000..ae442adcd --- /dev/null +++ b/src/citra_qt/configure_dialog.cpp @@ -0,0 +1,32 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "configure_dialog.h" +#include "ui_configure.h" + +#include "config.h" + +#include "core/settings.h" + +ConfigureDialog::ConfigureDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ConfigureDialog) +{ + ui->setupUi(this); + this->setConfiguration(); +} + +ConfigureDialog::~ConfigureDialog() { + delete ui; +} + +void ConfigureDialog::setConfiguration() { +} + +void ConfigureDialog::applyConfiguration() { + Config config; + ui->generalTab->applyConfiguration(); + ui->debugTab->applyConfiguration(); + config.Save(); +} diff --git a/src/citra_qt/configure_dialog.h b/src/citra_qt/configure_dialog.h new file mode 100644 index 000000000..d66049340 --- /dev/null +++ b/src/citra_qt/configure_dialog.h @@ -0,0 +1,31 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#ifndef CONFIGURE_DIALOG_H +#define CONFIGURE_DIALOG_H + +#include + +namespace Ui { +class ConfigureDialog; +} + +class ConfigureDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ConfigureDialog(QWidget *parent = 0); + ~ConfigureDialog(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + Ui::ConfigureDialog *ui; +}; + +#endif // CONFIGURE_DIALOG_H diff --git a/src/citra_qt/configure_general.cpp b/src/citra_qt/configure_general.cpp new file mode 100644 index 000000000..71d992ebe --- /dev/null +++ b/src/citra_qt/configure_general.cpp @@ -0,0 +1,40 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "citra_qt/configure_general.h" +#include "citra_qt/ui_configure_general.h" +#include "citra_qt/ui_settings.h" + +#include "core/settings.h" + +#include "video_core/video_core.h" + +ConfigureGeneral::ConfigureGeneral(QWidget *parent) : + QWidget(parent), + ui(new Ui::ConfigureGeneral) +{ + ui->setupUi(this); + this->setConfiguration(); +} + +ConfigureGeneral::~ConfigureGeneral() +{ + delete ui; +} + +void ConfigureGeneral::setConfiguration() { + ui->toogleCheckExit->setChecked(UISettings::values.check_closure); + ui->toogleHWRenderer->setChecked(Settings::values.use_hw_renderer); + ui->toogleShaderJIT->setChecked(Settings::values.use_shader_jit); +} + +void ConfigureGeneral::applyConfiguration() { + UISettings::values.check_closure = ui->toogleCheckExit->isChecked(); + + VideoCore::g_hw_renderer_enabled = + Settings::values.use_hw_renderer = ui->toogleHWRenderer->isChecked(); + + VideoCore::g_shader_jit_enabled = + Settings::values.use_shader_jit = ui->toogleShaderJIT->isChecked(); +} diff --git a/src/citra_qt/configure_general.h b/src/citra_qt/configure_general.h new file mode 100644 index 000000000..0f3b69332 --- /dev/null +++ b/src/citra_qt/configure_general.h @@ -0,0 +1,31 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#ifndef CONFIGURE_GENERAL_H +#define CONFIGURE_GENERAL_H + +#include + +namespace Ui { +class ConfigureGeneral; +} + +class ConfigureGeneral : public QWidget +{ + Q_OBJECT + +public: + explicit ConfigureGeneral(QWidget *parent = 0); + ~ConfigureGeneral(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + Ui::ConfigureGeneral *ui; +}; + +#endif // CONFIGURE_GENERAL_H diff --git a/src/citra_qt/configure_general.ui b/src/citra_qt/configure_general.ui new file mode 100644 index 000000000..f847d3c6c --- /dev/null +++ b/src/citra_qt/configure_general.ui @@ -0,0 +1,96 @@ + + + ConfigureGeneral + + + + 0 + 0 + 284 + 377 + + + + Form + + + + + + + + General + + + + + + + + Confirm exit while emulation is running + + + + + + + + + + + + Performance + + + + + + + + Enable hardware renderer + + + + + + + Enable Shader JIT + + + + + + + + + + + + Hotkeys + + + + + + + + + + + + + + + + + + + GHotkeysDialog + QWidget +
hotkeys.h
+ 1 +
+
+ + +
diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp index ed6b12fc4..929ba6f0e 100644 --- a/src/citra_qt/hotkeys.cpp +++ b/src/citra_qt/hotkeys.cpp @@ -94,7 +94,7 @@ QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widge } -GHotkeysDialog::GHotkeysDialog(QWidget* parent): QDialog(parent) +GHotkeysDialog::GHotkeysDialog(QWidget* parent): QWidget(parent) { ui.setupUi(this); diff --git a/src/citra_qt/hotkeys.h b/src/citra_qt/hotkeys.h index 2fe635882..50e6cbc21 100644 --- a/src/citra_qt/hotkeys.h +++ b/src/citra_qt/hotkeys.h @@ -42,7 +42,7 @@ void SaveHotkeys(QSettings& settings); */ void LoadHotkeys(QSettings& settings); -class GHotkeysDialog : public QDialog +class GHotkeysDialog : public QWidget { Q_OBJECT diff --git a/src/citra_qt/hotkeys.ui b/src/citra_qt/hotkeys.ui index 38a9a14d1..050fe064e 100644 --- a/src/citra_qt/hotkeys.ui +++ b/src/citra_qt/hotkeys.ui @@ -1,7 +1,7 @@ hotkeys - + 0 @@ -39,51 +39,8 @@ - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset - - - - - - buttonBox - accepted() - hotkeys - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - hotkeys - reject() - - - 316 - 260 - - - 286 - 274 - - - - + diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 32cceaf7e..573036a2a 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -13,6 +13,7 @@ #include "citra_qt/bootmanager.h" #include "citra_qt/config.h" +#include "citra_qt/configure_dialog.h" #include "citra_qt/game_list.h" #include "citra_qt/hotkeys.h" #include "citra_qt/main.h" @@ -145,17 +146,9 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) game_list->LoadInterfaceLayout(settings); - ui.action_Use_Gdbstub->setChecked(Settings::values.use_gdbstub); - SetGdbstubEnabled(ui.action_Use_Gdbstub->isChecked()); - + GDBStub::ToggleServer(Settings::values.use_gdbstub); GDBStub::SetServerPort(static_cast(Settings::values.gdbstub_port)); - ui.action_Use_Hardware_Renderer->setChecked(Settings::values.use_hw_renderer); - SetHardwareRendererEnabled(ui.action_Use_Hardware_Renderer->isChecked()); - - ui.action_Use_Shader_JIT->setChecked(Settings::values.use_shader_jit); - SetShaderJITEnabled(ui.action_Use_Shader_JIT->isChecked()); - ui.action_Single_Window_Mode->setChecked(settings.value("singleWindowMode", true).toBool()); ToggleWindowMode(); @@ -176,17 +169,14 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) // Setup connections connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString))); + connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(OnConfigure())); connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile())); connect(ui.action_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap())); connect(ui.action_Select_Game_List_Root, SIGNAL(triggered()), this, SLOT(OnMenuSelectGameListRoot())); connect(ui.action_Start, SIGNAL(triggered()), this, SLOT(OnStartGame())); connect(ui.action_Pause, SIGNAL(triggered()), this, SLOT(OnPauseGame())); connect(ui.action_Stop, SIGNAL(triggered()), this, SLOT(OnStopGame())); - connect(ui.action_Use_Hardware_Renderer, SIGNAL(triggered(bool)), this, SLOT(SetHardwareRendererEnabled(bool))); - connect(ui.action_Use_Shader_JIT, SIGNAL(triggered(bool)), this, SLOT(SetShaderJITEnabled(bool))); - connect(ui.action_Use_Gdbstub, SIGNAL(triggered(bool)), this, SLOT(SetGdbstubEnabled(bool))); connect(ui.action_Single_Window_Mode, SIGNAL(triggered(bool)), this, SLOT(ToggleWindowMode())); - connect(ui.action_Hotkeys, SIGNAL(triggered()), this, SLOT(OnOpenHotkeysDialog())); connect(this, SIGNAL(EmulationStarting(EmuThread*)), disasmWidget, SLOT(OnEmulationStarting(EmuThread*))); connect(this, SIGNAL(EmulationStopping()), disasmWidget, SLOT(OnEmulationStopping())); @@ -496,31 +486,6 @@ void GMainWindow::OnStopGame() { ShutdownGame(); } -void GMainWindow::OnOpenHotkeysDialog() { - GHotkeysDialog dialog(this); - dialog.exec(); -} - -void GMainWindow::SetHardwareRendererEnabled(bool enabled) { - VideoCore::g_hw_renderer_enabled = enabled; - - Config config; - Settings::values.use_hw_renderer = enabled; - config.Save(); -} - -void GMainWindow::SetGdbstubEnabled(bool enabled) { - GDBStub::ToggleServer(enabled); -} - -void GMainWindow::SetShaderJITEnabled(bool enabled) { - VideoCore::g_shader_jit_enabled = enabled; - - Config config; - Settings::values.use_shader_jit = enabled; - config.Save(); -} - void GMainWindow::ToggleWindowMode() { if (ui.action_Single_Window_Mode->isChecked()) { // Render in the main window... @@ -547,7 +512,12 @@ void GMainWindow::ToggleWindowMode() { } void GMainWindow::OnConfigure() { - //GControllerConfigDialog* dialog = new GControllerConfigDialog(controller_ports, this); + ConfigureDialog configureDialog(this); + auto result = configureDialog.exec(); + if ( result == QDialog::Accepted) + { + configureDialog.applyConfiguration(); + } } bool GMainWindow::ConfirmClose() { diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 6e4e56689..7fe425b40 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -104,12 +104,8 @@ private slots: /// Called whenever a user selects the "File->Select Game List Root" menu item void OnMenuSelectGameListRoot(); void OnMenuRecentFile(); - void OnOpenHotkeysDialog(); void OnConfigure(); void OnDisplayTitleBars(bool); - void SetHardwareRendererEnabled(bool); - void SetGdbstubEnabled(bool); - void SetShaderJITEnabled(bool); void ToggleWindowMode(); private: diff --git a/src/citra_qt/main.ui b/src/citra_qt/main.ui index 1e8a07cfb..441e0b81e 100644 --- a/src/citra_qt/main.ui +++ b/src/citra_qt/main.ui @@ -45,7 +45,7 @@ 0 0 1081 - 22 + 19 @@ -73,9 +73,6 @@ - - - @@ -84,7 +81,6 @@ - @@ -150,35 +146,6 @@ Single Window Mode - - - Configure &Hotkeys ... - - - - - true - - - Use Hardware Renderer - - - - - true - - - Use Shader JIT - - - - - true - - - Use Gdbstub - - Configure ... @@ -219,22 +186,6 @@ - - action_Configure - triggered() - MainWindow - OnConfigure() - - - -1 - -1 - - - 540 - 364 - - - actionDisplay_widget_title_bars triggered(bool) diff --git a/src/citra_qt/ui_settings.cpp b/src/citra_qt/ui_settings.cpp new file mode 100644 index 000000000..5f2215899 --- /dev/null +++ b/src/citra_qt/ui_settings.cpp @@ -0,0 +1,11 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "ui_settings.h" + +namespace UISettings { + +Values values = {}; + +} diff --git a/src/citra_qt/ui_settings.h b/src/citra_qt/ui_settings.h new file mode 100644 index 000000000..f0afbf2d3 --- /dev/null +++ b/src/citra_qt/ui_settings.h @@ -0,0 +1,16 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#ifndef UISETTINGS_H +#define UISETTINGS_H + +namespace UISettings { + +struct Values { + bool check_closure; +} extern values; + +} + +#endif // UISETTINGS_H From e33b9385054169c2850717e9c969a2531ee9b6f2 Mon Sep 17 00:00:00 2001 From: LittleWhite Date: Sun, 24 Jan 2016 21:23:55 +0100 Subject: [PATCH 2/3] Whole config is handled by Config class. This also means : we have only one config file, now --- src/citra_qt/config.cpp | 80 +++++++++++++++++++++++++- src/citra_qt/game_list.cpp | 13 ++--- src/citra_qt/game_list.h | 4 +- src/citra_qt/hotkeys.cpp | 51 ++++++----------- src/citra_qt/hotkeys.h | 4 +- src/citra_qt/main.cpp | 112 +++++++++++++------------------------ src/citra_qt/main.h | 3 + src/citra_qt/ui_settings.h | 32 +++++++++++ 8 files changed, 181 insertions(+), 118 deletions(-) diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index 8e247ff5c..981d92a9c 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp @@ -7,12 +7,12 @@ #include #include "citra_qt/config.h" +#include "citra_qt/ui_settings.h" #include "common/file_util.h" #include "core/settings.h" Config::Config() { - // TODO: Don't hardcode the path; let the frontend decide where to put the config files. qt_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "qt-config.ini"; FileUtil::CreateFullPath(qt_config_loc); @@ -67,6 +67,51 @@ void Config::ReadValues() { Settings::values.use_gdbstub = qt_config->value("use_gdbstub", false).toBool(); Settings::values.gdbstub_port = qt_config->value("gdbstub_port", 24689).toInt(); qt_config->endGroup(); + + qt_config->beginGroup("UI"); + + qt_config->beginGroup("UILayout"); + UISettings::values.geometry = qt_config->value("geometry").toByteArray(); + UISettings::values.state = qt_config->value("state").toByteArray(); + UISettings::values.renderwindow_geometry = qt_config->value("geometryRenderWindow").toByteArray(); + UISettings::values.gamelist_header_state = qt_config->value("gameListHeaderState").toByteArray(); + UISettings::values.microprofile_geometry = qt_config->value("microProfileDialogGeometry").toByteArray(); + UISettings::values.microprofile_visible = qt_config->value("microProfileDialogVisible", false).toBool(); + qt_config->endGroup(); + + qt_config->beginGroup("Paths"); + UISettings::values.roms_path = qt_config->value("romsPath").toString(); + UISettings::values.symbols_path = qt_config->value("symbolsPath").toString(); + UISettings::values.gamedir_path = qt_config->value("gameListRootDir", ".").toString(); + UISettings::values.gamedir_deepscan = qt_config->value("gameListDeepScan", false).toBool(); + UISettings::values.recent_files = qt_config->value("recentFiles").toStringList(); + qt_config->endGroup(); + + qt_config->beginGroup("Shortcuts"); + QStringList groups = qt_config->childGroups(); + for (auto group : groups) + { + qt_config->beginGroup(group); + + QStringList hotkeys = qt_config->childGroups(); + for (auto hotkey : hotkeys) + { + qt_config->beginGroup(hotkey); + UISettings::values.shortcuts.push_back(UISettings::Shortcut(group + "/" + hotkey, + UISettings::ContextedShortcut(qt_config->value("KeySeq").toString(), + qt_config->value("Context").toInt()))); + qt_config->endGroup(); + } + + qt_config->endGroup(); + } + qt_config->endGroup(); + + UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool(); + UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool(); + UISettings::values.first_start = qt_config->value("firstStart", true).toBool(); + + qt_config->endGroup(); } void Config::SaveValues() { @@ -107,6 +152,39 @@ void Config::SaveValues() { qt_config->setValue("use_gdbstub", Settings::values.use_gdbstub); qt_config->setValue("gdbstub_port", Settings::values.gdbstub_port); qt_config->endGroup(); + + qt_config->beginGroup("UI"); + + qt_config->beginGroup("UILayout"); + qt_config->setValue("geometry", UISettings::values.geometry); + qt_config->setValue("state", UISettings::values.state); + qt_config->setValue("geometryRenderWindow", UISettings::values.renderwindow_geometry); + qt_config->setValue("gameListHeaderState", UISettings::values.gamelist_header_state); + qt_config->setValue("microProfileDialogGeometry", UISettings::values.microprofile_geometry); + qt_config->setValue("microProfileDialogVisible", UISettings::values.microprofile_visible); + qt_config->endGroup(); + + qt_config->beginGroup("Paths"); + qt_config->setValue("romsPath", UISettings::values.roms_path); + qt_config->setValue("symbolsPath", UISettings::values.symbols_path); + qt_config->setValue("gameListRootDir", UISettings::values.gamedir_path); + qt_config->setValue("gameListDeepScan", UISettings::values.gamedir_deepscan); + qt_config->setValue("recentFiles", UISettings::values.recent_files); + qt_config->endGroup(); + + qt_config->beginGroup("Shortcuts"); + for (auto shortcut : UISettings::values.shortcuts ) + { + qt_config->setValue(shortcut.first + "/KeySeq", shortcut.second.first); + qt_config->setValue(shortcut.first + "/Context", shortcut.second.second); + } + qt_config->endGroup(); + + qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode); + qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar); + qt_config->setValue("firstStart", UISettings::values.first_start); + + qt_config->endGroup(); } void Config::Reload() { diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 1f8d69a03..faf057269 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -8,6 +8,7 @@ #include "game_list.h" #include "game_list_p.h" +#include "ui_settings.h" #include "core/loader/loader.h" @@ -100,19 +101,15 @@ void GameList::PopulateAsync(const QString& dir_path, bool deep_scan) current_worker = std::move(worker); } -void GameList::SaveInterfaceLayout(QSettings& settings) +void GameList::SaveInterfaceLayout() { - settings.beginGroup("UILayout"); - settings.setValue("gameListHeaderState", tree_view->header()->saveState()); - settings.endGroup(); + UISettings::values.gamelist_header_state = tree_view->header()->saveState(); } -void GameList::LoadInterfaceLayout(QSettings& settings) +void GameList::LoadInterfaceLayout() { auto header = tree_view->header(); - settings.beginGroup("UILayout"); - header->restoreState(settings.value("gameListHeaderState").toByteArray()); - settings.endGroup(); + header->restoreState(UISettings::values.gamelist_header_state); item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder()); } diff --git a/src/citra_qt/game_list.h b/src/citra_qt/game_list.h index 0950d9622..48febdc60 100644 --- a/src/citra_qt/game_list.h +++ b/src/citra_qt/game_list.h @@ -31,8 +31,8 @@ public: void PopulateAsync(const QString& dir_path, bool deep_scan); - void SaveInterfaceLayout(QSettings& settings); - void LoadInterfaceLayout(QSettings& settings); + void SaveInterfaceLayout(); + void LoadInterfaceLayout(); public slots: void AddEntry(QList entry_items); diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp index 929ba6f0e..92525d53c 100644 --- a/src/citra_qt/hotkeys.cpp +++ b/src/citra_qt/hotkeys.cpp @@ -4,11 +4,12 @@ #include +#include #include -#include #include #include "citra_qt/hotkeys.h" +#include "citra_qt/ui_settings.h" struct Hotkey { @@ -24,54 +25,38 @@ typedef std::map HotkeyGroupMap; HotkeyGroupMap hotkey_groups; -void SaveHotkeys(QSettings& settings) +void SaveHotkeys() { - settings.beginGroup("Shortcuts"); - + UISettings::values.shortcuts.clear(); for (auto group : hotkey_groups) { - settings.beginGroup(group.first); for (auto hotkey : group.second) { - settings.beginGroup(hotkey.first); - settings.setValue(QString("KeySeq"), hotkey.second.keyseq.toString()); - settings.setValue(QString("Context"), hotkey.second.context); - settings.endGroup(); + UISettings::values.shortcuts.push_back(UISettings::Shortcut(group.first + "/" + hotkey.first, + UISettings::ContextedShortcut(hotkey.second.keyseq.toString(), + hotkey.second.context))); } - settings.endGroup(); } - settings.endGroup(); } -void LoadHotkeys(QSettings& settings) +void LoadHotkeys() { - settings.beginGroup("Shortcuts"); - // Make sure NOT to use a reference here because it would become invalid once we call beginGroup() - QStringList groups = settings.childGroups(); - for (auto group : groups) + for (auto shortcut : UISettings::values.shortcuts) { - settings.beginGroup(group); + QStringList cat = shortcut.first.split("/"); + Q_ASSERT(cat.size() >= 2); - QStringList hotkeys = settings.childGroups(); - for (auto hotkey : hotkeys) + // RegisterHotkey assigns default keybindings, so use old values as default parameters + Hotkey& hk = hotkey_groups[cat[0]][cat[1]]; + if (!shortcut.second.first.isEmpty()) { - settings.beginGroup(hotkey); - - // RegisterHotkey assigns default keybindings, so use old values as default parameters - Hotkey& hk = hotkey_groups[group][hotkey]; - hk.keyseq = QKeySequence::fromString(settings.value("KeySeq", hk.keyseq.toString()).toString()); - hk.context = (Qt::ShortcutContext)settings.value("Context", hk.context).toInt(); - if (hk.shortcut) - hk.shortcut->setKey(hk.keyseq); - - settings.endGroup(); + hk.keyseq = QKeySequence::fromString(shortcut.second.first); + hk.context = (Qt::ShortcutContext)shortcut.second.second; } - - settings.endGroup(); + if (hk.shortcut) + hk.shortcut->setKey(hk.keyseq); } - - settings.endGroup(); } void RegisterHotkey(const QString& group, const QString& action, const QKeySequence& default_keyseq, Qt::ShortcutContext default_context) diff --git a/src/citra_qt/hotkeys.h b/src/citra_qt/hotkeys.h index 50e6cbc21..79a685074 100644 --- a/src/citra_qt/hotkeys.h +++ b/src/citra_qt/hotkeys.h @@ -33,14 +33,14 @@ QShortcut* GetHotkey(const QString& group, const QString& action, QWidget* widge * * @note Each hotkey group will be stored a settings group; For each hotkey inside that group, a settings group will be created to store the key sequence and the hotkey context. */ -void SaveHotkeys(QSettings& settings); +void SaveHotkeys(); /** * Loads hotkeys from the settings file. * * @note Yet unregistered hotkeys which are present in the settings will automatically be registered. */ -void LoadHotkeys(QSettings& settings); +void LoadHotkeys(); class GHotkeysDialog : public QWidget { diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 573036a2a..26904c71d 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -17,6 +17,7 @@ #include "citra_qt/game_list.h" #include "citra_qt/hotkeys.h" #include "citra_qt/main.h" +#include "citra_qt/ui_settings.h" // Debugger #include "citra_qt/debugger/callstack.h" @@ -51,12 +52,10 @@ #include "video_core/video_core.h" -GMainWindow::GMainWindow() : emu_thread(nullptr) +GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) { Pica::g_debug_context = Pica::DebugContext::Construct(); - Config config; - ui.setupUi(this); statusBar()->hide(); @@ -134,25 +133,21 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) setGeometry(x, y, w, h); // Restore UI state - QSettings settings; + restoreGeometry(UISettings::values.geometry); + restoreState(UISettings::values.state); + render_window->restoreGeometry(UISettings::values.renderwindow_geometry); + microProfileDialog->restoreGeometry(UISettings::values.microprofile_geometry); + microProfileDialog->setVisible(UISettings::values.microprofile_visible); - settings.beginGroup("UILayout"); - restoreGeometry(settings.value("geometry").toByteArray()); - restoreState(settings.value("state").toByteArray()); - render_window->restoreGeometry(settings.value("geometryRenderWindow").toByteArray()); - microProfileDialog->restoreGeometry(settings.value("microProfileDialogGeometry").toByteArray()); - microProfileDialog->setVisible(settings.value("microProfileDialogVisible").toBool()); - settings.endGroup(); - - game_list->LoadInterfaceLayout(settings); + game_list->LoadInterfaceLayout(); GDBStub::ToggleServer(Settings::values.use_gdbstub); GDBStub::SetServerPort(static_cast(Settings::values.gdbstub_port)); - ui.action_Single_Window_Mode->setChecked(settings.value("singleWindowMode", true).toBool()); + ui.action_Single_Window_Mode->setChecked(UISettings::values.single_window_mode); ToggleWindowMode(); - ui.actionDisplay_widget_title_bars->setChecked(settings.value("displayTitleBars", true).toBool()); + ui.actionDisplay_widget_title_bars->setChecked(UISettings::values.display_titlebar); OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked()); // Prepare actions for recent files @@ -165,12 +160,10 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) } UpdateRecentFiles(); - confirm_before_closing = settings.value("confirmClose", true).toBool(); - // Setup connections - connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString))); + connect(game_list, SIGNAL(GameChosen(QString)), this, SLOT(OnGameListLoadFile(QString)), Qt::DirectConnection); connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(OnConfigure())); - connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile())); + connect(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile()),Qt::DirectConnection); connect(ui.action_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap())); connect(ui.action_Select_Game_List_Root, SIGNAL(triggered()), this, SLOT(OnMenuSelectGameListRoot())); connect(ui.action_Start, SIGNAL(triggered()), this, SLOT(OnStartGame())); @@ -191,7 +184,7 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) // Setup hotkeys RegisterHotkey("Main Window", "Load File", QKeySequence::Open); RegisterHotkey("Main Window", "Start Emulation"); - LoadHotkeys(settings); + LoadHotkeys(); connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, SLOT(OnMenuLoadFile())); connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, SLOT(OnStartGame())); @@ -201,7 +194,7 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) show(); - game_list->PopulateAsync(settings.value("gameListRootDir", ".").toString(), settings.value("gameListDeepScan", false).toBool()); + game_list->PopulateAsync(UISettings::values.gamedir_path, UISettings::values.gamedir_deepscan); QStringList args = QApplication::arguments(); if (args.length() >= 2) { @@ -365,32 +358,24 @@ void GMainWindow::ShutdownGame() { emulation_running = false; } -void GMainWindow::StoreRecentFile(const std::string& filename) -{ - QSettings settings; - QStringList recent_files = settings.value("recentFiles").toStringList(); - recent_files.prepend(QString::fromStdString(filename)); - recent_files.removeDuplicates(); - while (recent_files.size() > max_recent_files_item) { - recent_files.removeLast(); +void GMainWindow::StoreRecentFile(const std::string& filename) { + UISettings::values.recent_files.prepend(QString::fromStdString(filename)); + UISettings::values.recent_files.removeDuplicates(); + while (UISettings::values.recent_files.size() > max_recent_files_item) { + UISettings::values.recent_files.removeLast(); } - settings.setValue("recentFiles", recent_files); - UpdateRecentFiles(); } void GMainWindow::UpdateRecentFiles() { - QSettings settings; - QStringList recent_files = settings.value("recentFiles").toStringList(); - - unsigned int num_recent_files = std::min(recent_files.size(), static_cast(max_recent_files_item)); + unsigned int num_recent_files = std::min(UISettings::values.recent_files.size(), static_cast(max_recent_files_item)); for (unsigned int i = 0; i < num_recent_files; i++) { - QString text = QString("&%1. %2").arg(i + 1).arg(QFileInfo(recent_files[i]).fileName()); + QString text = QString("&%1. %2").arg(i + 1).arg(QFileInfo(UISettings::values.recent_files[i]).fileName()); actions_recent_files[i]->setText(text); - actions_recent_files[i]->setData(recent_files[i]); - actions_recent_files[i]->setToolTip(recent_files[i]); + actions_recent_files[i]->setData(UISettings::values.recent_files[i]); + actions_recent_files[i]->setToolTip(UISettings::values.recent_files[i]); actions_recent_files[i]->setVisible(true); } @@ -411,36 +396,28 @@ void GMainWindow::OnGameListLoadFile(QString game_path) { } void GMainWindow::OnMenuLoadFile() { - QSettings settings; - QString rom_path = settings.value("romsPath", QString()).toString(); - - QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), rom_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)")); + QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), UISettings::values.roms_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)")); if (!filename.isEmpty()) { - settings.setValue("romsPath", QFileInfo(filename).path()); + UISettings::values.roms_path = QFileInfo(filename).path(); BootGame(filename.toLocal8Bit().data()); } } void GMainWindow::OnMenuLoadSymbolMap() { - QSettings settings; - QString symbol_path = settings.value("symbolsPath", QString()).toString(); - - QString filename = QFileDialog::getOpenFileName(this, tr("Load Symbol Map"), symbol_path, tr("Symbol map (*)")); + QString filename = QFileDialog::getOpenFileName(this, tr("Load Symbol Map"), UISettings::values.symbols_path, tr("Symbol map (*)")); if (!filename.isEmpty()) { - settings.setValue("symbolsPath", QFileInfo(filename).path()); + UISettings::values.symbols_path = QFileInfo(filename).path(); LoadSymbolMap(filename.toLocal8Bit().data()); } } void GMainWindow::OnMenuSelectGameListRoot() { - QSettings settings; - QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); if (!dir_path.isEmpty()) { - settings.setValue("gameListRootDir", dir_path); - game_list->PopulateAsync(dir_path, settings.value("gameListDeepScan").toBool()); + UISettings::values.gamedir_path = dir_path; + game_list->PopulateAsync(dir_path, UISettings::values.gamedir_deepscan); } } @@ -456,10 +433,7 @@ void GMainWindow::OnMenuRecentFile() { // Display an error message and remove the file from the list. QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename)); - QSettings settings; - QStringList recent_files = settings.value("recentFiles").toStringList(); - recent_files.removeOne(filename); - settings.setValue("recentFiles", recent_files); + UISettings::values.recent_files.removeOne(filename); UpdateRecentFiles(); } } @@ -536,23 +510,18 @@ void GMainWindow::closeEvent(QCloseEvent* event) { return; } - // Save window layout - QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Citra team", "Citra"); + UISettings::values.geometry = saveGeometry(); + UISettings::values.state = saveState(); + UISettings::values.renderwindow_geometry = render_window->saveGeometry(); + UISettings::values.microprofile_geometry = microProfileDialog->saveGeometry(); + UISettings::values.microprofile_visible = microProfileDialog->isVisible(); - settings.beginGroup("UILayout"); - settings.setValue("geometry", saveGeometry()); - settings.setValue("state", saveState()); - settings.setValue("geometryRenderWindow", render_window->saveGeometry()); - settings.setValue("microProfileDialogGeometry", microProfileDialog->saveGeometry()); - settings.setValue("microProfileDialogVisible", microProfileDialog->isVisible()); - settings.endGroup(); + UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked(); + UISettings::values.display_titlebar = ui.actionDisplay_widget_title_bars->isChecked(); + UISettings::values.first_start = false; - settings.setValue("singleWindowMode", ui.action_Single_Window_Mode->isChecked()); - settings.setValue("displayTitleBars", ui.actionDisplay_widget_title_bars->isChecked()); - settings.setValue("firstStart", false); - settings.setValue("confirmClose", confirm_before_closing); - game_list->SaveInterfaceLayout(settings); - SaveHotkeys(settings); + game_list->SaveInterfaceLayout(); + SaveHotkeys(); // Shutdown session if the emu thread is active... if (emu_thread != nullptr) @@ -577,7 +546,6 @@ int main(int argc, char* argv[]) { }); // Init settings params - QSettings::setDefaultFormat(QSettings::IniFormat); QCoreApplication::setOrganizationName("Citra team"); QCoreApplication::setApplicationName("Citra"); diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index 7fe425b40..bd620676b 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -10,6 +10,7 @@ #include "ui_main.h" +class Config; class GameList; class GImageInfo; class GRenderWindow; @@ -114,6 +115,8 @@ private: GRenderWindow* render_window; GameList* game_list; + std::unique_ptr config; + // Whether emulation is currently running in Citra. bool emulation_running = false; std::unique_ptr emu_thread; diff --git a/src/citra_qt/ui_settings.h b/src/citra_qt/ui_settings.h index f0afbf2d3..729866d56 100644 --- a/src/citra_qt/ui_settings.h +++ b/src/citra_qt/ui_settings.h @@ -5,10 +5,42 @@ #ifndef UISETTINGS_H #define UISETTINGS_H +#include +#include +#include + +#include + namespace UISettings { + typedef std::pair ContextedShortcut; + typedef std::pair Shortcut; + struct Values { + QByteArray geometry; + QByteArray state; + + QByteArray renderwindow_geometry; + + QByteArray gamelist_header_state; + + QByteArray microprofile_geometry; + bool microprofile_visible; + + bool single_window_mode; + bool display_titlebar; + bool check_closure; + bool first_start; + + QString roms_path; + QString symbols_path; + QString gamedir_path; + bool gamedir_deepscan; + QStringList recent_files; + + // Shortcut name + std::vector shortcuts; } extern values; } From 3eb737a5f5b199fd3f9951a7060255f46011e9ff Mon Sep 17 00:00:00 2001 From: LittleWhite Date: Sun, 24 Jan 2016 21:54:04 +0100 Subject: [PATCH 3/3] Add more stuff to configure. --- src/citra_qt/config.cpp | 22 +++--- src/citra_qt/configure.ui | 4 +- src/citra_qt/configure_debug.cpp | 21 +++--- src/citra_qt/configure_debug.h | 10 ++- src/citra_qt/configure_debug.ui | 108 ++++++++++++++++++----------- src/citra_qt/configure_dialog.cpp | 7 +- src/citra_qt/configure_dialog.h | 10 ++- src/citra_qt/configure_general.cpp | 23 +++--- src/citra_qt/configure_general.h | 10 ++- src/citra_qt/configure_general.ui | 80 +++++++++++++++++++-- src/citra_qt/hotkeys.cpp | 7 +- src/citra_qt/hotkeys.h | 2 + src/citra_qt/main.cpp | 9 +-- src/citra_qt/main.h | 1 - src/citra_qt/ui_settings.h | 17 +++-- 15 files changed, 211 insertions(+), 120 deletions(-) diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index 981d92a9c..ecf5c5a75 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp @@ -82,24 +82,23 @@ void Config::ReadValues() { qt_config->beginGroup("Paths"); UISettings::values.roms_path = qt_config->value("romsPath").toString(); UISettings::values.symbols_path = qt_config->value("symbolsPath").toString(); - UISettings::values.gamedir_path = qt_config->value("gameListRootDir", ".").toString(); + UISettings::values.gamedir = qt_config->value("gameListRootDir", ".").toString(); UISettings::values.gamedir_deepscan = qt_config->value("gameListDeepScan", false).toBool(); UISettings::values.recent_files = qt_config->value("recentFiles").toStringList(); qt_config->endGroup(); qt_config->beginGroup("Shortcuts"); QStringList groups = qt_config->childGroups(); - for (auto group : groups) - { + for (auto group : groups) { qt_config->beginGroup(group); QStringList hotkeys = qt_config->childGroups(); - for (auto hotkey : hotkeys) - { + for (auto hotkey : hotkeys) { qt_config->beginGroup(hotkey); - UISettings::values.shortcuts.push_back(UISettings::Shortcut(group + "/" + hotkey, - UISettings::ContextedShortcut(qt_config->value("KeySeq").toString(), - qt_config->value("Context").toInt()))); + UISettings::values.shortcuts.emplace_back( + UISettings::Shortcut(group + "/" + hotkey, + UISettings::ContextualShortcut(qt_config->value("KeySeq").toString(), + qt_config->value("Context").toInt()))); qt_config->endGroup(); } @@ -109,6 +108,7 @@ void Config::ReadValues() { UISettings::values.single_window_mode = qt_config->value("singleWindowMode", true).toBool(); UISettings::values.display_titlebar = qt_config->value("displayTitleBars", true).toBool(); + UISettings::values.confirm_before_closing = qt_config->value("confirmClose",true).toBool(); UISettings::values.first_start = qt_config->value("firstStart", true).toBool(); qt_config->endGroup(); @@ -167,14 +167,13 @@ void Config::SaveValues() { qt_config->beginGroup("Paths"); qt_config->setValue("romsPath", UISettings::values.roms_path); qt_config->setValue("symbolsPath", UISettings::values.symbols_path); - qt_config->setValue("gameListRootDir", UISettings::values.gamedir_path); + qt_config->setValue("gameListRootDir", UISettings::values.gamedir); qt_config->setValue("gameListDeepScan", UISettings::values.gamedir_deepscan); qt_config->setValue("recentFiles", UISettings::values.recent_files); qt_config->endGroup(); qt_config->beginGroup("Shortcuts"); - for (auto shortcut : UISettings::values.shortcuts ) - { + for (auto shortcut : UISettings::values.shortcuts ) { qt_config->setValue(shortcut.first + "/KeySeq", shortcut.second.first); qt_config->setValue(shortcut.first + "/Context", shortcut.second.second); } @@ -182,6 +181,7 @@ void Config::SaveValues() { qt_config->setValue("singleWindowMode", UISettings::values.single_window_mode); qt_config->setValue("displayTitleBars", UISettings::values.display_titlebar); + qt_config->setValue("confirmClose", UISettings::values.confirm_before_closing); qt_config->setValue("firstStart", UISettings::values.first_start); qt_config->endGroup(); diff --git a/src/citra_qt/configure.ui b/src/citra_qt/configure.ui index e4ac9a7d8..3c1f2ebba 100644 --- a/src/citra_qt/configure.ui +++ b/src/citra_qt/configure.ui @@ -7,7 +7,7 @@ 0 0 441 - 401 + 501 @@ -17,7 +17,7 @@ - Dialog + Citra Configuration diff --git a/src/citra_qt/configure_debug.cpp b/src/citra_qt/configure_debug.cpp index f8ff804b2..ba66d0833 100644 --- a/src/citra_qt/configure_debug.cpp +++ b/src/citra_qt/configure_debug.cpp @@ -2,13 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "core/core.h" -#include "core/gdbstub/gdbstub.h" // TODO: can't include gdbstub without core.h -#include "core/settings.h" - -#include "configure_debug.h" +#include "citra_qt/configure_debug.h" #include "ui_configure_debug.h" +#include "core/gdbstub/gdbstub.h" +#include "core/settings.h" + ConfigureDebug::ConfigureDebug(QWidget *parent) : QWidget(parent), ui(new Ui::ConfigureDebug) @@ -18,16 +17,16 @@ ConfigureDebug::ConfigureDebug(QWidget *parent) : } ConfigureDebug::~ConfigureDebug() { - delete ui; } void ConfigureDebug::setConfiguration() { - ui->toogleGDBStub->setChecked(Settings::values.use_gdbstub); - ui->GDBPortSpinBox->setValue(Settings::values.gdbstub_port); + ui->toogle_gdbstub->setChecked(Settings::values.use_gdbstub); + ui->gdbport_spinbox->setEnabled(Settings::values.use_gdbstub); + ui->gdbport_spinbox->setValue(Settings::values.gdbstub_port); } void ConfigureDebug::applyConfiguration() { - GDBStub::ToggleServer(ui->toogleGDBStub->isChecked()); - Settings::values.use_gdbstub = ui->toogleGDBStub->isChecked(); - Settings::values.gdbstub_port = ui->GDBPortSpinBox->value(); + GDBStub::ToggleServer(ui->toogle_gdbstub->isChecked()); + Settings::values.use_gdbstub = ui->toogle_gdbstub->isChecked(); + Settings::values.gdbstub_port = ui->gdbport_spinbox->value(); } diff --git a/src/citra_qt/configure_debug.h b/src/citra_qt/configure_debug.h index 9b7080d92..ab58ebbdc 100644 --- a/src/citra_qt/configure_debug.h +++ b/src/citra_qt/configure_debug.h @@ -2,9 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#ifndef CONFIGURE_DEBUG_H -#define CONFIGURE_DEBUG_H +#pragma once +#include #include namespace Ui { @@ -16,7 +16,7 @@ class ConfigureDebug : public QWidget Q_OBJECT public: - explicit ConfigureDebug(QWidget *parent = 0); + explicit ConfigureDebug(QWidget *parent = nullptr); ~ConfigureDebug(); void applyConfiguration(); @@ -25,7 +25,5 @@ private: void setConfiguration(); private: - Ui::ConfigureDebug *ui; + std::unique_ptr ui; }; - -#endif // CONFIGURE_DEBUG_H diff --git a/src/citra_qt/configure_debug.ui b/src/citra_qt/configure_debug.ui index 80acf6e31..3ba7f44da 100644 --- a/src/citra_qt/configure_debug.ui +++ b/src/citra_qt/configure_debug.ui @@ -13,54 +13,50 @@ Form - + - + GDB - + - + - - - - - Enable GDB Stub - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Port: - - - - - - - 65536 - - - - + + + Enable GDB Stub + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Port: + + + + + + + 65536 + + @@ -69,8 +65,38 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + - + + + toogle_gdbstub + toggled(bool) + gdbport_spinbox + setEnabled(bool) + + + 84 + 157 + + + 342 + 158 + + + + diff --git a/src/citra_qt/configure_dialog.cpp b/src/citra_qt/configure_dialog.cpp index ae442adcd..87c26c715 100644 --- a/src/citra_qt/configure_dialog.cpp +++ b/src/citra_qt/configure_dialog.cpp @@ -2,10 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "configure_dialog.h" +#include "citra_qt/config.h" +#include "citra_qt/configure_dialog.h" #include "ui_configure.h" -#include "config.h" #include "core/settings.h" @@ -18,15 +18,12 @@ ConfigureDialog::ConfigureDialog(QWidget *parent) : } ConfigureDialog::~ConfigureDialog() { - delete ui; } void ConfigureDialog::setConfiguration() { } void ConfigureDialog::applyConfiguration() { - Config config; ui->generalTab->applyConfiguration(); ui->debugTab->applyConfiguration(); - config.Save(); } diff --git a/src/citra_qt/configure_dialog.h b/src/citra_qt/configure_dialog.h index d66049340..89020eeb4 100644 --- a/src/citra_qt/configure_dialog.h +++ b/src/citra_qt/configure_dialog.h @@ -2,9 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#ifndef CONFIGURE_DIALOG_H -#define CONFIGURE_DIALOG_H +#pragma once +#include #include namespace Ui { @@ -16,7 +16,7 @@ class ConfigureDialog : public QDialog Q_OBJECT public: - explicit ConfigureDialog(QWidget *parent = 0); + explicit ConfigureDialog(QWidget *parent = nullptr); ~ConfigureDialog(); void applyConfiguration(); @@ -25,7 +25,5 @@ private: void setConfiguration(); private: - Ui::ConfigureDialog *ui; + std::unique_ptr ui; }; - -#endif // CONFIGURE_DIALOG_H diff --git a/src/citra_qt/configure_general.cpp b/src/citra_qt/configure_general.cpp index 71d992ebe..350bd794d 100644 --- a/src/citra_qt/configure_general.cpp +++ b/src/citra_qt/configure_general.cpp @@ -3,8 +3,8 @@ // Refer to the license.txt file included. #include "citra_qt/configure_general.h" -#include "citra_qt/ui_configure_general.h" #include "citra_qt/ui_settings.h" +#include "ui_configure_general.h" #include "core/settings.h" @@ -18,23 +18,26 @@ ConfigureGeneral::ConfigureGeneral(QWidget *parent) : this->setConfiguration(); } -ConfigureGeneral::~ConfigureGeneral() -{ - delete ui; +ConfigureGeneral::~ConfigureGeneral() { } void ConfigureGeneral::setConfiguration() { - ui->toogleCheckExit->setChecked(UISettings::values.check_closure); - ui->toogleHWRenderer->setChecked(Settings::values.use_hw_renderer); - ui->toogleShaderJIT->setChecked(Settings::values.use_shader_jit); + ui->toogle_deepscan->setChecked(UISettings::values.gamedir_deepscan); + ui->toogle_check_exit->setChecked(UISettings::values.confirm_before_closing); + ui->region_combobox->setCurrentIndex(Settings::values.region_value); + ui->toogle_hw_renderer->setChecked(Settings::values.use_hw_renderer); + ui->toogle_shader_jit->setChecked(Settings::values.use_shader_jit); } void ConfigureGeneral::applyConfiguration() { - UISettings::values.check_closure = ui->toogleCheckExit->isChecked(); + UISettings::values.gamedir_deepscan = ui->toogle_deepscan->isChecked(); + UISettings::values.confirm_before_closing = ui->toogle_check_exit->isChecked(); + + Settings::values.region_value = ui->region_combobox->currentIndex(); VideoCore::g_hw_renderer_enabled = - Settings::values.use_hw_renderer = ui->toogleHWRenderer->isChecked(); + Settings::values.use_hw_renderer = ui->toogle_hw_renderer->isChecked(); VideoCore::g_shader_jit_enabled = - Settings::values.use_shader_jit = ui->toogleShaderJIT->isChecked(); + Settings::values.use_shader_jit = ui->toogle_shader_jit->isChecked(); } diff --git a/src/citra_qt/configure_general.h b/src/citra_qt/configure_general.h index 0f3b69332..a6c68e62d 100644 --- a/src/citra_qt/configure_general.h +++ b/src/citra_qt/configure_general.h @@ -2,9 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#ifndef CONFIGURE_GENERAL_H -#define CONFIGURE_GENERAL_H +#pragma once +#include #include namespace Ui { @@ -16,7 +16,7 @@ class ConfigureGeneral : public QWidget Q_OBJECT public: - explicit ConfigureGeneral(QWidget *parent = 0); + explicit ConfigureGeneral(QWidget *parent = nullptr); ~ConfigureGeneral(); void applyConfiguration(); @@ -25,7 +25,5 @@ private: void setConfiguration(); private: - Ui::ConfigureGeneral *ui; + std::unique_ptr ui; }; - -#endif // CONFIGURE_GENERAL_H diff --git a/src/citra_qt/configure_general.ui b/src/citra_qt/configure_general.ui index f847d3c6c..47184c5c6 100644 --- a/src/citra_qt/configure_general.ui +++ b/src/citra_qt/configure_general.ui @@ -6,7 +6,7 @@ 0 0 - 284 + 300 377 @@ -25,7 +25,14 @@ - + + + Recursive scan for game folder + + + + + Confirm exit while emulation is running @@ -36,6 +43,69 @@ + + + + Emulation + + + + + + + + + + Region: + + + + + + + + JPN + + + + + USA + + + + + EUR + + + + + AUS + + + + + CHN + + + + + KOR + + + + + TWN + + + + + + + + + + + @@ -45,16 +115,16 @@ - + Enable hardware renderer - + - Enable Shader JIT + Enable shader JIT diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp index 92525d53c..41f95c63d 100644 --- a/src/citra_qt/hotkeys.cpp +++ b/src/citra_qt/hotkeys.cpp @@ -32,9 +32,10 @@ void SaveHotkeys() { for (auto hotkey : group.second) { - UISettings::values.shortcuts.push_back(UISettings::Shortcut(group.first + "/" + hotkey.first, - UISettings::ContextedShortcut(hotkey.second.keyseq.toString(), - hotkey.second.context))); + UISettings::values.shortcuts.emplace_back( + UISettings::Shortcut(group.first + "/" + hotkey.first, + UISettings::ContextualShortcut(hotkey.second.keyseq.toString(), + hotkey.second.context))); } } } diff --git a/src/citra_qt/hotkeys.h b/src/citra_qt/hotkeys.h index 79a685074..38aa5f012 100644 --- a/src/citra_qt/hotkeys.h +++ b/src/citra_qt/hotkeys.h @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#pragma once + #include "ui_hotkeys.h" class QDialog; diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 26904c71d..a81c6db3f 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -194,7 +194,7 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) show(); - game_list->PopulateAsync(UISettings::values.gamedir_path, UISettings::values.gamedir_deepscan); + game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan); QStringList args = QApplication::arguments(); if (args.length() >= 2) { @@ -416,7 +416,7 @@ void GMainWindow::OnMenuLoadSymbolMap() { void GMainWindow::OnMenuSelectGameListRoot() { QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory")); if (!dir_path.isEmpty()) { - UISettings::values.gamedir_path = dir_path; + UISettings::values.gamedir = dir_path; game_list->PopulateAsync(dir_path, UISettings::values.gamedir_deepscan); } } @@ -488,14 +488,15 @@ void GMainWindow::ToggleWindowMode() { void GMainWindow::OnConfigure() { ConfigureDialog configureDialog(this); auto result = configureDialog.exec(); - if ( result == QDialog::Accepted) + if (result == QDialog::Accepted) { configureDialog.applyConfiguration(); + config->Save(); } } bool GMainWindow::ConfirmClose() { - if (emu_thread == nullptr || !confirm_before_closing) + if (emu_thread == nullptr || !UISettings::values.confirm_before_closing) return true; auto answer = QMessageBox::question(this, tr("Citra"), diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h index bd620676b..477db5c5c 100644 --- a/src/citra_qt/main.h +++ b/src/citra_qt/main.h @@ -130,7 +130,6 @@ private: GPUCommandListWidget* graphicsCommandsWidget; QAction* actions_recent_files[max_recent_files_item]; - bool confirm_before_closing; }; #endif // _CITRA_QT_MAIN_HXX_ diff --git a/src/citra_qt/ui_settings.h b/src/citra_qt/ui_settings.h index 729866d56..62db4a73e 100644 --- a/src/citra_qt/ui_settings.h +++ b/src/citra_qt/ui_settings.h @@ -2,8 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#ifndef UISETTINGS_H -#define UISETTINGS_H +#pragma once #include #include @@ -13,8 +12,8 @@ namespace UISettings { - typedef std::pair ContextedShortcut; - typedef std::pair Shortcut; +using ContextualShortcut = std::pair ; +using Shortcut = std::pair; struct Values { QByteArray geometry; @@ -30,19 +29,19 @@ struct Values { bool single_window_mode; bool display_titlebar; - bool check_closure; + bool confirm_before_closing; bool first_start; QString roms_path; QString symbols_path; - QString gamedir_path; + QString gamedir; bool gamedir_deepscan; QStringList recent_files; // Shortcut name std::vector shortcuts; -} extern values; +}; + +extern Values values; } - -#endif // UISETTINGS_H