~wgrant/openlp/openlyrics_test

« back to all changes in this revision

Viewing changes to openlp/plugins/presentations/lib/presentationcontroller.py

  • Committer: Martin Zibricky
  • Date: 2011-10-06 16:16:29 UTC
  • mfrom: (1186.2.584 openlp)
  • Revision ID: mzibr.public@gmail.com-20111006161629-17tyvvq60h3h15dd
[merge] r1770, rename testing dir to tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
from PyQt4 import QtCore
33
33
 
34
 
from openlp.core.lib import Receiver, resize_image
 
34
from openlp.core.lib import Receiver, check_directory_exists, create_thumb, \
 
35
    validate_thumb
35
36
from openlp.core.utils import AppLocation
36
37
 
37
38
log = logging.getLogger(__name__)
97
98
        self.slidenumber = 0
98
99
        self.controller = controller
99
100
        self.filepath = name
100
 
        if not os.path.isdir(self.get_thumbnail_folder()):
101
 
            os.mkdir(self.get_thumbnail_folder())
 
101
        check_directory_exists(self.get_thumbnail_folder())
102
102
 
103
103
    def load_presentation(self):
104
104
        """
145
145
 
146
146
    def check_thumbnails(self):
147
147
        """
148
 
        Returns true if the thumbnail images look to exist and are more
149
 
        recent than the powerpoint
 
148
        Returns ``True`` if the thumbnail images exist and are more recent than
 
149
        the powerpoint file.
150
150
        """
151
151
        lastimage = self.get_thumbnail_path(self.get_slide_count(), True)
152
152
        if not (lastimage and os.path.isfile(lastimage)):
153
153
            return False
154
 
        imgdate = os.stat(lastimage).st_mtime
155
 
        pptdate = os.stat(self.filepath).st_mtime
156
 
        return imgdate >= pptdate
 
154
        return validate_thumb(self.filepath, lastimage)
157
155
 
158
156
    def close_presentation(self):
159
157
        """
246
244
        if self.check_thumbnails():
247
245
            return
248
246
        if os.path.isfile(file):
249
 
            img = resize_image(file, 320, 240)
250
 
            img.save(self.get_thumbnail_path(idx, False))
 
247
            thumb_path = self.get_thumbnail_path(idx, False)
 
248
            create_thumb(file, thumb_path, False, QtCore.QSize(320, 240))
251
249
 
252
250
    def get_thumbnail_path(self, slide_no, check_exists):
253
251
        """
387
385
            AppLocation.get_section_data_path(self.settings_section),
388
386
            u'thumbnails')
389
387
        self.thumbnail_prefix = u'slide'
390
 
        if not os.path.isdir(self.thumbnail_folder):
391
 
            os.makedirs(self.thumbnail_folder)
392
 
        if not os.path.isdir(self.temp_folder):
393
 
            os.makedirs(self.temp_folder)
 
388
        check_directory_exists(self.thumbnail_folder)
 
389
        check_directory_exists(self.temp_folder)
394
390
 
395
391
    def enabled(self):
396
392
        """