1 from Plugins.Plugin import PluginDescriptor
2 from Components.ConfigList import ConfigListScreen
3 from Components.config import getConfigListEntry, config, ConfigBoolean
4 from Components.ActionMap import ActionMap
5 from Components.Sources.StaticText import StaticText
6 from Screens.Screen import Screen
7 from Screens.VirtualKeyBoard import VirtualKeyBoard
8 from Screens.ChoiceBox import ChoiceBox
9 from Screens.MessageBox import MessageBox
10 from enigma import ePoint
11 from Tools import Notifications
12 from Tools.HardwareInfo import HardwareInfo
13 from VideoEnhancement import video_enhancement
16 class VideoEnhancementSetup(Screen, ConfigListScreen):
19 <screen name="VideoEnhancementSetup" position="center,center" size="560,430" title="VideoEnhancementSetup">
20 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
21 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
22 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
23 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
24 <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" />
25 <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" />
26 <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" />
27 <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" />
28 <widget name="config" position="5,50" size="550,340" scrollbarMode="showOnDemand" />
29 <ePixmap pixmap="skin_default/div-h.png" position="0,390" zPosition="1" size="560,2" />
30 <widget source="introduction" render="Label" position="5,400" size="550,25" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
33 def __init__(self, session, hw):
34 Screen.__init__(self, session)
36 self.session = session
38 self.onChangedEntry = [ ]
39 self.setup_title = "Videoenhancement"
41 self.contrastEntry = None
42 self.saturationEntry = None
44 self.brightnessEntry = None
45 self.splitEntry = None
46 self.sharpnessEntry = None
47 self.auto_fleshEntry = None
48 self.green_boostEntry = None
49 self.blue_boostEntry = None
50 self.block_noise_reductionEntry = None
51 self.mosquito_noise_reductionEntry = None
52 self.digital_contour_removalEntry = None
53 self.dynamic_contrastEntry = None
55 # handle hotplug by re-creating setup
56 self.onShow.append(self.startHotplug)
57 self.onHide.append(self.stopHotplug)
61 self.hw_type = HardwareInfo().get_device_name()
62 ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry)
64 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
66 "cancel": self.keyCancel,
68 "yellow": self.keyYellow,
72 self["key_red"] = StaticText(_("Cancel"))
73 self["key_green"] = StaticText(_("OK"))
74 self["key_yellow"] = StaticText(_("Last config"))
75 self["key_blue"] = StaticText(_("Default"))
76 self["introduction"] = StaticText()
79 self.rememberOldSettings()
80 self.onLayoutFinish.append(self.layoutFinished)
82 def layoutFinished(self):
83 self.setTitle(_("Video enhancement setup"))
85 def startHotplug(self):
86 self.hw.on_hotplug.append(self.createSetup)
88 def stopHotplug(self):
89 self.hw.on_hotplug.remove(self.createSetup)
91 def rememberOldSettings(self):
92 self.oldContrast = config.pep.contrast.value
93 self.oldSaturation = config.pep.saturation.value
94 self.oldHue = config.pep.hue.value
95 self.oldBrightness = config.pep.brightness.value
96 self.oldBlock_noise = config.pep.block_noise_reduction.value
97 self.oldMosquito_noise = config.pep.mosquito_noise_reduction.value
98 self.oldDigital_contour = config.pep.digital_contour_removal.value
99 if self.hw_type in ('dm8000', 'dm500hd'):
100 self.oldSplit = config.pep.split.value
101 self.oldSharpness = config.pep.sharpness.value
102 self.oldAuto_flesh = config.pep.auto_flesh.value
103 self.oldGreen_boost = config.pep.green_boost.value
104 self.oldBlue_boost = config.pep.blue_boost.value
105 self.oldDynamic_contrast = config.pep.dynamic_contrast.value
107 def createSetup(self):
108 self.contrastEntry = getConfigListEntry(_("Contrast"), config.pep.contrast)
109 self.saturationEntry = getConfigListEntry(_("Saturation"), config.pep.saturation)
110 self.hueEntry = getConfigListEntry(_("Hue"), config.pep.hue)
111 self.brightnessEntry = getConfigListEntry(_("Brightness"), config.pep.brightness)
112 self.block_noise_reductionEntry = getConfigListEntry(_("Block noise reduction"), config.pep.block_noise_reduction)
113 self.mosquito_noise_reductionEntry = getConfigListEntry(_("Mosquito noise reduction"), config.pep.mosquito_noise_reduction)
114 self.digital_contour_removalEntry = getConfigListEntry(_("Digital contour removal"), config.pep.digital_contour_removal)
121 self.saturationEntry,
125 if self.hw_type == 'dm800':
127 self.block_noise_reductionEntry,
128 self.mosquito_noise_reductionEntry,
129 self.digital_contour_removalEntry
132 elif self.hw_type in ( 'dm8000', 'dm500hd' ):
133 self.splitEntry = getConfigListEntry(_("Split preview mode"), config.pep.split)
134 self.sharpnessEntry = getConfigListEntry(_("Sharpness"), config.pep.sharpness)
135 self.auto_fleshEntry = getConfigListEntry(_("Auto flesh"), config.pep.auto_flesh)
136 self.green_boostEntry = getConfigListEntry(_("Green boost"), config.pep.green_boost)
137 self.blue_boostEntry = getConfigListEntry(_("Blue boost"), config.pep.blue_boost)
138 self.dynamic_contrastEntry = getConfigListEntry(_("Dynamic contrast"), config.pep.dynamic_contrast)
144 self.xtdlist.extend((
146 self.auto_fleshEntry,
147 self.green_boostEntry,
148 self.blue_boostEntry,
149 self.block_noise_reductionEntry,
150 self.mosquito_noise_reductionEntry,
151 self.digital_contour_removalEntry,
152 self.dynamic_contrastEntry
158 self.auto_fleshEntry,
159 self.green_boostEntry,
160 self.blue_boostEntry,
161 self.block_noise_reductionEntry,
162 self.mosquito_noise_reductionEntry,
163 self.digital_contour_removalEntry,
164 self.dynamic_contrastEntry
167 self["config"].list = self.list
168 self["config"].l.setSeperation(300)
169 self["config"].l.setList(self.list)
170 if not self.selectionChanged in self["config"].onSelectionChanged:
171 self["config"].onSelectionChanged.append(self.selectionChanged)
172 self.selectionChanged()
174 def selectionChanged(self):
175 self["introduction"].setText(_("Current value: ") + self.getCurrentValue())
177 def PreviewClosed(self):
178 self["config"].invalidate(self["config"].getCurrent())
182 current = self["config"].getCurrent()
183 if current == self.splitEntry:
184 ConfigListScreen.keyLeft(self)
186 elif current != self.splitEntry and current in self.xtdlist:
191 maxvalue = current[1].max
192 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value, maxValue = maxvalue)
197 maxvalue = current[1].max
198 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = None, maxValue = maxvalue)
201 current = self["config"].getCurrent()
202 if current == self.splitEntry:
203 ConfigListScreen.keyRight(self)
205 elif current != self.splitEntry and current in self.xtdlist:
210 maxvalue = current[1].max
211 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value, maxValue = maxvalue )
216 maxvalue = current[1].max
217 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = None, maxValue = maxvalue)
219 def confirm(self, confirmed):
221 print "not confirmed"
223 if self.splitEntry is not None:
224 config.pep.split.setValue('off')
228 self.session.openWithCallback(self.confirm, MessageBox, _("Use this video enhancement settings?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
230 def cancelConfirm(self, result):
233 self.keyYellowConfirm(True)
237 if self["config"].isChanged():
238 self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
242 def keyYellowConfirm(self, confirmed):
244 print "not confirmed"
246 if self.contrastEntry is not None:
247 config.pep.contrast.setValue(self.oldContrast)
248 if self.saturationEntry is not None:
249 config.pep.saturation.setValue(self.oldSaturation)
250 if self.hueEntry is not None:
251 config.pep.hue.setValue(self.oldHue)
252 if self.brightnessEntry is not None:
253 config.pep.brightness.setValue(self.oldBrightness)
254 if self.block_noise_reductionEntry is not None:
255 config.pep.block_noise_reduction.setValue(self.oldBlock_noise)
256 if self.mosquito_noise_reductionEntry is not None:
257 config.pep.mosquito_noise_reduction.setValue(self.oldMosquito_noise)
258 if self.digital_contour_removalEntry is not None:
259 config.pep.digital_contour_removal.setValue(self.oldDigital_contour)
261 if self.hw_type in ( 'dm8000', 'dm500hd' ):
262 if self.splitEntry is not None:
263 config.pep.split.setValue('off')
264 if self.sharpnessEntry is not None:
265 config.pep.sharpness.setValue(self.oldSharpness)
266 if self.auto_fleshEntry is not None:
267 config.pep.auto_flesh.setValue(self.oldAuto_flesh)
268 if self.green_boostEntry is not None:
269 config.pep.green_boost.setValue(self.oldGreen_boost)
270 if self.blue_boostEntry is not None:
271 config.pep.blue_boost.setValue(self.oldBlue_boost)
272 if self.dynamic_contrastEntry is not None:
273 config.pep.dynamic_contrast.setValue(self.oldDynamic_contrast)
277 self.session.openWithCallback(self.keyYellowConfirm, MessageBox, _("Reset video enhancement settings to your last configuration?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
279 def keyBlueConfirm(self, confirmed):
281 print "not confirmed"
283 if self.contrastEntry is not None:
284 config.pep.contrast.setValue(128)
285 if self.saturationEntry is not None:
286 config.pep.saturation.setValue(128)
287 if self.hueEntry is not None:
288 config.pep.hue.setValue(128)
289 if self.brightnessEntry is not None:
290 config.pep.brightness.setValue(128)
291 if self.block_noise_reductionEntry is not None:
292 config.pep.block_noise_reduction.setValue(0)
293 if self.mosquito_noise_reductionEntry is not None:
294 config.pep.mosquito_noise_reduction.setValue(0)
295 if self.digital_contour_removalEntry is not None:
296 config.pep.digital_contour_removal.setValue(0)
298 if self.hw_type in ( 'dm8000', 'dm500hd' ):
299 if self.splitEntry is not None:
300 config.pep.split.setValue('off')
301 if self.sharpnessEntry is not None:
302 config.pep.sharpness.setValue(0)
303 if self.auto_fleshEntry is not None:
304 config.pep.auto_flesh.setValue(0)
305 if self.green_boostEntry is not None:
306 config.pep.green_boost.setValue(0)
307 if self.blue_boostEntry is not None:
308 config.pep.blue_boost.setValue(0)
309 if self.dynamic_contrastEntry is not None:
310 config.pep.dynamic_contrast.setValue(0)
314 self.session.openWithCallback(self.keyBlueConfirm, MessageBox, _("Reset video enhancement settings to system defaults?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
317 def changedEntry(self):
318 for x in self.onChangedEntry:
320 self.selectionChanged()
322 def getCurrentEntry(self):
323 return self["config"].getCurrent()[0]
325 def getCurrentValue(self):
326 return str(self["config"].getCurrent()[1].getText())
328 def createSummary(self):
329 from Screens.Setup import SetupSummary
333 class VideoEnhancementPreview(Screen, ConfigListScreen):
336 <screen name="VideoEnhancementPreview" position="center,360" size="560,170" title="VideoEnhancementPreview">
337 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
338 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
339 <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" />
340 <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" />
341 <widget name="config" position="5,50" size="550,80" scrollbarMode="showOnDemand" />
342 <ePixmap pixmap="skin_default/div-h.png" position="0,130" zPosition="1" size="560,2" />
343 <widget source="introduction" render="Label" position="0,140" size="550,25" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
346 def __init__(self, session, configEntry = None, oldSplitMode = None, maxValue = None):
347 Screen.__init__(self, session)
349 self.onChangedEntry = [ ]
350 self.setup_title = "Videoenhancement"
351 self.oldSplitMode = oldSplitMode
352 self.maxValue = maxValue
353 self.configStepsEntry = None
354 self.isStepSlider = None
357 self.configEntry = configEntry
358 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
360 self["actions"] = ActionMap(["SetupActions"],
362 "cancel": self.keyCancel,
363 "save": self.keySave,
366 self["key_red"] = StaticText(_("Cancel"))
367 self["key_green"] = StaticText(_("OK"))
368 self["introduction"] = StaticText()
371 self.onLayoutFinish.append(self.layoutFinished)
373 def layoutFinished(self):
374 self.setTitle(_("Video enhancement preview"))
376 def createSetup(self):
378 if self.maxValue == 256:
379 self.configStepsEntry = getConfigListEntry(_("Change step size"), config.pep.configsteps)
381 if self.configEntry is not None:
382 self.list = self.configEntry
383 if self.maxValue == 256:
384 self.list.append(self.configStepsEntry)
386 self["config"].list = self.list
387 self["config"].l.setSeperation(300)
388 self["config"].l.setList(self.list)
389 if not self.selectionChanged in self["config"].onSelectionChanged:
390 self["config"].onSelectionChanged.append(self.selectionChanged)
391 self.selectionChanged()
393 def selectionChanged(self):
394 self["introduction"].setText(_("Current value: ") + self.getCurrentValue())
396 max_avail=self["config"].getCurrent()[1].max
398 self.isStepSlider = True
400 self.isStepSlider = False
401 except AttributeError:
405 if self.isStepSlider is True:
406 self["config"].getCurrent()[1].increment = config.pep.configsteps.value
407 ConfigListScreen.keyLeft(self)
410 if self.isStepSlider is True:
411 self["config"].getCurrent()[1].increment = config.pep.configsteps.value
412 ConfigListScreen.keyRight(self)
415 if self.oldSplitMode is not None:
416 currentSplitMode = config.pep.split.value
417 if self.oldSplitMode == 'off' and currentSplitMode != 'off':
418 config.pep.split.setValue('off')
424 for x in self["config"].list:
426 if self.oldSplitMode is not None:
427 currentSplitMode = config.pep.split.value
428 if self.oldSplitMode == 'off' and currentSplitMode != 'off':
429 config.pep.split.setValue('off')
435 def changedEntry(self):
436 for x in self.onChangedEntry:
438 self.selectionChanged()
440 def getCurrentEntry(self):
441 return self["config"].getCurrent()[0]
443 def getCurrentValue(self):
444 return str(self["config"].getCurrent()[1].getText())
446 def createSummary(self):
447 from Screens.Setup import SetupSummary
451 def videoEnhancementSetupMain(session, **kwargs):
452 session.open(VideoEnhancementSetup, video_enhancement)
455 def startSetup(menuid):
456 if menuid != "system":
459 return [(_("Video enhancement settings") , videoEnhancementSetupMain, "videoenhancement_setup", 41)]
462 def Plugins(**kwargs):
464 if config.usage.setup_level.index >= 2: # expert+
465 hw_type = HardwareInfo().get_device_name()
466 if hw_type in ( 'dm8000', 'dm800', 'dm500hd' ):
467 if (os.path.exists("/proc/stb/vmpeg/0/pep_apply") == True):
468 list.append(PluginDescriptor(name=_("Videoenhancement Setup"), description=_("Advanced Video Enhancement Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup))