From 7e98245ca47ff2ea0203930049cc725b4c433f72 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 5 Apr 2026 11:27:56 +0200 Subject: [PATCH 1/2] DolphinQt: Remove Presets from GameConfigEdit Back in 2018, a Presets system was added to DolphinQt's GameConfigEdit. Presets was a dropdown menu where you could select a particular setting to add to your custom game INI. Only a small number of settings were made available, with the intent that more would be added over time. 8 years later, the set of available settings hasn't been expanded at all, and I don't know of anyone who uses these presets. On top of this, we have now made good progress in exposing per-game settings graphically. I think the Presets system is best off removed. In place of the Presets menu, we now have "Refresh" and "Open in External Editor" buttons. These more useful actions were previously hidden away in the Presets menu. --- .../Core/DolphinQt/Config/GameConfigEdit.cpp | 109 +++--------------- Source/Core/DolphinQt/Config/GameConfigEdit.h | 9 +- 2 files changed, 16 insertions(+), 102 deletions(-) diff --git a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp index 3c49fcae05..e43c222293 100644 --- a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp +++ b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp @@ -7,9 +7,8 @@ #include #include #include +#include #include -#include -#include #include #include #include @@ -72,7 +71,6 @@ GameConfigEdit::GameConfigEdit(QWidget* parent, QString path, bool read_only) m_completer->setCompletionMode(QCompleter::PopupCompletion); m_completer->setWidget(m_edit); - AddMenubarOptions(); ConnectWidgets(); } @@ -82,17 +80,15 @@ void GameConfigEdit::CreateWidgets() m_edit->setReadOnly(m_read_only); m_edit->setAcceptRichText(false); + m_refresh_button = new QPushButton(tr("Refresh")); + m_external_editor_button = new QPushButton(tr("Open in External Editor")); + + auto* button_layout = new QHBoxLayout; + button_layout->addWidget(m_refresh_button); + button_layout->addWidget(m_external_editor_button); + auto* layout = new QVBoxLayout; - - auto* menu_button = new QPushButton; - - menu_button->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); - menu_button->setText(tr("Presets")); - - m_menu = new QMenu(menu_button); - menu_button->setMenu(m_menu); - - layout->addWidget(menu_button); + layout->addLayout(button_layout); layout->addWidget(m_edit); setLayout(layout); @@ -138,6 +134,10 @@ void GameConfigEdit::ConnectWidgets() connect(m_edit, &QTextEdit::selectionChanged, this, &GameConfigEdit::OnSelectionChanged); connect(m_completer, qOverload(&QCompleter::activated), this, &GameConfigEdit::OnAutoComplete); + + connect(m_refresh_button, &QPushButton::clicked, this, &GameConfigEdit::LoadFile); + connect(m_external_editor_button, &QPushButton::clicked, this, + &GameConfigEdit::OpenExternalEditor); } void GameConfigEdit::OnSelectionChanged() @@ -148,47 +148,6 @@ void GameConfigEdit::OnSelectionChanged() QWhatsThis::showText(QCursor::pos(), m_keyword_map[keyword], this); } -void GameConfigEdit::AddBoolOption(QMenu* menu, const QString& name, const QString& section, - const QString& key) -{ - auto* option = menu->addMenu(name); - - option->addAction(tr("On"), this, - [this, section, key] { SetOption(section, key, QStringLiteral("True")); }); - option->addAction(tr("Off"), this, - [this, section, key] { SetOption(section, key, QStringLiteral("False")); }); -} - -void GameConfigEdit::SetOption(const QString& section, const QString& key, const QString& value) -{ - auto section_cursor = - m_edit->document()->find(QRegularExpression(QStringLiteral("^\\[%1\\]").arg(section)), 0); - - // Check if the section this belongs in can be found - if (section_cursor.isNull()) - { - m_edit->append(QStringLiteral("[%1]\n\n%2 = %3\n").arg(section).arg(key).arg(value)); - } - else - { - auto value_cursor = m_edit->document()->find( - QRegularExpression(QStringLiteral("^%1 = .*").arg(key)), section_cursor); - - const QString new_line = QStringLiteral("%1 = %2").arg(key).arg(value); - - // Check if the value that has to be set already exists - if (value_cursor.isNull()) - { - section_cursor.clearSelection(); - section_cursor.insertText(QLatin1Char{'\n'} + new_line); - } - else - { - value_cursor.insertText(new_line); - } - } -} - QString GameConfigEdit::GetTextUnderCursor() { QTextCursor tc = m_edit->textCursor(); @@ -196,48 +155,6 @@ QString GameConfigEdit::GetTextUnderCursor() return tc.selectedText(); } -void GameConfigEdit::AddMenubarOptions() -{ - auto* editor = m_menu->addMenu(tr("Editor")); - - editor->addAction(tr("Refresh"), this, &GameConfigEdit::LoadFile); - editor->addAction(tr("Open in External Editor"), this, &GameConfigEdit::OpenExternalEditor); - - if (!m_read_only) - { - m_menu->addSeparator(); - auto* core_menubar = m_menu->addMenu(tr("Core")); - - AddBoolOption(core_menubar, tr("Dual Core"), QStringLiteral("Core"), - QStringLiteral("CPUThread")); - AddBoolOption(core_menubar, tr("MMU"), QStringLiteral("Core"), QStringLiteral("MMU")); - - auto* video_menubar = m_menu->addMenu(tr("Video")); - - AddBoolOption(video_menubar, tr("Store EFB Copies to Texture Only"), - QStringLiteral("Video_Hacks"), QStringLiteral("EFBToTextureEnable")); - - AddBoolOption(video_menubar, tr("Store XFB Copies to Texture Only"), - QStringLiteral("Video_Hacks"), QStringLiteral("XFBToTextureEnable")); - - { - auto* texture_cache = video_menubar->addMenu(tr("Texture Cache")); - texture_cache->addAction(tr("Safe"), this, [this] { - SetOption(QStringLiteral("Video_Settings"), QStringLiteral("SafeTextureCacheColorSamples"), - QStringLiteral("0")); - }); - texture_cache->addAction(tr("Medium"), this, [this] { - SetOption(QStringLiteral("Video_Settings"), QStringLiteral("SafeTextureCacheColorSamples"), - QStringLiteral("512")); - }); - texture_cache->addAction(tr("Fast"), this, [this] { - SetOption(QStringLiteral("Video_Settings"), QStringLiteral("SafeTextureCacheColorSamples"), - QStringLiteral("128")); - }); - } - } -} - void GameConfigEdit::OnAutoComplete(const QString& completion) { QTextCursor cursor = m_edit->textCursor(); diff --git a/Source/Core/DolphinQt/Config/GameConfigEdit.h b/Source/Core/DolphinQt/Config/GameConfigEdit.h index 1fceaedb8a..73184c2b13 100644 --- a/Source/Core/DolphinQt/Config/GameConfigEdit.h +++ b/Source/Core/DolphinQt/Config/GameConfigEdit.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include #include @@ -24,7 +25,6 @@ protected: private: void CreateWidgets(); void ConnectWidgets(); - void AddMenubarOptions(); void LoadFile(); void SaveFile(); @@ -35,15 +35,12 @@ private: QString GetTextUnderCursor(); - void AddBoolOption(QMenu* menu, const QString& name, const QString& section, const QString& key); - - void SetOption(const QString& section, const QString& key, const QString& value); - void AddDescription(const QString& keyword, const QString& description); QCompleter* m_completer; QStringList m_completions; - QMenu* m_menu; + QPushButton* m_refresh_button; + QPushButton* m_external_editor_button; QTextEdit* m_edit; const QString m_path; From 5fcdb6f8f9a5a0cb5fbc3e0e201119b832eef03c Mon Sep 17 00:00:00 2001 From: JosJuice Date: Mon, 6 Apr 2026 17:59:45 +0200 Subject: [PATCH 2/2] DolphinQt: Hide buttons for read-only game config The Open in External Editor button makes editing a game INI file easy, and the Refresh button is only useful if you edit the game INI. You're not supposed to edit read-only game INIs, so let's not show these two buttons for read-only game INIs. I implemented this by hiding the buttons instead of not creating them in the first place so we don't have to branch on whether the buttons exist in GameConfigEdit::ConnectWidgets. --- Source/Core/DolphinQt/Config/GameConfigEdit.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp index e43c222293..9d9f79848e 100644 --- a/Source/Core/DolphinQt/Config/GameConfigEdit.cpp +++ b/Source/Core/DolphinQt/Config/GameConfigEdit.cpp @@ -83,6 +83,12 @@ void GameConfigEdit::CreateWidgets() m_refresh_button = new QPushButton(tr("Refresh")); m_external_editor_button = new QPushButton(tr("Open in External Editor")); + if (m_read_only) + { + m_refresh_button->hide(); + m_external_editor_button->hide(); + } + auto* button_layout = new QHBoxLayout; button_layout->addWidget(m_refresh_button); button_layout->addWidget(m_external_editor_button);