Settings: Clicking the current tab goes back up to its root page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-11-10 13:06:28 +01:00
1 parent 7cb6276a00
commit e57c8ba756
6 files changed
+29

No files matched your search

+7
View File
@@ -244,6 +244,13 @@ void TabHolder::OnTabClick(EventParams &e) {
// We have e.b set when it was an explicit click action.
// In that case, we make the view gone and then visible - this scrolls scrollviews to the top.
if (e.b != 0) {
if ((int)e.a == currentTab_) {
UI::EventParams e2{};
e2.v = this;
e2.a = currentTab_;
OnReselectTab.Trigger(e2);
return;
}
// SetCurrentTab calls EnsureTab if needed.
SetCurrentTab((int)e.a);
}
+2
View File
@@ -53,6 +53,8 @@ public:
bool EnsureTab(int index); // return true if it actually created a tab.
Event OnChangeTab;
// A click on the tab that's already shown.
Event OnReselectTab;
private:
void AddTabContents(std::string_view title, ImageID imageId, ViewGroup *tabContents);
+14
View File
@@ -594,3 +594,17 @@ int SettingsPagesDialogScreen::InitialTab() {
void SettingsPagesDialogScreen::TabChanged(int tab) {
SetSearchText("");
}
// Picking the tab that's shown leaves the search, and goes back up to the tab's root page.
void SettingsPagesDialogScreen::TabReselected(int tab) {
SetSearchText("");
int settingsTab = CurrentSettingsTab();
if (settingsTab < 0) {
return;
}
const std::vector<int> &path = pagePaths_[settingsTabs_[settingsTab].tag];
if (path.empty()) {
return;
}
ShowPage(settingsTab, {}, path[0]); // Focuses the link to the page we're leaving.
}
+1
View File
@@ -58,6 +58,7 @@ protected:
// with the page, like lists read from disk, doesn't need to be read again.
bool RecreatingForPageChange() const { return pageChange_; }
void TabChanged(int tab) override;
void TabReselected(int tab) override;
// Whether there's a way to type a search.
static bool CanShowSearch();
+3
View File
@@ -111,6 +111,9 @@ void UITabbedBaseDialogScreen::CreateViews() {
}
TabChanged(e.a);
});
tabHolder_->OnReselectTab.Add([this](UI::EventParams &e) {
TabReselected(e.a);
});
int initialTab = InitialTab();
if (initialTab >= 0) {
+2
View File
@@ -50,6 +50,8 @@ protected:
// The tab to show first, after CreateTabs, if not the saved one (-1).
virtual int InitialTab() { return -1; }
virtual void TabChanged(int tab) {}
// The tab already shown was clicked.
virtual void TabReselected(int tab) {}
int GetCurrentTab() const;
void SetCurrentTab(int tab);