From 09ca5b479d99617068c3a2e301960c208276e3ba Mon Sep 17 00:00:00 2001 From: Littlesat Date: Sun, 5 Jan 2025 10:10:06 +0100 Subject: [PATCH] Add an instant method to change the order and layout of the Helpscreen With short help you get some help instructions and with long help you can now toggle between the different order/layout modes the help screen offers without going deep into the menus --- data/keymap.xml | 2 ++ lib/python/Components/HelpMenuList.py | 22 +++++++++++++--------- lib/python/Screens/HelpMenu.py | 13 ++++++++++--- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/data/keymap.xml b/data/keymap.xml index 111e990993b..5ddb72e3858 100644 --- a/data/keymap.xml +++ b/data/keymap.xml @@ -37,8 +37,10 @@ + + diff --git a/lib/python/Components/HelpMenuList.py b/lib/python/Components/HelpMenuList.py index cefa580dcfc..c114a9e212e 100644 --- a/lib/python/Components/HelpMenuList.py +++ b/lib/python/Components/HelpMenuList.py @@ -49,15 +49,19 @@ class HelpMenuList(List): def __init__(self, helplist, callback, rcPos=None): List.__init__(self) self.callback = callback - formatFlags = 0 self.rcPos = rcPos + self.helplist=helplist + self.createHelpList() + + def createHelpList(self): + def getActionmapGroupKey(actionmap, context): + return getattr(actionmap, "description", None) or context + self.rcKeyIndex = None self.buttonMap = {} self.longSeen = False self.skipKeys = getFpAndKbdKeys() - - def getActionmapGroupKey(actionmap, context): - return getattr(actionmap, "description", None) or context + formatFlags = 0 headings, sortKey = { "headings+alphabetic": (True, self._sortKeyAlpha), @@ -66,16 +70,16 @@ def getActionmapGroupKey(actionmap, context): "flat+remotegroups": (False, self._sortInd) }.get(config.usage.help_sortorder.value, (False, None)) - if rcPos is None: + if self.rcPos is None: if sortKey in (self._sortPos, self._sortInd): sortKey = None else: if sortKey == self._sortInd: - self.rcKeyIndex = dict((x[1], x[0]) for x in enumerate(rcPos.getRcKeyList())) + self.rcKeyIndex = dict((x[1], x[0]) for x in enumerate(self.rcPos.getRcKeyList())) buttonsProcessed = set() helpSeen = defaultdict(list) - sortedHelplist = sorted(helplist, key=lambda hle: hle[0].prio) + sortedHelplist = sorted(self.helplist, key=lambda hle: hle[0].prio) actionMapHelp = defaultdict(list) for (actionmap, context, actions) in sortedHelplist: @@ -137,7 +141,7 @@ def getActionmapGroupKey(actionmap, context): self.list = [] extendedPadding = (None, ) if formatFlags & self.EXTENDED else () if headings: - for (actionmap, context, actions) in sorted(helplist, key=self._sortHeadingsAlpha): + for (actionmap, context, actions) in sorted(self.helplist, key=self._sortHeadingsAlpha): actionmapGroupKey = getActionmapGroupKey(actionmap, context) if actionmapGroupKey in actionMapHelp: if sortKey: @@ -147,7 +151,7 @@ def getActionmapGroupKey(actionmap, context): self.list.extend(actionMapHelp[actionmapGroupKey]) del actionMapHelp[actionmapGroupKey] else: - for (actionmap, context, actions) in helplist: + for (actionmap, context, actions) in self.helplist: actionmapGroupKey = getActionmapGroupKey(actionmap, context) if actionmapGroupKey in actionMapHelp: self.list.extend(actionMapHelp[actionmapGroupKey]) diff --git a/lib/python/Screens/HelpMenu.py b/lib/python/Screens/HelpMenu.py index d8579bed469..6c7bff6e3b3 100644 --- a/lib/python/Screens/HelpMenu.py +++ b/lib/python/Screens/HelpMenu.py @@ -2,6 +2,7 @@ from Screens.TextBox import TextBox from Tools.KeyBindings import keyBindings from Tools.BoundFunction import boundFunction +from Components.config import config from Components.Label import Label from Components.ActionMap import ActionMap from Components.HelpMenuList import HelpMenuList @@ -19,12 +20,11 @@ def helpText(self): _("Other buttons will jump to the help for that button, if there is help."), _("If an action is user-configurable, its help entry will be flagged (C)"), _("A highlight on the remote control image shows which button the help refers to. If more than one button performs the indicated function, more than one highlight will be shown. Text below the list indicates whether the function is for a long press of the button(s)."), - _("The order and grouping of the help information list can be controlled using MENU>Setup>User Interface>Settings>Sort order for help screen.")]) + _("The order and grouping of the help information list can be controlled using MENU>Setup>User Interface>Settings>Sort order for help screen or pressing long help")]) def __init__(self, session, list): Screen.__init__(self, session) - self.setup_title = _("Help") - Screen.setTitle(self, self.setup_title) + Screen.setTitle(self, _("Help")) Rc.__init__(self) self["list"] = HelpMenuList(list, self.close, rcPos=self.getRcPositions()) self["longshift_key0"] = Label("") @@ -68,6 +68,7 @@ def __init__(self, session, list): self["helpActions"] = ActionMap(["HelpActions"], { "displayHelp": self.showHelp, + "toggleConfig": self.toggleConfig, }) self.onLayoutFinish.append(self.doOnLayoutFinish) @@ -141,6 +142,12 @@ def interceptButton(self, key, flag): def showHelp(self): self.session.open(TextBox, self.helpText(), _("Help Screen")) + def toggleConfig(self): + config.usage.help_sortorder.selectNext() + config.usage.help_sortorder.save() + Screen.setTitle(self, "%s - %s" % (_("Help"), config.usage.help_sortorder.getText())) + self["list"].createHelpList() + class HelpableScreen: def __init__(self):