Merge branch 'bug_713_fix_timerlist_sort' into experimental
[vuplus_dvbapp] / lib / python / Components / UsageConfig.py
1 from Components.Harddisk import harddiskmanager
2 from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigNumber, ConfigSet, ConfigLocations
3 from Tools.Directories import resolveFilename, SCOPE_HDD
4 from enigma import Misc_Options, setTunerTypePriorityOrder, eEnv;
5 from SystemInfo import SystemInfo
6 import os
7
8 def InitUsageConfig():
9         config.usage = ConfigSubsection();
10         config.usage.showdish = ConfigYesNo(default = True)
11         config.usage.multibouquet = ConfigYesNo(default = False)
12         config.usage.multiepg_ask_bouquet = ConfigYesNo(default = False)
13
14         config.usage.quickzap_bouquet_change = ConfigYesNo(default = False)
15         config.usage.e1like_radio_mode = ConfigYesNo(default = False)
16         config.usage.infobar_timeout = ConfigSelection(default = "5", choices = [
17                 ("0", _("no timeout")), ("1", "1 " + _("second")), ("2", "2 " + _("seconds")), ("3", "3 " + _("seconds")),
18                 ("4", "4 " + _("seconds")), ("5", "5 " + _("seconds")), ("6", "6 " + _("seconds")), ("7", "7 " + _("seconds")),
19                 ("8", "8 " + _("seconds")), ("9", "9 " + _("seconds")), ("10", "10 " + _("seconds"))])
20         config.usage.show_infobar_on_zap = ConfigYesNo(default = True)
21         config.usage.show_infobar_on_skip = ConfigYesNo(default = True)
22         config.usage.show_infobar_on_event_change = ConfigYesNo(default = True)
23         config.usage.hdd_standby = ConfigSelection(default = "600", choices = [
24                 ("0", _("no standby")), ("10", "10 " + _("seconds")), ("30", "30 " + _("seconds")),
25                 ("60", "1 " + _("minute")), ("120", "2 " + _("minutes")),
26                 ("300", "5 " + _("minutes")), ("600", "10 " + _("minutes")), ("1200", "20 " + _("minutes")),
27                 ("1800", "30 " + _("minutes")), ("3600", "1 " + _("hour")), ("7200", "2 " + _("hours")),
28                 ("14400", "4 " + _("hours")) ])
29         config.usage.output_12V = ConfigSelection(default = "do not change", choices = [
30                 ("do not change", _("do not change")), ("off", _("off")), ("on", _("on")) ])
31
32         config.usage.pip_zero_button = ConfigSelection(default = "standard", choices = [
33                 ("standard", _("standard")), ("swap", _("swap PiP and main picture")),
34                 ("swapstop", _("move PiP to main picture")), ("stop", _("stop PiP")) ])
35
36         config.usage.default_path = ConfigText(default = resolveFilename(SCOPE_HDD))
37         config.usage.timer_path = ConfigText(default = "<default>")
38         config.usage.instantrec_path = ConfigText(default = "<default>")
39         config.usage.timeshift_path = ConfigText(default = "/media/hdd/")
40         config.usage.allowed_timeshift_paths = ConfigLocations(default = ["/media/hdd/"])
41
42         config.usage.on_movie_start = ConfigSelection(default = "ask", choices = [
43                 ("ask", _("Ask user")), ("resume", _("Resume from last position")), ("beginning", _("Start from the beginning")) ])
44         config.usage.on_movie_stop = ConfigSelection(default = "ask", choices = [
45                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")) ])
46         config.usage.on_movie_eof = ConfigSelection(default = "ask", choices = [
47                 ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")), ("pause", _("Pause movie at end")) ])
48
49         config.usage.setup_level = ConfigSelection(default = "intermediate", choices = [
50                 ("simple", _("Simple")),
51                 ("intermediate", _("Intermediate")),
52                 ("expert", _("Expert")) ])
53
54         config.usage.on_long_powerpress = ConfigSelection(default = "show_menu", choices = [
55                 ("show_menu", _("show shutdown menu")),
56                 ("shutdown", _("immediate shutdown")),
57                 ("standby", _("Standby")) ] )
58         
59         config.usage.on_short_powerpress = ConfigSelection(default = "standby", choices = [
60                 ("show_menu", _("show shutdown menu")),
61                 ("shutdown", _("immediate shutdown")),
62                 ("standby", _("Standby")) ] )
63
64
65         config.usage.alternatives_priority = ConfigSelection(default = "0", choices = [
66                 ("0", "DVB-S/-C/-T"),
67                 ("1", "DVB-S/-T/-C"),
68                 ("2", "DVB-C/-S/-T"),
69                 ("3", "DVB-C/-T/-S"),
70                 ("4", "DVB-T/-C/-S"),
71                 ("5", "DVB-T/-S/-C") ])
72
73         config.usage.show_event_progress_in_servicelist = ConfigYesNo(default = False)
74
75         config.usage.blinking_display_clock_during_recording = ConfigYesNo(default = False)
76
77         config.usage.show_message_when_recording_starts = ConfigYesNo(default = True)
78
79         config.usage.load_length_of_movies_in_moviellist = ConfigYesNo(default = True)
80         
81         def TunerTypePriorityOrderChanged(configElement):
82                 setTunerTypePriorityOrder(int(configElement.value))
83         config.usage.alternatives_priority.addNotifier(TunerTypePriorityOrderChanged, immediate_feedback=False)
84
85         def setHDDStandby(configElement):
86                 for hdd in harddiskmanager.HDDList():
87                         hdd[1].setIdleTime(int(configElement.value))
88         config.usage.hdd_standby.addNotifier(setHDDStandby, immediate_feedback=False)
89
90         def set12VOutput(configElement):
91                 if configElement.value == "on":
92                         Misc_Options.getInstance().set_12V_output(1)
93                 elif configElement.value == "off":
94                         Misc_Options.getInstance().set_12V_output(0)
95         config.usage.output_12V.addNotifier(set12VOutput, immediate_feedback=False)
96
97         SystemInfo["12V_Output"] = Misc_Options.getInstance().detected_12V_output()
98
99         config.usage.keymap = ConfigText(default = eEnv.resolve("${datadir}/enigma2/keymap.xml"))
100
101         config.seek = ConfigSubsection()
102         config.seek.selfdefined_13 = ConfigNumber(default=15)
103         config.seek.selfdefined_46 = ConfigNumber(default=60)
104         config.seek.selfdefined_79 = ConfigNumber(default=300)
105
106         config.seek.speeds_forward = ConfigSet(default=[2, 4, 8, 16, 32, 64, 128], choices=[2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128])
107         config.seek.speeds_backward = ConfigSet(default=[2, 4, 8, 16, 32, 64, 128], choices=[1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128])
108         config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25])
109
110         config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
111         config.seek.enter_backward = ConfigSelection(default = "1", choices = ["1", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
112
113         config.seek.on_pause = ConfigSelection(default = "play", choices = [
114                 ("play", _("Play")),
115                 ("step", _("Singlestep (GOP)")),
116                 ("last", _("Last speed")) ])
117
118         config.usage.timerlist_finished_timer_position = ConfigSelection(default = "beginning", choices = [("beginning", _("at beginning")), ("end", _("at end"))])
119
120         def updateEnterForward(configElement):
121                 if not configElement.value:
122                         configElement.value = [2]
123                 updateChoices(config.seek.enter_forward, configElement.value)
124
125         config.seek.speeds_forward.addNotifier(updateEnterForward, immediate_feedback = False)
126
127         def updateEnterBackward(configElement):
128                 if not configElement.value:
129                         configElement.value = [2]
130                 updateChoices(config.seek.enter_backward, configElement.value)
131
132         config.seek.speeds_backward.addNotifier(updateEnterBackward, immediate_feedback = False)
133
134 def updateChoices(sel, choices):
135         if choices:
136                 defval = None
137                 val = int(sel.value)
138                 if not val in choices:
139                         tmp = choices[:]
140                         tmp.reverse()
141                         for x in tmp:
142                                 if x < val:
143                                         defval = str(x)
144                                         break
145                 sel.setChoices(map(str, choices), defval)
146
147 def preferredPath(path):
148         if config.usage.setup_level.index < 2 or path == "<default>":
149                 return None  # config.usage.default_path.value, but delay lookup until usage
150         elif path == "<current>":
151                 return config.movielist.last_videodir.value
152         elif path == "<timer>":
153                 return config.movielist.last_timer_videodir.value
154         else:
155                 return path
156
157 def preferredTimerPath():
158         return preferredPath(config.usage.timer_path.value)
159
160 def preferredInstantRecordPath():
161         return preferredPath(config.usage.instantrec_path.value)
162
163 def defaultMoviePath():
164         return config.usage.default_path.value
165