mirror of
https://github.com/aclist/dztui.git
synced 2026-08-25 17:32:36 +02:00
feat: add descriptive tooltips to filters
This commit is contained in:
parent
b209c9912d
commit
cd4bc7ff4e
@ -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])
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user