bug #219
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Mon, 2 Nov 2009 13:44:08 +0000 (14:44 +0100)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Mon, 2 Nov 2009 13:44:08 +0000 (14:44 +0100)
- 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
lib/python/Components/AVSwitch.py
lib/python/Components/config.py

index fe91ba2..0d59d8b 100644 (file)
@@ -13,8 +13,8 @@
                        <item level="0" text="TV System">config.av.tvsystem</item>
                        <item level="1" text="WSS on 4:3">config.av.wss</item>
                        <item level="1" text="AC3 default">config.av.defaultac3</item>
                        <item level="0" text="TV System">config.av.tvsystem</item>
                        <item level="1" text="WSS on 4:3">config.av.wss</item>
                        <item level="1" text="AC3 default">config.av.defaultac3</item>
-                       <item level="1" text="General AC3 delay">config.av.generalAC3delay</item>
-                       <item level="1" text="General PCM delay">config.av.generalPCMdelay</item>
+                       <item level="1" text="General AC3 delay (ms)">config.av.generalAC3delay</item>
+                       <item level="1" text="General PCM delay (ms)">config.av.generalPCMdelay</item>
                        <item level="1" text="AC3 downmix" requires="CanDownmixAC3">config.av.downmix_ac3</item>
                        <item level="1" text="Auto scart switching" requires="ScartSwitch">config.av.vcrswitch</item>
                </setup>
                        <item level="1" text="AC3 downmix" requires="CanDownmixAC3">config.av.downmix_ac3</item>
                        <item level="1" text="Auto scart switching" requires="ScartSwitch">config.av.vcrswitch</item>
                </setup>
index bc2a66a..2658f9b 100644 (file)
@@ -1,5 +1,5 @@
 from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, \
 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
 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.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()
        config.av.vcrswitch = ConfigEnableDisable(default = False)
 
        iAVSwitch = AVSwitch()
index e249caf..789ec32 100755 (executable)
@@ -1017,6 +1017,42 @@ class ConfigPassword(ConfigText):
                ConfigText.onDeselect(self, session)
                self.hidden = True
 
                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)
 class ConfigNumber(ConfigText):
        def __init__(self, default = 0):
                ConfigText.__init__(self, str(default), fixed_size = False)