1 from Plugins.Plugin import PluginDescriptor
2 from Components.ConfigList import ConfigListScreen
3 from Components.config import getConfigListEntry, config, ConfigNothing, ConfigSelection
4 from Components.ActionMap import ActionMap
5 from Components.Sources.StaticText import StaticText
6 from Screens.Screen import Screen
7 from Screens.MessageBox import MessageBox
8 import VideoEnhancement
9 from os import path as os_path
11 class VideoEnhancementSetup(Screen, ConfigListScreen):
14 <screen name="VideoEnhancementSetup" position="center,center" size="560,430" title="VideoEnhancementSetup">
15 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
16 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
17 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
18 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
19 <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
20 <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
21 <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
22 <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
23 <widget name="config" position="5,50" size="550,340" scrollbarMode="showOnDemand" />
24 <ePixmap pixmap="skin_default/div-h.png" position="0,390" zPosition="1" size="560,2" />
25 <widget source="introduction" render="Label" position="5,400" size="550,25" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
28 def __init__(self, session):
29 Screen.__init__(self, session)
31 self.session = session
32 self.onChangedEntry = [ ]
33 self.setup_title = "Videoenhancement"
37 ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry)
39 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
41 "cancel": self.keyCancel,
43 "yellow": self.keyYellow,
47 self["key_red"] = StaticText(_("Cancel"))
48 self["key_green"] = StaticText(_("OK"))
49 self["key_yellow"] = StaticText(_("Last config"))
50 self["key_blue"] = StaticText(_("Default"))
51 self["introduction"] = StaticText()
54 self.rememberOldSettings()
55 self.onLayoutFinish.append(self.layoutFinished)
57 def layoutFinished(self):
58 self.setTitle(_("Video enhancement setup"))
60 def rememberOldSettings(self):
61 self.oldContrast = config.pep.contrast.value
62 self.oldSaturation = config.pep.saturation.value
63 self.oldHue = config.pep.hue.value
64 self.oldBrightness = config.pep.brightness.value
65 self.oldBlock_noise = config.pep.block_noise_reduction.value
66 self.oldMosquito_noise = config.pep.mosquito_noise_reduction.value
67 self.oldDigital_contour = config.pep.digital_contour_removal.value
68 self.oldScaler_sharpness = config.av.scaler_sharpness.value
69 self.oldSplit = config.pep.split.value
70 self.oldSharpness = config.pep.sharpness.value
71 self.oldAuto_flesh = config.pep.auto_flesh.value
72 self.oldGreen_boost = config.pep.green_boost.value
73 self.oldBlue_boost = config.pep.blue_boost.value
74 self.oldDynamic_contrast = config.pep.dynamic_contrast.value
76 def addToConfigList(self, description, configEntry, add_to_xtdlist=False):
77 if isinstance(configEntry, ConfigNothing):
79 entry = getConfigListEntry(description, configEntry)
80 self.list.append(entry);
82 self.xtdlist.append(entry)
85 def createSetup(self):
88 addToConfigList = self.addToConfigList
89 self.contrastEntry = addToConfigList(_("Contrast"), config.pep.contrast)
90 self.saturationEntry = addToConfigList(_("Saturation"), config.pep.saturation)
91 self.hueEntry = addToConfigList(_("Hue"), config.pep.hue)
92 self.brightnessEntry = addToConfigList(_("Brightness"), config.pep.brightness)
93 self.scaler_sharpnessEntry = addToConfigList(_("Scaler sharpness"), config.av.scaler_sharpness)
94 self.splitEntry = addToConfigList(_("Split preview mode"), config.pep.split, True)
95 add_to_xtdlist = self.splitEntry is not None
96 self.sharpnessEntry = addToConfigList(_("Sharpness"), config.pep.sharpness, add_to_xtdlist)
97 self.auto_fleshEntry = addToConfigList(_("Auto flesh"), config.pep.auto_flesh, add_to_xtdlist)
98 self.green_boostEntry = addToConfigList(_("Green boost"), config.pep.green_boost, add_to_xtdlist)
99 self.blue_boostEntry = addToConfigList(_("Blue boost"), config.pep.blue_boost, add_to_xtdlist)
100 self.dynamic_contrastEntry = addToConfigList(_("Dynamic contrast"), config.pep.dynamic_contrast, add_to_xtdlist)
101 self.block_noise_reductionEntry = addToConfigList(_("Block noise reduction"), config.pep.block_noise_reduction, add_to_xtdlist)
102 self.mosquito_noise_reductionEntry = addToConfigList(_("Mosquito noise reduction"), config.pep.mosquito_noise_reduction, add_to_xtdlist)
103 self.digital_contour_removalEntry = addToConfigList(_("Digital contour removal"), config.pep.digital_contour_removal, add_to_xtdlist)
105 self["config"].list = self.list
106 self["config"].l.setSeperation(300)
107 self["config"].l.setList(self.list)
108 if not self.selectionChanged in self["config"].onSelectionChanged:
109 self["config"].onSelectionChanged.append(self.selectionChanged)
110 self.selectionChanged()
112 def selectionChanged(self):
113 self["introduction"].setText(_("Current value: ") + self.getCurrentValue())
115 def PreviewClosed(self):
116 self["config"].invalidate(self["config"].getCurrent())
120 current = self["config"].getCurrent()
121 if current == self.splitEntry:
122 ConfigListScreen.keyLeft(self)
123 elif current != self.splitEntry and current in self.xtdlist:
128 maxvalue = current[1].max
129 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value, maxValue = maxvalue)
134 maxvalue = current[1].max
135 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = None, maxValue = maxvalue)
138 current = self["config"].getCurrent()
139 if current == self.splitEntry:
140 ConfigListScreen.keyRight(self)
141 elif current != self.splitEntry and current in self.xtdlist:
146 maxvalue = current[1].max
147 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value, maxValue = maxvalue )
152 maxvalue = current[1].max
153 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = None, maxValue = maxvalue)
155 def confirm(self, confirmed):
157 print "not confirmed"
159 if self.splitEntry is not None:
160 config.pep.split.setValue('off')
164 self.session.openWithCallback(self.confirm, MessageBox, _("Use this video enhancement settings?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
166 def cancelConfirm(self, result):
169 self.keyYellowConfirm(True)
173 if self["config"].isChanged():
174 self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
178 def keyYellowConfirm(self, confirmed):
180 print "not confirmed"
182 if self.contrastEntry is not None:
183 config.pep.contrast.setValue(self.oldContrast)
184 if self.saturationEntry is not None:
185 config.pep.saturation.setValue(self.oldSaturation)
186 if self.hueEntry is not None:
187 config.pep.hue.setValue(self.oldHue)
188 if self.brightnessEntry is not None:
189 config.pep.brightness.setValue(self.oldBrightness)
190 if self.block_noise_reductionEntry is not None:
191 config.pep.block_noise_reduction.setValue(self.oldBlock_noise)
192 if self.mosquito_noise_reductionEntry is not None:
193 config.pep.mosquito_noise_reduction.setValue(self.oldMosquito_noise)
194 if self.digital_contour_removalEntry is not None:
195 config.pep.digital_contour_removal.setValue(self.oldDigital_contour)
196 if self.scaler_sharpnessEntry is not None:
197 config.av.scaler_sharpness.setValue(self.oldScaler_sharpness)
198 if self.splitEntry is not None:
199 config.pep.split.setValue('off')
200 if self.sharpnessEntry is not None:
201 config.pep.sharpness.setValue(self.oldSharpness)
202 if self.auto_fleshEntry is not None:
203 config.pep.auto_flesh.setValue(self.oldAuto_flesh)
204 if self.green_boostEntry is not None:
205 config.pep.green_boost.setValue(self.oldGreen_boost)
206 if self.blue_boostEntry is not None:
207 config.pep.blue_boost.setValue(self.oldBlue_boost)
208 if self.dynamic_contrastEntry is not None:
209 config.pep.dynamic_contrast.setValue(self.oldDynamic_contrast)
213 self.session.openWithCallback(self.keyYellowConfirm, MessageBox, _("Reset video enhancement settings to your last configuration?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
215 def keyBlueConfirm(self, confirmed):
217 print "not confirmed"
219 if self.contrastEntry is not None:
220 config.pep.contrast.setValue(128)
221 if self.saturationEntry is not None:
222 config.pep.saturation.setValue(128)
223 if self.hueEntry is not None:
224 config.pep.hue.setValue(128)
225 if self.brightnessEntry is not None:
226 config.pep.brightness.setValue(128)
227 if self.block_noise_reductionEntry is not None:
228 config.pep.block_noise_reduction.setValue(0)
229 if self.mosquito_noise_reductionEntry is not None:
230 config.pep.mosquito_noise_reduction.setValue(0)
231 if self.digital_contour_removalEntry is not None:
232 config.pep.digital_contour_removal.setValue(0)
233 if self.scaler_sharpnessEntry is not None:
234 config.av.scaler_sharpness.setValue(13)
235 if self.splitEntry is not None:
236 config.pep.split.setValue('off')
237 if self.sharpnessEntry is not None:
238 config.pep.sharpness.setValue(0)
239 if self.auto_fleshEntry is not None:
240 config.pep.auto_flesh.setValue(0)
241 if self.green_boostEntry is not None:
242 config.pep.green_boost.setValue(0)
243 if self.blue_boostEntry is not None:
244 config.pep.blue_boost.setValue(0)
245 if self.dynamic_contrastEntry is not None:
246 config.pep.dynamic_contrast.setValue(0)
250 self.session.openWithCallback(self.keyBlueConfirm, MessageBox, _("Reset video enhancement settings to system defaults?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
253 def changedEntry(self):
254 for x in self.onChangedEntry:
256 self.selectionChanged()
258 def getCurrentEntry(self):
259 return self["config"].getCurrent()[0]
261 def getCurrentValue(self):
262 return str(self["config"].getCurrent()[1].getText())
264 def createSummary(self):
265 from Screens.Setup import SetupSummary
269 class VideoEnhancementPreview(Screen, ConfigListScreen):
272 <screen name="VideoEnhancementPreview" position="center,360" size="560,170" title="VideoEnhancementPreview">
273 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
274 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
275 <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
276 <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
277 <widget name="config" position="5,50" size="550,80" scrollbarMode="showOnDemand" />
278 <ePixmap pixmap="skin_default/div-h.png" position="0,130" zPosition="1" size="560,2" />
279 <widget source="introduction" render="Label" position="0,140" size="550,25" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
282 def __init__(self, session, configEntry = None, oldSplitMode = None, maxValue = None):
283 Screen.__init__(self, session)
285 self.onChangedEntry = [ ]
286 self.setup_title = "Videoenhancement"
287 self.oldSplitMode = oldSplitMode
288 self.maxValue = maxValue
289 self.configStepsEntry = None
290 self.isStepSlider = None
293 self.configEntry = configEntry
294 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
296 self["actions"] = ActionMap(["SetupActions"],
298 "cancel": self.keyCancel,
299 "save": self.keySave,
302 self["key_red"] = StaticText(_("Cancel"))
303 self["key_green"] = StaticText(_("OK"))
304 self["introduction"] = StaticText()
307 self.onLayoutFinish.append(self.layoutFinished)
309 def layoutFinished(self):
310 self.setTitle(_("Video enhancement preview"))
312 def createSetup(self):
314 if self.maxValue == 256:
315 self.configStepsEntry = getConfigListEntry(_("Change step size"), config.pep.configsteps)
317 if self.configEntry is not None:
318 self.list = self.configEntry
319 if self.maxValue == 256:
320 self.list.append(self.configStepsEntry)
322 self["config"].list = self.list
323 self["config"].l.setSeperation(300)
324 self["config"].l.setList(self.list)
325 if not self.selectionChanged in self["config"].onSelectionChanged:
326 self["config"].onSelectionChanged.append(self.selectionChanged)
327 self.selectionChanged()
329 def selectionChanged(self):
330 self["introduction"].setText(_("Current value: ") + self.getCurrentValue())
332 max_avail=self["config"].getCurrent()[1].max
334 self.isStepSlider = True
336 self.isStepSlider = False
337 except AttributeError:
341 if self.isStepSlider is True:
342 self["config"].getCurrent()[1].increment = config.pep.configsteps.value
343 ConfigListScreen.keyLeft(self)
346 if self.isStepSlider is True:
347 self["config"].getCurrent()[1].increment = config.pep.configsteps.value
348 ConfigListScreen.keyRight(self)
351 if self.oldSplitMode is not None:
352 currentSplitMode = config.pep.split.value
353 if self.oldSplitMode == 'off' and currentSplitMode != 'off':
354 config.pep.split.setValue('off')
360 for x in self["config"].list:
362 if self.oldSplitMode is not None:
363 currentSplitMode = config.pep.split.value
364 if self.oldSplitMode == 'off' and currentSplitMode != 'off':
365 config.pep.split.setValue('off')
371 def changedEntry(self):
372 for x in self.onChangedEntry:
374 self.selectionChanged()
376 def getCurrentEntry(self):
377 return self["config"].getCurrent()[0]
379 def getCurrentValue(self):
380 return str(self["config"].getCurrent()[1].getText())
382 def createSummary(self):
383 from Screens.Setup import SetupSummary
386 def videoEnhancementSetupMain(session, **kwargs):
387 session.open(VideoEnhancementSetup)
389 def startSetup(menuid):
390 if menuid != "system":
392 return [(_("Video enhancement settings") , videoEnhancementSetupMain, "videoenhancement_setup", 41)]
394 def Plugins(**kwargs):
396 if config.usage.setup_level.index >= 2 and os_path.exists("/proc/stb/vmpeg/0/pep_apply"):
397 list.append(PluginDescriptor(name=_("Videoenhancement Setup"), description=_("Advanced Video Enhancement Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup))