Qt: Add GUI for game-specific settings (#3533)

* Open settings dialog from context menu

* initial version complete

* add context menu item to delete game config if it exists

* Create game config from base value instead of default value

* Require confirmation before deleting game configs with menu item

* fix rebase

* Reset game specific values when creating a new game config

* Add icon for entries with game config

* clang format

* Add submenu for game-specific settings

* Log if game-specific config exists, remove hidden tab from tab selection

* Add other experimental options to game-specific GUI

* clang format

* Add flag to specify if game-specific file needs creation

* refactor: remove additional arguments, reset game-specific status on save instead

* Fix return

* cleanup - remove unneeded load

* Set tab to general if hidden tab is set as default

* Cleanup variable names and strings, default tab fix, volumeslider fix

* cleanup: missed a couple of variables to standardize

* More readable way to reset volume slider
This commit is contained in:
rainmakerv2
2025-09-10 17:18:39 +08:00
committed by GitHub
parent 4abc6b3010
commit 319db3bebe
13 changed files with 893 additions and 625 deletions

View File

@@ -17,6 +17,7 @@
#include "compatibility_info.h"
#include "game_info.h"
#include "gui_settings.h"
#include "settings_dialog.h"
#include "trophy_viewer.h"
#ifdef Q_OS_WIN
@@ -66,6 +67,24 @@ public:
menu.addMenu(openFolderMenu);
QMenu* gameConfigMenu = new QMenu(tr("Game-specific Settings..."), widget);
QAction gameConfigConfigure(tr("Configure Game-specific Settings"), widget);
QAction gameConfigCreate(tr("Create Game-specific Settings from Global Settings"), widget);
QAction gameConfigDelete(tr("Delete Game-specific Settings"), widget);
if (std::filesystem::exists(Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) /
(m_games[itemID].serial + ".toml"))) {
gameConfigMenu->addAction(&gameConfigConfigure);
} else {
gameConfigMenu->addAction(&gameConfigCreate);
}
if (std::filesystem::exists(Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) /
(m_games[itemID].serial + ".toml")))
gameConfigMenu->addAction(&gameConfigDelete);
menu.addMenu(gameConfigMenu);
QString serialStr = QString::fromStdString(m_games[itemID].serial);
QList<QString> list = gui_settings::Var2List(m_gui_settings->GetValue(gui::favorites_list));
bool isFavorite = list.contains(serialStr);
@@ -76,6 +95,7 @@ public:
} else {
toggleFavorite = new QAction(tr("Add to Favorites"), widget);
}
QAction createShortcut(tr("Create Shortcut"), widget);
QAction openCheats(tr("Cheats / Patches"), widget);
QAction openSfoViewer(tr("SFO Viewer"), widget);
@@ -123,9 +143,9 @@ public:
// Compatibility submenu.
QMenu* compatibilityMenu = new QMenu(tr("Compatibility..."), widget);
QAction* updateCompatibility = new QAction(tr("Update database"), widget);
QAction* viewCompatibilityReport = new QAction(tr("View report"), widget);
QAction* submitCompatibilityReport = new QAction(tr("Submit a report"), widget);
QAction* updateCompatibility = new QAction(tr("Update Database"), widget);
QAction* viewCompatibilityReport = new QAction(tr("View Report"), widget);
QAction* submitCompatibilityReport = new QAction(tr("Submit a Report"), widget);
compatibilityMenu->addAction(updateCompatibility);
compatibilityMenu->addAction(viewCompatibilityReport);
@@ -387,6 +407,22 @@ public:
[trophyViewer]() { trophyViewer->deleteLater(); });
}
if (selected == &gameConfigConfigure || selected == &gameConfigCreate) {
auto settingsWindow = new SettingsDialog(m_gui_settings, m_compat_info, widget, true,
serialStr.toStdString());
settingsWindow->exec();
}
if (selected == &gameConfigDelete) {
if (QMessageBox::Yes == QMessageBox::question(widget, tr("Confirm deletion"),
tr("Delete game-specific settings?"),
QMessageBox::Yes | QMessageBox::No)) {
std::filesystem::remove(
Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs) /
(m_games[itemID].serial + ".toml"));
}
}
if (selected == &createShortcut) {
QString targetPath;
Common::FS::PathToQString(targetPath, m_games[itemID].path);