From 4303e086bf880d2f0658fe5df38390851e3815c8 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Sun, 27 Apr 2025 11:40:51 -0700 Subject: [PATCH] EnhancementsWidget: Fix display of default post-processing effect Show "(off)" instead of "" when the default post-processing effect is selected. This also indirectly fixes issues with keyboard navigation of the post-processing effect combobox when the default is selected, resolving https://bugs.dolphin-emu.org/issues/13863. m_post_processing_effect was previously using the ConfigStringChoice constructor that assumes the text and data of each option are identical. This is true for all the other effects, but since "(off)" has the config value of "" this assumption was failing for it, causing the combobox to be blank. --- .../Config/Graphics/EnhancementsWidget.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp index 0e10eea187..a8eb606a5c 100644 --- a/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp +++ b/Source/Core/DolphinQt/Config/Graphics/EnhancementsWidget.cpp @@ -137,8 +137,12 @@ void EnhancementsWidget::CreateWidgets() m_configure_color_correction = new ToolTipPushButton(tr("Configure")); - m_post_processing_effect = new ConfigStringChoice(VideoCommon::PostProcessing::GetShaderList(), - Config::GFX_ENHANCE_POST_SHADER, m_game_layer); + // The post-processing effect "(off)" has the config value "", so we need to use the constructor + // that sets ConfigStringChoice's m_text_is_data to false. m_post_processing_effect is cleared in + // LoadPostProcessingShaders so it's pointless to fill it with real data here. + const std::vector> separate_data_and_text; + m_post_processing_effect = + new ConfigStringChoice(separate_data_and_text, Config::GFX_ENHANCE_POST_SHADER, m_game_layer); m_configure_post_processing_effect = new NonDefaultQPushButton(tr("Configure")); m_configure_post_processing_effect->setDisabled(true); @@ -287,7 +291,7 @@ void EnhancementsWidget::LoadPostProcessingShaders() // Populate widget if (stereo_mode != StereoMode::Anaglyph && stereo_mode != StereoMode::Passive) - m_post_processing_effect->addItem(tr("(off)")); + m_post_processing_effect->addItem(tr("(off)"), QStringLiteral("")); auto selected_shader = ReadSetting(Config::GFX_ENHANCE_POST_SHADER); @@ -295,7 +299,8 @@ void EnhancementsWidget::LoadPostProcessingShaders() for (const auto& shader : shaders) { - m_post_processing_effect->addItem(QString::fromStdString(shader)); + const QString name = QString::fromStdString(shader); + m_post_processing_effect->addItem(name, name); if (selected_shader == shader) { m_post_processing_effect->setCurrentIndex(m_post_processing_effect->count() - 1); @@ -314,7 +319,7 @@ void EnhancementsWidget::LoadPostProcessingShaders() selected_shader = ""; const int index = - std::max(0, m_post_processing_effect->findText(QString::fromStdString(selected_shader))); + std::max(0, m_post_processing_effect->findData(QString::fromStdString(selected_shader))); m_post_processing_effect->setCurrentIndex(index); // Save forced shader, but avoid forcing an option into a game ini layer.