diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 9b3eb2cd65..6660d98799 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/config.cpp b/src/citra_qt/config.cpp index 8e247ff5c0..ecf5c5a750 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 = 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.emplace_back( + UISettings::Shortcut(group + "/" + hotkey, + UISettings::ContextualShortcut(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.confirm_before_closing = qt_config->value("confirmClose",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); + 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("confirmClose", UISettings::values.confirm_before_closing); + qt_config->setValue("firstStart", UISettings::values.first_start); + + qt_config->endGroup(); } void Config::Reload() { diff --git a/src/citra_qt/configure.ui b/src/citra_qt/configure.ui new file mode 100644 index 0000000000..3c1f2ebba0 --- /dev/null +++ b/src/citra_qt/configure.ui @@ -0,0 +1,109 @@ + + + ConfigureDialog + + + + 0 + 0 + 441 + 501 + + + + + 370 + 219 + + + + Citra Configuration + + + + + + + 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 0000000000..ba66d08339 --- /dev/null +++ b/src/citra_qt/configure_debug.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 "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) +{ + ui->setupUi(this); + this->setConfiguration(); +} + +ConfigureDebug::~ConfigureDebug() { +} + +void ConfigureDebug::setConfiguration() { + 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->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 new file mode 100644 index 0000000000..ab58ebbdc7 --- /dev/null +++ b/src/citra_qt/configure_debug.h @@ -0,0 +1,29 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureDebug; +} + +class ConfigureDebug : public QWidget +{ + Q_OBJECT + +public: + explicit ConfigureDebug(QWidget *parent = nullptr); + ~ConfigureDebug(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + std::unique_ptr ui; +}; diff --git a/src/citra_qt/configure_debug.ui b/src/citra_qt/configure_debug.ui new file mode 100644 index 0000000000..3ba7f44da0 --- /dev/null +++ b/src/citra_qt/configure_debug.ui @@ -0,0 +1,102 @@ + + + ConfigureDebug + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + GDB + + + + + + + + Enable GDB Stub + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Port: + + + + + + + 65536 + + + + + + + + + + + + + + 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 new file mode 100644 index 0000000000..87c26c7157 --- /dev/null +++ b/src/citra_qt/configure_dialog.cpp @@ -0,0 +1,29 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "citra_qt/config.h" +#include "citra_qt/configure_dialog.h" +#include "ui_configure.h" + + +#include "core/settings.h" + +ConfigureDialog::ConfigureDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::ConfigureDialog) +{ + ui->setupUi(this); + this->setConfiguration(); +} + +ConfigureDialog::~ConfigureDialog() { +} + +void ConfigureDialog::setConfiguration() { +} + +void ConfigureDialog::applyConfiguration() { + ui->generalTab->applyConfiguration(); + ui->debugTab->applyConfiguration(); +} diff --git a/src/citra_qt/configure_dialog.h b/src/citra_qt/configure_dialog.h new file mode 100644 index 0000000000..89020eeb46 --- /dev/null +++ b/src/citra_qt/configure_dialog.h @@ -0,0 +1,29 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureDialog; +} + +class ConfigureDialog : public QDialog +{ + Q_OBJECT + +public: + explicit ConfigureDialog(QWidget *parent = nullptr); + ~ConfigureDialog(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + std::unique_ptr ui; +}; diff --git a/src/citra_qt/configure_general.cpp b/src/citra_qt/configure_general.cpp new file mode 100644 index 0000000000..350bd794d1 --- /dev/null +++ b/src/citra_qt/configure_general.cpp @@ -0,0 +1,43 @@ +// 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_settings.h" +#include "ui_configure_general.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() { +} + +void ConfigureGeneral::setConfiguration() { + 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.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->toogle_hw_renderer->isChecked(); + + VideoCore::g_shader_jit_enabled = + 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 new file mode 100644 index 0000000000..a6c68e62d5 --- /dev/null +++ b/src/citra_qt/configure_general.h @@ -0,0 +1,29 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui { +class ConfigureGeneral; +} + +class ConfigureGeneral : public QWidget +{ + Q_OBJECT + +public: + explicit ConfigureGeneral(QWidget *parent = nullptr); + ~ConfigureGeneral(); + + void applyConfiguration(); + +private: + void setConfiguration(); + +private: + std::unique_ptr ui; +}; diff --git a/src/citra_qt/configure_general.ui b/src/citra_qt/configure_general.ui new file mode 100644 index 0000000000..47184c5c63 --- /dev/null +++ b/src/citra_qt/configure_general.ui @@ -0,0 +1,166 @@ + + + ConfigureGeneral + + + + 0 + 0 + 300 + 377 + + + + Form + + + + + + + + General + + + + + + + + Recursive scan for game folder + + + + + + + Confirm exit while emulation is running + + + + + + + + + + + + Emulation + + + + + + + + + + Region: + + + + + + + + JPN + + + + + USA + + + + + EUR + + + + + AUS + + + + + CHN + + + + + KOR + + + + + TWN + + + + + + + + + + + + + + + Performance + + + + + + + + Enable hardware renderer + + + + + + + Enable shader JIT + + + + + + + + + + + + Hotkeys + + + + + + + + + + + + + + + + + + + GHotkeysDialog + QWidget +
hotkeys.h
+ 1 +
+
+ + +
diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index ffcab1f03c..d145321026 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 0950d96220..48febdc602 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 ed6b12fc48..41f95c63d5 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,39 @@ 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.emplace_back( + UISettings::Shortcut(group.first + "/" + hotkey.first, + UISettings::ContextualShortcut(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) @@ -94,7 +80,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 2fe6358829..38aa5f012e 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; @@ -33,16 +35,16 @@ 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 QDialog +class GHotkeysDialog : public QWidget { Q_OBJECT diff --git a/src/citra_qt/hotkeys.ui b/src/citra_qt/hotkeys.ui index 38a9a14d1c..050fe064e1 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 ca0ae6f7b6..23eb28259f 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -14,9 +14,11 @@ #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" +#include "citra_qt/ui_settings.h" // Debugger #include "citra_qt/debugger/callstack.h" @@ -50,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(); @@ -133,33 +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); - - ui.action_Use_Gdbstub->setChecked(Settings::values.use_gdbstub); - SetGdbstubEnabled(ui.action_Use_Gdbstub->isChecked()); + game_list->LoadInterfaceLayout(); + 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()); + 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 @@ -172,21 +160,16 @@ 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(ui.action_Load_File, SIGNAL(triggered()), this, SLOT(OnMenuLoadFile())); + 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()),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())); 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())); @@ -201,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())); @@ -211,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, UISettings::values.gamedir_deepscan); QStringList args = QApplication::arguments(); if (args.length() >= 2) { @@ -375,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); } @@ -421,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.toStdString()); } } 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.toStdString()); } } 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 = dir_path; + game_list->PopulateAsync(dir_path, UISettings::values.gamedir_deepscan); } } @@ -466,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(); } } @@ -496,31 +460,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,11 +486,17 @@ 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(); + 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"), @@ -566,23 +511,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) @@ -607,7 +547,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 6e4e566893..477db5c5cc 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; @@ -104,12 +105,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: @@ -118,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; @@ -131,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/main.ui b/src/citra_qt/main.ui index 1e8a07cfb4..441e0b81e0 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 0000000000..5f2215899f --- /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 0000000000..62db4a73eb --- /dev/null +++ b/src/citra_qt/ui_settings.h @@ -0,0 +1,47 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include + +#include + +namespace UISettings { + +using ContextualShortcut = std::pair ; +using Shortcut = std::pair; + +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 confirm_before_closing; + bool first_start; + + QString roms_path; + QString symbols_path; + QString gamedir; + bool gamedir_deepscan; + QStringList recent_files; + + // Shortcut name + std::vector shortcuts; +}; + +extern Values values; + +}