X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FScreens%2FSleepTimerEdit.py;h=e5e7af4e3e522fc2102c8fa250394011c069390b;hp=f724bc5f7bbf369f6c3ec5df4cab00816cf9312a;hb=0cf3bc28d59e7bfb8519839a8e9c36a87ea382c8;hpb=67b53c1cb06988394c35a6e965c99b72b67fe1be diff --git a/lib/python/Screens/SleepTimerEdit.py b/lib/python/Screens/SleepTimerEdit.py index f724bc5..e5e7af4 100644 --- a/lib/python/Screens/SleepTimerEdit.py +++ b/lib/python/Screens/SleepTimerEdit.py @@ -4,7 +4,13 @@ from Components.ActionMap import NumberActionMap from Components.Input import Input from Components.Label import Label from Components.Pixmap import Pixmap -from Components.config import config +from Components.config import config, ConfigInteger +from Components.SystemInfo import SystemInfo +from enigma import eEPGCache +from SleepTimer import SleepTimer +from time import time + +config.SleepTimer.defaulttime = ConfigInteger(default = 30) class SleepTimerEdit(Screen): def __init__(self, session): @@ -18,14 +24,26 @@ class SleepTimerEdit(Screen): self["green_text"] = Label() self["yellow_text"] = Label() self["blue_text"] = Label() + self["current_status"] = Label() self.is_active = self.session.nav.SleepTimer.isActive() + if self.is_active: + self["current_status"].setText(_("Timer status:") + " " + _("Enabled")) + else: + self["current_status"].setText(_("Timer status:") + " " + _("Disabled")) + + if self.is_active: + self.time = self.session.nav.SleepTimer.getCurrentSleepTime() + else: + self.time = config.SleepTimer.defaulttime.value + self["input"] = Input(text = str(self.time), maxSize = False, type = Input.NUMBER) + + self.status = True self.updateColors() self["pretext"] = Label(_("Shutdown Dreambox after")) - self["input"] = Input(text = str(self.session.nav.SleepTimer.getCurrentSleepTime()), maxSize = False, type = Input.NUMBER) self["aftertext"] = Label(_("minutes")) - self["actions"] = NumberActionMap(["SleepTimerEditorActions"], + self["actions"] = NumberActionMap(["SleepTimerEditorActions", "TextEntryActions", "KeyboardInputActions"], { "exit": self.cancel, "select": self.select, @@ -41,19 +59,30 @@ class SleepTimerEdit(Screen): "0": self.keyNumberGlobal, "selectLeft": self.selectLeft, "selectRight": self.selectRight, + "left": self.selectLeft, + "right": self.selectRight, + "home": self.selectHome, + "end": self.selectEnd, + "deleteForward": self.deleteForward, + "deleteBackward": self.deleteBackward, "disableTimer": self.disableTimer, "toggleAction": self.toggleAction, - "toggleAsk": self.toggleAsk + "toggleAsk": self.toggleAsk, + "useServiceTime": self.useServiceTime }, -1) def updateColors(self): - if self.is_active: - self["red_text"].setText(_("Timer status:") + " " + _("Enabled")) + if self.status: + self["red_text"].setText(_("Action:") + " " + _("Enable timer")) else: - self["red_text"].setText(_("Timer status:") + " " + _("Disabled")) + self["red_text"].setText(_("Action:") + " " + _("Disable timer")) if config.SleepTimer.action.value == "shutdown": - self["green_text"].setText(_("Sleep timer action:") + " " + _("Deep Standby")) + if SystemInfo["DeepstandbySupport"]: + shutdownString = _("Deep Standby") + else: + shutdownString = _("Shutdown") + self["green_text"].setText(_("Sleep timer action:") + " " + shutdownString) elif config.SleepTimer.action.value == "standby": self["green_text"].setText(_("Sleep timer action:") + " " + _("Standby")) @@ -61,7 +90,7 @@ class SleepTimerEdit(Screen): self["yellow_text"].setText(_("Ask before shutdown:") + " " + _("yes")) else: self["yellow_text"].setText(_("Ask before shutdown:") + " " + _("no")) - self["blue_text"].setText(_("Settings")) + self["blue_text"].setText(_("Use time of currently running service")) def cancel(self): config.SleepTimer.ask.cancel() @@ -69,8 +98,12 @@ class SleepTimerEdit(Screen): self.close() def select(self): - if self.is_active: - self.session.nav.SleepTimer.setSleepTime(int(self["input"].getText())) + if self.status: + time = int(self["input"].getText()) + config.SleepTimer.defaulttime.setValue(time) + config.SleepTimer.defaulttime.save() + config.SleepTimer.action.save() + self.session.nav.SleepTimer.setSleepTime(time) self.session.openWithCallback(self.close, MessageBox, _("The sleep timer has been activated."), MessageBox.TYPE_INFO) else: self.session.nav.SleepTimer.clear() @@ -85,8 +118,20 @@ class SleepTimerEdit(Screen): def selectRight(self): self["input"].right() + def selectHome(self): + self["input"].home() + + def selectEnd(self): + self["input"].end() + + def deleteForward(self): + self["input"].delete() + + def deleteBackward(self): + self["input"].deleteBackward() + def disableTimer(self): - self.is_active = not self.is_active + self.status = not self.status self.updateColors() def toggleAction(self): @@ -99,3 +144,31 @@ class SleepTimerEdit(Screen): def toggleAsk(self): config.SleepTimer.ask.value = not config.SleepTimer.ask.value self.updateColors() + + def useServiceTime(self): + remaining = None + ref = self.session.nav.getCurrentlyPlayingServiceReference() + if ref: + path = ref.getPath() + if path: # Movie + service = self.session.nav.getCurrentService() + seek = service and service.seek() + if seek: + length = seek.getLength() + position = seek.getPlayPosition() + if length and position: + remaining = length[1] - position[1] + if remaining > 0: + remaining = remaining / 90000 + else: # DVB + epg = eEPGCache.getInstance() + event = epg.lookupEventTime(ref, -1, 0) + if event: + now = int(time()) + start = event.getBeginTime() + duration = event.getDuration() + end = start + duration + remaining = end - now + if remaining: + config.SleepTimer.defaulttime.value = (remaining / 60) + 2 + self["input"].setText(str((remaining / 60) + 2))