Mercurial > libervia-desktop-kivy
diff cagou/core/widgets_handler.py @ 405:84ff5c917064
widgets: implemented ordering in ContactItem and CagouWidget:
ordering of slides in collection_carousel were using a specific key during the sort, this
has been replaced by an ordering implemented directly into the classes.
Ordering has also been implemented in ContactItem to have items appearing in a consistent
order notably for opened chats.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 12 Feb 2020 20:02:58 +0100 |
parents | 4d660b252487 |
children | 3c9ba4a694ef |
line wrap: on
line diff
--- a/cagou/core/widgets_handler.py Wed Feb 12 20:02:58 2020 +0100 +++ b/cagou/core/widgets_handler.py Wed Feb 12 20:02:58 2020 +0100 @@ -497,17 +497,6 @@ continue yield w - def widgets_sort(self, widget): - """method used as key to sort the widgets - - order of the widgets when changing slide is affected - @param widget(QuickWidget): widget to sort - @return: a value which will be used for sorting - """ - try: - return str(widget.target).lower() - except AttributeError: - return str(list(widget.targets)[0]).lower() def _updateHiddenSlides(self): """adjust carousel slides according to visible widgets""" @@ -522,7 +511,7 @@ # we ignore current_slide as it may not be visible yet (e.g. if an other # screen is shown hidden = list(self.hiddenList(visible_list, ignore=current_slide)) - slides_sorted = sorted(set(hidden + [current_slide]), key=self.widgets_sort) + slides_sorted = sorted(set(hidden + [current_slide])) to_remove = set(self.carousel.slides).difference({current_slide}) for w in to_remove: self.carousel.remove_widget(w)