From a5e6cc358b68dd645151feaadabf56ee89cbfd08 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Sun, 3 Mar 2013 20:35:11 +0100 Subject: [PATCH] Moved initial images list conversion to app_startup --- openlp/core/lib/plugin.py | 8 ++------ openlp/plugins/images/imageplugin.py | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 8482428a2..a82651275 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -35,7 +35,6 @@ from PyQt4 import QtCore from openlp.core.lib import Settings, Registry, UiStrings from openlp.core.utils import get_application_version -from openlp.plugins.images.converter import ImagesListSaver log = logging.getLogger(__name__) @@ -301,13 +300,10 @@ class Plugin(QtCore.QObject): # FIXME: Remove after 2.2 release. # This is needed to load the list of images/media/presentation from the config saved # before the settings rewrite. - if self.mediaItemClass is not None: + if self.mediaItemClass is not None and self.name != u'images': loaded_list = Settings().get_files_from_config(self) # Now save the list to the config using our Settings class. - if self.name == u'images': - ImagesListSaver.save_converted_images_list(loaded_list) - else: - Settings().setValue(u'%s/%s files' % (self.settingsSection, self.name), loaded_list) + Settings().setValue(u'%s/%s files' % (self.settingsSection, self.name), loaded_list) def usesTheme(self, theme): """ diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 646d1c33a..44146d4ae 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -34,7 +34,7 @@ import logging from openlp.core.lib import Plugin, StringContent, Registry, ImageSource, Settings, build_icon, translate from openlp.core.lib.db import Manager from openlp.plugins.images.lib import ImageMediaItem, ImageTab -from openlp.plugins.images.lib.db import init_schema +from openlp.plugins.images.lib.db import init_schema, ImageFilenames log = logging.getLogger(__name__) @@ -69,6 +69,23 @@ class ImagePlugin(Plugin): 'provided by the theme.') return about_text + def app_startup(self): + """ + Perform tasks on application startup + """ + Plugin.app_startup(self) + # Convert old settings-based image list to the database + files_from_config = Settings().get_files_from_config(self) + if len(files_from_config) > 0: + log.debug(u'Importing images list from old config: %s' % files_from_config) + for filename in files_from_config: + imageFile = ImageFilenames() + imageFile.group_id = 0 + imageFile.filename = unicode(filename) + self.manager.save_object(imageFile) + self.mediaItem.loadFullList(self.manager.get_all_objects(ImageFilenames, + order_by_ref=ImageFilenames.filename)) + def setPluginTextStrings(self): """ Called to define all translatable texts of the plugin