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