-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DateTimeInput.py] Replace TimeDateInput with DateTimeInput (#3198)
[DateTimeInput.py] - This is a new module that offers a more concise user interface for setting times for instant recordings and EPG navigation. - This new code is a subclass of Setup to reduce the amount of code copied from Setup.py and ConfigList.py. - This code uses consistent navigation relative to other Setup based screens. - The times entered now directly and accurately update the date *without* requiring an extra control with which users must interact. - The range of times and dates the user may select is now limited to only valid values. For example, instant recordings are now correctly limited to 24 hours and EPG jumps can be made forward in time as well as backwards in time to the extent of the EPG history that is enabled. - HELP is now available in this screen. - Button labels better reflect the actions to be performed when pressed. [InfoBarGenerics.py] - Switch from using TimeDateInput.py to DateTimeInput.py. - Optimize some code. - Improve some translation strings. - Use f-strings to improve performance of the button press logging. [EpgSelection.py] - Switch from using TimeDateInput.py to DateTimeInput.py. - Improve the action map that controls the DateTimeInput screen. - Remove use of getSkinFactor as it is not used in openATV (openATV has fully integrated and automatic skin scaling) and can cause skin issues. - PEP8 correct some code indentation. - Improve some translation strings. --------- Co-authored-by: jbleyel <[email protected]>
- Loading branch information
Showing
4 changed files
with
167 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from time import time | ||
|
||
from Components.ActionMap import HelpableActionMap | ||
from Components.config import ConfigDateTime, config | ||
from Screens.Setup import Setup | ||
|
||
|
||
class DateTime(Setup): | ||
def __init__(self, session, setupSection, default, smallStep=60): | ||
self.dateTime = ConfigDateTime(default, f"{config.usage.date.daylong.value} {config.usage.time.short.value}", increment=smallStep) | ||
Setup.__init__(self, session, setupSection) | ||
self.skinName.insert(0, "SetupDateTime") | ||
self["prevNextActions"] = HelpableActionMap(self, ["PreviousNextActions"], { # This is for users who do not use PREV/NEXT as first/last. | ||
"previous": (self.keyFirst, _("Jump back one hour") if self.bigStep == 3600 else _("Jump back one day")), | ||
"next": (self.keyLast, _("Jump forward one hour") if self.bigStep == 3600 else _("Jump forward one day")) | ||
}, prio=0, description=_("Date Time Input Actions")) | ||
|
||
def changedEntry(self): # This overrides the same class in Setup.py. | ||
current = self["config"].getCurrent() | ||
if current and current[1] == self.dateTime: | ||
if self.dateTime.value < self.minLimit: | ||
self.dateTime.value = self.minLimit | ||
elif self.dateTime.value > self.maxLimit: | ||
self.dateTime.value = self.maxLimit | ||
self["config"].invalidateCurrent() | ||
Setup.changedEntry(self) | ||
|
||
def keyFirst(self): # This overrides the same class in ConfigList.py as part of Setup.py. | ||
current = self["config"].getCurrent() | ||
if current and current[1] == self.dateTime: | ||
self.dateTime.value -= self.bigStep | ||
if self.dateTime.value < self.minLimit: | ||
self.dateTime.value = self.minLimit | ||
self["config"].invalidateCurrent() | ||
|
||
def keyLast(self): # This overrides the same class in ConfigList.py as part of Setup.py. | ||
current = self["config"].getCurrent() | ||
if current and current[1] == self.dateTime: | ||
self.dateTime.value += self.bigStep | ||
if self.dateTime.value > self.maxLimit: | ||
self.dateTime.value = self.maxLimit | ||
self["config"].invalidateCurrent() | ||
|
||
def keySave(self): # This overrides the same class in ConfigList.py as part of Setup.py. | ||
self.close((True, self.dateTime.value)) | ||
|
||
def keyCancel(self): # This overrides the same class in ConfigList.py as part of Setup.py. | ||
self.close((False,)) | ||
|
||
def closeRecursive(self): # This overrides the same class in ConfigList.py as part of Setup.py. | ||
self.close((True,)) | ||
|
||
|
||
class EPGJumpTime(DateTime): | ||
def __init__(self, session, configElement, historyBuffer): | ||
self.minLimit = int(time()) - (historyBuffer * 60) # Now - EPG history buffer length. | ||
self.maxLimit = int(time()) + 2419200 # Now + 4 weeks. | ||
self.smallStep = 3600 # 1 Hour. | ||
self.bigStep = 86400 # 1 Day. | ||
DateTime.__init__(self, session, "EPGJumpTime", default=int(time()), smallStep=self.smallStep) | ||
self.setTitle(_("EPG Jump")) | ||
self["key_green"].setText(_("Jump")) | ||
|
||
def createSetup(self): # This overrides the same class in Setup.py. | ||
configList = [ | ||
(_("Jump time"), self.dateTime, _("Select the time to which the EPG should be positioned. Press LEFT/RIGHT to decrease/increase the time by an hour. Press PREV/NEXT to decrease/increase the time by a day.")) | ||
] | ||
self["config"].setList(configList) | ||
|
||
|
||
class InstantRecordingEndTime(DateTime): | ||
def __init__(self, session, endTime): | ||
self.minLimit = int(time()) + 60 # Now + 1 minute. | ||
self.maxLimit = int(time()) + 86400 # Now + 1 day. | ||
self.smallStep = 60 # 1 Minute. | ||
self.bigStep = 3600 # 1 Hour. | ||
DateTime.__init__(self, session, "InstantRecordingEndTime", default=endTime, smallStep=self.smallStep) | ||
self.setTitle(_("Instant Recording End Time")) | ||
self["key_green"].setText(_("Set Time")) | ||
|
||
def createSetup(self): # This overrides the same class in Setup.py. | ||
configList = [ | ||
(_("End time"), self.dateTime, _("Select the time when this instant recording timer should end. Press LEFT/RIGHT to decrease/increase the time by a minute. Press PREV/NEXT to decrease/increase the time by an hour.")) | ||
] | ||
self["config"].setList(configList) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
3324017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a problem.
I initialize InstantRecordingEndTime with a time and 35 seconds deviation to the full minute.
If I change the time, I get the new displayed time +35 seconds. But I should get the full minute, because seconds are not displayed.
Except I do not make any changes, then it would be good to keep the 35 seconds.
Another ask!
Why "smallStep=60"? Then bigStep=3600 too!