def testHighlights(self, callback=None): if not self.selectPics or not self.selectPics[0].pixmaps: return self.hideSelectPics() pixmap = self.selectPics[0].pixmaps[0] pixmap.show() rcPos = self["rc"].getPosition() pixmap.clearPath() for keyId in remoteControl.getRemoteControlKeyList(): pos = remoteControl.getRemoteControlKeyPos(keyId) pixmap.addMovePoint(rcPos[0] + pos[0], rcPos[1] + pos[1], time=5) pixmap.addMovePoint(rcPos[0] + pos[0], rcPos[1] + pos[1], time=10) pixmap.startMoving(callback)
def __init__(self, helpList, callback): List.__init__(self) self.callback = callback self.rcKeyIndex = None self.buttonMap = {} self.longSeen = False formatFlags = 0 def actMapId(): return getattr(actionmap, "description", None) or id(actionmap) headings, sortCmp, sortKey = { "headings+alphabetic": (True, None, self._sortKeyAlpha), "flat+alphabetic": (False, None, self._sortKeyAlpha), "flat+remotepos": (False, self._sortCmpPos, None), "flat+remotegroups": (False, self._sortCmpInd, None) }.get(config.usage.helpSortOrder.value, (False, None, None)) if remoteControl is None: if sortCmp in (self._sortCmpPos, self._sortCmpInd): sortCmp = None else: if sortCmp == self._sortCmpInd: self.rcKeyIndex = dict((x[1], x[0]) for x in enumerate( remoteControl.getRemoteControlKeyList())) buttonsProcessed = set() helpSeen = defaultdict(list) sortedHelpList = sorted(helpList, key=lambda hle: hle[0].prio) actionMapHelp = defaultdict(list) for (actionmap, context, actions) in sortedHelpList: # print("[HelpMenu] HelpMenuList DEBUG: actionmap='%s', context='%s', actions='%s'." % (str(actionmap), context, str(actions))) if not actionmap.enabled: # print("[HelpMenu] Action map disabled.") continue amId = actMapId() if headings and actionmap.description and not (formatFlags & self.HEADINGS): # print("[HelpMenu] HelpMenuList DEBUG: Headings found.") formatFlags |= self.HEADINGS for (action, help) in actions: # DEBUG: Should help be response? helpTags = [ ] # if mapFlag else [pgettext("Abbreviation of 'Disabled'", "Disabled")] if callable(help): help = help() helpTags.append( pgettext("Abbreviation of 'Configurable'", "Configurable")) if help is None: # print("[HelpMenu] HelpMenuList DEBUG: No help text found.") # help = _("No help text available") continue buttons = queryKeyBinding(context, action) # print("[HelpMenu] HelpMenuList DEBUG: queryKeyBinding buttons=%s." % str(buttons)) if not buttons: # Do not display entries which are not accessible from keys. # print("[HelpMenu] HelpMenuList DEBUG: No buttons allocated.") # helpTags.append(pgettext("Abbreviation of 'Unassigned'", "Unassigned")) continue buttonLabels = [] for keyId, flags in buttons: if remoteControl.getRemoteControlKeyPos(keyId): buttonLabels.append( (keyId, "LONG") if flags & 8 else (keyId, ) ) # For long keypresses, make the second tuple item "LONG". if not buttonLabels: # Only show entries with keys that are available on the used rc. # print("[HelpMenu] HelpMenuList DEBUG: Button not available on current remote control.") # helpTags.append(pgettext("Abbreviation of 'No Button'", "No Button")) continue isExtended = isinstance(help, (list, tuple)) if isExtended and not (formatFlags & self.EXTENDED): # print("[HelpMenu] HelpMenuList DEBUG: Extended help entry found.") formatFlags |= self.EXTENDED if helpTags: helpStr = help[0] if isExtended else help tagsStr = pgettext("Text list separator", ", ").join(helpTags) helpStr = _("%s (%s)") % (helpStr, tagsStr) help = [helpStr, help[1]] if isExtended else helpStr entry = [(actionmap, context, action, buttonLabels, help), help] if self._filterHelpList(entry, helpSeen): actionMapHelp[actMapId()].append(entry) helpMenuList = [] extendedPadding = (None, ) if formatFlags & self.EXTENDED else () for (actionmap, context, actions) in helpList: amId = actMapId() if headings and amId in actionMapHelp and getattr( actionmap, "description", None): if sortCmp: actionMapHelp[amId].sort(key=cmp_to_key(sortCmp)) elif sortKey: actionMapHelp[amId].sort(key=sortKey) self.addListBoxContext(actionMapHelp[amId], formatFlags) helpMenuList.append((None, actionmap.description, None) + extendedPadding) helpMenuList.extend(actionMapHelp[amId]) del actionMapHelp[amId] if actionMapHelp: if formatFlags & self.HEADINGS: # Add a header if other actionmaps have descriptions. helpMenuList.append((None, _("Other Actions"), None) + extendedPadding) otherHelp = [] for (actionmap, context, actions) in helpList: amId = actMapId() if amId in actionMapHelp: otherHelp.extend(actionMapHelp[amId]) del actionMapHelp[amId] if sortCmp: otherHelp.sort(key=cmp_to_key(sortCmp)) elif sortKey: otherHelp.sort(key=sortKey) self.addListBoxContext(otherHelp, formatFlags) helpMenuList.extend(otherHelp) ignoredKeyIds = (KEYIDS.get("KEY_OK"), KEYIDS.get("KEY_EXIT")) for index, entry in enumerate(helpMenuList): if entry[0] and entry[0][3]: # This should not be required. for button in entry[0][3]: if button[0] not in ( ignoredKeyIds ): # Ignore "break" events from OK and EXIT on return from help popup. self.buttonMap[button] = index self.style = ( "default", "default+headings", "extended", "extended+headings", )[formatFlags] # [(actionmap, context, [(action, help), (action, help), ...]), ...] # [((ActionMap, Context, Action, [(Button, Device/Long), ...], HelpText), HelpText), ...] self.list = helpMenuList