diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 695fc1c54..167fcdd4a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -229,6 +229,8 @@ class Ui_MainWindow(object): self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder', u':/general/general_open.png', category=UiStrings().Tools) + self.updateThemeImages = base_action(mainWindow, + u'updateThemeImages', category=UiStrings().Tools) action_list.add_category(UiStrings().Settings, CategoryOrder.standardMenu) self.settingsPluginListItem = shortcut_action(mainWindow, u'settingsPluginListItem', [QtGui.QKeySequence(u'Alt+F7')], @@ -292,6 +294,7 @@ class Ui_MainWindow(object): self.SettingsConfigureItem)) add_actions(self.ToolsMenu, (self.ToolsAddToolItem, None)) add_actions(self.ToolsMenu, (self.ToolsOpenDataFolder, None)) + add_actions(self.ToolsMenu, [self.updateThemeImages]) add_actions(self.HelpMenu, (self.HelpDocumentationItem, self.HelpOnlineHelpItem, None, self.helpWebSiteItem, self.HelpAboutItem)) @@ -433,6 +436,11 @@ class Ui_MainWindow(object): translate('OpenLP.MainWindow', 'Open &Data Folder...')) self.ToolsOpenDataFolder.setStatusTip(translate('OpenLP.MainWindow', 'Open the folder where songs, bibles and other data resides.')) + self.updateThemeImages.setText( + translate('OpenLP.MainWindow', 'Update Theme Images')) + self.updateThemeImages.setStatusTip( + translate('OpenLP.MainWindow', 'Update the preview images for all ' + 'themes.')) self.ModeDefaultItem.setText( translate('OpenLP.MainWindow', '&Default')) self.ModeDefaultItem.setStatusTip(translate('OpenLP.MainWindow', @@ -505,6 +513,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.SIGNAL(u'triggered()'), self.onHelpOnLineHelpClicked) QtCore.QObject.connect(self.ToolsOpenDataFolder, QtCore.SIGNAL(u'triggered()'), self.onToolsOpenDataFolderClicked) + QtCore.QObject.connect(self.updateThemeImages, + QtCore.SIGNAL(u'triggered()'), self.onUpdateThemeImages) QtCore.QObject.connect(self.DisplayTagItem, QtCore.SIGNAL(u'triggered()'), self.onDisplayTagItemClicked) QtCore.QObject.connect(self.SettingsConfigureItem, @@ -717,6 +727,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): path = AppLocation.get_data_path() QtGui.QDesktopServices.openUrl(QtCore.QUrl("file:///" + path)) + def onUpdateThemeImages(self): + """ + Updates the new theme preview images. + """ + self.themeManagerContents.updatePreviewImages() + def onDisplayTagItemClicked(self): """ Show the Settings dialog diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index e30c9dea3..4b2de8500 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -660,6 +660,31 @@ class ThemeManager(QtGui.QWidget): pixmap.save(thumb, u'png') log.debug(u'Theme image written to %s', samplepathname) + def updatePreviewImages(self): + """ + Called to update the themes' preview images. + """ + progressDialog = QtGui.QProgressDialog(self.mainwindow) + progressDialog.setWindowModality(QtCore.Qt.WindowModal) + progressDialog.setLabelText( + translate('OpenLP.ThemeManager', 'Starting update...', + 'Shown when you update the theme images.')) + progressDialog.setCancelButton(None) + progressDialog.setRange(0, len(self.themelist)) + progressDialog.setMinimumDuration(0) + progressDialog.forceShow() + Receiver.send_message(u'openlp_process_events') + for index, theme in enumerate(self.themelist): + progressDialog.setValue(index) + progressDialog.setLabelText(unicode(translate('OpenLP.ThemeManager', + 'Updating %s...', + 'Shown when you update the theme images.')) % theme) + Receiver.send_message(u'openlp_process_events') + self.generateAndSaveImage( + self.path, theme, self.getThemeData(theme)) + progressDialog.setValue(len(self.themelist)) + self.loadThemes() + def generateImage(self, themeData, forcePage=False): """ Call the renderer to build a Sample Image diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 3051301d6..c5c08fad4 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -342,7 +342,7 @@ def add_actions(target, actions): The menu or toolbar to add actions to. ``actions`` - The actions to be added. An action consisting of the keyword 'None' + The actions to be added. An action consisting of the keyword ``None`` will result in a separator being inserted into the target. """ for action in actions: