Simplify the inactivity and sleeptimer
authorlittlesat <littlesat99@yahoo.com>
Sat, 7 Jun 2014 09:25:52 +0000 (11:25 +0200)
committerlittlesat <littlesat99@yahoo.com>
Sat, 7 Jun 2014 09:25:52 +0000 (11:25 +0200)
Remove the direct actions to go to deep standby/shutdown as this is not
really required anymore die to the standby timeout that allows the
receiver to go to deepstandby/shutdown later. This allows you when the box
goes by accident to deepstamdby that you quickly can undo it as there is
still some time added in standby. This also makes it much easier to avoid
going to deep standby when streaming is ongoing. I added also 1, 5 and 10
minutes to the standby to deepstandby timer.

lib/python/Components/UsageConfig.py
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/SleepTimerEdit.py

index b180dac..0cfb7c6 100644 (file)
@@ -107,37 +107,25 @@ def InitUsageConfig():
                ("shutdown", _("Immediate shutdown")),
                ("standby", _("Standby")) ] )
 
-       choicelist = []
-       for i in range(-21600, 21601, 3600):
+       choicelist = [("0", _("Do nothing"))]
+       for i in range(3600, 21601, 3600):
                h = abs(i / 3600)
                h = ngettext("%d hour", "%d hours", h) % h
-               if i < 0:
-                       choicelist.append(("%d" % i, _("Shutdown in ") + h))
-               elif i > 0:
-                       choicelist.append(("%d" % i, _("Standby in ") + h))
-               else:
-                       choicelist.append(("0", _("Do nothing")))
+               choicelist.append(("%d" % i, _("Standby in ") + h))
        config.usage.inactivity_timer = ConfigSelection(default = "0", choices = choicelist)
        config.usage.inactivity_timer_blocktime = ConfigYesNo(default = True)
        config.usage.inactivity_timer_blocktime_begin = ConfigClock(default = time.mktime((0, 0, 0, 6, 0, 0, 0, 0, 0)))
        config.usage.inactivity_timer_blocktime_end = ConfigClock(default = time.mktime((0, 0, 0, 23, 0, 0, 0, 0, 0)))
 
-       choicelist = []
-       for i in range(-7200, 7201, 900):
+       choicelist = [("0", _("Disabled")),("event_standby", _("Standby after current event"))]
+       for i in range(900, 7201, 900):
                m = abs(i / 60)
                m = ngettext("%d minute", "%d minutes", m) % m
-               if i < 0:
-                       choicelist.append(("%d" % i, _("Shutdown in ") + m))
-               elif i > 0:
-                       choicelist.append(("%d" % i, _("Standby in ") + m))
-               else:
-                       choicelist.append(("event_shutdown", _("Shutdown after current event")))
-                       choicelist.append(("0", _("Disabled")))
-                       choicelist.append(("event_standby", _("Standby after current event")))
+               choicelist.append(("%d" % i, _("Standby in ") + m))
        config.usage.sleep_timer = ConfigSelection(default = "0", choices = choicelist)
 
        choicelist = [("0", _("Disabled"))]
-       for i in range(900, 7201, 900):
+       for i in [60, 300, 600] + range(900, 7201, 900):
                m = abs(i / 60)
                m = ngettext("%d minute", "%d minutes", m) % m
                choicelist.append(("%d" % i, _("after ") + m))
index 6e63381..8bd52d0 100644 (file)
@@ -2951,71 +2951,49 @@ class InfoBarPowersaver:
                if Screens.Standby.inStandby:
                        self.inactivityTimeoutCallback(True)
                else:
-                       if int(config.usage.inactivity_timer.value) < 0:
-                               message = _("Your receiver will shutdown due to inactivity.")
-                       else:
-                               message = _("Your receiver will got to standby due to inactivity.")
-                       message += "\n" + _("Do you want this?")
+                       message = _("Your receiver will got to standby due to inactivity.") + "\n" + _("Do you want this?")
                        self.session.openWithCallback(self.inactivityTimeoutCallback, MessageBox, message, timeout=60, simple=True, default=False, timeout_default=True)        
 
        def inactivityTimeoutCallback(self, answer):
                if answer:
-                       self.goShutdownOrStandby(int(config.usage.inactivity_timer.value))
+                       self.goStandby()
                else:
                        print "[InfoBarPowersaver] abort"
 
        def setSleepTimer(self, time):
                print "[InfoBarPowersaver] set sleeptimer", time
                if time:
-                       if time < 0:
-                               message = _("And will shutdown your receiver over ")
-                       else:
-                               message = _("And will put your receiver in standby over ")
+                       message = _("And will put your receiver in standby over ")
                        m = abs(time / 60)
                        message = _("The sleep timer has been activated.") + "\n" + message + ngettext("%d minute", "%d minutes", m) % m
-                       self.sleepTimer.startLongTimer(abs(time))
+                       self.sleepTimer.startLongTimer(time)
                else:
                        message = _("The sleep timer has been disabled.")
                        self.sleepTimer.stop()
                Notifications.AddPopup(message, type = MessageBox.TYPE_INFO, timeout = 5)
-               self.sleepTimerSetting = time
 
        def sleepTimerTimeout(self):
