From 0fd217d2eef3ae87953e6622edb977aded899a52 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Mon, 2 Nov 2009 14:44:08 +0100 Subject: [PATCH] bug #219 - introduce ConfigSelectionNumber to allow left/right buttons for positive and negative number ranges - use it to set up config.av.generalAC3delay and config.av.generalPCMdelay --- data/setup.xml | 4 ++-- lib/python/Components/AVSwitch.py | 6 +++--- lib/python/Components/config.py | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/data/setup.xml b/data/setup.xml index fe91ba2..0d59d8b 100644 --- a/data/setup.xml +++ b/data/setup.xml @@ -13,8 +13,8 @@ config.av.tvsystem config.av.wss config.av.defaultac3 - config.av.generalAC3delay - config.av.generalPCMdelay + config.av.generalAC3delay + config.av.generalPCMdelay config.av.downmix_ac3 config.av.vcrswitch diff --git a/lib/python/Components/AVSwitch.py b/lib/python/Components/AVSwitch.py index bc2a66a..2658f9b 100644 --- a/lib/python/Components/AVSwitch.py +++ b/lib/python/Components/AVSwitch.py @@ -1,5 +1,5 @@ from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, \ - ConfigEnableDisable, ConfigSubsection, ConfigBoolean, ConfigNumber, ConfigNothing, NoSave + ConfigEnableDisable, ConfigSubsection, ConfigBoolean, ConfigSelectionNumber, ConfigNothing, NoSave from enigma import eAVSwitch, getDesktop from SystemInfo import SystemInfo from os import path as os_path @@ -112,8 +112,8 @@ def InitAVSwitch(): config.av.tvsystem = ConfigSelection(choices = {"pal": _("PAL"), "ntsc": _("NTSC"), "multinorm": _("multinorm")}, default="pal") config.av.wss = ConfigEnableDisable(default = True) config.av.defaultac3 = ConfigYesNo(default = False) - config.av.generalAC3delay = ConfigNumber(default = 0) - config.av.generalPCMdelay = ConfigNumber(default = 0) + config.av.generalAC3delay = ConfigSelectionNumber(-1000, 1000, 25, default = 0) + config.av.generalPCMdelay = ConfigSelectionNumber(-1000, 1000, 25, default = 0) config.av.vcrswitch = ConfigEnableDisable(default = False) iAVSwitch = AVSwitch() diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index e249caf..789ec32 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -1017,6 +1017,42 @@ class ConfigPassword(ConfigText): ConfigText.onDeselect(self, session) self.hidden = True +# lets the user select between [min, min+stepwidth, min+(stepwidth*2)..., maxval] with maxval <= max depending +# on the stepwidth +# min, max, stepwidth, default are int values +# wraparound: pressing RIGHT key at max value brings you to min value and vice versa if set to True +class ConfigSelectionNumber(ConfigSelection): + def __init__(self, min, max, stepwidth, default = None, wraparound = False): + self.wraparound = wraparound + if default is None: + default = min + default = str(default) + choices = [] + step = min + while step <= max: + choices.append(str(step)) + step += stepwidth + + ConfigSelection.__init__(self, choices, default) + + def getValue(self): + return int(self.text) + + def setValue(self, val): + self.text = str(val) + + def handleKey(self, key): + if not self.wraparound: + if key == KEY_RIGHT: + if len(self.choices) == (self.choices.index(self.value) + 1): + return + if key == KEY_LEFT: + if self.choices.index(self.value) == 0: + return + ConfigSelection.handleKey(self, key) + + + class ConfigNumber(ConfigText): def __init__(self, default = 0): ConfigText.__init__(self, str(default), fixed_size = False) -- 2.7.4