From 516fa2e6731c54800979a297765e8b505ea79085 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 1 Dec 2023 18:23:04 +0100 Subject: [PATCH] quick_frontend, tui: fix name conflict with `show_resources` --- .../quick_frontend/quick_contact_list.py | 23 +++++++++++++++---- libervia/tui/contact_list.py | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/libervia/frontends/quick_frontend/quick_contact_list.py b/libervia/frontends/quick_frontend/quick_contact_list.py index 86bd3c80..21df7dc9 100644 --- a/libervia/frontends/quick_frontend/quick_contact_list.py +++ b/libervia/frontends/quick_frontend/quick_contact_list.py @@ -84,7 +84,7 @@ class ProfileContactList(object): # options self.show_disconnected = False self._show_empty_groups = True - self.show_resources = False + self._show_resources = False self.show_status = False # do we show entities with notifications? # if True, entities will be show even if they normally would not @@ -765,11 +765,16 @@ class ProfileContactList(object): self._show_empty_groups = show self.update(type_=C.UPDATE_STRUCTURE, profile=self.profile) - def show_resources(self, show): + @property + def show_resources(self) -> bool: + return self._show_resources + + @show_resources.setter + def show_resources(self, show: bool) -> None: assert isinstance(show, bool) - if self.show_resources == show: + if self._show_resources == show: return - self.show_resources = show + self._show_resources = show self.update(type_=C.UPDATE_STRUCTURE, profile=self.profile) def plug(self): @@ -1068,7 +1073,7 @@ class QuickContactList(QuickWidget): # True or False mean override these values for all profiles self.show_disconnected = None # TODO self._show_empty_groups = None # TODO - self.show_resources = None # TODO + self._show_resources = None # TODO self.show_status = None # TODO def post_init(self): @@ -1083,6 +1088,14 @@ class QuickContactList(QuickWidget): def items(self): return handler.items + @property + def show_resources(self) -> bool|None: + return self._show_resources + + @show_resources.setter + def show_resources(self, show: bool|None) -> None: + self._show_resources = show + @property def items_sorted(self): return handler.items_sorted diff --git a/libervia/tui/contact_list.py b/libervia/tui/contact_list.py index 85e672e5..1290767a 100644 --- a/libervia/tui/contact_list.py +++ b/libervia/tui/contact_list.py @@ -92,7 +92,7 @@ class ContactList(LiberviaTUIWidget, QuickContactList): profile_key=self.profile, ) elif key == a_key["RESOURCES_HIDE"]: # user wants to (un)hide contacts resources - self.contact_list.show_resources(not self.contact_list.show_resources) + self.contact_list.show_resources = not self.contact_list.show_resources self.update() return super(ContactList, self).keypress(size, key)