-               if Screens.Standby.inStandby:
-                       self.sleepTimerTimeoutCallback(True)
-               else:
+               if not Screens.Standby.inStandby:
                        list = [ (_("Yes"), True), (_("Extend sleeptimer 15 minutes"), "extend"), (_("No"), False) ]
-                       if self.sleepTimerSetting < 0:
-                               message = _("Your receiver will shutdown due to the sleeptimer.")
-                       elif self.sleepTimerSetting > 0:
-                               message = _("Your receiver will got to stand by due to the sleeptimer.")
+                       message = _("Your receiver will got to stand by due to the sleeptimer.")
                        message += "\n" + _("Do you want this?")
                        self.session.openWithCallback(self.sleepTimerTimeoutCallback, MessageBox, message, timeout=60, simple=True, list=list, default=False, timeout_default=True)     
 
        def sleepTimerTimeoutCallback(self, answer):
                if answer == "extend":
                        print "[InfoBarPowersaver] extend sleeptimer"
-                       if self.sleepTimerSetting < 0:
-                               self.setSleepTimer(-900)
-                       else:
-                               self.setSleepTimer(900)
+                       self.setSleepTimer(900)
                elif answer:
-                       self.goShutdownOrStandby(self.sleepTimerSetting)
+                       self.goStandby()
                else:
                        print "[InfoBarPowersaver] abort"
                        self.setSleepTimer(0)
 
-       def goShutdownOrStandby(self, value):
-               if value < 0:
-                       if Screens.Standby.inStandby:
-                               print "[InfoBarPowersaver] already in standby now shut down"
-                               RecordTimerEntry.TryQuitMainloop()
-                       elif not Screens.Standby.inTryQuitMainloop:
-                               print "[InfoBarPowersaver] goto shutdown"
-                               self.session.open(Screens.Standby.TryQuitMainloop, 1)
-               elif not Screens.Standby.inStandby:
+       def goStandby(self):
+               if not Screens.Standby.inStandby:
                        print "[InfoBarPowersaver] goto standby"
                        self.session.open(Screens.Standby.Standby)
+
 class InfoBarHDMI:
        def __init__(self):
                self["HDMIActions"] = HelpableActionMap(self, "InfobarHDMIActions",
index 224632a..ee5f8a2 100644 (file)
@@ -40,10 +40,10 @@ class SleepTimerEdit(ConfigListScreen, Screen):
                self.list = []
                self.list.append(getConfigListEntry(_("Sleeptimer"),
                        config.usage.sleep_timer,
-                       _("Configure the duration in minutes and action, which could be shut down or standby, for the sleeptimer. Select this entry and click OK or green to start/stop the sleeptimer")))
+                       _("Configure the duration in minutes for the sleeptimer. Select this entry and click OK or green to start/stop the sleeptimer")))
                self.list.append(getConfigListEntry(_("Inactivity Sleeptimer"),
                        config.usage.inactivity_timer,
-                       _("Configure the duration in hours and action, which could be shut down or standby, when the receiver is not controlled.")))
+                       _("Configure the duration in hours the receiver should go to standby when the receiver is not controlled.")))
                if int(config.usage.inactivity_timer.value):
                        self.list.append(getConfigListEntry(_("Specify timeframe to ignore inactivity sleeptimer"),
                                config.usage.inactivity_timer_blocktime,
@@ -61,7 +61,7 @@ class SleepTimerEdit(ConfigListScreen, Screen):
                if int(config.usage.standby_to_shutdown_timer.value):
                        self.list.append(getConfigListEntry(_("Specify timeframe to ignore the shutdown in standby"),
                                config.usage.standby_to_shutdown_timer_blocktime,
-                               _("When enabled you can specify a timeframe were the inactivity sleeptimer is ignored. Not the detection is disabled during this timeframe but the inactivity timeout is disabled")))
+                               _("When enabled you can specify a timeframe to ignore the shutdown timer when the receiver is in standby mode")))
                        if config.usage.inactivity_timer_blocktime.value:
                                self.list.append(getConfigListEntry(_("Start time to ignore shutdown in standby"),
                                        config.usage.standby_to_shutdown_timer_blocktime_begin,
@@ -73,21 +73,13 @@ class SleepTimerEdit(ConfigListScreen, Screen):
                self["config"].l.setList(self.list)
 
        def ok(self):
-               config.usage.sleep_timer.save()
-               config.usage.inactivity_timer.save()
-               config.usage.inactivity_timer_blocktime.save()
-               config.usage.inactivity_timer_blocktime_begin.save()
-               config.usage.inactivity_timer_blocktime_end.save()
-               config.usage.standby_to_shutdown_timer.save()
-               config.usage.standby_to_shutdown_timer_blocktime.save()
-               config.usage.standby_to_shutdown_timer_blocktime_begin.save()
-               config.usage.standby_to_shutdown_timer_blocktime_end.save()
-
+               if self["config"].isChanged():
+                       for x in self["config"].list:
+                               x[1].save()
+                       self.close()
                if self.getCurrentEntry() == _("Sleeptimer"):
                        sleepTimer = config.usage.sleep_timer.value
-                       if sleepTimer == "event_shutdown":
-                               sleepTimer = -self.currentEventTime()
-                       elif sleepTimer == "event_standby":
+                       if sleepTimer == "event_standby":
                                sleepTimer = self.currentEventTime()
                        else:
                                sleepTimer = int(sleepTimer)