X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/9f233a55dbc640a9dd8d1aa46c1291d28fdea3b4..3bc4feea6206761d48e7ead73dfd32721bf8e259:/lib/python/Plugins/Extensions/PicturePlayer/plugin.py?ds=sidebyside
diff --git a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py
old mode 100644
new mode 100755
index 7d62d2be..5d1c2cba
--- a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py
+++ b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py
@@ -1,21 +1,20 @@
from enigma import ePicLoad, eTimer, getDesktop
from Screens.Screen import Screen
-from Tools.Directories import resolveFilename, pathExists, SCOPE_MEDIA
+from Tools.Directories import resolveFilename, pathExists, fileExists, SCOPE_MEDIA
from Plugins.Plugin import PluginDescriptor
from Components.Pixmap import Pixmap, MovingPixmap
from Components.ActionMap import ActionMap, NumberActionMap
-from Components.Label import Label
-from Components.Button import Button
+from Components.Sources.StaticText import StaticText
from Components.FileList import FileList
from Components.AVSwitch import AVSwitch
from Components.Sources.List import List
-from Components.ConfigList import ConfigList
+from Components.ConfigList import ConfigList, ConfigListScreen
from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigText, ConfigEnableDisable, KEY_LEFT, KEY_RIGHT, KEY_0, getConfigListEntry
-def getAspectforPic():
+def getScale():
return AVSwitch().getFramebufferScale()
config.pic = ConfigSubsection()
@@ -30,37 +29,39 @@ config.pic.bgcolor = ConfigSelection(default="#00000000", choices = [("#00000000
config.pic.textcolor = ConfigSelection(default="#0038FF48", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
class picshow(Screen):
- def __init__(self, session):
- self.skin = """
-
-
-
-
-
-
-
-
-
+ skin = """
+
+
+
+
+
+
+
+
+
+
- """
+ """
+ def __init__(self, session):
Screen.__init__(self, session)
self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions"],
{
"cancel": self.KeyExit,
- "red": self.KeyRed,
+ "red": self.KeyExit,
+ "green": self.KeyGreen,
"yellow": self.KeyYellow,
"blue": self.KeyBlue,
"ok": self.KeyOk
}, -1)
- self["key_red"] = Button(_("Thumbnails"))
- self["key_green"] = Button()
- self["key_yellow"] = Button(_("Exif"))
- self["key_blue"] = Button(_("Setup"))
- self["label"] = Label()
+ self["key_red"] = StaticText(_("Close"))
+ self["key_green"] = StaticText(_("Thumbnails"))
+ self["key_yellow"] = StaticText("")
+ self["key_blue"] = StaticText(_("Setup"))
+ self["label"] = StaticText("")
self["thn"] = Pixmap()
currDir = config.pic.lastDir.value
@@ -70,13 +71,13 @@ class picshow(Screen):
self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)")
self["filelist"] = self.filelist
self["filelist"].onSelectionChanged.append(self.selectionChanged)
-
+
self.ThumbTimer = eTimer()
self.ThumbTimer.callback.append(self.showThumb)
self.picload = ePicLoad()
self.picload.PictureData.get().append(self.showPic)
-
+
self.onLayoutFinish.append(self.setConf)
def showPic(self, picInfo=""):
@@ -87,28 +88,30 @@ class picshow(Screen):
text = picInfo.split('\n',1)
self["label"].setText(text[1])
- self["label"].show()
-
+ self["key_yellow"].setText(_("Exif"))
+
def showThumb(self):
if not self.filelist.canDescent():
- if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1:
- self.ThumbTimer.start(500, True)
+ if self.filelist.getCurrentDirectory() and self.filelist.getFilename():
+ if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1:
+ self.ThumbTimer.start(500, True)
def selectionChanged(self):
if not self.filelist.canDescent():
self.ThumbTimer.start(500, True)
else:
- self["label"].hide()
+ self["label"].setText("")
self["thn"].hide()
-
- def KeyRed(self):
+ self["key_yellow"].setText("")
+
+ def KeyGreen(self):
#if not self.filelist.canDescent():
self.session.openWithCallback(self.callbackView, Pic_Thumb, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory())
-
+
def KeyYellow(self):
if not self.filelist.canDescent():
self.session.open(Pic_Exif, self.picload.getInfo(self.filelist.getCurrentDirectory() + self.filelist.getFilename()))
-
+
def KeyBlue(self):
self.session.openWithCallback(self.setConf ,Pic_Setup)
@@ -119,9 +122,11 @@ class picshow(Screen):
self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory())
def setConf(self):
+ self.setTitle(_("PicturePlayer"))
+ sc = getScale()
#0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB)
- self.picload.setPara([self["thn"].instance.size().width(), self["thn"].instance.size().height(), getAspectforPic(), config.pic.cache.value, int(config.pic.resize.value), "#00000000"])
-
+ self.picload.setPara((self["thn"].instance.size().width(), self["thn"].instance.size().height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), "#00000000"))
+
def callbackView(self, val=0):
if val > 0:
self.filelist.moveToIndex(val)
@@ -139,69 +144,97 @@ class picshow(Screen):
#------------------------------------------------------------------------------------------
-class Pic_Setup(Screen):
+class Pic_Setup(Screen, ConfigListScreen):
+
def __init__(self, session):
- self.skin = """
-
- """
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"],
+ {
+ "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, on_change = self.changedEntry)
+ self.createSetup()
+ self.onLayoutFinish.append(self.layoutFinished)
+
+ def layoutFinished(self):
+ self.setTitle(self.setup_title)
+
+ def createSetup(self):
+ self.list = []
+ self.list.append(getConfigListEntry(_("Slideshow Interval (sec.)"), config.pic.slidetime))
+ self.list.append(getConfigListEntry(_("Scaling Mode"), config.pic.resize))
+ self.list.append(getConfigListEntry(_("Cache Thumbnails"), config.pic.cache))
+ self.list.append(getConfigListEntry(_("show Infoline"), config.pic.infoline))
+ self.list.append(getConfigListEntry(_("Frame size in full view"), config.pic.framesize))
+ self.list.append(getConfigListEntry(_("slide picture in loop"), config.pic.loop))
+ self.list.append(getConfigListEntry(_("backgroundcolor"), config.pic.bgcolor))
+ self.list.append(getConfigListEntry(_("textcolor"), config.pic.textcolor))
+ self["config"].list = self.list
+ self["config"].l.setList(self.list)
- self["actions"] = NumberActionMap(["SetupActions"],
- {
- "cancel": self.close,
- "left": self.keyLeft,
- "right": self.keyRight,
- "0": self.keyNumber,
- "1": self.keyNumber,
- "2": self.keyNumber,
- "3": self.keyNumber,
- "4": self.keyNumber,
- "5": self.keyNumber,
- "6": self.keyNumber,
- "7": self.keyNumber,
- "8": self.keyNumber,
- "9": self.keyNumber
- }, -1)
-
- list = []
- self["liste"] = ConfigList(list)
- list.append(getConfigListEntry(_("Slideshow Interval (sec.)"), config.pic.slidetime))
- list.append(getConfigListEntry(_("Scaling Mode"), config.pic.resize))
- list.append(getConfigListEntry(_("Cache Thumbnails"), config.pic.cache))
- list.append(getConfigListEntry(_("show Infoline"), config.pic.infoline))
- list.append(getConfigListEntry(_("Frame size in full view"), config.pic.framesize))
- list.append(getConfigListEntry(_("slide picture in loop"), config.pic.loop))
- list.append(getConfigListEntry(_("backgroundcolor"), config.pic.bgcolor))
- list.append(getConfigListEntry(_("textcolor"), config.pic.textcolor))
-
def keyLeft(self):
- self["liste"].handleKey(KEY_LEFT)
+ ConfigListScreen.keyLeft(self)
def keyRight(self):
- self["liste"].handleKey(KEY_RIGHT)
-
- def keyNumber(self, number):
- self["liste"].handleKey(KEY_0 + number)
+ 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):
- def __init__(self, session, exiflist):
- self.skin = """
-
+ skin = """
+
+
+
+
- {"template": [ MultiContentEntryText(pos = (5, 5), size = (250, 30), flags = RT_HALIGN_LEFT, text = 0), MultiContentEntryText(pos = (260, 5), size = (290, 30), flags = RT_HALIGN_LEFT, text = 1)], "fonts": [gFont("Regular", 20)], "itemHeight": 30 }
+ {
+ "template": [ MultiContentEntryText(pos = (5, 5), size = (250, 30), flags = RT_HALIGN_LEFT, text = 0), MultiContentEntryText(pos = (260, 5), size = (290, 30), flags = RT_HALIGN_LEFT, text = 1)],
+ "fonts": [gFont("Regular", 20)],
+ "itemHeight": 30
+ }
-
- """
+
+ """
+
+ def __init__(self, session, exiflist):
Screen.__init__(self, session)
- self["actions"] = ActionMap(["OkCancelActions"],
+ self["actions"] = ActionMap(["SetupActions", "ColorActions"],
{
"cancel": self.close
}, -1)
-
- exifdesc = [_("Filename:"), "EXIF-Version:", "Make:", "Camera:", "Date/Time:", "Width / Height:", "Flash used:", "Orientation:", "User Comments:", "Metering Mode:", "Exposure Program:", "Light Source:", "CompressedBitsPerPixel:", "ISO Speed Rating:", "X-Resolution:", "Y-Resolution:", "Resolution Unit:", "Brightness:", "Exposure Time:", "Exposure Bias:", "Distance:", "CCD-Width:", "ApertureFNumber:"]
+
+ self["key_red"] = StaticText(_("Close"))
+
+ exifdesc = [_("filename")+':', "EXIF-Version:", "Make:", "Camera:", "Date/Time:", "Width / Height:", "Flash used:", "Orientation:", "User Comments:", "Metering Mode:", "Exposure Program:", "Light Source:", "CompressedBitsPerPixel:", "ISO Speed Rating:", "X-Resolution:", "Y-Resolution:", "Resolution Unit:", "Brightness:", "Exposure Time:", "Exposure Bias:", "Distance:", "CCD-Width:", "ApertureFNumber:"]
list = []
for x in range(len(exiflist)):
@@ -211,6 +244,10 @@ class Pic_Exif(Screen):
name = exiflist[x].split('/')[-1]
list.append((exifdesc[x], name))
self["menu"] = List(list)
+ self.onLayoutFinish.append(self.layoutFinished)
+
+ def layoutFinished(self):
+ self.setTitle(_("Info"))
#----------------------------------------------------------------------------------------
@@ -230,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 = ""
@@ -246,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 += ""
-
+ skincontent += ""
skincontent += ""
-
-
+
# Screen, backgroundlabel and MovingPixmap
self.skin = " \
" + skincontent + ""
-
+
Screen.__init__(self, session)
-
+
self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
{
"cancel": self.Exit,
@@ -271,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)] = Label()
+ self["label"+str(x)] = StaticText()
self["thumb"+str(x)] = Pixmap()
-
+
self.Thumbnaillist = []
self.filelist = []
self.currPage = -1
@@ -296,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:
@@ -304,17 +339,17 @@ 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)
def setPicloadConf(self):
- self.picload.setPara([self["thumb0"].instance.size().width(), self["thumb0"].instance.size().height(), getAspectforPic(), config.pic.cache.value, int(config.pic.resize.value), self.color])
+ sc = getScale()
+ self.picload.setPara([self["thumb0"].instance.size().width(), self["thumb0"].instance.size().height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), self.color])
self.paintFrame()
-
-
+
def paintFrame(self):
#print "index=" + str(self.index)
if self.maxentry < self.index or self.index < 0:
@@ -323,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()
@@ -339,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()
@@ -363,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:
@@ -411,15 +446,15 @@ 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.__init__(self, session)
-
+
self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
{
"cancel": self.Exit,
@@ -431,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"] = Label(_("please wait, loading picture..."))
-
+ self["file"] = StaticText(_("please wait, loading picture..."))
+
self.old_index = 0
self.filelist = []
self.lastindex = index
@@ -450,6 +485,11 @@ class Pic_Full_View(Screen):
self.filelist.append(path + x[0][0])
else:
self.dirlistcount += 1
+ elif len(filelist[0]) == 2: #scanlist
+ if x[0][1] == False:
+ self.filelist.append(x[0][0])
+ else:
+ self.dirlistcount += 1
else: # thumbnaillist
self.filelist.append(x[T_FULL])
@@ -457,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)
@@ -468,11 +508,12 @@ class Pic_Full_View(Screen):
self.onLayoutFinish.append(self.setPicloadConf)
def setPicloadConf(self):
- self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), getAspectforPic(), 0, int(config.pic.resize.value), self.bgcolor])
-
+ 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"].hide()
+ self["file"].setText("")
self.start_decode()
def ShowPicture(self):
@@ -482,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()
@@ -542,7 +583,7 @@ class Pic_Full_View(Screen):
def nextPic(self):
self.shownow = True
self.ShowPicture()
-
+
def StartExif(self):
if self.maxentry < 0:
return
@@ -578,7 +619,7 @@ def filescan(**kwargs):
ScanPath(path = "", with_subdirs = False),
],
name = "Pictures",
- description = "View Photos...",
+ description = _("View Photos..."),
openfnc = filescan_open,
)