From f7c13b8fcc4373f972387a0e7928658b818392b9 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 18 Nov 2005 04:53:43 +0000 Subject: [PATCH] helplist: keys are not anymore secret, at least not for us professionals. skin fixed a bit. (discrete) standby added to help. --- data/skin.xml | 1 + keymapparser.py | 4 ++++ lib/python/Components/HelpMenuList.py | 27 ++++++++++++++++----- lib/python/Screens/InfoBarGenerics.py | 34 ++++++++++++++++----------- lib/python/Tools/KeyBindings.py | 17 ++++++++++++++ lib/python/Tools/__init__.py | 2 +- 6 files changed, 64 insertions(+), 21 deletions(-) create mode 100644 lib/python/Tools/KeyBindings.py diff --git a/data/skin.xml b/data/skin.xml index 990b0546..50663968 100644 --- a/data/skin.xml +++ b/data/skin.xml @@ -207,6 +207,7 @@ + diff --git a/keymapparser.py b/keymapparser.py index 6ce0abae..23cd5a86 100644 --- a/keymapparser.py +++ b/keymapparser.py @@ -3,6 +3,9 @@ import enigma from keyids import KEYIDS; +# these are only informational (for help)... +from Tools.KeyBindings import addKeyBinding + def readKeymap(): p = enigma.eActionMapPtr() @@ -71,6 +74,7 @@ def readKeymap(): # print context + "::" + mapto + " -> " + device + "." + hex(keyid) p.bindKey(device, keyid, flags, context, mapto) + addKeyBinding(keyid, context, mapto) parseKeys("generic", cmap) diff --git a/lib/python/Components/HelpMenuList.py b/lib/python/Components/HelpMenuList.py index 34eb4119..58335c08 100644 --- a/lib/python/Components/HelpMenuList.py +++ b/lib/python/Components/HelpMenuList.py @@ -2,6 +2,8 @@ from GUIComponent import * from enigma import eListboxPythonMultiContent, eListbox, gFont +from Tools.KeyBindings import queryKeyBinding, getKeyDescription + # [ ( actionmap, context, [(action, help), (action, help), ...] ), (actionmap, ... ), ... ] class HelpMenuList(GUIComponent): @@ -13,17 +15,30 @@ class HelpMenuList(GUIComponent): l = [ ] for (actionmap, context, actions) in list: - - print "actionmap:" + str(actionmap) - print "context: " + str(context) - print "actions: " + str(actions) - for (action, help) in actions: entry = [ ] entry.append( (actionmap, context, action) ) - entry.append( (0, 36, 200, 20, 1, 0, "you can also press a secret button") ) + buttons = queryKeyBinding(context, action) + buttonstring = "" + + first = True + for n in buttons: + name = getKeyDescription(n) + if name is None: + continue + + if not first: + buttonstring += ", or " + + first = False + buttonstring += name + + if not first: + buttonstring = "You can also press " + buttonstring + "." + entry.append( (0, 0, 200, 36, 0, 0, help) ) + entry.append( (0, 40, 200, 20, 1, 0, buttonstring) ) l.append(entry) diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 45c7745e..68e082e5 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -179,10 +179,12 @@ class InfoBarPowerKey: def __init__(self): self.powerKeyTimer = eTimer() self.powerKeyTimer.timeout.get().append(self.powertimer) - self["PowerKeyActions"] = ActionMap( ["PowerKeyActions"], + self["PowerKeyActions"] = HelpableActionMap(self, "PowerKeyActions", { "powerdown": self.powerdown, "powerup": self.powerup, + "discreteStandby": (self.standby, "Go standby"), + "discretePowerOff": (self.quit, "Go to deep standby"), }) def powertimer(self): @@ -197,10 +199,14 @@ class InfoBarPowerKey: self.powerKeyTimer.stop() if self.standbyblocked == 0: self.standbyblocked = 1 - self.session.open(Standby, self) + self.standby() + + def standby(self): + self.session.open(Standby, self) def quit(self): - quitMainloop(0) + # halt + quitMainloop(1) class InfoBarNumberZap: """ Handles an initial number for NumberZapping """ @@ -262,9 +268,9 @@ class InfoBarChannelSelection: class InfoBarMenu: """ Handles a menu action, to open the (main) menu """ def __init__(self): - self["MenuActions"] = ActionMap( [ "InfobarMenuActions" ], + self["MenuActions"] = HelpableActionMap(self, "InfobarMenuActions", { - "mainMenu": self.mainMenu, + "mainMenu": (self.mainMenu, "Enter main menu..."), }) def mainMenu(self): @@ -329,13 +335,13 @@ class InfoBarServiceName: class InfoBarPVR: """handles PVR specific actions like seeking, pause""" def __init__(self): - self["PVRActions"] = ActionMap( [ "InfobarPVRActions" ], + self["PVRActions"] = HelpableActionMap(self, "InfobarPVRActions", { - "pauseService": self.pauseService, - "unPauseService": self.unPauseService, + "pauseService": (self.pauseService, "pause"), + "unPauseService": (self.unPauseService, "continue"), - "seekFwd": self.seekFwd, - "seekBack": self.seekBack, + "seekFwd": (self.seekFwd, "skip forward"), + "seekBack": (self.seekBack, "skip backward"), }) def pauseService(self): @@ -364,9 +370,9 @@ class InfoBarInstantRecord: """Instant Record - handles the instantRecord action in order to start/stop instant records""" def __init__(self): - self["InstnantRecordActions"] = ActionMap( [ "InfobarInstantRecord" ], + self["InstnantRecordActions"] = HelpableActionMap(self, "InfobarInstantRecord", { - "instantRecord": self.instantRecord, + "instantRecord": (self.instantRecord, "Instant Record..."), }) self.recording = None @@ -416,9 +422,9 @@ from Screens.AudioSelection import AudioSelection class InfoBarAudioSelection: def __init__(self): - self["AudioSelectionAction"] = ActionMap( [ "InfobarAudioSelectionActions" ], + self["AudioSelectionAction"] = HelpableActionMap(self, "InfobarAudioSelectionActions", { - "audioSelection": self.audioSelection, + "audioSelection": (self.audioSelection, "Audio Options..."), }) def audioSelection(self): diff --git a/lib/python/Tools/KeyBindings.py b/lib/python/Tools/KeyBindings.py new file mode 100644 index 00000000..b55e3555 --- /dev/null +++ b/lib/python/Tools/KeyBindings.py @@ -0,0 +1,17 @@ + +keyBindings = { } + +def addKeyBinding(key, context, action): + if (context, action) in keyBindings: + keyBindings[(context, action)].append(key) + else: + keyBindings[(context, action)] = [key] + +def queryKeyBinding(context, action): + if (context, action) in keyBindings: + return keyBindings[(context, action)] + else: + return [ ] + +def getKeyDescription(key): + return "key_%0x" % key diff --git a/lib/python/Tools/__init__.py b/lib/python/Tools/__init__.py index 72a1abb7..d8e646d0 100644 --- a/lib/python/Tools/__init__.py +++ b/lib/python/Tools/__init__.py @@ -1 +1 @@ -all = ["FuzzyDate.py", "XMLTools.py", "Directories.py"] +all = ["FuzzyDate.py", "XMLTools.py", "Directories.py", "KeyBindings.py"] -- 2.30.2