PicturePlayer/plugin.py: -use "Setup" Skin but still allow individual skinning over...
[enigma2.git] / lib / python / Plugins / Extensions / PicturePlayer / plugin.py
index 3925b07cd3194c0c0fc981eee1c19e6de903ffe6..5d1c2cba843f584af3f73d705eb2db100e11520a 100755 (executable)
@@ -142,36 +142,35 @@ class picshow(Screen):
                config.pic.save()
                self.close()
 
+#------------------------------------------------------------------------------------------
 
 class Pic_Setup(Screen, ConfigListScreen):
-       skin = """
-               <screen name="Pic_Setup" position="center,center" size="550,350" title="Settings" >
-                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
-                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
-                       <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
-                       <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
-                       <widget name="config" position="5,50" size="540,300" />
-               </screen>"""
+
        def __init__(self, session):
                Screen.__init__(self, session)
+               # for the skin: first try MediaPlayerSettings, then Setup, this allows individual skinning
+               self.skinName = ["PicturePlayerSetup", "Setup" ]
+               self.setup_title = _("Settings")
+               self.onChangedEntry = [ ]
                self.session = session
 
-               self["actions"] = ActionMap(["SetupActions", "ColorActions"],
+               self["actions"] = ActionMap(["SetupActions"],
                        {
                                "cancel": self.keyCancel,
                                "save": self.keySave,
+                               "ok": self.keySave,
                        }, -2)
 
                self["key_red"] = StaticText(_("Cancel"))
                self["key_green"] = StaticText(_("OK"))
 
                self.list = []
-               ConfigListScreen.__init__(self, self.list, session = self.session)
+               ConfigListScreen.__init__(self, self.list, session = self.session, on_change = self.changedEntry)
                self.createSetup()
                self.onLayoutFinish.append(self.layoutFinished)
 
        def layoutFinished(self):
-               self.setTitle(_("Settings"))
+               self.setTitle(self.setup_title)
 
        def createSetup(self):
                self.list = []
@@ -192,6 +191,22 @@ class Pic_Setup(Screen, ConfigListScreen):
        def keyRight(self):
                ConfigListScreen.keyRight(self)
 
+       # for summary:
+       def changedEntry(self):
+               for x in self.onChangedEntry:
+                       x()
+
+       def getCurrentEntry(self):
+               return self["config"].getCurrent()[0]
+
+       def getCurrentValue(self):
+               return str(self["config"].getCurrent()[1].getText())
+
+       def createSummary(self):
+               from Screens.Setup import SetupSummary
+               return SetupSummary
+
+#---------------------------------------------------------------------------
 
 class Pic_Exif(Screen):
        skin = """
@@ -212,7 +227,7 @@ class Pic_Exif(Screen):
        def __init__(self, session, exiflist):
                Screen.__init__(self, session)
 
-               self["actions"] = ActionMap(["OkCancelActions"],
+               self["actions"] = ActionMap(["SetupActions", "ColorActions"],
                {
                        "cancel": self.close
                }, -1)
@@ -234,6 +249,7 @@ class Pic_Exif(Screen):
        def layoutFinished(self):
                self.setTitle(_("Info"))
 
+#----------------------------------------------------------------------------------------
 
 T_INDEX = 0
 T_FRAME_POS = 1
@@ -251,13 +267,13 @@ class Pic_Thumb(Screen):
                self.picX = 190
                self.spaceY = 30
                self.picY = 200
-               
+
                size_w = getDesktop(0).size().width()
                size_h = getDesktop(0).size().height()
                self.thumbsX = size_w / (self.spaceX + self.picX) # thumbnails in X
                self.thumbsY = size_h / (self.spaceY + self.picY) # thumbnails in Y
                self.thumbsC = self.thumbsX * self.thumbsY # all thumbnails
-               
+
                self.positionlist = []
                skincontent = ""
 
@@ -267,21 +283,19 @@ class Pic_Thumb(Screen):
                        posX += 1
                        if posX >= self.thumbsX:
                                posX = 0
-                       
+
                        absX = self.spaceX + (posX*(self.spaceX + self.picX))
                        absY = self.spaceY + (posY*(self.spaceY + self.picY))
                        self.positionlist.append((absX, absY))
                        skincontent += "<widget source=\"label" + str(x) + "\" render=\"Label\" position=\"" + str(absX+5) + "," + str(absY+self.picY-textsize) + "\" size=\"" + str(self.picX - 10) + ","  + str(textsize) + "\" font=\"Regular;14\" zPosition=\"2\" transparent=\"1\" noWrap=\"1\" foregroundColor=\"" + self.textcolor + "\" />"
-               
                        skincontent += "<widget name=\"thumb" + str(x) + "\" position=\"" + str(absX+5)+ "," + str(absY+5) + "\" size=\"" + str(self.picX -10) + "," + str(self.picY - (textsize*2)) + "\" zPosition=\"2\" transparent=\"1\" alphatest=\"on\" />"
-               
-               
+
                # Screen, backgroundlabel and MovingPixmap
                self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
                        <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\"" + self.color + "\" /><widget name=\"frame\" position=\"35,30\" size=\"190,200\" pixmap=\"pic_frame.png\" zPosition=\"1\" alphatest=\"on\" />"  + skincontent + "</screen>"
-               
+
                Screen.__init__(self, session)
-               
+
                self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
                {
                        "cancel": self.Exit,
@@ -292,12 +306,12 @@ class Pic_Thumb(Screen):
                        "down": self.key_down,
                        "showEventInfo": self.StartExif,
                }, -1)
-               
+
                self["frame"] = MovingPixmap()
                for x in range(self.thumbsC):
                        self["label"+str(x)] = StaticText()
                        self["thumb"+str(x)] = Pixmap()
-                       
+
                self.Thumbnaillist = []
                self.filelist = []
                self.currPage = -1
@@ -317,7 +331,7 @@ class Pic_Thumb(Screen):
                                        Page += 1
                        else:
                                self.dirlistcount += 1
-               
+
                self.maxentry = len(self.filelist)-1
                self.index = lastindex - self.dirlistcount
                if self.index < 0:
@@ -325,9 +339,9 @@ class Pic_Thumb(Screen):
 
                self.picload = ePicLoad()
                self.picload.PictureData.get().append(self.showPic)
-               
+
                self.onLayoutFinish.append(self.setPicloadConf)
-               
+
                self.ThumbTimer = eTimer()
                self.ThumbTimer.callback.append(self.showPic)
 
@@ -344,7 +358,7 @@ class Pic_Thumb(Screen):
                pos = self.positionlist[self.filelist[self.index][T_FRAME_POS]]
                self["frame"].moveTo( pos[0], pos[1], 1)
                self["frame"].startMoving()
-               
+
                if self.currPage != self.filelist[self.index][T_PAGE]:
                        self.currPage = self.filelist[self.index][T_PAGE]
                        self.newPage()
@@ -360,7 +374,7 @@ class Pic_Thumb(Screen):
                        if x[T_PAGE] == self.currPage:
                                self["label"+str(x[T_FRAME_POS])].setText("(" + str(x[T_INDEX]+1) + ") " + x[T_NAME])
                                self.Thumbnaillist.append([0, x[T_FRAME_POS], x[T_FULL]])
-                               
+
                #paint Thumbnail start
                self.showPic()
 
@@ -384,19 +398,19 @@ class Pic_Thumb(Screen):
                if self.index < 0:
                        self.index = self.maxentry
                self.paintFrame()
-               
+
        def key_right(self):
                self.index += 1
                if self.index > self.maxentry:
                        self.index = 0
                self.paintFrame()
-               
+
        def key_up(self):
                self.index -= self.thumbsX
                if self.index < 0:
                        self.index =self.maxentry
                self.paintFrame()
-               
+
        def key_down(self):
                self.index += self.thumbsX
                if self.index > self.maxentry:
@@ -432,7 +446,7 @@ class Pic_Full_View(Screen):
                space = config.pic.framesize.value
                size_w = getDesktop(0).size().width()
                size_h = getDesktop(0).size().height()
-               
+
                self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
                        <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\""+ self.bgcolor +"\" /><widget name=\"pic\" position=\"" + str(space) + "," + str(space) + "\" size=\"" + str(size_w-(space*2)) + "," + str(size_h-(space*2)) + "\" zPosition=\"1\" alphatest=\"on\" /> \
                        <widget name=\"point\" position=\""+ str(space+5) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/record.png\" alphatest=\"on\" /> \
@@ -440,7 +454,7 @@ class Pic_Full_View(Screen):
                        <widget source=\"file\" render=\"Label\" position=\""+ str(space+45) + "," + str(space) + "\" size=\""+ str(size_w-(space*2)-50) + ",25\" font=\"Regular;20\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>"
 
                Screen.__init__(self, session)
-               
+
                self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
                {
                        "cancel": self.Exit,
@@ -452,12 +466,12 @@ class Pic_Full_View(Screen):
                        "right": self.nextPic,
                        "showEventInfo": self.StartExif,
                }, -1)
-               
+
                self["point"] = Pixmap()
                self["pic"] = Pixmap()
                self["play_icon"] = Pixmap()
                self["file"] = StaticText(_("please wait, loading picture..."))
-               
+
                self.old_index = 0
                self.filelist = []
                self.lastindex = index
@@ -483,10 +497,10 @@ class Pic_Full_View(Screen):
                self.index = index - self.dirlistcount
                if self.index < 0:
                        self.index = 0
-               
+
                self.picload = ePicLoad()
                self.picload.PictureData.get().append(self.finish_decode)
-               
+
                self.slideTimer = eTimer()
                self.slideTimer.callback.append(self.slidePic)
 
@@ -496,7 +510,7 @@ class Pic_Full_View(Screen):
        def setPicloadConf(self):
                sc = getScale()
                self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), sc[0], sc[1], 0, int(config.pic.resize.value), self.bgcolor])
-               
+
                self["play_icon"].hide()
                if config.pic.infoline.value == False:
                        self["file"].setText("")
@@ -509,10 +523,10 @@ class Pic_Full_View(Screen):
                        self.lastindex = self.currPic[1]
                        self["pic"].instance.setPixmap(self.currPic[2].__deref__())
                        self.currPic = []
-                       
+
                        self.next()
                        self.start_decode()
-       
+
        def finish_decode(self, picInfo=""):
                self["point"].hide()
                ptr = self.picload.getData()
@@ -569,7 +583,7 @@ class Pic_Full_View(Screen):
        def nextPic(self):
                self.shownow = True
                self.ShowPicture()
-               
+
        def StartExif(self):
                if self.maxentry < 0:
                        return