feat: add descriptive tooltips to filters

This commit is contained in:
aclist 2026-08-14 08:09:56 +09:00
parent b209c9912d
commit cd4bc7ff4e
2 changed files with 30 additions and 2 deletions

View File

@ -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])

View File

@ -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")