re-add question for test card to the video wizard
[enigma2.git] / lib / python / Plugins / SystemPlugins / Videomode / VideoWizard.py
1 from Screens.Wizard import Wizard, wizardManager
2 import sys
3 from VideoHardware import video_hw
4
5 from Components.Pixmap import Pixmap, MovingPixmap
6 from Components.config import config, ConfigBoolean, configfile
7
8 class VideoWizard(Wizard):
9         skin = """
10                 <screen position="0,0" size="720,576" title="Welcome..." flags="wfNoBorder" >
11                         <widget name="text" position="153,50" size="340,270" font="Regular;23" />
12                         <widget source="list" render="Listbox" position="50,300" size="440,200" scrollbarMode="showOnDemand" >
13                                 <convert type="StringList" />
14                         </widget>
15                         <widget name="config" position="50,300" zPosition="1" size="440,200" transparent="1" scrollbarMode="showOnDemand" />                    
16                         <widget name="stepslider" position="50,500" zPosition="1" borderWidth="2" size="440,20" backgroundColor="dark" />
17                         <widget name="wizard" pixmap="wizard.png" position="40,50" zPosition="10" size="110,174" transparent="1" alphatest="on"/>
18                         <widget name="rc" pixmap="rc.png" position="500,600" zPosition="10" size="154,475" transparent="1" alphatest="on"/>
19                         <widget name="arrowdown" pixmap="arrowdown.png" position="0,0" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
20                         <widget name="arrowup" pixmap="arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
21                         <widget name="arrowup2" pixmap="arrowup.png" position="-100,-100" zPosition="11" size="37,70" transparent="1" alphatest="on"/>
22                 </screen>"""
23         
24         def __init__(self, session):
25                 # FIXME anyone knows how to use relative paths from the plugin's directory?
26                 self.xmlfile = sys.path[0] + "/Plugins/SystemPlugins/Videomode/videowizard.xml"
27                 self.hw = video_hw
28                 
29                 Wizard.__init__(self, session, showSteps = False)
30                 self["wizard"] = Pixmap()
31                 self["rc"] = MovingPixmap()
32                 self["arrowdown"] = MovingPixmap()
33                 self["arrowup"] = MovingPixmap()
34                 self["arrowup2"] = MovingPixmap()
35                 
36                 self.port = None
37                 self.mode = None
38                 
39                 config.misc.showtestcard = ConfigBoolean(default = False)
40                 
41         def createSummary(self):
42                 print "++++++++++++***++**** VideoWizard-createSummary"
43                 from Screens.Wizard import WizardSummary
44                 return WizardSummary
45                 
46         def markDone(self):
47                 pass
48         
49         def listInputChannels(self):
50                 list = []
51
52                 for port in self.hw.getPortList():
53                         if self.hw.isPortUsed(port):
54                                 list.append((port, port))
55                 return list
56
57         def inputSelectionMade(self, index):
58                 print "inputSelectionMade:", index
59                 self.port = index
60                 self.inputSelect(index)
61                 
62         def inputSelectionMoved(self):
63                 print "input selection moved:", self.selection
64                 self.inputSelect(self.selection)
65                 
66         def inputSelect(self, port):
67                 print "inputSelect:", port
68                 modeList = self.hw.getModeList(self.selection)
69                 print "modeList:", modeList
70                 self.hw.setMode(port = port, mode = modeList[0][0], rate = modeList[0][1][0])
71                 
72         def listModes(self):
73                 list = []
74                 print "modes for port", self.port
75                 for mode in self.hw.getModeList(self.port):
76                         list.append((mode[0], mode[0]))
77                 return list
78         
79         def modeSelectionMade(self, index):
80                 print "modeSelectionMade:", index
81                 self.mode = index
82                 self.modeSelect(index)
83                 
84         def modeSelectionMoved(self):
85                 print "mode selection moved:", self.selection
86                 self.modeSelect(self.selection)
87                 
88         def modeSelect(self, mode):
89                 ratesList = self.listRates(mode)
90                 print "ratesList:", ratesList
91                 self.hw.setMode(port = self.port, mode = mode, rate = ratesList[0][0])
92                 
93         def listRates(self, querymode = None):
94                 if querymode is None:
95                         querymode = self.mode
96                 list = []
97                 print "modes for port", self.port, "and mode", querymode
98                 for mode in self.hw.getModeList(self.port):
99                         print mode
100                         if mode[0] == querymode:
101                                 for rate in mode[1]:
102                                         list.append((rate, rate))
103                 return list
104         
105         def rateSelectionMade(self, index):
106                 print "rateSelectionMade:", index
107                 self.rateSelect(index)
108                 
109         def rateSelectionMoved(self):
110                 print "rate selection moved:", self.selection
111                 self.rateSelect(self.selection)
112
113         def rateSelect(self, rate):
114                 self.hw.setMode(port = self.port, mode = self.mode, rate = rate)
115
116         def showTestCard(self, selection = None):
117                 if selection is None:
118                         selection = self.selection
119                 print "set config.misc.showtestcard to", {'yes': True, 'no': False}[selection]
120                 if selection == "yes":
121                         config.misc.showtestcard.value = True
122                 else:
123                         config.misc.showtestcard.value = False