From 55738636d9d1c91aff1621a665184bf61560c2d2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 16 May 2011 13:41:43 +0200 Subject: [PATCH 1/5] render the themes when the screen size changed --- openlp/core/ui/mainwindow.py | 1 + openlp/core/ui/thememanager.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 11727f4ae..2d56a2e0c 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -783,6 +783,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.renderer.update_display() self.liveController.screenSizeChanged() self.previewController.screenSizeChanged() + self.themeManagerContents.updatePreviewImages() self.setFocus() self.activateWindow() diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index e30c9dea3..1a9c71cab 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -660,6 +660,15 @@ 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. + """ + for theme in self.themelist: + self.generateAndSaveImage( + self.path, theme, self.getThemeData(theme)) + self.loadThemes() + def generateImage(self, themeData, forcePage=False): """ Call the renderer to build a Sample Image From 7829de85978a177fa10237469c90aafec00727ba Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 16 May 2011 14:22:08 +0200 Subject: [PATCH 2/5] set cursor busy, update the preview images before the displays --- openlp/core/ui/mainwindow.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 593a3de05..1bb7f7bcf 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -778,17 +778,19 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def screenChanged(self): """ - The screen has changed to so tell the displays to update_display - their locations + The screen has changed so we have to update components such as the + renderer. """ log.debug(u'screenChanged') + Receiver.send_message(u'cursor_busy') self.image_manager.update_display() self.renderer.update_display() - self.liveController.screenSizeChanged() - self.previewController.screenSizeChanged() self.themeManagerContents.updatePreviewImages() + self.previewController.screenSizeChanged() + self.liveController.screenSizeChanged() self.setFocus() self.activateWindow() + Receiver.send_message(u'cursor_normal') def closeEvent(self, event): """ From 875202decaf458b0fd45c3130c2ba9473c43901a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 19 May 2011 08:01:28 +0200 Subject: [PATCH 3/5] reverted changes --- openlp/core/ui/mainwindow.py | 1 - openlp/core/ui/thememanager.py | 9 --------- 2 files changed, 10 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 1bb7f7bcf..695fc1c54 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -785,7 +785,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Receiver.send_message(u'cursor_busy') self.image_manager.update_display() self.renderer.update_display() - self.themeManagerContents.updatePreviewImages() self.previewController.screenSizeChanged() self.liveController.screenSizeChanged() self.setFocus() diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 1a9c71cab..e30c9dea3 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -660,15 +660,6 @@ 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. - """ - for theme in self.themelist: - self.generateAndSaveImage( - self.path, theme, self.getThemeData(theme)) - self.loadThemes() - def generateImage(self, themeData, forcePage=False): """ Call the renderer to build a Sample Image From 304f4ff732ed4b96fb9d59fb6cdfddd59cb946b2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 20 May 2011 13:45:39 +0200 Subject: [PATCH 4/5] added menu entry to update the theme images --- openlp/core/ui/mainwindow.py | 16 ++++++++++++++++ openlp/core/ui/thememanager.py | 25 +++++++++++++++++++++++++ openlp/core/utils/__init__.py | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) 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: From 383670e446cc4f25ce2823d18f69fd25b36189ae Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 20 May 2011 17:00:27 +0200 Subject: [PATCH 5/5] use the awesome mainwindow progress bar --- openlp/core/ui/thememanager.py | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 4b2de8500..190939ab9 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -664,25 +664,12 @@ class ThemeManager(QtGui.QWidget): """ 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.mainwindow.displayProgressBar(len(self.themelist)) + for theme in self.themelist: + self.mainwindow.incrementProgressBar() self.generateAndSaveImage( self.path, theme, self.getThemeData(theme)) - progressDialog.setValue(len(self.themelist)) + self.mainwindow.finishedProgressBar() self.loadThemes() def generateImage(self, themeData, forcePage=False):