1 from Screens.Screen import Screen
2 from Screens.ChannelSelection import FLAG_IS_DEDICATED_3D
3 from Components.ConfigList import ConfigListScreen
4 from Components.ServiceEventTracker import ServiceEventTracker
5 from Components.SystemInfo import SystemInfo
6 from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigSlider, getConfigListEntry
7 from enigma import iPlayableService, iServiceInformation, eServiceCenter, eServiceReference, eDVBDB
9 modelist = {"off": _("Off"), "auto": _("Auto"), "sidebyside": _("Side by side"), "topandbottom": _("Top and bottom")}
11 config.plugins.OSD3DSetup = ConfigSubsection()
12 config.plugins.OSD3DSetup.mode = ConfigSelection(choices = modelist, default = "auto")
13 config.plugins.OSD3DSetup.znorm = ConfigInteger(default = 0)
15 class OSD3DSetupScreen(Screen, ConfigListScreen):
17 <screen position="c-200,c-100" size="400,200" title="OSD 3D setup">
18 <widget name="config" position="c-175,c-75" size="350,150" />
19 <ePixmap pixmap="skin_default/buttons/green.png" position="c-145,e-45" zPosition="0" size="140,40" alphatest="on" />
20 <ePixmap pixmap="skin_default/buttons/red.png" position="c+5,e-45" zPosition="0" size="140,40" alphatest="on" />
21 <widget name="ok" position="c-145,e-45" size="140,40" valign="center" halign="center" zPosition="1" font="Regular;20" transparent="1" backgroundColor="green" />
22 <widget name="cancel" position="c+5,e-45" size="140,40" valign="center" halign="center" zPosition="1" font="Regular;20" transparent="1" backgroundColor="red" />
25 def __init__(self, session):
26 self.skin = OSD3DSetupScreen.skin
27 Screen.__init__(self, session)
29 from Components.ActionMap import ActionMap
30 from Components.Button import Button
32 self["ok"] = Button(_("OK"))
33 self["cancel"] = Button(_("Cancel"))
35 self["actions"] = ActionMap(["SetupActions", "ColorActions", "MenuActions"],
39 "cancel": self.keyCancel,
41 "red": self.keyCancel,
42 "menu": self.closeRecursive,
46 ConfigListScreen.__init__(self, self.list, session = self.session)
48 mode = config.plugins.OSD3DSetup.mode.value
49 znorm = config.plugins.OSD3DSetup.znorm.value
51 self.mode = ConfigSelection(choices = modelist, default = mode)
52 self.znorm = ConfigSlider(default = znorm + 50, increment = 1, limits = (0, 100))
53 self.list.append(getConfigListEntry(_("3d mode"), self.mode))
54 self.list.append(getConfigListEntry(_("Depth"), self.znorm))
55 self["config"].list = self.list
56 self["config"].l.setList(self.list)
59 ConfigListScreen.keyLeft(self)
60 self.setPreviewSettings()
63 ConfigListScreen.keyRight(self)
64 self.setPreviewSettings()
66 def setPreviewSettings(self):
67 applySettings(self.mode.value, int(self.znorm.value) - 50)
70 config.plugins.OSD3DSetup.mode.value = self.mode.value
71 config.plugins.OSD3DSetup.znorm.value = int(self.znorm.value) - 50
72 config.plugins.OSD3DSetup.save()
82 def applySettings(mode=config.plugins.OSD3DSetup.mode.value, znorm=int(config.plugins.OSD3DSetup.znorm.value)):
83 global previous, isDedicated3D
84 mode = isDedicated3D and mode == "auto" and "sidebyside" or mode
85 mode == "3dmode" in SystemInfo["3DMode"] and mode or mode == 'sidebyside' and 'sbs' or mode == 'topandbottom' and 'tab' or 'off'
86 if previous != (mode, znorm):
88 open(SystemInfo["3DMode"], "w").write(mode)
89 open(SystemInfo["3DZNorm"], "w").write('%d' % znorm)
90 previous = (mode, znorm)
95 def __init__(self, session):
96 Screen.__init__(self, session)
97 self.session = session
98 self.__event_tracker = ServiceEventTracker(screen = self, eventmap =
100 iPlayableService.evStart: self.__evStart
103 def checkIfDedicated3D(self):
104 service = self.session.nav.getCurrentlyPlayingServiceReference()
105 servicepath = service and service.getPath()
106 if servicepath.startswith("/"):
107 if service.toString().startswith("1:"):
108 info = eServiceCenter.getInstance().info(service)
109 service = info and info.getInfoString(service, iServiceInformation.sServiceref)
110 return service and eDVBDB.getInstance().getFlag(eServiceReference(service)) & FLAG_IS_DEDICATED_3D == FLAG_IS_DEDICATED_3D and "sidebyside"
112 return ".3d." in servicepath.lower() and "sidebyside" or ".tab." in servicepath.lower() and "topandbottom"
113 service = self.session.nav.getCurrentService()
114 info = service and service.info()
115 return info and info.getInfo(iServiceInformation.sIsDedicated3D) == 1 and "sidebyside"
118 if config.plugins.OSD3DSetup.mode.value == "auto":
120 isDedicated3D = self.checkIfDedicated3D()
122 applySettings(isDedicated3D)
126 def main(session, **kwargs):
127 session.open(OSD3DSetupScreen)
129 def startSetup(menuid):
130 if menuid != "system":
132 return [(_("OSD 3D setup"), main, "auto_3d_setup", 0)]
134 def autostart(reason, **kwargs):
135 "session" in kwargs and kwargs["session"].open(auto3D)
137 def Plugins(**kwargs):
138 if SystemInfo["3DMode"]:
139 from Plugins.Plugin import PluginDescriptor
140 return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART], fnc = autostart),
141 PluginDescriptor(name = "OSD 3D setup", description = _("Adjust 3D settings"), where = PluginDescriptor.WHERE_MENU, fnc = startSetup)]