changeset 360:a77386b73e55

core: change selected_widget when root screen widget is changed
author Goffi <goffi@goffi.org>
date Sat, 18 Jan 2020 23:12:52 +0100
parents 38d763febed6
children f20ec8462493
files cagou/core/cagou_main.py
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Sat Jan 18 23:12:52 2020 +0100
+++ b/cagou/core/cagou_main.py	Sat Jan 18 23:12:52 2020 +0100
@@ -419,10 +419,16 @@
         self.app.default_avatar = os.path.join(self.media_dir, "misc/default_avatar.png")
         self.app.icon = os.path.join(self.media_dir,
                                      "icons/muchoslava/png/cagou_profil_bleu_96.png")
-        self._plg_wids = []  # main widgets plugins
-        self._plg_wids_transfer = []  # transfer widgets plugins
+        # main widgets plugins
+        self._plg_wids = []
+        # transfer widgets plugins
+        self._plg_wids_transfer = []
         self._import_plugins()
-        self._visible_widgets = {}  # visible widgets by classes
+        # visible widgets by classes
+        self._visible_widgets = {}
+        # used to keep track of last selected widget in "main" screen when changing
+        # root screen
+        self._selected_widget_main = None
         self.backend_version = sat.__version__  # will be replaced by getVersion()
         if C.APP_VERSION.endswith('D'):
             self.version = "{} {}".format(
@@ -976,14 +982,20 @@
         """show a XMLUI"""
         self.app.root.changeWidget(ui, "xmlui")
         self.app.root.show("xmlui")
+        self._selected_widget_main = self.selected_widget
+        self.selected_widget = ui
 
     def showExtraUI(self, widget):
         """show any extra widget"""
         self.app.root.changeWidget(widget, "extra")
         self.app.root.show("extra")
+        self._selected_widget_main = self.selected_widget
+        self.selected_widget = widget
 
     def closeUI(self):
         self.app.root.show()
+        self.selected_widget = self._selected_widget_main
+        self._selected_widget_main = None
         screen = self.app.root._manager.get_screen("extra")
         screen.clear_widgets()