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,440" 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,350" scrollbarMode="showOnDemand" />
24 <ePixmap pixmap="skin_default/div-h.png" position="0,400" zPosition="1" size="560,2" />
25 <widget source="introduction" render="Label" position="5,410" size="550,30" 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.oldScaler_vertical_dejagging = config.pep.scaler_vertical_dejagging.value
70 self.oldSmooth = config.pep.smooth.value
71 self.oldSplit = config.pep.split.value
72 self.oldSharpness = config.pep.sharpness.value
73 self.oldAuto_flesh = config.pep.auto_flesh.value
74 self.oldGreen_boost = config.pep.green_boost.value
75 self.oldBlue_boost = config.pep.blue_boost.value
76 self.oldDynamic_contrast = config.pep.dynamic_contrast.value
78 def addToConfigList(self, description, configEntry, add_to_xtdlist=False):
79 if isinstance(configEntry, ConfigNothing):
81 entry = getConfigListEntry(description, configEntry)
82 self.list.append(entry);
84 self.xtdlist.append(entry)
87 def createSetup(self):
90 addToConfigList = self.addToConfigList
91 self.contrastEntry = addToConfigList(_("Contrast"), config.pep.contrast)
92 self.saturationEntry = addToConfigList(_("Saturation"), config.pep.saturation)
93 self.hueEntry = addToConfigList(_("Hue"), config.pep.hue)
94 self.brightnessEntry = addToConfigList(_("Brightness"), config.pep.brightness)
95 self.scaler_sharpnessEntry = addToConfigList(_("Scaler sharpness"), config.av.scaler_sharpness)
96 self.scaler_vertical_dejaggingEntry = addToConfigList(_("Scaler vertical dejagging"), config.pep.scaler_vertical_dejagging)
97 self.smoothEntry = addToConfigList(_("Smooth"), config.pep.smooth)
98 self.splitEntry = addToConfigList(_("Split preview mode"), config.pep.split, True)
99 add_to_xtdlist = self.splitEntry is not None
100 self.sharpnessEntry = addToConfigList(_("Sharpness"), config.pep.sharpness, add_to_xtdlist)
101 self.auto_fleshEntry = addToConfigList(_("Auto flesh"), config.pep.auto_flesh, add_to_xtdlist)
102 self.green_boostEntry = addToConfigList(_("Green boost"), config.pep.green_boost, add_to_xtdlist)
103 self.blue_boostEntry = addToConfigList(_("Blue boost"), config.pep.blue_boost, add_to_xtdlist)
104 self.dynamic_contrastEntry = addToConfigList(_("Dynamic contrast"), config.pep.dynamic_contrast, add_to_xtdlist)
105 self.block_noise_reductionEntry = addToConfigList(_("Block noise reduction"), config.pep.block_noise_reduction, add_to_xtdlist)
106 self.mosquito_noise_reductionEntry = addToConfigList(_("Mosquito noise reduction"), config.pep.mosquito_noise_reduction, add_to_xtdlist)
107 self.digital_contour_removalEntry = addToConfigList(_("Digital contour removal"), config.pep.digital_contour_removal, add_to_xtdlist)
109 self["config"].list = self.list
110 self["config"].l.setSeperation(300)
111 self["config"].l.setList(self.list)
112 if not self.selectionChanged in self["config"].onSelectionChanged:
113 self["config"].onSelectionChanged.append(self.selectionChanged)
114 self.selectionChanged()
116 def selectionChanged(self):
117 self["introduction"].setText(_("Current value: ") + self.getCurrentValue())
119 def PreviewClosed(self):
120 self["config"].invalidate(self["config"].getCurrent())
124 current = self["config"].getCurrent()
125 if current == self.splitEntry:
126 ConfigListScreen.keyLeft(self)
127 elif (current == self.scaler_vertical_dejaggingEntry) or (current == self.smoothEntry):
128 ConfigListScreen.keyLeft(self)
129 elif current != self.splitEntry and current in self.xtdlist:
134 maxvalue = current[1].max
135 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value, maxValue = maxvalue)
140 maxvalue = current[1].max
141 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = None, maxValue = maxvalue)
144 current = self["config"].getCurrent()
145 if current == self.splitEntry:
146 ConfigListScreen.keyRight(self)
147 elif (current == self.scaler_vertical_dejaggingEntry) or (current == self.smoothEntry):
148 ConfigListScreen.keyRight(self)
149 elif current != self.splitEntry and current in self.xtdlist:
154 maxvalue = current[1].max
155 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value, maxValue = maxvalue )
160 maxvalue = current[1].max
161 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = None, maxValue = maxvalue)
164 def confirm(self, confirmed):
166 print "not confirmed"
168 if self.splitEntry is not None:
169 config.pep.split.setValue('off')
173 self.session.openWithCallback(self.confirm, MessageBox, _("Use this video enhancement settings?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
175 def cancelConfirm(self, result):
178 self.keyYellowConfirm(True)
182 if self["config"].isChanged():
183 self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
187 def keyYellowConfirm(self, confirmed):
189 print "not confirmed"
191 if self.contrastEntry is not None:
192 config.pep.contrast.setValue(self.oldContrast)
193 if self.saturationEntry is not None:
194 config.pep.saturation.setValue(self.oldSaturation)
195 if self.hueEntry is not None:
196 config.pep.hue.setValue(self.oldHue)
197 if self.brightnessEntry is not None:
198 config.pep.brightness.setValue(self.oldBrightness)
199 if self.block_noise_reductionEntry is not None:
200 config.pep.block_noise_reduction.setValue(self.oldBlock_noise)
201 if self.mosquito_noise_reductionEntry is not None:
202 config.pep.mosquito_noise_reduction.setValue(self.oldMosquito_noise)
203 if self.digital_contour_removalEntry is not None:
204 config.pep.digital_contour_removal.setValue(self.oldDigital_contour)
205 if self.scaler_sharpnessEntry is not None:
206 config.av.scaler_sharpness.setValue(self.oldScaler_sharpness)
207 if self.scaler_vertical_dejaggingEntry is not None:
208 config.pep.scaler_vertical_dejagging.setValue(self.oldScaler_vertical_dejagging)
209 if self.smoothEntry is not None:
210 config.pep.smooth.setValue(self.oldSmooth)
211 if self.splitEntry is not None:
212 config.pep.split.setValue('off')
213 if self.sharpnessEntry is not None:
214 config.pep.sharpness.setValue(self.oldSharpness)
215 if self.auto_fleshEntry is not None:
216 config.pep.auto_flesh.setValue(self.oldAuto_flesh)
217 if self.green_boostEntry is not None:
218 config.pep.green_boost.setValue(self.oldGreen_boost)
219 if self.blue_boostEntry is not None:
220 config.pep.blue_boost.setValue(self.oldBlue_boost)
221 if self.dynamic_contrastEntry is not None:
222 config.pep.dynamic_contrast.setValue(self.oldDynamic_contrast)
226 self.session.openWithCallback(self.keyYellowConfirm, MessageBox, _("Reset video enhancement settings to your last configuration?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
228 def keyBlueConfirm(self, confirmed):
230 print "not confirmed"
232 if self.contrastEntry is not None:
233 config.pep.contrast.setValue(128)
234 if self.saturationEntry is not None:
235 config.pep.saturation.setValue(128)
236 if self.hueEntry is not None:
237 config.pep.hue.setValue(128)
238 if self.brightnessEntry is not None:
239 config.pep.brightness.setValue(128)
240 if self.block_noise_reductionEntry is not None:
241 config.pep.block_noise_reduction.setValue(0)
242 if self.mosquito_noise_reductionEntry is not None:
243 config.pep.mosquito_noise_reduction.setValue(0)
244 if self.digital_contour_removalEntry is not None:
245 config.pep.digital_contour_removal.setValue(0)
246 if self.scaler_sharpnessEntry is not None:
247 config.av.scaler_sharpness.setValue(13)
248 if self.scaler_vertical_dejaggingEntry is not None:
249 config.pep.scaler_vertical_dejagging.setValue(False)
250 if self.smoothEntry is not None:
251 config.pep.smooth.setValue(False)
252 if self.splitEntry is not None:
253 config.pep.split.setValue('off')
254 if self.sharpnessEntry is not None:
255 config.pep.sharpness.setValue(0)
256 if self.auto_fleshEntry is not None:
257 config.pep.auto_flesh.setValue(0)
258 if self.green_boostEntry is not None:
259 config.pep.green_boost.setValue(0)
260 if self.blue_boostEntry is not None:
261 config.pep.blue_boost.setValue(0)
262 if self.dynamic_contrastEntry is not None:
263 config.pep.dynamic_contrast.setValue(0)
267 self.session.openWithCallback(self.keyBlueConfirm, MessageBox, _("Reset video enhancement settings to system defaults?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
270 def changedEntry(self):
271 for x in self.onChangedEntry:
273 self.selectionChanged()
275 def getCurrentEntry(self):
276 return self["config"].getCurrent()[0]
278 def getCurrentValue(self):
279 return str(self["config"].getCurrent()[1].getText())
281 def createSummary(self):
282 from Screens.Setup import SetupSummary
286 class VideoEnhancementPreview(Screen, ConfigListScreen):
289 <screen name="VideoEnhancementPreview" position="center,360" size="560,170" title="VideoEnhancementPreview">
290 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
291 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
292 <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" />
293 <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" />
294 <widget name="config" position="5,50" size="550,80" scrollbarMode="showOnDemand" />
295 <ePixmap pixmap="skin_default/div-h.png" position="0,130" zPosition="1" size="560,2" />
296 <widget source="introduction" render="Label" position="0,140" size="550,25" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
299 def __init__(self, session, configEntry = None, oldSplitMode = None, maxValue = None):
300 Screen.__init__(self, session)
302 self.onChangedEntry = [ ]
303 self.setup_title = "Videoenhancement"
304 self.oldSplitMode = oldSplitMode
305 self.maxValue = maxValue
306 self.configStepsEntry = None
307 self.isStepSlider = None
310 self.configEntry = configEntry
311 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
313 self["actions"] = ActionMap(["SetupActions"],
315 "cancel": self.keyCancel,
316 "save": self.keySave,
319 self["key_red"] = StaticText(_("Cancel"))
320 self["key_green"] = StaticText(_("OK"))
321 self["introduction"] = StaticText()
324 self.onLayoutFinish.append(self.layoutFinished)
326 def layoutFinished(self):
327 self.setTitle(_("Video enhancement preview"))
329 def createSetup(self):
331 if self.maxValue == 256:
332 self.configStepsEntry = getConfigListEntry(_("Change step size"), config.pep.configsteps)
334 if self.configEntry is not None:
335 self.list = self.configEntry
336 if self.maxValue == 256:
337 self.list.append(self.configStepsEntry)
339 self["config"].list = self.list
340 self["config"].l.setSeperation(300)
341 self["config"].l.setList(self.list)
342 if not self.selectionChanged in self["config"].onSelectionChanged:
343 self["config"].onSelectionChanged.append(self.selectionChanged)
344 self.selectionChanged()
346 def selectionChanged(self):
347 self["introduction"].setText(_("Current value: ") + self.getCurrentValue())
349 max_avail=self["config"].getCurrent()[1].max
351 self.isStepSlider = True
353 self.isStepSlider = False
354 except AttributeError:
358 if self.isStepSlider is True:
359 self["config"].getCurrent()[1].increment = config.pep.configsteps.value
360 ConfigListScreen.keyLeft(self)
363 if self.isStepSlider is True:
364 self["config"].getCurrent()[1].increment = config.pep.configsteps.value
365 ConfigListScreen.keyRight(self)
368 if self.oldSplitMode is not None:
369 currentSplitMode = config.pep.split.value
370 if self.oldSplitMode == 'off' and currentSplitMode != 'off':
371 config.pep.split.setValue('off')
377 for x in self["config"].list:
379 if self.oldSplitMode is not None:
380 currentSplitMode = config.pep.split.value
381 if self.oldSplitMode == 'off' and currentSplitMode != 'off':
382 config.pep.split.setValue('off')
388 def changedEntry(self):
389 for x in self.onChangedEntry:
391 self.selectionChanged()
393 def getCurrentEntry(self):
394 return self["config"].getCurrent()[0]
396 def getCurrentValue(self):
397 return str(self["config"].getCurrent()[1].getText())
399 def createSummary(self):
400 from Screens.Setup import SetupSummary
403 def videoEnhancementSetupMain(session, **kwargs):
404 session.open(VideoEnhancementSetup)
406 def startSetup(menuid):
407 if menuid != "system":
409 return [(_("Video enhancement settings") , videoEnhancementSetupMain, "videoenhancement_setup", 41)]
411 def Plugins(**kwargs):
413 if config.usage.setup_level.index >= 2 and os_path.exists("/proc/stb/vmpeg/0/pep_apply"):
414 list.append(PluginDescriptor(name=_("Videoenhancement Setup"), description=_("Advanced Video Enhancement Setup"), where = PluginDescriptor.WHERE_MENU, needsRestart = False, fnc=startSetup))