From: Stefan Pluecken Date: Mon, 23 Jun 2008 16:05:19 +0000 (+0000) Subject: simplify enabling the sleep timer by defaulting the action of the sleep X-Git-Tag: 2.6.0~1112 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/830d79376a0bc82a7c50930c5dc7d48b35bb8a21 simplify enabling the sleep timer by defaulting the action of the sleep timer editor to "enable" and restoring the last setting for the sleep time --- diff --git a/SleepTimer.py b/SleepTimer.py index f9aae1aa..221e8f0b 100644 --- a/SleepTimer.py +++ b/SleepTimer.py @@ -9,6 +9,10 @@ from Components.config import config, ConfigYesNo, ConfigSelection, ConfigSubsec from Screens.MessageBox import MessageBox import Screens.Standby +config.SleepTimer = ConfigSubsection() +config.SleepTimer.ask = ConfigYesNo(default = True) +config.SleepTimer.action = ConfigSelection(default = "shutdown", choices = [("shutdown", _("shutdown")), ("standby", _("standby"))]) + class SleepTimerEntry(timer.TimerEntry): def __init__(self, begin): timer.TimerEntry.__init__(self, int(begin), int(begin)) @@ -48,9 +52,6 @@ class SleepTimerEntry(timer.TimerEntry): class SleepTimer(timer.Timer): def __init__(self): - config.SleepTimer = ConfigSubsection() - config.SleepTimer.ask = ConfigYesNo(default = True) - config.SleepTimer.action = ConfigSelection(default = "shutdown", choices = [("shutdown", _("shutdown")), ("standby", _("standby"))]) timer.Timer.__init__(self) self.defaultTime = 30 diff --git a/data/skin_default.xml b/data/skin_default.xml index 995cb083..a2bf0b69 100644 --- a/data/skin_default.xml +++ b/data/skin_default.xml @@ -848,15 +848,16 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) - - - - + + + + + - - - - + + + + @@ -963,9 +964,9 @@ self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) - - - + + + diff --git a/lib/python/Screens/SleepTimerEdit.py b/lib/python/Screens/SleepTimerEdit.py index 54dd7e14..2416dd03 100644 --- a/lib/python/Screens/SleepTimerEdit.py +++ b/lib/python/Screens/SleepTimerEdit.py @@ -4,7 +4,10 @@ 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 SleepTimer import SleepTimer + +config.SleepTimer.defaulttime = ConfigInteger(default = 30) class SleepTimerEdit(Screen): def __init__(self, session): @@ -18,11 +21,24 @@ 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", "TextEntryActions", "KeyboardInputActions"], @@ -53,10 +69,10 @@ class SleepTimerEdit(Screen): }, -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")) @@ -75,8 +91,10 @@ 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) + 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() @@ -104,7 +122,7 @@ class SleepTimerEdit(Screen): self["input"].deleteBackward() def disableTimer(self): - self.is_active = not self.is_active + self.status = not self.status self.updateColors() def toggleAction(self):