b4afd8d13dff7d6889bb393fdb88a0f4d3c99506
[openblackhole/openblackhole-enigma2.git] / lib / python / Plugins / Extensions / PicturePlayer / ui.py
1 from enigma import ePicLoad, eTimer, getDesktop, gMainDC, eSize
2
3 from Screens.Screen import Screen
4 from Tools.Directories import resolveFilename, pathExists, SCOPE_MEDIA, SCOPE_CURRENT_SKIN
5
6 from Components.Pixmap import Pixmap, MovingPixmap
7 from Components.ActionMap import ActionMap, NumberActionMap
8 from Components.Sources.StaticText import StaticText
9 from Components.FileList import FileList
10 from Components.AVSwitch import AVSwitch
11 from Components.Sources.List import List
12 from Components.ConfigList import ConfigList, ConfigListScreen
13
14 from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigText, ConfigYesNo, KEY_LEFT, KEY_RIGHT, KEY_0, getConfigListEntry
15 import skin
16
17 def getScale():
18         return AVSwitch().getFramebufferScale()
19
20 config.pic = ConfigSubsection()
21 config.pic.framesize = ConfigInteger(default=30, limits=(5, 99))
22 config.pic.slidetime = ConfigInteger(default=10, limits=(1, 60))
23 config.pic.resize = ConfigSelection(default="1", choices = [("0", _("simple")), ("1", _("better"))])
24 config.pic.cache = ConfigYesNo(default=True)
25 config.pic.lastDir = ConfigText(default=resolveFilename(SCOPE_MEDIA))
26 config.pic.infoline = ConfigYesNo(default=True)
27 config.pic.loop = ConfigYesNo(default=True)
28 config.pic.bgcolor = ConfigSelection(default="#00000000", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
29 config.pic.textcolor = ConfigSelection(default="#0038FF48", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
30
31 class picshow(Screen):
32         skin = """
33                 <screen name="picshow" position="center,center" size="560,440" title="Picture player" >
34                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
35                         <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
36                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
37                         <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" />
38                         <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" />
39                         <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
40                         <widget source="label" render="Label" position="5,55" size="350,140" font="Regular;19" backgroundColor="#25062748" transparent="1"  />
41                         <widget name="thn" position="360,40" size="180,160" alphatest="on" />
42                         <widget name="filelist" position="5,205" zPosition="2" size="550,230" scrollbarMode="showOnDemand" />
43                 </screen>"""
44
45         def __init__(self, session):
46                 Screen.__init__(self, session)
47
48                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MenuActions"],
49                 {
50                         "cancel": self.KeyExit,
51                         "red": self.KeyExit,
52                         "green": self.KeyGreen,
53                         "yellow": self.KeyYellow,
54                         "menu": self.KeyMenu,
55                         "ok": self.KeyOk
56                 }, -1)
57
58                 self["key_red"] = StaticText(_("Close"))
59                 self["key_green"] = StaticText(_("Thumbnails"))
60                 self["key_yellow"] = StaticText("")
61                 self["label"] = StaticText("")
62                 self["thn"] = Pixmap()
63
64                 currDir = config.pic.lastDir.value
65                 if not pathExists(currDir):
66                         currDir = "/"
67
68                 self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)")
69                 self["filelist"] = self.filelist
70                 self["filelist"].onSelectionChanged.append(self.selectionChanged)
71
72                 self.ThumbTimer = eTimer()
73                 self.ThumbTimer.callback.append(self.showThumb)
74
75                 self.picload = ePicLoad()
76                 self.picload.PictureData.get().append(self.showPic)
77
78                 self.onLayoutFinish.append(self.setConf)
79
80         def showPic(self, picInfo=""):
81                 ptr = self.picload.getData()
82                 if ptr != None:
83                         self["thn"].instance.setPixmap(ptr.__deref__())
84                         self["thn"].show()
85
86                 text = picInfo.split('\n',1)
87                 self["label"].setText(text[1])
88                 self["key_yellow"].setText(_("Exif"))
89
90         def showThumb(self):
91                 if not self.filelist.canDescent():
92                         if self.filelist.getCurrentDirectory() and self.filelist.getFilename():
93                                 if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1:
94                                         self.ThumbTimer.start(500, True)
95
96         def selectionChanged(self):
97                 if not self.filelist.canDescent():
98                         self.ThumbTimer.start(500, True)
99                 else:
100                         self["label"].setText("")
101                         self["thn"].hide()
102                         self["key_yellow"].setText("")
103
104         def KeyGreen(self):
105                 #if not self.filelist.canDescent():
106                 self.session.openWithCallback(self.callbackView, Pic_Thumb, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory())
107
108         def KeyYellow(self):
109                 if not self.filelist.canDescent():
110                         self.session.open(Pic_Exif, self.picload.getInfo(self.filelist.getCurrentDirectory() + self.filelist.getFilename()))
111
112         def KeyMenu(self):
113                 self.session.openWithCallback(self.setConf ,Pic_Setup)
114
115         def KeyOk(self):
116                 if self.filelist.canDescent():
117                         self.filelist.descent()
118                 else:
119                         self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory())
120
121         def setConf(self, retval=None):
122                 self.setTitle(_("Picture player"))
123                 sc = getScale()
124                 #0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB)
125                 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"))
126
127         def callbackView(self, val=0):
128                 if val > 0:
129                         self.filelist.moveToIndex(val)
130
131         def KeyExit(self):
132                 del self.picload
133
134                 if self.filelist.getCurrentDirectory() is None:
135                         config.pic.lastDir.value = "/"
136                 else:
137                         config.pic.lastDir.value = self.filelist.getCurrentDirectory()
138
139                 config.pic.save()
140                 self.close()
141
142 #------------------------------------------------------------------------------------------
143
144 class Pic_Setup(Screen, ConfigListScreen):
145
146         def __init__(self, session):
147                 Screen.__init__(self, session)
148                 # for the skin: first try MediaPlayerSettings, then Setup, this allows individual skinning
149                 self.skinName = ["PicturePlayerSetup", "Setup"]
150                 self.setup_title = _("Settings")
151                 self.onChangedEntry = []
152                 self.session = session
153                 ConfigListScreen.__init__(self, [], session = session, on_change = self.changedEntry)
154                 self["actions"] = ActionMap(["SetupActions", "MenuActions"],
155                         {
156                                 "cancel": self.keyCancel,
157                                 "save": self.keySave,
158                                 "ok": self.keySave,
159                                 "menu": self.closeRecursive,
160                         }, -2)
161                 self["key_red"] = StaticText(_("Cancel"))
162                 self["key_green"] = StaticText(_("OK"))
163                 self.createSetup()
164                 self.onLayoutFinish.append(self.layoutFinished)
165
166         def layoutFinished(self):
167                 self.setTitle(self.setup_title)
168
169         def createSetup(self):
170                 setup_list = [
171                         getConfigListEntry(_("Slide show interval (sec.)"), config.pic.slidetime),
172                         getConfigListEntry(_("Scaling mode"), config.pic.resize),
173                         getConfigListEntry(_("Cache thumbnails"), config.pic.cache),
174                         getConfigListEntry(_("Show info line"), config.pic.infoline),
175                         getConfigListEntry(_("Frame size in full view"), config.pic.framesize),
176                         getConfigListEntry(_("Slide picture in loop"), config.pic.loop),
177                         getConfigListEntry(_("Background color"), config.pic.bgcolor),
178                         getConfigListEntry(_("Text color"), config.pic.textcolor),
179                         getConfigListEntry(_("Fulview resulution"), config.usage.pic_resolution),
180                 ]
181                 self["config"].list = setup_list
182                 self["config"].l.setList(setup_list)
183
184         def keyLeft(self):
185                 ConfigListScreen.keyLeft(self)
186
187         def keyRight(self):
188                 ConfigListScreen.keyRight(self)
189
190         # for summary:
191         def changedEntry(self):
192                 for x in self.onChangedEntry:
193                         x()
194
195         def getCurrentEntry(self):
196                 return self["config"].getCurrent()[0]
197
198         def getCurrentValue(self):
199                 return str(self["config"].getCurrent()[1].getText())
200
201         def createSummary(self):
202                 from Screens.Setup import SetupSummary
203                 return SetupSummary
204
205 #---------------------------------------------------------------------------
206
207 class Pic_Exif(Screen):
208         skin = """
209                 <screen name="Pic_Exif" position="center,center" size="560,360" title="Info" >
210                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
211                         <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" />
212                         <widget source="menu" render="Listbox" position="5,50" size="550,310" scrollbarMode="showOnDemand" selectionDisabled="1" >
213                                 <convert type="TemplatedMultiContent">
214                                 {
215                                         "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)],
216                                         "fonts": [gFont("Regular", 20)],
217                                         "itemHeight": 30
218                                 }
219                                 </convert>
220                         </widget>
221                 </screen>"""
222
223         def __init__(self, session, exiflist):
224                 Screen.__init__(self, session)
225
226                 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
227                 {
228                         "cancel": self.close
229                 }, -1)
230
231                 self["key_red"] = StaticText(_("Close"))
232
233                 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:"]
234                 list = []
235
236                 for x in range(len(exiflist)):
237                         if x>0:
238                                 list.append((exifdesc[x], exiflist[x]))
239                         else:
240                                 name = exiflist[x].split('/')[-1]
241                                 list.append((exifdesc[x], name))
242                 self["menu"] = List(list)
243                 self.onLayoutFinish.append(self.layoutFinished)
244
245         def layoutFinished(self):
246                 self.setTitle(_("Info"))
247
248 #----------------------------------------------------------------------------------------
249
250 T_INDEX = 0
251 T_FRAME_POS = 1
252 T_PAGE = 2
253 T_NAME = 3
254 T_FULL = 4
255
256 class Pic_Thumb(Screen):
257         def __init__(self, session, piclist, lastindex, path):
258
259                 self.textcolor = config.pic.textcolor.value
260                 self.color = config.pic.bgcolor.value
261                 self.spaceX, self.picX, self.spaceY, self.picY, textsize, thumtxt  = skin.parameters.get("PicturePlayerThumb",(35, 190, 30, 200, 20, 14))
262
263                 pic_frame = resolveFilename(SCOPE_CURRENT_SKIN, "pic_frame.png")
264
265                 size_w = getDesktop(0).size().width()
266                 size_h = getDesktop(0).size().height()
267                 self.thumbsX = size_w / (self.spaceX + self.picX) # thumbnails in X
268                 self.thumbsY = size_h / (self.spaceY + self.picY) # thumbnails in Y
269                 self.thumbsC = self.thumbsX * self.thumbsY # all thumbnails
270
271                 self.positionlist = []
272                 skincontent = ""
273
274                 posX = -1
275                 for x in range(self.thumbsC):
276                         posY = x / self.thumbsX
277                         posX += 1
278                         if posX >= self.thumbsX:
279                                 posX = 0
280
281                         absX = self.spaceX + (posX*(self.spaceX + self.picX))
282                         absY = self.spaceY + (posY*(self.spaceY + self.picY))
283                         self.positionlist.append((absX, absY))
284                         skincontent += "<widget source=\"label" + str(x) + "\" render=\"Label\" position=\"" + str(absX+5) + "," + str(absY+self.picY-textsize) + "\" size=\"" + str(self.picX - 10) + ","  + str(textsize) \
285                                         + "\" font=\"Regular;" + str(thumtxt) + "\" zPosition=\"2\" transparent=\"1\" noWrap=\"1\" foregroundColor=\"" + self.textcolor + "\" />"
286                         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\" />"
287
288                 # Screen, backgroundlabel and MovingPixmap
289                 self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
290                         <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\"" + self.color + "\" />" \
291                         + "<widget name=\"frame\" position=\"" + str(self.spaceX)+ "," + str(self.spaceY)+ "\" size=\"" + str(self.picX) + "," + str(self.picY) + "\" pixmap=\"" + pic_frame + "\" zPosition=\"1\" alphatest=\"on\" />" \
292                         + skincontent + "</screen>"
293
294                 Screen.__init__(self, session)
295
296                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
297                 {
298                         "cancel": self.Exit,
299                         "ok": self.KeyOk,
300                         "left": self.key_left,
301                         "right": self.key_right,
302                         "up": self.key_up,
303                         "down": self.key_down,
304                         "showEventInfo": self.StartExif,
305                 }, -1)
306
307                 self["frame"] = MovingPixmap()
308                 for x in range(self.thumbsC):
309                         self["label"+str(x)] = StaticText()
310                         self["thumb"+str(x)] = Pixmap()
311
312                 self.Thumbnaillist = []
313                 self.filelist = []
314                 self.currPage = -1
315                 self.dirlistcount = 0
316                 self.path = path
317
318                 index = 0
319                 framePos = 0
320                 Page = 0
321                 for x in piclist:
322                         if x[0][1] == False:
323                                 self.filelist.append((index, framePos, Page, x[0][0],  path + x[0][0]))
324                                 index += 1
325                                 framePos += 1
326                                 if framePos > (self.thumbsC -1):
327                                         framePos = 0
328                                         Page += 1
329                         else:
330                                 self.dirlistcount += 1
331
332                 self.maxentry = len(self.filelist)-1
333                 self.index = lastindex - self.dirlistcount
334                 if self.index < 0:
335                         self.index = 0
336
337                 self.picload = ePicLoad()
338                 self.picload.PictureData.get().append(self.showPic)
339
340                 self.onLayoutFinish.append(self.setPicloadConf)
341
342                 self.ThumbTimer = eTimer()
343                 self.ThumbTimer.callback.append(self.showPic)
344
345         def setPicloadConf(self):
346                 sc = getScale()
347                 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])
348                 self.paintFrame()
349
350         def paintFrame(self):
351                 #print "index=" + str(self.index)
352                 if self.maxentry < self.index or self.index < 0:
353                         return
354
355                 pos = self.positionlist[self.filelist[self.index][T_FRAME_POS]]
356                 self["frame"].moveTo( pos[0], pos[1], 1)
357                 self["frame"].startMoving()
358
359                 if self.currPage != self.filelist[self.index][T_PAGE]:
360                         self.currPage = self.filelist[self.index][T_PAGE]
361                         self.newPage()
362
363         def newPage(self):
364                 self.Thumbnaillist = []
365                 #clear Labels and Thumbnail
366                 for x in range(self.thumbsC):
367                         self["label"+str(x)].setText("")
368                         self["thumb"+str(x)].hide()
369                 #paint Labels and fill Thumbnail-List
370                 for x in self.filelist:
371                         if x[T_PAGE] == self.currPage:
372                                 self["label"+str(x[T_FRAME_POS])].setText("(" + str(x[T_INDEX]+1) + ") " + x[T_NAME])
373                                 self.Thumbnaillist.append([0, x[T_FRAME_POS], x[T_FULL]])
374
375                 #paint Thumbnail start
376                 self.showPic()
377
378         def showPic(self, picInfo=""):
379                 for x in range(len(self.Thumbnaillist)):
380                         if self.Thumbnaillist[x][0] == 0:
381                                 if self.picload.getThumbnail(self.Thumbnaillist[x][2]) == 1: #zu tun probier noch mal
382                                         self.ThumbTimer.start(500, True)
383                                 else:
384                                         self.Thumbnaillist[x][0] = 1
385                                 break
386                         elif self.Thumbnaillist[x][0] == 1:
387                                 self.Thumbnaillist[x][0] = 2
388                                 ptr = self.picload.getData()
389                                 if ptr != None:
390                                         self["thumb" + str(self.Thumbnaillist[x][1])].instance.setPixmap(ptr.__deref__())
391                                         self["thumb" + str(self.Thumbnaillist[x][1])].show()
392
393         def key_left(self):
394                 self.index -= 1
395                 if self.index < 0:
396                         self.index = self.maxentry
397                 self.paintFrame()
398
399         def key_right(self):
400                 self.index += 1
401                 if self.index > self.maxentry:
402                         self.index = 0
403                 self.paintFrame()
404
405         def key_up(self):
406                 self.index -= self.thumbsX
407                 if self.index < 0:
408                         self.index =self.maxentry
409                 self.paintFrame()
410
411         def key_down(self):
412                 self.index += self.thumbsX
413                 if self.index > self.maxentry:
414                         self.index = 0
415                 self.paintFrame()
416
417         def StartExif(self):
418                 if self.maxentry < 0:
419                         return
420                 self.session.open(Pic_Exif, self.picload.getInfo(self.filelist[self.index][T_FULL]))
421
422         def KeyOk(self):
423                 if self.maxentry < 0:
424                         return
425                 self.old_index = self.index
426                 self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist, self.index, self.path)
427
428         def callbackView(self, val=0):
429                 self.index = val
430                 if self.old_index != self.index:
431                         self.paintFrame()
432         def Exit(self):
433                 del self.picload
434                 self.close(self.index + self.dirlistcount)
435
436 #---------------------------------------------------------------------------
437
438 class Pic_Full_View(Screen):
439         def __init__(self, session, filelist, index, path):
440
441                 self.textcolor = config.pic.textcolor.value
442                 self.bgcolor = config.pic.bgcolor.value
443                 space = config.pic.framesize.value
444
445                 self.size_w = size_w = getDesktop(0).size().width()
446                 self.size_h = size_h = getDesktop(0).size().height()
447
448                 if config.usage.pic_resolution.value and (size_w, size_h) != eval(config.usage.pic_resolution.value):
449                         (size_w, size_h) = eval(config.usage.pic_resolution.value)
450                         gMainDC.getInstance().setResolution(size_w, size_h)
451                         getDesktop(0).resize(eSize(size_w, size_h))
452
453                 self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
454                         <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\" /> \
455                         <widget name=\"point\" position=\""+ str(space+5) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/record.png\" alphatest=\"on\" /> \
456                         <widget name=\"play_icon\" position=\""+ str(space+25) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/ico_mp_play.png\"  alphatest=\"on\" /> \
457                         <widget source=\"file\" render=\"Label\" position=\""+ str(space+45) + "," + str(space) + "\" size=\""+ str(size_w-(space*2)-50) + ",25\" font=\"Regular;20\" borderWidth=\"1\" borderColor=\"#000000\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>"
458
459                 Screen.__init__(self, session)
460
461                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
462                 {
463                         "cancel": self.Exit,
464                         "green": self.PlayPause,
465                         "yellow": self.PlayPause,
466                         "blue": self.nextPic,
467                         "red": self.prevPic,
468                         "left": self.prevPic,
469                         "right": self.nextPic,
470                         "showEventInfo": self.StartExif,
471                 }, -1)
472
473                 self["point"] = Pixmap()
474                 self["pic"] = Pixmap()
475                 self["play_icon"] = Pixmap()
476                 self["file"] = StaticText(_("please wait, loading picture..."))
477
478                 self.old_index = 0
479                 self.filelist = []
480                 self.lastindex = index
481                 self.currPic = []
482                 self.shownow = True
483                 self.dirlistcount = 0
484
485                 for x in filelist:
486                         if len(filelist[0]) == 3: #orig. filelist
487                                 if x[0][1] == False:
488                                         self.filelist.append(path + x[0][0])
489                                 else:
490                                         self.dirlistcount += 1
491                         elif len(filelist[0]) == 2: #scanlist
492                                 if x[0][1] == False:
493                                         self.filelist.append(x[0][0])
494                                 else:
495                                         self.dirlistcount += 1
496                         else: # thumbnaillist
497                                 self.filelist.append(x[T_FULL])
498
499                 self.maxentry = len(self.filelist)-1
500                 self.index = index - self.dirlistcount
501                 if self.index < 0:
502                         self.index = 0
503
504                 self.picload = ePicLoad()
505                 self.picload.PictureData.get().append(self.finish_decode)
506
507                 self.slideTimer = eTimer()
508                 self.slideTimer.callback.append(self.slidePic)
509
510                 if self.maxentry >= 0:
511                         self.onLayoutFinish.append(self.setPicloadConf)
512
513         def setPicloadConf(self):
514                 sc = getScale()
515                 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])
516
517                 self["play_icon"].hide()
518                 if config.pic.infoline.value == False:
519                         self["file"].setText("")
520                 self.start_decode()
521
522         def ShowPicture(self):
523                 if self.shownow and len(self.currPic):
524                         self.shownow = False
525                         if config.pic.infoline.value:
526                                 self["file"].setText(self.currPic[0])
527                         else:
528                                 self["file"].setText("")
529                         self.lastindex = self.currPic[1]
530                         self["pic"].instance.setPixmap(self.currPic[2].__deref__())
531                         self.currPic = []
532
533                         self.next()
534                         self.start_decode()
535
536         def finish_decode(self, picInfo=""):
537                 self["point"].hide()
538                 ptr = self.picload.getData()
539                 if ptr != None:
540                         text = ""
541                         try:
542                                 text = picInfo.split('\n',1)
543                                 text = "(" + str(self.index+1) + "/" + str(self.maxentry+1) + ") " + text[0].split('/')[-1]
544                         except:
545                                 pass
546                         self.currPic = []
547                         self.currPic.append(text)
548                         self.currPic.append(self.index)
549                         self.currPic.append(ptr)
550                         self.ShowPicture()
551
552         def start_decode(self):
553                 self.picload.startDecode(self.filelist[self.index])
554                 self["point"].show()
555
556         def next(self):
557                 self.index += 1
558                 if self.index > self.maxentry:
559                         self.index = 0
560
561         def prev(self):
562                 self.index -= 1
563                 if self.index < 0:
564                         self.index = self.maxentry
565
566         def slidePic(self):
567                 print "slide to next Picture index=" + str(self.lastindex)
568                 if config.pic.loop.value==False and self.lastindex == self.maxentry:
569                         self.PlayPause()
570                 self.shownow = True
571                 self.ShowPicture()
572
573         def PlayPause(self):
574                 if self.slideTimer.isActive():
575                         self.slideTimer.stop()
576                         self["play_icon"].hide()
577                 else:
578                         self.slideTimer.start(config.pic.slidetime.value*1000)
579                         self["play_icon"].show()
580                         self.nextPic()
581
582         def prevPic(self):
583                 self.currPic = []
584                 self.index = self.lastindex
585                 self.prev()
586                 self.start_decode()
587                 self.shownow = True
588
589         def nextPic(self):
590                 self.shownow = True
591                 self.ShowPicture()
592
593         def StartExif(self):
594                 if self.maxentry < 0:
595                         return
596                 self.session.open(Pic_Exif, self.picload.getInfo(self.filelist[self.lastindex]))
597
598         def Exit(self):
599                 del self.picload
600
601                 if config.usage.pic_resolution.value and (self.size_w, self.size_h) != eval(config.usage.pic_resolution.value):
602                         gMainDC.getInstance().setResolution(self.size_w, self.size_h)
603                         getDesktop(0).resize(eSize(self.size_w, self.size_h))
604
605                 self.close(self.lastindex + self.dirlistcount)
606