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