Presentation fixes

This commit is contained in:
Phill Ridout 2015-01-20 21:56:05 +00:00
parent b4eb42fed2
commit 4d749a89ac
5 changed files with 38 additions and 11 deletions

View File

@ -373,8 +373,7 @@ s
duplicates_found = False
files_added = False
for file_path in files:
filename = os.path.split(str(file_path))[1]
if filename in names:
if file_path in full_list:
duplicates_found = True
else:
files_added = True

View File

@ -74,6 +74,7 @@ class ImagePlugin(Plugin):
"""
Perform tasks on application startup.
"""
# TODO: Can be removed when the upgrade path from 2.0.x to 2.2.x is no longer needed
Plugin.app_startup(self)
# Convert old settings-based image list to the database.
files_from_config = Settings().get_files_from_config(self)
@ -94,6 +95,7 @@ class ImagePlugin(Plugin):
:param settings: The Settings object containing the old settings.
"""
# TODO: Can be removed when the upgrade path from 2.0.x to 2.2.x is no longer needed
files_from_config = settings.get_files_from_config(self)
if files_from_config:
log.debug('Importing images list from old config: %s' % files_from_config)

View File

@ -229,10 +229,7 @@ class PresentationMediaItem(MediaManagerItem):
self.main_window.display_progress_bar(len(row_list))
for item in items:
filepath = str(item.data(QtCore.Qt.UserRole))
for cidx in self.controllers:
doc = self.controllers[cidx].add_document(filepath)
doc.presentation_deleted()
doc.close_presentation()
self.delete_presentation(filepath)
self.main_window.increment_progress_bar()
self.main_window.finished_progress_bar()
self.application.set_busy_cursor()
@ -240,6 +237,12 @@ class PresentationMediaItem(MediaManagerItem):
self.list_view.takeItem(row)
Settings().setValue(self.settings_section + '/presentations files', self.get_file_list())
def delete_presentation(self, filepath):
for cidx in self.controllers:
doc = self.controllers[cidx].add_document(filepath)
doc.presentation_deleted()
doc.close_presentation()
def generate_slide_data(self, service_item, item=None, xml_version=False, remote=False,
context=ServiceItemContext.Service, presentation_file=None):
"""

View File

@ -27,13 +27,14 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import hashlib
import logging
import os
import shutil
from PyQt4 import QtCore
from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists
from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, md5_hash
from openlp.core.lib import create_thumb, validate_thumb
log = logging.getLogger(__name__)
@ -139,13 +140,21 @@ class PresentationDocument(object):
"""
The location where thumbnail images will be stored
"""
return os.path.join(self.controller.thumbnail_folder, self.get_file_name())
if Settings().value('presentations/thumbnail_scheme') == 'md5':
folder = md5_hash('', self.file_path)
else:
folder = self.get_file_name()
return os.path.join(self.controller.thumbnail_folder, folder)
def get_temp_folder(self):
"""
The location where thumbnail images will be stored
"""
return os.path.join(self.controller.temp_folder, self.get_file_name())
if Settings().value('presentations/thumbnail_scheme') == 'md5':
folder = md5_hash('', self.file_path)
else:
folder = folder = self.get_file_name()
return os.path.join(self.controller.temp_folder, folder)
def check_thumbnails(self):
"""

View File

@ -35,7 +35,7 @@ import logging
from PyQt4 import QtCore
from openlp.core.common import AppLocation, translate
from openlp.core.common import AppLocation, Settings, translate
from openlp.core.lib import Plugin, StringContent, build_icon
from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab
@ -50,7 +50,8 @@ __default_settings__ = {'presentations/override app': QtCore.Qt.Unchecked,
'presentations/Powerpoint': QtCore.Qt.Checked,
'presentations/Powerpoint Viewer': QtCore.Qt.Checked,
'presentations/Pdf': QtCore.Qt.Checked,
'presentations/presentations files': []
'presentations/presentations files': [],
'presentations/thumbnail_scheme': ''
}
@ -141,6 +142,19 @@ class PresentationPlugin(Plugin):
self.register_controllers(controller)
return bool(self.controllers)
def app_startup(self):
"""
Perform tasks on application startup.
"""
super().app_startup()
files_from_config = Settings().value('presentations/presentations files')
for file in files_from_config:
self.media_item.delete_presentation(file)
#Settings().setValue('presentations/presentations files', [])
self.media_item.list_view.clear()
Settings().setValue('presentations/thumbnail_scheme', 'md5')
self.media_item.validate_and_load(files_from_config)
def about(self):
"""
Return information about this plugin.