comparison cagou/core/cagou_main.py @ 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 8efed1d47d9f
children 816a0c880f52
comparison
equal deleted inserted replaced
359:38d763febed6 360:a77386b73e55
417 except OSError as e: 417 except OSError as e:
418 log.warnings(_("Can't create downloads dir: {reason}").format(reason=e)) 418 log.warnings(_("Can't create downloads dir: {reason}").format(reason=e))
419 self.app.default_avatar = os.path.join(self.media_dir, "misc/default_avatar.png") 419 self.app.default_avatar = os.path.join(self.media_dir, "misc/default_avatar.png")
420 self.app.icon = os.path.join(self.media_dir, 420 self.app.icon = os.path.join(self.media_dir,
421 "icons/muchoslava/png/cagou_profil_bleu_96.png") 421 "icons/muchoslava/png/cagou_profil_bleu_96.png")
422 self._plg_wids = [] # main widgets plugins 422 # main widgets plugins
423 self._plg_wids_transfer = [] # transfer widgets plugins 423 self._plg_wids = []
424 # transfer widgets plugins
425 self._plg_wids_transfer = []
424 self._import_plugins() 426 self._import_plugins()
425 self._visible_widgets = {} # visible widgets by classes 427 # visible widgets by classes
428 self._visible_widgets = {}
429 # used to keep track of last selected widget in "main" screen when changing
430 # root screen
431 self._selected_widget_main = None
426 self.backend_version = sat.__version__ # will be replaced by getVersion() 432 self.backend_version = sat.__version__ # will be replaced by getVersion()
427 if C.APP_VERSION.endswith('D'): 433 if C.APP_VERSION.endswith('D'):
428 self.version = "{} {}".format( 434 self.version = "{} {}".format(
429 C.APP_VERSION, 435 C.APP_VERSION,
430 sat_utils.getRepositoryData(cagou) 436 sat_utils.getRepositoryData(cagou)
974 980
975 def showUI(self, ui): 981 def showUI(self, ui):
976 """show a XMLUI""" 982 """show a XMLUI"""
977 self.app.root.changeWidget(ui, "xmlui") 983 self.app.root.changeWidget(ui, "xmlui")
978 self.app.root.show("xmlui") 984 self.app.root.show("xmlui")
985 self._selected_widget_main = self.selected_widget
986 self.selected_widget = ui
979 987
980 def showExtraUI(self, widget): 988 def showExtraUI(self, widget):
981 """show any extra widget""" 989 """show any extra widget"""
982 self.app.root.changeWidget(widget, "extra") 990 self.app.root.changeWidget(widget, "extra")
983 self.app.root.show("extra") 991 self.app.root.show("extra")
992 self._selected_widget_main = self.selected_widget
993 self.selected_widget = widget
984 994
985 def closeUI(self): 995 def closeUI(self):
986 self.app.root.show() 996 self.app.root.show()
997 self.selected_widget = self._selected_widget_main
998 self._selected_widget_main = None
987 screen = self.app.root._manager.get_screen("extra") 999 screen = self.app.root._manager.get_screen("extra")
988 screen.clear_widgets() 1000 screen.clear_widgets()
989 1001
990 def getDefaultAvatar(self, entity=None): 1002 def getDefaultAvatar(self, entity=None):
991 return self.app.default_avatar 1003 return self.app.default_avatar