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 self.oldBlock_noise = config.pep.block_noise_reduction.value
99 self.oldMosquito_noise = config.pep.mosquito_noise_reduction.value
100 self.oldDigital_contour = config.pep.digital_contour_removal.value
101 if self.hw_type == 'dm8000':
102 self.oldSplit = config.pep.split.value
103 self.oldSharpness = config.pep.sharpness.value
104 self.oldAuto_flesh = config.pep.auto_flesh.value
105 self.oldGreen_boost = config.pep.green_boost.value
106 self.oldBlue_boost = config.pep.blue_boost.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)
114 self.block_noise_reductionEntry = getConfigListEntry(_("Block noise reduction"), config.pep.block_noise_reduction)
115 self.mosquito_noise_reductionEntry = getConfigListEntry(_("Mosquito noise reduction"), config.pep.mosquito_noise_reduction)
116 self.digital_contour_removalEntry = getConfigListEntry(_("Digital contour removal"), config.pep.digital_contour_removal)
123 self.saturationEntry,
127 if self.hw_type == 'dm800':
129 self.block_noise_reductionEntry,
130 self.mosquito_noise_reductionEntry,
131 self.digital_contour_removalEntry
134 elif self.hw_type == 'dm8000':
135 self.splitEntry = getConfigListEntry(_("Split preview mode"), config.pep.split)
136 self.sharpnessEntry = getConfigListEntry(_("Sharpness"), config.pep.sharpness)
137 self.auto_fleshEntry = getConfigListEntry(_("Auto flesh"), config.pep.auto_flesh)
138 self.green_boostEntry = getConfigListEntry(_("Green boost"), config.pep.green_boost)
139 self.blue_boostEntry = getConfigListEntry(_("Blue boost"), config.pep.blue_boost)
140 self.dynamic_contrastEntry = getConfigListEntry(_("Dynamic contrast"), config.pep.dynamic_contrast)
146 self.xtdlist.extend((
148 self.auto_fleshEntry,
149 self.green_boostEntry,
150 self.blue_boostEntry,
151 self.block_noise_reductionEntry,
152 self.mosquito_noise_reductionEntry,
153 self.digital_contour_removalEntry,
154 self.dynamic_contrastEntry
160 self.auto_fleshEntry,
161 self.green_boostEntry,
162 self.blue_boostEntry,
163 self.block_noise_reductionEntry,
164 self.mosquito_noise_reductionEntry,
165 self.digital_contour_removalEntry,
166 self.dynamic_contrastEntry
169 self["config"].list = self.list
170 self["config"].l.setSeperation(300)
171 self["config"].l.setList(self.list)
172 if not self.selectionChanged in self["config"].onSelectionChanged:
173 self["config"].onSelectionChanged.append(self.selectionChanged)
174 self.selectionChanged()
176 def selectionChanged(self):
177 self["introduction"].setText(_("Current value: ") + self.getCurrentValue())
179 def PreviewClosed(self):
180 self["config"].invalidate(self["config"].getCurrent())
184 current = self["config"].getCurrent()
185 if current == self.splitEntry:
186 ConfigListScreen.keyLeft(self)
188 elif current != self.splitEntry and current in self.xtdlist:
193 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value)
198 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist)
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 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist, oldSplitMode = config.pep.split.value )
215 self.session.openWithCallback(self.PreviewClosed, VideoEnhancementPreview, configEntry = self.previewlist)
217 def confirm(self, confirmed):
219 print "not confirmed"
221 if self.splitEntry is not None:
222 config.pep.split.setValue('off')
226 self.session.openWithCallback(self.confirm, MessageBox, _("Use this video enhancement settings?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
228 def cancelConfirm(self, result):
231 self.keyYellowConfirm(True)
235 if self["config"].isChanged():
236 self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
240 def keyYellowConfirm(self, confirmed):
242 print "not confirmed"
244 if self.contrastEntry is not None:
245 config.pep.contrast.setValue(self.oldContrast)
246 if self.saturationEntry is not None:
247 config.pep.saturation.setValue(self.oldSaturation)
248 if self.hueEntry is not None:
249 config.pep.hue.setValue(self.oldHue)
250 if self.brightnessEntry is not None:
251 config.pep.brightness.setValue(self.oldBrightness)
252 if self.block_noise_reductionEntry is not None:
253 config.pep.block_noise_reduction.setValue(self.oldBlock_noise)
254 if self.mosquito_noise_reductionEntry is not None:
255 config.pep.mosquito_noise_reduction.setValue(self.oldMosquito_noise)
256 if self.digital_contour_removalEntry is not None:
257 config.pep.digital_contour_removal.setValue(self.oldDigital_contour)
259 if self.hw_type == 'dm8000':
260 if self.splitEntry is not None:
261 config.pep.split.setValue('off')
262 if self.sharpnessEntry is not None:
263 config.pep.sharpness.setValue(self.oldSharpness)
264 if self.auto_fleshEntry is not None:
265 config.pep.auto_flesh.setValue(self.oldAuto_flesh)
266 if self.green_boostEntry is not None:
267 config.pep.green_boost.setValue(self.oldGreen_boost)
268 if self.blue_boostEntry is not None:
269 config.pep.blue_boost.setValue(self.oldBlue_boost)
270 if self.dynamic_contrastEntry is not None:
271 config.pep.dynamic_contrast.setValue(self.oldDynamic_contrast)
275 self.session.openWithCallback(self.keyYellowConfirm, MessageBox, _("Reset video enhancement settings to your last configuration?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
277 def keyBlueConfirm(self, confirmed):
279 print "not confirmed"
281 if self.contrastEntry is not None:
282 config.pep.contrast.setValue(128)
283 if self.saturationEntry is not None:
284 config.pep.saturation.setValue(128)
285 if self.hueEntry is not None:
286 config.pep.hue.setValue(128)
287 if self.brightnessEntry is not None:
288 config.pep.brightness.setValue(128)
289 if self.block_noise_reductionEntry is not None:
290 config.pep.block_noise_reduction.setValue(0)
291 if self.mosquito_noise_reductionEntry is not None:
292 config.pep.mosquito_noise_reduction.setValue(0)
293 if self.digital_contour_removalEntry is not None:
294 config.pep.digital_contour_removal.setValue(0)
296 if self.hw_type == 'dm8000':
297 if self.splitEntry is not None:
298 config.pep.split.setValue('off')
299 if self.sharpnessEntry is not None:
300 config.pep.sharpness.setValue(0)
301 if self.auto_fleshEntry is not None:
302 config.pep.auto_flesh.setValue(0)
303 if self.green_boostEntry is not None:
304 config.pep.green_boost.setValue(0)
305 if self.blue_boostEntry is not None:
306 config.pep.blue_boost.setValue(0)
307 if self.dynamic_contrastEntry is not None:
308 config.pep.dynamic_contrast.setValue(0)
312 self.session.openWithCallback(self.keyBlueConfirm, MessageBox, _("Reset video enhancement settings to system defaults?"), MessageBox.TYPE_YESNO, timeout = 20, default = False)
315 def changedEntry(self):
316 for x in self.onChangedEntry:
319 def getCurrentEntry(self):
320 return self["config"].getCurrent()[0]
322 def getCurrentValue(self):
323 return str(self["config"].getCurrent()[1].getText())
325 def createSummary(self):
326 from Screens.Setup import SetupSummary
330 class VideoEnhancementPreview(Screen, ConfigListScreen):
333 <screen name="VideoEnhancementPreview" position="90,430" size="560,110" title="VideoEnhancementPreview">
334 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
335 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
336 <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
337 <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
338 <widget name="config" position="5,50" size="550,60" scrollbarMode="showOnDemand" />
341 def __init__(self, session, configEntry = None, oldSplitMode = None):
342 Screen.__init__(self, session)
344 self.onChangedEntry = [ ]
345 self.setup_title = "Videoenhancement"
346 self.oldSplitMode = oldSplitMode
349 self.configEntry = configEntry
350 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
352 self["actions"] = ActionMap(["SetupActions"],
354 "cancel": self.keyCancel,
355 "save": self.keySave,
358 self["key_red"] = Button(_("Cancel"))
359 self["key_green"] = Button(_("OK"))
362 self.onLayoutFinish.append(self.layoutFinished)
364 def layoutFinished(self):
365 self.setTitle(_("Video enhancement preview"))
367 def createSetup(self):
369 if self.configEntry is not None:
370 self.list = self.configEntry
371 self["config"].list = self.list
372 self["config"].l.setSeperation(300)
373 self["config"].l.setList(self.list)
376 ConfigListScreen.keyLeft(self)
380 ConfigListScreen.keyRight(self)
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 for x in self["config"].list:
395 if self.oldSplitMode is not None:
396 currentSplitMode = config.pep.split.value
397 if self.oldSplitMode == 'off' and currentSplitMode != 'off':
398 config.pep.split.setValue('off')
404 def changedEntry(self):
405 for x in self.onChangedEntry:
408 def getCurrentEntry(self):
409 return self["config"].getCurrent()[0]
411 def getCurrentValue(self):
412 return str(self["config"].getCurrent()[1].getText())
414 def createSummary(self):
415 from Screens.Setup import SetupSummary
419 def videoEnhancementSetupMain(session, **kwargs):
420 session.open(VideoEnhancementSetup, video_enhancement)
423 def startSetup(menuid):
424 if menuid != "system":
427 return [(_("Video enhancement settings") , videoEnhancementSetupMain, "videoenhancement_setup", 41)]
430 def Plugins(**kwargs):
432 if config.usage.setup_level.index >= 2: # expert+
433 hw_type = HardwareInfo().get_device_name()
434 if hw_type == 'dm8000' or hw_type == 'dm800':
435 if (os.path.exists("/proc/stb/vmpeg/0/pep_apply") == True):
436 list.append(PluginDescriptor(name=_("Videoenhancement Setup"), description=_("Advanced Video Enhancement Setup"), where = PluginDescriptor.WHERE_MENU, fnc=startSetup))