Moved initial images list conversion to app_startup

This commit is contained in:
Arjan Schrijver 2013-03-03 20:35:11 +01:00
parent 97184a9ea1
commit a5e6cc358b
2 changed files with 20 additions and 7 deletions

View File

@ -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):
"""

View File

@ -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