From: Stefan Pluecken Date: Mon, 7 Nov 2005 23:07:53 +0000 (+0000) Subject: add TimerEntry for later use in TimerEdit X-Git-Tag: 2.6.0~5421 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/554e450207f364dba6ff44cabed008427dc44440 add TimerEntry for later use in TimerEdit add configDateTime as a config entry to select time, date, weekday or whatever is wanted... flexible as always :) --- diff --git a/data/menu.xml b/data/menu.xml index f023a2ad..ecc9b4af 100644 --- a/data/menu.xml +++ b/data/menu.xml @@ -18,6 +18,7 @@ + print "radio mode" diff --git a/data/skin.xml b/data/skin.xml index 82c48d8a..16908a3b 100644 --- a/data/skin.xml +++ b/data/skin.xml @@ -74,6 +74,10 @@ + + + + diff --git a/lib/python/Components/__init__.py b/lib/python/Components/__init__.py index be75d13f..f697b956 100644 --- a/lib/python/Components/__init__.py +++ b/lib/python/Components/__init__.py @@ -5,4 +5,4 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo", "ServiceName", "ServiceScan", "VariableText", "VariableValue", "VolumeBar", "components", "config", "TimerList", "TimeInput", "MovieList", "InputDevice", "ServicePosition", "IPAddress", "VariableIP", "IPGateway", - "IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager" ] + "IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry" ] diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index 7e797861..a28c40ca 100644 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -1,3 +1,5 @@ +from time import * + class configFile: def __init__(self): self.changed = 0 @@ -80,6 +82,38 @@ class configSelection: self.checkValues() return ("text", self.parent.vals[self.parent.value]) +class configDateTime: + def __init__(self, parent): + self.parent = parent + + def checkValues(self): + pass +# if self.parent.value < 0: + #self.parent.value = 0 + + #if(self.parent.value >= (len(self.parent.vals) - 1)): + #self.parent.value = len(self.parent.vals) - 1 + + def cancel(self): + self.parent.reload() + + def save(self): + self.parent.save() + + def handleKey(self, key): + if key == config.key["prevElement"]: + self.parent.value = self.parent.value - self.parent.vals[1] + if key == config.key["nextElement"]: + self.parent.value = self.parent.value + self.parent.vals[1] + + self.checkValues() + + self.parent.change() + + def __call__(self, selected): #needed by configlist + self.checkValues() + return ("text", strftime(self.parent.vals[0], localtime(self.parent.value))) + class configSatlist: def __init__(self, parent): self.parent = parent @@ -308,6 +342,8 @@ class configElement: return int(data); elif control == configSelection: return int(data); + elif control == configDateTime: + return int(data); elif control == configSequence: list = [ ] part = data.split(self.vals[0]) @@ -324,6 +360,8 @@ class configElement: return str(data); elif control == configSelection: return str(data); + elif control == configDateTime: + return str(data); elif control == configSequence: value = ((len(data) * ("%d" + self.vals[0]))[0:-1]) % tuple(data) # just in case you don't understand the above, here an equivalent: diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am index 14c397c6..ecd2da55 100644 --- a/lib/python/Screens/Makefile.am +++ b/lib/python/Screens/Makefile.am @@ -4,4 +4,4 @@ install_PYTHON = \ ChannelSelection.py ClockDisplay.py ConfigMenu.py InfoBar.py Menu.py \ MessageBox.py ScartLoopThrough.py Screen.py ServiceScan.py TimerEdit.py \ MovieSelection.py Setup.py About.py HarddiskSetup.py FixedMenu.py \ - Satconfig.py ScanSetup.py NetworkSetup.py Ci.py __init__.py + Satconfig.py ScanSetup.py NetworkSetup.py Ci.py TimerEntry.py __init__.py diff --git a/lib/python/Screens/TimerEntry.py b/lib/python/Screens/TimerEntry.py new file mode 100644 index 00000000..f09a16b2 --- /dev/null +++ b/lib/python/Screens/TimerEntry.py @@ -0,0 +1,84 @@ +from Screen import Screen +from Components.config import * +from Components.ActionMap import NumberActionMap +from Components.ConfigList import ConfigList +from Components.NimManager import nimmanager +from Components.Label import Label +from time import * + +class TimerEntry(Screen): + def __init__(self, session): + Screen.__init__(self, session) + + self.createConfig() + + self["actions"] = NumberActionMap(["SetupActions"], + { + "ok": self.keyGo, + "cancel": self.keyCancel, + "left": self.keyLeft, + "right": self.keyRight, + "1": self.keyNumberGlobal, + "2": self.keyNumberGlobal, + "3": self.keyNumberGlobal, + "4": self.keyNumberGlobal, + "5": self.keyNumberGlobal, + "6": self.keyNumberGlobal, + "7": self.keyNumberGlobal, + "8": self.keyNumberGlobal, + "9": self.keyNumberGlobal, + "0": self.keyNumberGlobal + }, -1) + + self.list = [] + self["config"] = ConfigList(self.list) + self.createSetup() + + self["introduction"] = Label("Press OK to start the scan") + + def createConfig(self): + config.timerentry = ConfigSubsection() + + config.timerentry.date = configElement_nonSave("config.timerentry.date", configDateTime, time(), ("%d.%B %Y", 86400)) + config.timerentry.time = configElement_nonSave("config.timerentry.time", configDateTime, time(), ("%H:%M", 60)) + + def createSetup(self): + self.list = [] + + self.list.append(getConfigListEntry("Date", config.timerentry.date)) + self.list.append(getConfigListEntry("Time", config.timerentry.time)) + + self["config"].list = self.list + self["config"].l.setList(self.list) + + def newConfig(self): + print self["config"].getCurrent() + if self["config"].getCurrent()[0] == "Type of scan": + self.createSetup() + if self["config"].getCurrent()[0] == "Tuner": + self.createSetup() + + def keyLeft(self): + self["config"].handleKey(config.key["prevElement"]) + self.newConfig() + + def keyRight(self): + self["config"].handleKey(config.key["nextElement"]) + self.newConfig() + + def keyNumberGlobal(self, number): + print "You pressed number " + str(number) + if (self["config"].getCurrent()[1].parent.enabled == True): + self["config"].handleKey(config.key[str(number)]) + + def keyGo(self): + for x in self["config"].list: + x[1].save() + self.session.openWithCallback(self.keyCancel, ServiceScan) + + #self.close() + + def keyCancel(self): + for x in self["config"].list: + x[1].cancel() + self.close() \ No newline at end of file