add missing dm800se color oled screens. refs #530
[enigma2.git] / lib / python / Plugins / SystemPlugins / Videomode / VideoWizard.py
1 from Screens.Wizard import WizardSummary
2 from Screens.WizardLanguage import WizardLanguage
3 from Screens.Rc import Rc
4 from VideoHardware import video_hw
5
6 from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap
7 from Components.config import config, ConfigBoolean, configfile
8
9 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
10 from Tools.HardwareInfo import HardwareInfo
11
12 config.misc.showtestcard = ConfigBoolean(default = False)
13
14 class VideoWizardSummary(WizardSummary):
15         skin = (
16         """<screen name="VideoWizardSummary" position="0,0" size="132,64" id="1">
17                 <widget name="text" position="6,4" size="120,40" font="Regular;12" transparent="1" />
18                 <widget source="parent.list" render="Label" position="6,40" size="120,21" font="Regular;14">
19                         <convert type="StringListSelection" />
20                 </widget>
21                 <!--widget name="pic" pixmap="%s" position="6,22" zPosition="10" size="64,64" transparent="1" alphatest="on"/-->
22         </screen>""",
23         """<screen name="VideoWizardSummary" position="0,0" size="96,64" id="2">
24                 <widget name="text" position="0,4" size="96,40" font="Regular;12" transparent="1" />
25                 <widget source="parent.list" render="Label" position="0,40" size="96,21" font="Regular;14">
26                         <convert type="StringListSelection" />
27                 </widget>
28                 <!--widget name="pic" pixmap="%s" position="0,22" zPosition="10" size="64,64" transparent="1" alphatest="on"/-->
29         </screen>""")
30         #% (resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/lcd_Scart.png"))
31         
32         def __init__(self, session, parent):
33                 WizardSummary.__init__(self, session, parent)
34                 #self["pic"] = Pixmap()
35                 
36         def setLCDPicCallback(self):
37                 self.parent.setLCDTextCallback(self.setText)
38                 
39         def setLCDPic(self, file):
40                 self["pic"].instance.setPixmapFromFile(file)
41
42 class VideoWizard(WizardLanguage, Rc):
43         skin = """
44                 <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
45                         <widget name="text" position="153,50" size="340,270" font="Regular;23" />
46                         <widget source="list" render="Listbox" position="200,300" size="290,200" scrollbarMode="showOnDemand" >
47                                 <convert type="StringList" />
48                         </widget>
49                         <widget name="config" position="50,300" zPosition="1" size="440,200" transparent="1" scrollbarMode="showOnDemand" />
50                         <widget name="wizard" pixmap="skin_default/wizard.png" position="40,50" zPosition="10" size="110,174" transparent="1" alphatest="on"/>
51                         <ePixmap pixmap="skin_default/buttons/button_red.png" position="40,225" zPosition="0" size="15,16" transparent="1" alphatest="on" />
52                         <widget name="languagetext" position="55,225" size="95,30" font="Regular;18" />
53                         <widget name="portpic" pixmap="%s" position="50,300" zPosition="10" size="150,150" transparent="1" alphatest="on"/>
54                         <widget name="rc" pixmaps="skin_default/rc.png,skin_default/rcold.png" position="500,50" zPosition="10" size="154,500" transparent="1" alphatest="on"/>
55                         <widget name="arrowdown" pixmap="skin_default/arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
56                         <widget name="arrowdown2" pixmap="skin_default/arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
57                         <widget name="arrowup" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
58                         <widget name="arrowup2" pixmap="skin_default/arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
59                 </screen>""" % (resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/Scart.png"))
60         
61         def __init__(self, session):
62                 # FIXME anyone knows how to use relative paths from the plugin's directory?
63                 self.xmlfile = resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/videowizard.xml")
64                 self.hw = video_hw
65                 
66                 WizardLanguage.__init__(self, session, showSteps = False, showStepSlider = False)
67                 Rc.__init__(self)
68                 self["wizard"] = Pixmap()
69                 self["portpic"] = Pixmap()
70                 
71                 self.port = None
72                 self.mode = None
73                 self.rate = None
74                 
75                 
76         def createSummary(self):
77                 print "++++++++++++***++**** VideoWizard-createSummary"
78                 from Screens.Wizard import WizardSummary
79                 return VideoWizardSummary
80                 
81         def markDone(self):
82                 config.misc.videowizardenabled.value = 0
83                 config.misc.videowizardenabled.save()
84                 configfile.save()
85         
86         def listInputChannels(self):
87                 hw_type = HardwareInfo().get_device_name()
88                 list = []
89
90                 for port in self.hw.getPortList():
91                         if self.hw.isPortUsed(port):
92                                 descr = port
93                                 if descr == 'DVI' and hw_type in ('dm500hd', 'dm800se'):
94                                         descr = 'HDMI'
95                                 if port != "DVI-PC":
96                                         list.append((descr,port))
97                 list.sort(key = lambda x: x[0])
98                 print "listInputChannels:", list
99                 return list
100
101         def inputSelectionMade(self, index):
102                 print "inputSelectionMade:", index
103                 self.port = index
104                 self.inputSelect(index)
105                 
106         def inputSelectionMoved(self):
107                 print "input selection moved:", self.selection
108                 self.inputSelect(self.selection)
109                 if self["portpic"].instance is not None:
110                         picname = self.selection
111                         if picname == "DVI" and HardwareInfo().get_device_name() in ("dm500hd", "dm800se"):
112                                 picname = "HDMI"
113                         self["portpic"].instance.setPixmapFromFile(resolveFilename(SCOPE_PLUGINS, "SystemPlugins/Videomode/" + picname + ".png"))
114                 
115         def inputSelect(self, port):
116                 print "inputSelect:", port
117                 modeList = self.hw.getModeList(self.selection)
118                 print "modeList:", modeList
119                 self.port = port
120                 if (len(modeList) > 0):
121                         ratesList = self.listRates(modeList[0][0])
122                         self.hw.setMode(port = port, mode = modeList[0][0], rate = ratesList[0][0])
123                 
124         def listModes(self):
125                 list = []
126                 print "modes for port", self.port
127                 for mode in self.hw.getModeList(self.port):
128                         #if mode[0] != "PC":
129                                 list.append((mode[0], mode[0]))
130                 print "modeslist:", list
131                 return list
132         
133         def modeSelectionMade(self, index):
134                 print "modeSelectionMade:", index
135                 self.mode = index
136                 self.modeSelect(index)
137                 
138         def modeSelectionMoved(self):
139                 print "mode selection moved:", self.selection
140                 self.modeSelect(self.selection)
141                 
142         def modeSelect(self, mode):
143                 ratesList = self.listRates(mode)
144                 print "ratesList:", ratesList
145                 if self.port == "DVI" and mode in ("720p", "1080i"):
146                         self.rate = "multi"
147                         self.hw.setMode(port = self.port, mode = mode, rate = "multi")
148                 else:
149                         self.hw.setMode(port = self.port, mode = mode, rate = ratesList[0][0])
150         
151         def listRates(self, querymode = None):
152                 if querymode is None:
153                         querymode = self.mode
154                 list = []
155                 print "modes for port", self.port, "and mode", querymode
156                 for mode in self.hw.getModeList(self.port):
157                         print mode
158                         if mode[0] == querymode:
159                                 for rate in mode[1]:
160                                         if self.port == "DVI-PC":
161                                                 print "rate:", rate
162                                                 if rate == "640x480":
163                                                         list.insert(0, (rate, rate))
164                                                         continue
165                                         list.append((rate, rate))
166                 return list
167         
168         def rateSelectionMade(self, index):
169                 print "rateSelectionMade:", index
170                 self.rate = index
171                 self.rateSelect(index)
172                 
173         def rateSelectionMoved(self):
174                 print "rate selection moved:", self.selection
175                 self.rateSelect(self.selection)
176
177         def rateSelect(self, rate):
178                 self.hw.setMode(port = self.port, mode = self.mode, rate = rate)
179
180         def showTestCard(self, selection = None):
181                 if selection is None:
182                         selection = self.selection
183                 print "set config.misc.showtestcard to", {'yes': True, 'no': False}[selection]
184                 if selection == "yes":
185                         config.misc.showtestcard.value = True
186                 else:
187                         config.misc.showtestcard.value = False
188
189         def keyNumberGlobal(self, number):
190                 if number in (1,2,3):
191                         if number == 1:
192                                 self.hw.saveMode("DVI", "720p", "multi")
193                         elif number == 2:
194                                 self.hw.saveMode("DVI", "1080i", "multi")
195                         elif number == 3:
196                                 self.hw.saveMode("Scart", "Multi", "multi")
197                         self.hw.setConfiguredMode()
198                         self.close()
199
200                 WizardLanguage.keyNumberGlobal(self, number)