From cd4bc7ff4edc3a0463df6fd0ae4a86325aff7539 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 14 Aug 2026 08:09:56 +0900 Subject: [PATCH] feat: add descriptive tooltips to filters --- dzgui/managers/filter.py | 20 ++++++++++++++++++++ dzgui/views/components/filter_panel.py | 12 ++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/dzgui/managers/filter.py b/dzgui/managers/filter.py index 634bf8b..923dd79 100644 --- a/dzgui/managers/filter.py +++ b/dzgui/managers/filter.py @@ -29,6 +29,22 @@ class FilterManager: strings.filter_modded: True, } + # TODO: strings + self.tooltips = { + strings.filter_1pp: "First-person perspective", + strings.filter_day: "In-game time between 0700 and 1659", + strings.filter_empty: "Servers contain no players", + strings.filter_3pp: "Third-person perspective", + strings.filter_night: "In-game time between 1700 and 0659", + strings.filter_full: "Servers have no open slots", + strings.filter_official: "Bohemia official servers", + strings.filter_nonascii: "Server names using non-standard, complex glyphs", + strings.filter_lowpop: "Current population is under 30%", + strings.filter_unofficial: "Third-party servers", + strings.filter_duplicate: "Duplicate of existing servers (usually spoofed)", + strings.filter_modded: "Server has one or more mods", + } + self.active_keyword = "" self.active_map = (0, all_maps) self.prior_map = all_maps @@ -36,6 +52,9 @@ class FilterManager: self.filters: list self.enabled_filters = dict(self.default_filters) + def get_tooltips(self) -> dict[str, str]: + return self.tooltips + def set_prior_map(self, name: str) -> None: self.prior_map = name @@ -86,6 +105,7 @@ class FilterManager: self.reinit_map_store() maps.sort() for m in maps: + # TODO: strings if m == "All maps": continue self.append_map([m]) diff --git a/dzgui/views/components/filter_panel.py b/dzgui/views/components/filter_panel.py index 4554cf8..b93f06f 100644 --- a/dzgui/views/components/filter_panel.py +++ b/dzgui/views/components/filter_panel.py @@ -29,7 +29,7 @@ if TYPE_CHECKING: class ButtonGrid(Gtk.Grid): - def __init__(self, controller: "Controller", defaults: dict) -> None: + def __init__(self, controller: "Controller", defaults: dict[str, str], tooltips: dict[str, str]) -> None: super().__init__( halign=Gtk.Align.CENTER, column_spacing=5, column_homogeneous=True ) @@ -44,6 +44,13 @@ class ButtonGrid(Gtk.Grid): for check in defaults.keys(): checkbox = Gtk.CheckButton(label=check) + try: + tt = tooltips[check] + except Exception as e: + logger.debug(e) + tt = "" + + checkbox.set_tooltip_text(tt) label = checkbox.get_child() if label is not None: label.set_ellipsize(Pango.EllipsizeMode.END) # type: ignore @@ -161,11 +168,12 @@ class FilterPanel(Gtk.Box): filter_man = self.controller.get_filter_man() defaults = filter_man.get_default_filters() + tooltips = filter_man.get_tooltips() self.map_store = filter_man.get_map_store() self.enabled_filters = defaults self.keyword_entry = KeywordEntry(self.controller) - self.button_grid = ButtonGrid(self.controller, defaults) + self.button_grid = ButtonGrid(self.controller, defaults, tooltips) # TODO: strings self.filters_label = BoldLabel("Filters")