From 52042f0e78c5dbbfed66abf2a67548d04a641aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 22 Oct 2026 14:59:05 +0200 Subject: [PATCH] TabbedDialog: Remove the old search filter Every screen with a search tab now uses settings pages, so the filter that hid non-matching views and disabled tabs, the filter notice above the tabs, and the GAMESETTINGS_SEARCH message are gone. Co-Authored-By: Claude Opus 5.5 (1M context) --- Common/System/System.h | 1 - UI/TabbedDialogScreen.cpp | 115 +------------------------------------- UI/TabbedDialogScreen.h | 10 ---- 3 files changed, 2 insertions(+), 124 deletions(-) diff --git a/Common/System/System.h b/Common/System/System.h index 741ccce696..749ffd977e 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -312,7 +312,6 @@ enum class UIMessage { POSTSHADER_UPDATED, ACHIEVEMENT_LOGIN_STATE_CHANGE, SAVESTATE_DISPLAY_SLOT, - GAMESETTINGS_SEARCH, SAVEDATA_SEARCH, RESTART_GRAPHICS, RECENT_FILES_CHANGED, diff --git a/UI/TabbedDialogScreen.cpp b/UI/TabbedDialogScreen.cpp index 2755dfd042..6bb31f055f 100644 --- a/UI/TabbedDialogScreen.cpp +++ b/UI/TabbedDialogScreen.cpp @@ -83,14 +83,6 @@ void UITabbedBaseDialogScreen::CreateViews() { // Scrolling action menu to the right. using namespace UI; - // Only created with the search tab, which depends on the orientation, so may not be there this time. - clearSearchChoice_ = nullptr; - noSearchResults_ = nullptr; - - auto se = GetI18NCategory(I18NCat::SEARCH); - filterNotice_ = new TextView("(filter notice, you shouldn't see this text", new LinearLayoutParams(Margins(20, 5))); - filterNotice_->SetVisibility(V_GONE); - if (portrait) { auto di = GetI18NCategory(I18NCat::DIALOG); LinearLayout *verticalLayout = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT)); @@ -107,7 +99,7 @@ void UITabbedBaseDialogScreen::CreateViews() { }, nullptr)); }; } - tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 200, tabHolderFlags, filterNotice_, contextMenu, new LinearLayoutParams(1.0f)); + tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 200, tabHolderFlags, nullptr, contextMenu, new LinearLayoutParams(1.0f)); verticalLayout->Add(tabHolder_); if (!(flags_ & TabDialogFlags::ContextMenuInPortrait)) { CreateExtraButtons(verticalLayout, 0); @@ -118,7 +110,7 @@ void UITabbedBaseDialogScreen::CreateViews() { if (flags_ & TabDialogFlags::VerticalShowIcons) { tabHolderFlags |= TabHolderFlags::VerticalShowIcons; } - tabHolder_ = new TabHolder(ORIENT_VERTICAL, 300, tabHolderFlags, filterNotice_, nullptr, new AnchorLayoutParams(10, 0, 0, 0)); + tabHolder_ = new TabHolder(ORIENT_VERTICAL, 300, tabHolderFlags, nullptr, nullptr, new AnchorLayoutParams(10, 0, 0, 0)); CreateExtraButtons(tabHolder_->Container(), 10); tabHolder_->AddBack(this); root_ = tabHolder_; @@ -146,24 +138,6 @@ void UITabbedBaseDialogScreen::CreateViews() { AddTab("GameSettingsSearch", ms->T("Search"), ImageID("I_SEARCH"), [this](UI::LinearLayout *parent) { CreateSearchTab(parent); }); - } else if (ShowSearchControls() && CanShowSearch()) { - auto ms = GetI18NCategory(I18NCat::MAINSETTINGS); - AddTab("GameSettingsSearch", ms->T("Search"), ImageID("I_SEARCH"), [this](UI::LinearLayout *searchSettings) { - auto se = GetI18NCategory(I18NCat::SEARCH); - - searchSettings->Add(new ItemHeader(se->T("Find settings"))); - searchSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &searchFilter_, se->T("Filter"), "", 64, screenManager()))->OnChange.Add([this](UI::EventParams &e) { - System_PostUIMessage(UIMessage::GAMESETTINGS_SEARCH, StripSpaces(searchFilter_)); - }); - - clearSearchChoice_ = searchSettings->Add(new Choice(se->T("Clear filter"))); - clearSearchChoice_->OnClick.Add([](UI::EventParams &e) { - System_PostUIMessage(UIMessage::GAMESETTINGS_SEARCH, ""); - }); - clearSearchChoice_->SetVisibility(searchFilter_.empty() ? UI::V_GONE : UI::V_VISIBLE); - - noSearchResults_ = searchSettings->Add(new TextView("", new LinearLayoutParams(Margins(20, 5)))); - }); } // After the search tab, which the saved tab can be. @@ -172,22 +146,6 @@ void UITabbedBaseDialogScreen::CreateViews() { } else { tabHolder_->EnsureTab(tabHolder_->GetCurrentTab()); } - - // Need to handle recreates, both important and accidental ones. - if (!searchFilter_.empty()) { - ApplySearchFilter(); - } -} - -void UITabbedBaseDialogScreen::sendMessage(UIMessage message, const char *value) { - UIBaseDialogScreen::sendMessage(message, value); - if (message == UIMessage::GAMESETTINGS_SEARCH) { - std::string filter = value ? value : ""; - searchFilter_.resize(filter.size()); - std::transform(filter.begin(), filter.end(), searchFilter_.begin(), tolower); - - ApplySearchFilter(); - } } void UITabbedBaseDialogScreen::EnsureTabs() { @@ -214,75 +172,6 @@ bool UITabbedBaseDialogScreen::CanShowSearch() { return (g_display.dp_xres < g_display.dp_yres || g_display.dp_yres >= 500) && deviceType != DEVICE_TYPE_VR; } -void UITabbedBaseDialogScreen::ApplySearchFilter() { - using namespace UI; - // GAMESETTINGS_SEARCH is broadcast to every screen, including ones whose views don't exist yet, - // and ones that search some other way. - if (!tabHolder_ || !ShowSearchControls()) { - return; - } - auto se = GetI18NCategory(I18NCat::SEARCH); - - EnsureTabs(); - - // Show an indicator that a filter is applied. - filterNotice_->SetVisibility(searchFilter_.empty() ? UI::V_GONE : UI::V_VISIBLE); - filterNotice_->SetText(ApplySafeSubstitutions(se->T("Filtering settings by '%1'"), searchFilter_)); - - bool matches = searchFilter_.empty(); - - const std::vector settingTabs = tabHolder_->GetTabContentViews(); - - for (int t = 0; t < (int)settingTabs.size(); ++t) { - const ViewGroup *tabContents = settingTabs[t]; - std::string_view tag = tabContents->Tag(); - - // Dive down to the actual list of settings. - // TODO: Do this recursively instead. - while (tabContents->GetNumSubviews() == 1) { - View *v = tabContents->GetViewByIndex(0); - if (v->IsViewGroup()) { - tabContents = (ViewGroup *)v; - } else { - break; - } - } - - if (tag == "GameSettingsSearch") { - continue; - } - - bool tabMatches = searchFilter_.empty(); - - UI::View *lastHeading = nullptr; - for (int i = 1; i < tabContents->GetNumSubviews(); ++i) { - UI::View *v = tabContents->GetViewByIndex(i); - if (!v->CanBeFocused()) { - lastHeading = v; - } - - std::string label = v->DescribeText(); - std::transform(label.begin(), label.end(), label.begin(), tolower); - bool match = v->CanBeFocused() && label.find(searchFilter_) != label.npos; - tabMatches = tabMatches || match; - - if (match && lastHeading) - lastHeading->SetVisibility(UI::V_VISIBLE); - v->SetVisibility((searchFilter_.empty() || match) ? UI::V_VISIBLE : UI::V_GONE); - } - tabHolder_->EnableTab(t, tabMatches); - matches = matches || tabMatches; - } - - if (noSearchResults_) { - noSearchResults_->SetText(ApplySafeSubstitutions(se->T("No settings matched '%1'"), searchFilter_)); - noSearchResults_->SetVisibility(matches ? UI::V_GONE : UI::V_VISIBLE); - } - if (clearSearchChoice_) { - clearSearchChoice_->SetVisibility(searchFilter_.empty() ? UI::V_GONE : UI::V_VISIBLE); - } -} - static bool SettingTextMatches(const SettingText &text, I18NCat pageCat, std::string_view query) { if (text.empty()) { return false; diff --git a/UI/TabbedDialogScreen.h b/UI/TabbedDialogScreen.h index 9afb115487..8ec0c3af8f 100644 --- a/UI/TabbedDialogScreen.h +++ b/UI/TabbedDialogScreen.h @@ -62,10 +62,7 @@ protected: // Whether there's room and a way to type a search. static bool CanShowSearch(); - void sendMessage(UIMessage message, const char *value) override; - private: - void ApplySearchFilter(); void CreateSearchTab(UI::LinearLayout *parent); void GoToSetting(int settingsTab, int itemIndex); @@ -82,13 +79,6 @@ private: UI::View *pendingFocusView_ = nullptr; UI::TabHolder *tabHolder_ = nullptr; - UI::TextView *filterNotice_ = nullptr; - UI::Choice *clearSearchChoice_ = nullptr; - UI::TextView *noSearchResults_ = nullptr; - - // If we recreate the views while this is active we show it again - std::string oldSettingInfo_; - std::string searchFilter_; int *currentTabSetting_ = nullptr;