mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-09-09 14:39:07 +01:00
Whole config is handled by Config class.
This also means : we have only one config file, now
This commit is contained in:
parent
426c4a2a5b
commit
e33b938505
8 changed files with 181 additions and 118 deletions
|
@ -7,12 +7,12 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "citra_qt/config.h"
|
#include "citra_qt/config.h"
|
||||||
|
#include "citra_qt/ui_settings.h"
|
||||||
|
|
||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
|
||||||
Config::Config() {
|
Config::Config() {
|
||||||
|
|
||||||
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
// 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";
|
qt_config_loc = FileUtil::GetUserPath(D_CONFIG_IDX) + "qt-config.ini";
|
||||||
FileUtil::CreateFullPath(qt_config_loc);
|
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.use_gdbstub = qt_config->value("use_gdbstub", false).toBool();
|
||||||
Settings::values.gdbstub_port = qt_config->value("gdbstub_port", 24689).toInt();
|
Settings::values.gdbstub_port = qt_config->value("gdbstub_port", 24689).toInt();
|
||||||
qt_config->endGroup();
|
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() {
|
void Config::SaveValues() {
|
||||||
|
@ -107,6 +152,39 @@ void Config::SaveValues() {
|
||||||
qt_config->setValue("use_gdbstub", Settings::values.use_gdbstub);
|
qt_config->setValue("use_gdbstub", Settings::values.use_gdbstub);
|
||||||
qt_config->setValue("gdbstub_port", Settings::values.gdbstub_port);
|
qt_config->setValue("gdbstub_port", Settings::values.gdbstub_port);
|
||||||
qt_config->endGroup();
|
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() {
|
void Config::Reload() {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "game_list.h"
|
#include "game_list.h"
|
||||||
#include "game_list_p.h"
|
#include "game_list_p.h"
|
||||||
|
#include "ui_settings.h"
|
||||||
|
|
||||||
#include "core/loader/loader.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);
|
current_worker = std::move(worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::SaveInterfaceLayout(QSettings& settings)
|
void GameList::SaveInterfaceLayout()
|
||||||
{
|
{
|
||||||
settings.beginGroup("UILayout");
|
UISettings::values.gamelist_header_state = tree_view->header()->saveState();
|
||||||
settings.setValue("gameListHeaderState", tree_view->header()->saveState());
|
|
||||||
settings.endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameList::LoadInterfaceLayout(QSettings& settings)
|
void GameList::LoadInterfaceLayout()
|
||||||
{
|
{
|
||||||
auto header = tree_view->header();
|
auto header = tree_view->header();
|
||||||
settings.beginGroup("UILayout");
|
header->restoreState(UISettings::values.gamelist_header_state);
|
||||||
header->restoreState(settings.value("gameListHeaderState").toByteArray());
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
|
item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ public:
|
||||||
|
|
||||||
void PopulateAsync(const QString& dir_path, bool deep_scan);
|
void PopulateAsync(const QString& dir_path, bool deep_scan);
|
||||||
|
|
||||||
void SaveInterfaceLayout(QSettings& settings);
|
void SaveInterfaceLayout();
|
||||||
void LoadInterfaceLayout(QSettings& settings);
|
void LoadInterfaceLayout();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void AddEntry(QList<QStandardItem*> entry_items);
|
void AddEntry(QList<QStandardItem*> entry_items);
|
||||||
|
|
|
@ -4,11 +4,12 @@
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QSettings>
|
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
#include "citra_qt/hotkeys.h"
|
#include "citra_qt/hotkeys.h"
|
||||||
|
#include "citra_qt/ui_settings.h"
|
||||||
|
|
||||||
struct Hotkey
|
struct Hotkey
|
||||||
{
|
{
|
||||||
|
@ -24,54 +25,38 @@ typedef std::map<QString, HotkeyMap> HotkeyGroupMap;
|
||||||
|
|
||||||
HotkeyGroupMap hotkey_groups;
|
HotkeyGroupMap hotkey_groups;
|
||||||
|
|
||||||
void SaveHotkeys(QSettings& settings)
|
void SaveHotkeys()
|
||||||
{
|
{
|
||||||
settings.beginGroup("Shortcuts");
|
UISettings::values.shortcuts.clear();
|
||||||
|
|
||||||
for (auto group : hotkey_groups)
|
for (auto group : hotkey_groups)
|
||||||
{
|
{
|
||||||
settings.beginGroup(group.first);
|
|
||||||
for (auto hotkey : group.second)
|
for (auto hotkey : group.second)
|
||||||
{
|
{
|
||||||
settings.beginGroup(hotkey.first);
|
UISettings::values.shortcuts.push_back(UISettings::Shortcut(group.first + "/" + hotkey.first,
|
||||||
settings.setValue(QString("KeySeq"), hotkey.second.keyseq.toString());
|
UISettings::ContextedShortcut(hotkey.second.keyseq.toString(),
|
||||||
settings.setValue(QString("Context"), hotkey.second.context);
|
hotkey.second.context)));
|
||||||
settings.endGroup();
|
|
||||||
}
|
}
|
||||||
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()
|
// Make sure NOT to use a reference here because it would become invalid once we call beginGroup()
|
||||||
QStringList groups = settings.childGroups();
|
for (auto shortcut : UISettings::values.shortcuts)
|
||||||
for (auto group : groups)
|
|
||||||
{
|
{
|
||||||
settings.beginGroup(group);
|
QStringList cat = shortcut.first.split("/");
|
||||||
|
Q_ASSERT(cat.size() >= 2);
|
||||||
|
|
||||||
QStringList hotkeys = settings.childGroups();
|
// RegisterHotkey assigns default keybindings, so use old values as default parameters
|
||||||
for (auto hotkey : hotkeys)
|
Hotkey& hk = hotkey_groups[cat[0]][cat[1]];
|
||||||
|
if (!shortcut.second.first.isEmpty())
|
||||||
{
|
{
|
||||||
settings.beginGroup(hotkey);
|
hk.keyseq = QKeySequence::fromString(shortcut.second.first);
|
||||||
|
hk.context = (Qt::ShortcutContext)shortcut.second.second;
|
||||||
// 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();
|
|
||||||
}
|
}
|
||||||
|
if (hk.shortcut)
|
||||||
settings.endGroup();
|
hk.shortcut->setKey(hk.keyseq);
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterHotkey(const QString& group, const QString& action, const QKeySequence& default_keyseq, Qt::ShortcutContext default_context)
|
void RegisterHotkey(const QString& group, const QString& action, const QKeySequence& default_keyseq, Qt::ShortcutContext default_context)
|
||||||
|
|
|
@ -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.
|
* @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.
|
* Loads hotkeys from the settings file.
|
||||||
*
|
*
|
||||||
* @note Yet unregistered hotkeys which are present in the settings will automatically be registered.
|
* @note Yet unregistered hotkeys which are present in the settings will automatically be registered.
|
||||||
*/
|
*/
|
||||||
void LoadHotkeys(QSettings& settings);
|
void LoadHotkeys();
|
||||||
|
|
||||||
class GHotkeysDialog : public QWidget
|
class GHotkeysDialog : public QWidget
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "citra_qt/game_list.h"
|
#include "citra_qt/game_list.h"
|
||||||
#include "citra_qt/hotkeys.h"
|
#include "citra_qt/hotkeys.h"
|
||||||
#include "citra_qt/main.h"
|
#include "citra_qt/main.h"
|
||||||
|
#include "citra_qt/ui_settings.h"
|
||||||
|
|
||||||
// Debugger
|
// Debugger
|
||||||
#include "citra_qt/debugger/callstack.h"
|
#include "citra_qt/debugger/callstack.h"
|
||||||
|
@ -51,12 +52,10 @@
|
||||||
|
|
||||||
#include "video_core/video_core.h"
|
#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();
|
Pica::g_debug_context = Pica::DebugContext::Construct();
|
||||||
|
|
||||||
Config config;
|
|
||||||
|
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
statusBar()->hide();
|
statusBar()->hide();
|
||||||
|
|
||||||
|
@ -134,25 +133,21 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
|
||||||
setGeometry(x, y, w, h);
|
setGeometry(x, y, w, h);
|
||||||
|
|
||||||
// Restore UI state
|
// 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");
|
game_list->LoadInterfaceLayout();
|
||||||
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);
|
|
||||||
|
|
||||||
GDBStub::ToggleServer(Settings::values.use_gdbstub);
|
GDBStub::ToggleServer(Settings::values.use_gdbstub);
|
||||||
GDBStub::SetServerPort(static_cast<u32>(Settings::values.gdbstub_port));
|
GDBStub::SetServerPort(static_cast<u32>(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();
|
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());
|
OnDisplayTitleBars(ui.actionDisplay_widget_title_bars->isChecked());
|
||||||
|
|
||||||
// Prepare actions for recent files
|
// Prepare actions for recent files
|
||||||
|
@ -165,12 +160,10 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
|
||||||
}
|
}
|
||||||
UpdateRecentFiles();
|
UpdateRecentFiles();
|
||||||
|
|
||||||
confirm_before_closing = settings.value("confirmClose", true).toBool();
|
|
||||||
|
|
||||||
// Setup connections
|
// 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_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_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap()));
|
||||||
connect(ui.action_Select_Game_List_Root, SIGNAL(triggered()), this, SLOT(OnMenuSelectGameListRoot()));
|
connect(ui.action_Select_Game_List_Root, SIGNAL(triggered()), this, SLOT(OnMenuSelectGameListRoot()));
|
||||||
connect(ui.action_Start, SIGNAL(triggered()), this, SLOT(OnStartGame()));
|
connect(ui.action_Start, SIGNAL(triggered()), this, SLOT(OnStartGame()));
|
||||||
|
@ -191,7 +184,7 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
|
||||||
// Setup hotkeys
|
// Setup hotkeys
|
||||||
RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
|
RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
|
||||||
RegisterHotkey("Main Window", "Start Emulation");
|
RegisterHotkey("Main Window", "Start Emulation");
|
||||||
LoadHotkeys(settings);
|
LoadHotkeys();
|
||||||
|
|
||||||
connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, SLOT(OnMenuLoadFile()));
|
connect(GetHotkey("Main Window", "Load File", this), SIGNAL(activated()), this, SLOT(OnMenuLoadFile()));
|
||||||
connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, SLOT(OnStartGame()));
|
connect(GetHotkey("Main Window", "Start Emulation", this), SIGNAL(activated()), this, SLOT(OnStartGame()));
|
||||||
|
@ -201,7 +194,7 @@ GMainWindow::GMainWindow() : emu_thread(nullptr)
|
||||||
|
|
||||||
show();
|
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();
|
QStringList args = QApplication::arguments();
|
||||||
if (args.length() >= 2) {
|
if (args.length() >= 2) {
|
||||||
|
@ -365,32 +358,24 @@ void GMainWindow::ShutdownGame() {
|
||||||
emulation_running = false;
|
emulation_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::StoreRecentFile(const std::string& filename)
|
void GMainWindow::StoreRecentFile(const std::string& filename) {
|
||||||
{
|
UISettings::values.recent_files.prepend(QString::fromStdString(filename));
|
||||||
QSettings settings;
|
UISettings::values.recent_files.removeDuplicates();
|
||||||
QStringList recent_files = settings.value("recentFiles").toStringList();
|
while (UISettings::values.recent_files.size() > max_recent_files_item) {
|
||||||
recent_files.prepend(QString::fromStdString(filename));
|
UISettings::values.recent_files.removeLast();
|
||||||
recent_files.removeDuplicates();
|
|
||||||
while (recent_files.size() > max_recent_files_item) {
|
|
||||||
recent_files.removeLast();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.setValue("recentFiles", recent_files);
|
|
||||||
|
|
||||||
UpdateRecentFiles();
|
UpdateRecentFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::UpdateRecentFiles() {
|
void GMainWindow::UpdateRecentFiles() {
|
||||||
QSettings settings;
|
unsigned int num_recent_files = std::min(UISettings::values.recent_files.size(), static_cast<int>(max_recent_files_item));
|
||||||
QStringList recent_files = settings.value("recentFiles").toStringList();
|
|
||||||
|
|
||||||
unsigned int num_recent_files = std::min(recent_files.size(), static_cast<int>(max_recent_files_item));
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < num_recent_files; i++) {
|
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]->setText(text);
|
||||||
actions_recent_files[i]->setData(recent_files[i]);
|
actions_recent_files[i]->setData(UISettings::values.recent_files[i]);
|
||||||
actions_recent_files[i]->setToolTip(recent_files[i]);
|
actions_recent_files[i]->setToolTip(UISettings::values.recent_files[i]);
|
||||||
actions_recent_files[i]->setVisible(true);
|
actions_recent_files[i]->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,36 +396,28 @@ void GMainWindow::OnGameListLoadFile(QString game_path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnMenuLoadFile() {
|
void GMainWindow::OnMenuLoadFile() {
|
||||||
QSettings settings;
|
QString filename = QFileDialog::getOpenFileName(this, tr("Load File"), UISettings::values.roms_path, tr("3DS executable (*.3ds *.3dsx *.elf *.axf *.cci *.cxi)"));
|
||||||
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)"));
|
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
settings.setValue("romsPath", QFileInfo(filename).path());
|
UISettings::values.roms_path = QFileInfo(filename).path();
|
||||||
|
|
||||||
BootGame(filename.toLocal8Bit().data());
|
BootGame(filename.toLocal8Bit().data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnMenuLoadSymbolMap() {
|
void GMainWindow::OnMenuLoadSymbolMap() {
|
||||||
QSettings settings;
|
QString filename = QFileDialog::getOpenFileName(this, tr("Load Symbol Map"), UISettings::values.symbols_path, tr("Symbol map (*)"));
|
||||||
QString symbol_path = settings.value("symbolsPath", QString()).toString();
|
|
||||||
|
|
||||||
QString filename = QFileDialog::getOpenFileName(this, tr("Load Symbol Map"), symbol_path, tr("Symbol map (*)"));
|
|
||||||
if (!filename.isEmpty()) {
|
if (!filename.isEmpty()) {
|
||||||
settings.setValue("symbolsPath", QFileInfo(filename).path());
|
UISettings::values.symbols_path = QFileInfo(filename).path();
|
||||||
|
|
||||||
LoadSymbolMap(filename.toLocal8Bit().data());
|
LoadSymbolMap(filename.toLocal8Bit().data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnMenuSelectGameListRoot() {
|
void GMainWindow::OnMenuSelectGameListRoot() {
|
||||||
QSettings settings;
|
|
||||||
|
|
||||||
QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
|
QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
|
||||||
if (!dir_path.isEmpty()) {
|
if (!dir_path.isEmpty()) {
|
||||||
settings.setValue("gameListRootDir", dir_path);
|
UISettings::values.gamedir_path = dir_path;
|
||||||
game_list->PopulateAsync(dir_path, settings.value("gameListDeepScan").toBool());
|
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.
|
// 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));
|
QMessageBox::information(this, tr("File not found"), tr("File \"%1\" not found").arg(filename));
|
||||||
|
|
||||||
QSettings settings;
|
UISettings::values.recent_files.removeOne(filename);
|
||||||
QStringList recent_files = settings.value("recentFiles").toStringList();
|
|
||||||
recent_files.removeOne(filename);
|
|
||||||
settings.setValue("recentFiles", recent_files);
|
|
||||||
UpdateRecentFiles();
|
UpdateRecentFiles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -536,23 +510,18 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save window layout
|
UISettings::values.geometry = saveGeometry();
|
||||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Citra team", "Citra");
|
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");
|
UISettings::values.single_window_mode = ui.action_Single_Window_Mode->isChecked();
|
||||||
settings.setValue("geometry", saveGeometry());
|
UISettings::values.display_titlebar = ui.actionDisplay_widget_title_bars->isChecked();
|
||||||
settings.setValue("state", saveState());
|
UISettings::values.first_start = false;
|
||||||
settings.setValue("geometryRenderWindow", render_window->saveGeometry());
|
|
||||||
settings.setValue("microProfileDialogGeometry", microProfileDialog->saveGeometry());
|
|
||||||
settings.setValue("microProfileDialogVisible", microProfileDialog->isVisible());
|
|
||||||
settings.endGroup();
|
|
||||||
|
|
||||||
settings.setValue("singleWindowMode", ui.action_Single_Window_Mode->isChecked());
|
game_list->SaveInterfaceLayout();
|
||||||
settings.setValue("displayTitleBars", ui.actionDisplay_widget_title_bars->isChecked());
|
SaveHotkeys();
|
||||||
settings.setValue("firstStart", false);
|
|
||||||
settings.setValue("confirmClose", confirm_before_closing);
|
|
||||||
game_list->SaveInterfaceLayout(settings);
|
|
||||||
SaveHotkeys(settings);
|
|
||||||
|
|
||||||
// Shutdown session if the emu thread is active...
|
// Shutdown session if the emu thread is active...
|
||||||
if (emu_thread != nullptr)
|
if (emu_thread != nullptr)
|
||||||
|
@ -577,7 +546,6 @@ int main(int argc, char* argv[]) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Init settings params
|
// Init settings params
|
||||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
|
||||||
QCoreApplication::setOrganizationName("Citra team");
|
QCoreApplication::setOrganizationName("Citra team");
|
||||||
QCoreApplication::setApplicationName("Citra");
|
QCoreApplication::setApplicationName("Citra");
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "ui_main.h"
|
#include "ui_main.h"
|
||||||
|
|
||||||
|
class Config;
|
||||||
class GameList;
|
class GameList;
|
||||||
class GImageInfo;
|
class GImageInfo;
|
||||||
class GRenderWindow;
|
class GRenderWindow;
|
||||||
|
@ -114,6 +115,8 @@ private:
|
||||||
GRenderWindow* render_window;
|
GRenderWindow* render_window;
|
||||||
GameList* game_list;
|
GameList* game_list;
|
||||||
|
|
||||||
|
std::unique_ptr<Config> config;
|
||||||
|
|
||||||
// Whether emulation is currently running in Citra.
|
// Whether emulation is currently running in Citra.
|
||||||
bool emulation_running = false;
|
bool emulation_running = false;
|
||||||
std::unique_ptr<EmuThread> emu_thread;
|
std::unique_ptr<EmuThread> emu_thread;
|
||||||
|
|
|
@ -5,10 +5,42 @@
|
||||||
#ifndef UISETTINGS_H
|
#ifndef UISETTINGS_H
|
||||||
#define UISETTINGS_H
|
#define UISETTINGS_H
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace UISettings {
|
namespace UISettings {
|
||||||
|
|
||||||
|
typedef std::pair<QString, int> ContextedShortcut;
|
||||||
|
typedef std::pair<QString, ContextedShortcut> Shortcut;
|
||||||
|
|
||||||
struct Values {
|
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 check_closure;
|
||||||
|
bool first_start;
|
||||||
|
|
||||||
|
QString roms_path;
|
||||||
|
QString symbols_path;
|
||||||
|
QString gamedir_path;
|
||||||
|
bool gamedir_deepscan;
|
||||||
|
QStringList recent_files;
|
||||||
|
|
||||||
|
// Shortcut name <Shortcut, context>
|
||||||
|
std::vector<Shortcut> shortcuts;
|
||||||
} extern values;
|
} extern values;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue