Use <center> for screens (ToDo: Make Plugin- Screen Movable for HD- Skins)
[vuplus_dvbapp-plugin] / ac3lipsync / src / AC3setup.py
1 from AC3main import AC3LipSync
2 from AC3utils import dec2hex, hex2dec, PLUGIN_BASE, PLUGIN_VERSION
3 from Components.ActionMap import ActionMap, NumberActionMap
4 from Components.Button import Button
5 from Components.ConfigList import ConfigListScreen
6 from Components.Label import Label,MultiColorLabel
7 from Components.ProgressBar import ProgressBar
8 from Components.config import config, getConfigListEntry
9 from Screens.ChoiceBox import ChoiceBox
10 from Screens.MessageBox import MessageBox
11 from Screens.Screen import Screen
12 from __init__ import _
13 import os
14
15 class AC3LipSyncSetup(ConfigListScreen, Screen):
16     skin = """
17     <screen position="center,center" size="560,400" title="AC3 Lip Sync Setup">
18       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/AC3LipSync/img/button-red.png" position="0,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
19       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/AC3LipSync/img/button-green.png" position="140,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
20       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/AC3LipSync/img/button-yellow.png" position="280,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
21       <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/AC3LipSync/img/button-blue.png" position="420,0" zPosition="0" size="140,40" transparent="1" alphatest="on" />
22       <widget name="key_red" position="0,0" zPosition="1" size="140,40"
23         font="Regular;20" valign="center" halign="center" backgroundColor="#9f1313" transparent="1"
24         shadowColor="#000000" shadowOffset="-1,-1" />
25       <widget name="key_green" position="140,0" zPosition="1" size="140,40"
26         font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1"
27         shadowColor="#000000" shadowOffset="-1,-1" />
28       <widget name="key_yellow" position="280,0" zPosition="1" size="140,40"
29         font="Regular;20" valign="center" halign="center" backgroundColor="#a08500" transparent="1"
30         shadowColor="#000000" shadowOffset="-1,-1" />
31       <widget name="key_blue" position="420,0" zPosition="1" size="140,40"
32         font="Regular;20" valign="center" halign="center" backgroundColor="#18188b" transparent="1"
33         shadowColor="#000000" shadowOffset="-1,-1" />
34       <widget name="config" position="10,40" size="540,320" scrollbarMode="showOnDemand" />
35       <widget name="PluginInfo" position="10,370" size="540,20" zPosition="4" font="Regular;18" foregroundColor="#cccccc" />
36     </screen>"""
37
38     def __init__(self, session, plugin_path):
39         Screen.__init__(self, session)
40
41         # Lets get a list of elements for the config list
42         self.list = [
43             getConfigListEntry(_("Outer Bound (+/-)"), config.plugins.AC3LipSync.outerBounds),
44             getConfigListEntry(_("Step in ms for arrow keys"), config.plugins.AC3LipSync.arrowStepSize),
45             getConfigListEntry(_("Wait time in ms before activation:"), config.plugins.AC3LipSync.activationDelay),
46             getConfigListEntry(_("Step in ms for keys '%s'") % ("1/3"), config.plugins.AC3LipSync.stepSize13),
47             getConfigListEntry(_("Step in ms for keys '%s'") % ("4/6"), config.plugins.AC3LipSync.stepSize46),
48             getConfigListEntry(_("Step in ms for keys '%s'") % ("7/9"), config.plugins.AC3LipSync.stepSize79),
49             getConfigListEntry(_("Step in ms for key %i") % (2), config.plugins.AC3LipSync.absoluteStep2),
50             getConfigListEntry(_("Step in ms for key %i") % (5), config.plugins.AC3LipSync.absoluteStep5),
51             getConfigListEntry(_("Step in ms for key %i") % (8), config.plugins.AC3LipSync.absoluteStep8)
52         ]
53         
54         ConfigListScreen.__init__(self, self.list)
55
56         self["config"].list = self.list
57
58         self.skin_path = plugin_path
59
60         # Plugin Information
61         self["PluginInfo"] = Label(_("Plugin: %(plugin)s , Version: %(version)s") %dict(plugin=PLUGIN_BASE,version=PLUGIN_VERSION))
62
63         # BUTTONS
64         self["key_red"] = Button(_("Cancel"))
65         self["key_green"] = Button(_("Save"))
66         self["key_yellow"] = Button(_(" "))
67         self["key_blue"] = Button(" ")
68
69         self["setupActions"] = NumberActionMap(["SetupActions", "ColorActions"],
70         {
71             "save": self.save,
72             "cancel": self.cancel,
73             "green": self.save,
74             "red": self.cancel,
75             "ok": self.save,
76         }, -2)
77
78     def save(self):
79         for x in self.list:
80             x[1].save()
81         self.close()
82
83     def cancel(self):
84         for x in self["config"].list:
85             x[1].cancel()
86         self.close()