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.Button import Button
6 from Components.Label import Label
7 from Screens.Screen import Screen
8 from Screens.VirtualKeyBoard import VirtualKeyBoard
9 from Screens.ChoiceBox import ChoiceBox
10 from Screens.MessageBox import MessageBox
11 from enigma import ePoint
12 from Tools import Notifications
13 from Tools.HardwareInfo import HardwareInfo
14 from VideoEnhancement import video_enhancement
17 class VideoEnhancementSetup(Screen, ConfigListScreen):
20 <screen name="VideoEnhancementSetup" position="center,center" size="560,430" title="VideoEnhancementSetup">
21 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
22 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
23 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
24 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
25 <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
26 <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
27 <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
28 <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
29 <widget name="config" position="5,50" size="550,340" scrollbarMode="showOnDemand" />
30 <ePixmap pixmap="skin_default/div-h.png" position="0,390" zPosition="1" size="560,2" />
31 <widget name="introduction" position="5,400" size="550,25" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
35 def __init__(self, session, hw):
36 Screen.__init__(self, session)
38 self.session = session
40 self.onChangedEntry = [ ]
41 self.setup_title = "Videoenhancement"
43 self.contrastEntry = None
44 self.saturationEntry = None
46 self.brightnessEntry = None
47 self.splitEntry = None
48 self.sharpnessEntry = None
49 self.auto_fleshEntry = None
50 self.green_boostEntry = None
51 self.blue_boostEntry = None
52 self.block_noise_reductionEntry = None
53 self.mosquito_noise_reductionEntry = None
54 self.digital_contour_removalEntry = None
55 self.dynamic_contrastEntry = None
57 # handle hotplug by re-creating setup
58 self.onShow.append(self.startHotplug)
59 self.onHide.append(self.stopHotplug)
63 self.hw_type = HardwareInfo().get_device_name()
64 ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry)
66 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
68 "cancel": self.keyCancel,
70 "yellow": self.keyYellow,
74 self["key_red"] = Button(_("Cancel"))
75 self["key_green"] = Button(_("OK"))
76 self["key_yellow"] = Button(_("Last config"))
77 self["key_blue"] = Button(_("Default"))
78 self["introduction"] = Label()
81 self.rememberOldSettings()
82 self.onLayoutFinish.append(self.layoutFinished)
84 def layoutFinished(self):
85 self.setTitle(_("Video enhancement setup"))
87 def startHotplug(self):
88 self.hw.on_hotplug.append(self.createSetup)
90 def stopHotplug(self):
91 self.hw.on_hotplug.remove(self.createSetup)
93 def rememberOldSettings(self):
94 self.oldContrast = config.pep.contrast.value
95 self.oldSaturation = config.pep.saturation.value
96 self.oldHue = config.pep.hue.value
97 self.oldBrightness = config.pep.brightness.value
98 if self.hw_type == 'dm8000':
99 self.oldSplit = config.pep.split.value
100 self.oldSharpness = config.pep.sharpness.value
101 self.oldAuto_flesh = config.pep.auto_flesh.value
102 self.oldGreen_boost = config.pep.green_boost.value
103 self.oldBlue_boost = config.pep.blue_boost.value
104 self.oldBlock_noise = config.pep.block_noise_reduction.value
105 self.oldMosquito_noise = config.pep.mosquito_noise_reduction.value
106 self.oldDigital_contour = config.pep.digital_contour_removal.value
107 self.oldDynamic_contrast = config.pep.dynamic_contrast.value
109 def createSetup(self):
110 self.contrastEntry = getConfigListEntry(_("Contrast"), config.pep.contrast)
111 self.saturationEntry = getConfigListEntry(_("Saturation"), config.pep.saturation)
112 self.hueEntry = getConfigListEntry(_("Hue"), config.pep.hue)
113 self.brightnessEntry = getConfigListEntry(_("Brightness"), config.pep.brightness)
120 self.saturationEntry,
124 if self.hw_type == 'dm8000':
125 self.splitEntry = getConfigListEntry(_("Split preview mode"), config.pep.split)
126 self.sharpnessEntry = getConfigListEntry(_("Sharpness"), config.pep.sharpness)
127 self.auto_fleshEntry = getConfigListEntry(_("Auto flesh"), config.pep.auto_flesh)
128 self.green_boostEntry = getConfigListEntry(_("Green boost"), config.pep.green_boost)
129 self.blue_boostEntry = getConfigListEntry(_("Blue boost"), config.pep.blue_boost)
130 self.block_noise_reductionEntry = getConfigListEntry(_("Block noise reduction"), config.pep.block_noise_reduction)
131 self.mosquito_noise_reductionEntry = getConfigListEntry(_("Mosquito noise reduction"), config.pep.mosquito_noise_reduction)
132 self.digital_contour_removalEntry = getConfigListEntry(_("Digital contour removal"), config.pep.digital_contour_removal)
133 self.dynamic_contrastEntry = getConfigListEntry(_("Dynamic contrast"), config.pep.dynamic_contrast)
139 self.xtdlist.extend((
141 self.auto_fleshEntry,
142 self.green_boostEntry,
143 self.blue_boostEntry,
144 self.block_noise_reductionEntry,
145 self.mosquito_noise_reductionEntry,
146 self.digital_contour_removalEntry,
147 self.dynamic_contrastEntry
153 self.auto_fleshEntry,
154 self.green_boostEntry,
155 self.blue_boostEntry,
156 self.block_noise_reductionEntry,
157 self.mosquito_noise_reductionEntry,
158 self.digital_contour_removalEntry,
159 self.dynamic_contrastEntry
162 self["config"].list = self.list
163 self["config"].l.setSeperation(300)
164 self["config"].l.setList(self.list)
165 if not self.selectionChanged in self["config"].onSelectionChanged:
166 self["config"].onSelectionChanged.append(self.selectionChanged)
167 self.selectionChanged()
169 def selectionChanged(self):
170 self["introduction"].setText(_("Current value: ") + self.getCurrentValue())
172 def PreviewClosed(self):
173 self["config"].invalidate(self["config"].getCurrent())
177 current = self["config"].getCurrent()
178 if current == self.splitEntry:
179 ConfigListScreen.keyLeft(self)
181 elif current != self.splitEntry and current in self.xtdlist:
186 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value)
191 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist)
194 current = self["config"].getCurrent()
195 if current == self.splitEntry:
196 ConfigListScreen.keyRight(self)
198 elif current != self.splitEntry and current in self.xtdlist:
203 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value )
208 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist)
210 def confirm(self, confirmed):
212 print "not confirmed"
214 if self.splitEntry is not None:
215 config.pep.split.setValue('off')
219 self.session.openWithCallback(self.confirm, MessageBox, _("Use this video enhancement settings?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
221 def cancelConfirm(self, result):
224 self.keyYellowConfirm(True)
228 if self["config"].isChanged():
229 self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
233 def keyYellowConfirm(self, confirmed):
235 print "not confirmed"
237 if self.contrastEntry is not None:
238 config.pep.contrast.setValue(self.oldContrast)
239 if self.saturationEntry is not None:
240 config.pep.saturation.setValue(self.oldSaturation)
241 if self.hueEntry is not None:
242 config.pep.hue.setValue(self.oldHue)
243 if self.brightnessEntry is not None:
244 config.pep.brightness.setValue(self.oldBrightness)
246 if self.hw_type == 'dm8000':
247 if self.splitEntry is not None:
248 config.pep.split.setValue('off')
249 if self.sharpnessEntry is not None:
250 config.pep.sharpness.setValue(self.oldSharpness)
251 if self.auto_fleshEntry is not None:
252 config.pep.auto_flesh.setValue(self.oldAuto_flesh)
253 if self.green_boostEntry is not None:
254 config.pep.green_boost.setValue(self.oldGreen_boost)
255 if self.blue_boostEntry is not None:
256 config.pep.blue_boost.setValue(self.oldBlue_boost)
257 if self.block_noise_reductionEntry is not None:
258 config.pep.block_noise_reduction.setValue(self.oldBlock_noise)
259 if self.mosquito_noise_reductionEntry is not None:
260 config.pep.mosquito_noise_reduction.setValue(self.oldMosquito_noise)
261 if self.digital_contour_removalEntry is not None:
262 config.pep.digital_contour_removal.setValue(self.oldDigital_contour)
263 if self.dynamic_contrastEntry is not None:
264 config.pep.dynamic_contrast.setValue(self.oldDynamic_contrast)
268 self.session.openWithCallback(self.keyYellowConfirm, MessageBox, _("Reset video enhancement settings to your last configuration?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
270 def keyBlueConfirm(self, confirmed):
272 print "not confirmed"
274 if self.contrastEntry is not None:
275 config.pep.contrast.setValue(128)
276 if self.saturationEntry is not None:
277 config.pep.saturation.setValue(128)
278 if self.hueEntry is not None:
279 config.pep.hue.setValue(128)
280 if self.brightnessEntry is not None:
281 config.pep.brightness.setValue(128)
283 if self.hw_type == 'dm8000':
284 if self.splitEntry is not None:
285 config.pep.split.setValue('off')
286 if self.sharpnessEntry is not None:
287 config.pep.sharpness.setValue(0)
288 if self.auto_fleshEntry is not None:
289 config.pep.auto_flesh.setValue(0)
290 if self.green_boostEntry is not None:
291 config.pep.green_boost.setValue(0)
292 if self.blue_boostEntry is not None:
293 config.pep.blue_boost.setValue(0)
294 if self.block_noise_reductionEntry is not None:
295 config.pep.block_noise_reduction.setValue(0)
296 if self.mosquito_noise_reductionEntry is not None:
297 config.pep.mosquito_noise_reduction.setValue(0)
298 if self.digital_contour_removalEntry is not None:
299 config.pep.digital_contour_removal.setValue(0)
300 if self.dynamic_contrastEntry is not None:
301 config.pep.dynamic_contrast.setValue(0)
305 self.session.openWithCallback(self.keyBlueConfirm, MessageBox, _("Reset video enhancement settings to system defaults?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
308 def changedEntry(self):
309 for x in self.onChangedEntry:
312 def getCurrentEntry(self):
313 return self["config"].getCurrent()[0]
315 def getCurrentValue(self):
316 return str(self["config"].getCurrent()[1].getText())
318 def createSummary(self):
319 from Screens.Setup import SetupSummary
323 class VideoEnhancementPreview(Screen, ConfigListScreen):
326 <screen name="VideoEnhancementSetup" position="90,430" size="560,110" title="VideoEnhancementSetup">
327 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
328 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
329 <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
330 <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
331 <widget name="config" position="5,50" size="550,60" scrollbarMode="showOnDemand" />
334 def __init__(self, session, configEntry = None, oldSplitMode = None):
335 Screen.__init__(self, session)
337 self.onChangedEntry = [ ]
338 self.setup_title = "Videoenhancement"
339 self.oldSplitMode = oldSplitMode
342 self.configEntry = configEntry
343 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
345 self["actions"] = ActionMap(["SetupActions"],
347 "cancel": self.keyCancel,
348 "save": self.keySave,
351 self["key_red"] = Button(_("Cancel"))
352 self["key_green"] = Button(_("OK"))
356 def createSetup(self):
358 if self.configEntry is not None:
359 self.list = self.configEntry
360 self["config"].list = self.list
361 self["config"].l.setSeperation(300)
362 self["config"].l.setList(self.list)
365 ConfigListScreen.keyLeft(self)
369 ConfigListScreen.keyRight(self)
373 if self.oldSplitMode is not None:
374 currentSplitMode = config.pep.split.value
375 if self.oldSplitMode == 'off' and currentSplitMode != 'off':
376 config.pep.split.setValue('off')
382 for x in self["config"].list:
384 if self.oldSplitMode is not None:
385 currentSplitMode = config.pep.split.value
386 if self.oldSplitMode == 'off' and currentSplitMode != 'off':
387 config.pep.split.setValue('off')
393 def changedEntry(self):
394 for x in self.onChangedEntry:
397 def getCurrentEntry(self):
398 return self["config"].getCurrent()[0]
400 def getCurrentValue(self):
401 return str(self["config"].getCurrent()[1].getText())
403 def createSummary(self):
404 from Screens.Setup import SetupSummary
408 def videoEnhancementSetupMain(session, **kwargs):
409 session.open(VideoEnhancementSetup, video_enhancement)
412 def startSetup(menuid):
413 if menuid != "system":
416 return [(_("Video enhancement settings") , videoEnhancementSetupMain, "videoenhancement_setup", 41)]
419 def Plugins(**kwargs):
421 if config.usage.setup_level.index >= 2: # expert+
422 hw_type = HardwareInfo().get_device_name()
423 if hw_type == 'dm8000' or hw_type == 'dm800':
424 if (os.path.exists("/proc/stb/vmpeg/0/pep_apply") == True):
425 list.append(PluginDescriptor(name=_("Videoenhancement Setup"), description=_("Advanced Video Enhancement Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup))