3 from Screens.Screen import Screen
4 from Screens.ServiceInfo import ServiceInfoList, ServiceInfoListEntry
5 from Components.ActionMap import ActionMap, NumberActionMap
6 from Components.Pixmap import Pixmap, MovingPixmap
7 from Components.Label import Label
9 from Components.ConfigList import ConfigList
10 from Components.config import *
12 from Tools.Directories import resolveFilename, SCOPE_MEDIA
13 from Components.FileList import FileEntryComponent, FileList
14 from Components.AVSwitch import AVSwitch
16 from Plugins.Plugin import PluginDescriptor
20 config.pic = ConfigSubsection()
21 config.pic.slidetime = ConfigInteger(default=10, limits=(5, 60))
22 config.pic.resize = ConfigSelection(default="0", choices = [("0", _("simple")), ("1", _("better"))])
23 config.pic.cache = ConfigEnableDisable(default=True)
24 config.pic.lastDir = ConfigText(default=resolveFilename(SCOPE_MEDIA))
25 config.pic.rotate = ConfigSelection(default="0", choices = [("0", _("none")), ("1", _("manual")), ("2", _("by Exif"))])
28 val = AVSwitch().getAspectRatioSetting()
31 #------------------------------------------------------------------------------------------
33 class ThumbView(Screen):
35 <screen position="0,0" size="720,576" flags="wfNoBorder" title="ThumbView" >
36 <eLabel position="0,0" zPosition="0" size="720,576" backgroundColor="black" />
37 <widget name="frame" position="50,63" size="190,200" pixmap="pic_frame.png" zPosition="1" alphatest="on" />
38 <widget name="label0" position="55,240" size="180,20" font="Regular;13" halign="center" zPosition="2" transparent="1" />
39 <widget name="label1" position="270,240" size="180,20" font="Regular;13" halign="center" zPosition="2" transparent="1" />
40 <widget name="label2" position="485,240" size="180,20" font="Regular;13" halign="center" zPosition="2" transparent="1" />
41 <widget name="label3" position="55,465" size="180,20" font="Regular;13" halign="center" zPosition="2" transparent="1" />
42 <widget name="label4" position="270,465" size="180,20" font="Regular;13" halign="center" zPosition="2" transparent="1" />
43 <widget name="label5" position="485,465" size="180,20" font="Regular;13" halign="center" zPosition="2" transparent="1" />
44 <widget name="thumb0" position="55,68" size="180,160" zPosition="2" transparent="1" />
45 <widget name="thumb1" position="270,68" size="180,160" zPosition="2" transparent="1" />
46 <widget name="thumb2" position="485,68" size="180,160" zPosition="2" transparent="1" />
47 <widget name="thumb3" position="55,293" size="180,160" zPosition="2" transparent="1" />
48 <widget name="thumb4" position="270,293" size="180,160" zPosition="2" transparent="1" />
49 <widget name="thumb5" position="485,293" size="180,160" zPosition="2" transparent="1" />
52 def __init__(self, session, filelist, name, path):
53 self.skin = ThumbView.skin
54 Screen.__init__(self, session)
56 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "MovieSelectionActions"],
60 "showEventInfo": self.StartExif,
61 "right": self.key_right,
62 "left": self.key_left,
68 self["label"+str(x)] = Label()
69 self["thumb"+str(x)] = Pixmap()
70 self["frame"] = MovingPixmap()
72 self.aspect = getAspect()
74 self.filelist = filelist
81 self.poslist = [[50,63],[265,63],[480,63],[50,288],[265,288],[480,288]]
85 for x in self.filelist:
87 self.list.append((x[0][0], self.path + x[0][0], count/6, pos, "(" + str(count+1) + ") "))
94 self.maxentry = len(self.list)-1
96 self.ThumbTimer = eTimer()
97 self.ThumbTimer.timeout.get().append(self.showThumb)
104 self.index = self.maxentry
109 if self.index > self.maxentry:
121 if self.index > self.maxentry:
122 self.index = self.maxentry
126 self["frame"].moveTo(self.poslist[self.list[self.index][3]][0], self.poslist[self.list[self.index][3]][1], 1)
127 self["frame"].startMoving()
129 if self.list[self.index][2] != self.currPage:
130 self.currPage = self.list[self.index][2]
131 textlist = ["","","","","",""]
132 self.thumblist = ["","","","","",""]
135 if x[2] == self.currPage:
136 textlist[x[3]] = x[4] + x[0]
137 self.thumblist[x[3]] = x[0]
140 self["label"+str(x)].setText(textlist[x])
141 self["thumb"+str(x)].hide()
143 self.ThumbTimer.start(500, True)
146 if self.thumblist[self.thumbindex] != "":
148 if config.pic.cache.value:
149 cachedir = self.path + ".Thumbnails/"
150 if not os.path.exists(cachedir):
152 cachefile = cachedir + self.thumblist[self.thumbindex] + str(180) + str(160) + str(self.aspect)
154 ptr = loadPic(self.path + self.thumblist[self.thumbindex], 180, 160, self.aspect, int(config.pic.resize.value), int(config.pic.rotate.value),1, cachefile)
156 self["thumb"+str(self.thumbindex)].show()
157 self["thumb"+str(self.thumbindex)].instance.setPixmap(ptr.__deref__())
160 if self.thumbindex < 6:
161 self.ThumbTimer.start(500, True)
168 self.session.open(ExifView, self.list[self.index][1], self.list[self.index][0])
171 self.old_index = self.index
172 self.session.openWithCallback(self.returnView ,PicView, self.filelist, self.list[self.index][0], self.path)
174 def returnView(self, val=0):
176 if self.old_index != self.index:
180 self.close(self.index)
182 #------------------------------------------------------------------------------------------
184 class PicView(Screen):
186 <screen position="0,0" size="720,576" flags="wfNoBorder" title="PicturePlayer" >
187 <eLabel position="0,0" zPosition="0" size="720,576" backgroundColor="black" />
188 <widget name="picture" position="80,50" size="560,450" zPosition="1" transparent="1" />
189 <widget name="point" position="80,515" size="15,15" zPosition="1" pixmap="BlinkingPoint-fs8.png" alphatest="on" />
190 <widget name="file" position="150,510" size="350,30" font="Regular;20" halign="center" zPosition="1" transparent="1" />
191 <ePixmap position="500,515" size="36,20" pixmap="key_info-fs8.png" zPosition="1" alphatest="on" />
192 <ePixmap position="550,515" size="20,20" pixmap="ico_mp_rewind.png" zPosition="1" alphatest="on" />
193 <widget name="play" position="575,515" size="20,20" pixmap="ico_mp_play.png" zPosition="1" alphatest="on" />
194 <widget name="pause" position="600,515" size="20,20" pixmap="ico_mp_pause.png" zPosition="1" alphatest="on" />
195 <ePixmap position="625,515" size="20,20" pixmap="ico_mp_forward.png" zPosition="1" alphatest="on" />
198 def __init__(self, session, filelist, name, path):
199 self.skin = PicView.skin
200 Screen.__init__(self, session)
202 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "MovieSelectionActions"],
205 "showEventInfo": self.StartExif,
207 "yellow": self.Pause,
208 "blue": self.nextPic,
212 self.aspect = getAspect()
213 self.blinking = False
223 self.list.append((x[0][0], path + x[0][0], 0))
227 self.maxentry = len(self.list)-1
229 self["file"] = Label(_("please wait, loading picture..."))
230 self["picture"] = Pixmap()
231 self["point"] = Pixmap()
232 self["play"] = Pixmap()
233 self["pause"] = Pixmap()
235 self.decodeTimer = eTimer()
236 self.decodeTimer.timeout.get().append(self.decodePic)
237 self.decodeTimer.start(300, True)
239 self.slideTimer = eTimer()
240 self.slideTimer.timeout.get().append(self.slidePic)
254 if self.pauseOn == False:
260 self.slideTimer.start(1000, True)
262 self.slideValue = int(config.pic.slidetime.value)
265 if self.slideOn == True and self.pauseOn == False:
266 self.blinkingWidget("play")
268 if self.slideValue <= 0:
269 self.slideValue = int(config.pic.slidetime.value)
272 self.slideTimer.start(1000, True)
275 self.blinkingWidget("pause")
276 self.slideTimer.start(1000, True)
279 self.currPic = loadPic(self.list[self.index][1], 560, 450, self.aspect, int(config.pic.resize.value), int(config.pic.rotate.value),1)
283 self.autoShow = False
286 if self.currPic != None:
287 self.old = self.index
288 self["file"].setText(self.list[self.old][0] + " (" + str(self.old+1) + "/" + str(self.maxentry+1) + ")")
289 self["picture"].instance.setPixmap(self.currPic.__deref__())
293 self.decodeTimer.start(300, True)
299 self.index = self.old
303 self.decodeTimer.start(300, True)
307 if self.index > self.maxentry:
313 self.index = self.maxentry
315 def blinkingWidget(self, name):
324 if self.pauseOn == False:
326 self.session.openWithCallback(self.StopExif ,ExifView, self.list[self.old][1], self.list[self.old][0])
335 #------------------------------------------------------------------------------------------
337 class ExifView(Screen):
339 <screen position="80,130" size="560,320" title="Exif-Data" >
340 <widget name="exiflist" position="5,5" size="550,310" selectionDisabled="1" />
343 def __init__(self, session, fullname, name):
344 self.skin = ExifView.skin
345 Screen.__init__(self, session)
347 self["actions"] = ActionMap(["OkCancelActions"],
352 dlist = ["Name:", "EXIF-Version:", "Camera-Make:", "Camera-Model:", "Date/Time:", "User Comments:", "Width / Height:", "Orientation:", "Metering Mode:", "Exposure Program:", "Light Source:", "Flash used:", "CompressedBitsPerPixel:", "ISO Speed Rating:", "X-Resolution:", "Y-Resolution:", "Resolution Unit:", "Brightness:", "Exposure Time:", "Exposure Bias:", "Distance:", "CCD-Width:", "ApertureFNumber:"]
354 self["exiflist"] = ServiceInfoList(tlist)
355 tlist.append(ServiceInfoListEntry(dlist[0], name))
357 for x in getExif(fullname):
358 tlist.append(ServiceInfoListEntry(dlist[count], x))
361 #------------------------------------------------------------------------------------------
363 class PicSetup(Screen):
365 <screen position="160,220" size="400,120" title="Settings" >
366 <widget name="liste" position="10,10" size="380,100" />
369 def __init__(self, session):
370 self.skin = PicSetup.skin
371 Screen.__init__(self, session)
373 self["actions"] = NumberActionMap(["SetupActions"],
375 "cancel": self.close,
376 "left": self.keyLeft,
377 "right": self.keyRight,
391 self["liste"] = ConfigList(self.list)
392 self.list.append(getConfigListEntry(_("Slideshow Interval (sec.)"), config.pic.slidetime))
393 self.list.append(getConfigListEntry(_("Scaling Mode"), config.pic.resize))
394 self.list.append(getConfigListEntry(_("Cache Thumbnails"), config.pic.cache))
395 #self.list.append(getConfigListEntry(_("Rotate Picture"), config.pic.rotate))
398 self["liste"].handleKey(KEY_LEFT)
401 self["liste"].handleKey(KEY_RIGHT)
403 def keyNumber(self, number):
404 self["liste"].handleKey(KEY_0 + number)
407 #------------------------------------------------------------------------------------------
409 class picmain(Screen):
411 <screen position="160,90" size="400,390" title="PicturePlayer" >
412 <ePixmap position="10,40" size="36,20" pixmap="key_menu-fs8.png" transparent="1" alphatest="on" />
413 <ePixmap position="10,70" size="36,20" pixmap="key_info-fs8.png" transparent="1" alphatest="on" />
414 <ePixmap position="12,100" size="36,20" pixmap="key_red-fs8.png" transparent="1" alphatest="on" />
415 <eLabel text="Settings" position="60,40" size="120,25" font="Regular;20" transparent="1" />
416 <eLabel text="Exif-Data" position="60,70" size="120,25" font="Regular;20" transparent="1" />
417 <eLabel text="Thumbnails" position="60,100" size="120,25" font="Regular;20" transparent="1" />
418 <widget name="thumbnail" position="200,5" size="180,160" alphatest="on" />
419 <widget name="filelist" position="5,170" zPosition="2" size="390,210" scrollbarMode="showOnDemand" />
422 def __init__(self, session):
423 self.skin = picmain.skin
424 Screen.__init__(self, session)
426 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ColorActions", "MovieSelectionActions"],
430 "right": self.rightDown,
434 "showEventInfo": self.StartExif,
435 "contextMenu": self.Settings,
436 "red": self.StartThumb
439 self.aspect = getAspect()
440 self.currDir = config.pic.lastDir.value
441 if not os.path.exists(self.currDir):
444 self.filelist = FileList(self.currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|png|bmp)")
445 self["filelist"] = self.filelist
446 self["thumbnail"] = Pixmap()
448 self.ThumbTimer = eTimer()
449 self.ThumbTimer.timeout.get().append(self.showThumb)
450 self.ThumbTimer.start(500, True)
453 self["filelist"].up()
454 self.ThumbTimer.start(1500, True)
457 self["filelist"].down()
458 self.ThumbTimer.start(1500, True)
461 self["filelist"].pageUp()
462 self.ThumbTimer.start(1500, True)
465 self["filelist"].pageDown()
466 self.ThumbTimer.start(1500, True)
469 if not self.filelist.canDescent():
471 if config.pic.cache.value:
472 cachedir = self.currDir + ".Thumbnails/"
473 if not os.path.exists(cachedir):
475 cachefile = cachedir + self.filelist.getSelection()[0] + str(180) + str(160) + str(self.aspect)
477 ptr = loadPic(self.currDir + self.filelist.getSelection()[0], 180, 160, self.aspect, int(config.pic.resize.value), 0, 0, cachefile)
479 self["thumbnail"].show()
480 self["thumbnail"].instance.setPixmap(ptr.__deref__())
482 self["thumbnail"].hide()
485 if self.filelist.canDescent():
486 self.currDir = self.filelist.getSelection()[0]
487 self.filelist.descent()
489 self.session.openWithCallback(self.returnVal, PicView, self.filelist.getFileList(), self.filelist.getSelection()[0], self.currDir)
491 def StartThumb(self):
492 self.session.openWithCallback(self.returnVal, ThumbView, self.filelist.getFileList(), self.filelist.getSelection()[0], self.currDir)
494 def returnVal(self, val=0):
498 if not self.filelist.canDescent():
499 self.session.open(ExifView, self.currDir + self.filelist.getSelection()[0], self.filelist.getSelection()[0])
502 self.session.open(PicSetup)
505 config.pic.lastDir.value = self.currDir
509 #------------------------------------------------------------------------------------------
511 def main(session, **kwargs):
512 session.open(picmain)
514 def Plugins(**kwargs):
515 return PluginDescriptor(name="PicturePlayer", description="Picture Viewer (BMP, PNG, JPG)", icon="pictureplayer.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)