From 1cc7c9ec396de85c6dc0ef6c538553dbf65546fa Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 22 Jan 2011 12:21:43 +0000 Subject: [PATCH 01/17] Cleanups --- openlp/core/utils/__init__.py | 6 +++--- openlp/plugins/alerts/alertsplugin.py | 8 +++----- openlp/plugins/alerts/forms/alertform.py | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 9dd133852..37bd02a4e 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -140,7 +140,7 @@ class AppLocation(object): return _get_os_dir_path(u'openlp', os.path.join(os.getenv(u'HOME'), u'Library', u'Application Support', u'openlp'), - None, os.path.join(os.getenv(u'HOME'), u'.openlp'), dir_type) + os.path.join(os.getenv(u'HOME'), u'.openlp'), dir_type) @staticmethod def get_data_path(): @@ -163,8 +163,8 @@ class AppLocation(object): os.makedirs(path) return path -def _get_os_dir_path(win_option, darwin_option, base_dir_option, - non_base_dir_option, dir_type=1): +def _get_os_dir_path(win_option, darwin_option, non_base_dir_option, + dir_type=1): """ Return a path based on which OS and environment we are running in. """ diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 61be922d5..54478b2c3 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -45,16 +45,14 @@ class AlertsPlugin(Plugin): self.icon = build_icon(u':/plugins/plugin_alerts.png') self.alertsmanager = AlertsManager(self) self.manager = Manager(u'alerts', init_schema) - visible_name = self.getString(StringContent.VisibleName) - self.alertForm = AlertForm(self, visible_name[u'title']) + self.visible_name = self.getString(StringContent.VisibleName) + self.alertForm = AlertForm(self) def getSettingsTab(self): """ Return the settings tab for the Alerts plugin """ - visible_name = self.getString(StringContent.VisibleName) - self.alertsTab = AlertsTab(self, visible_name[u'title']) - return self.alertsTab + return AlertsTab(self, self.visible_name[u'title']) def addToolsMenuItem(self, tools_menu): """ diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 1d6a566fd..f1a0f7fea 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -35,7 +35,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): """ Provide UI for the alert system """ - def __init__(self, plugin, visible_title): + def __init__(self, plugin): """ Initialise the alert form """ From 7fc5bea107417ba8db6b11c4223113c51abbae9c Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sat, 22 Jan 2011 17:50:32 +0000 Subject: [PATCH 02/17] Couple of cleanups --- openlp/plugins/alerts/alertsplugin.py | 3 ++- openlp/plugins/presentations/lib/impresscontroller.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 54478b2c3..443ec1e84 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -52,7 +52,8 @@ class AlertsPlugin(Plugin): """ Return the settings tab for the Alerts plugin """ - return AlertsTab(self, self.visible_name[u'title']) + self.alertsTab = AlertsTab(self, self.visible_name[u'title']) + return self.alertsTab def addToolsMenuItem(self, tools_menu): """ diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 6ca67c2ae..f12d36dc8 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -171,11 +171,11 @@ class ImpressController(PresentationController): desktop = self.get_com_desktop() #Sometimes we get a failure and desktop is None if not desktop: - log.exception(u'Failed to terminate OpenOffice') + log.exception(u'Failed to find an OpenOffice desktop to terminate') return docs = desktop.getComponents() if docs.hasElements(): - log.debug(u'OpenOffice not terminated') + log.debug(u'OpenOffice not terminated as docs are still open') else: try: desktop.terminate() From 09aee63cd204ef23a816db15f05171533ca325d6 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 23 Jan 2011 00:27:29 +0000 Subject: [PATCH 03/17] Fix Windows AppLocation (Bug #706396) --- openlp/core/utils/__init__.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 37bd02a4e..22781f769 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -137,10 +137,7 @@ class AppLocation(object): os.path.split(openlp.__file__)[0]) return os.path.join(app_path, u'i18n') else: - return _get_os_dir_path(u'openlp', - os.path.join(os.getenv(u'HOME'), u'Library', - u'Application Support', u'openlp'), - os.path.join(os.getenv(u'HOME'), u'.openlp'), dir_type) + return _get_os_dir_path(dir_type) @staticmethod def get_data_path(): @@ -163,16 +160,16 @@ class AppLocation(object): os.makedirs(path) return path -def _get_os_dir_path(win_option, darwin_option, non_base_dir_option, - dir_type=1): +def _get_os_dir_path(dir_type): """ Return a path based on which OS and environment we are running in. """ if sys.platform == u'win32': - return os.path.join(os.getenv(u'APPDATA'), win_option) + return os.path.join(os.getenv(u'APPDATA', u'openlp') elif sys.platform == u'darwin': if dir_type == AppLocation.DataDir: - return os.path.join(darwin_option, u'Data') + return os.path.join(os.getenv(u'HOME'), u'Library', + u'Application Support', u'openlp', u'Data') return darwin_option else: if XDG_BASE_AVAILABLE: @@ -183,7 +180,7 @@ def _get_os_dir_path(win_option, darwin_option, non_base_dir_option, elif dir_type == AppLocation.CacheDir: return os.path.join(BaseDirectory.xdg_cache_home, u'openlp') else: - return non_base_dir_option + return os.path.join(os.getenv(u'HOME'), u'.openlp') def _get_frozen_path(frozen_option, non_frozen_option): """ From 01826ddda8408f7c485220cb1b970ed0afc6071d Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Sun, 23 Jan 2011 00:46:51 +0000 Subject: [PATCH 04/17] Fix fix --- openlp/core/utils/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 22781f769..37cbd7a63 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -165,12 +165,13 @@ def _get_os_dir_path(dir_type): Return a path based on which OS and environment we are running in. """ if sys.platform == u'win32': - return os.path.join(os.getenv(u'APPDATA', u'openlp') + return os.path.join(os.getenv(u'APPDATA'), u'openlp') elif sys.platform == u'darwin': if dir_type == AppLocation.DataDir: return os.path.join(os.getenv(u'HOME'), u'Library', u'Application Support', u'openlp', u'Data') - return darwin_option + return os.path.join(os.getenv(u'HOME'), u'Library', + u'Application Support', u'openlp') else: if XDG_BASE_AVAILABLE: if dir_type == AppLocation.ConfigDir: From a0746c08656334e6d27f1dc09bc768776b4df8da Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 23 Jan 2011 08:25:21 +0000 Subject: [PATCH 05/17] Fix theme editor losing options --- openlp/core/ui/maindisplay.py | 8 +++++--- openlp/core/ui/themeform.py | 30 ++++++++++++++++-------------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 911aeda10..b0280f19b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -67,6 +67,7 @@ class MainDisplay(DisplayWidget): self.isLive = live self.alertTab = None self.hideMode = None + self.override_image = None mainIcon = build_icon(u':/icon/openlp-logo-16x16.png') self.setWindowIcon(mainIcon) self.retranslateUi() @@ -205,14 +206,15 @@ class MainDisplay(DisplayWidget): """ self.imageManager.add_image(name, path) self.image(name) + self.override_image = name def image(self, name): """ - Add an image as the background. The image is converted to a bytestream - on route. + Add an image as the background. The image has already been added + to the cache. `Image` - The Image to be displayed can be QImage or QPixmap + The name of the image to be displayed """ log.debug(u'image to display') image = self.imageManager.get_image_bytes(name) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 2db76063c..60c1b97bc 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -250,25 +250,27 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Change state as Outline check box changed """ - if state == QtCore.Qt.Checked: - self.theme.font_main_outline = True - else: - self.theme.font_main_outline = False - self.outlineColorButton.setEnabled(self.theme.font_main_outline) - self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline) - self.calculateLines() + if self.updateThemeAllowed: + if state == QtCore.Qt.Checked: + self.theme.font_main_outline = True + else: + self.theme.font_main_outline = False + self.outlineColorButton.setEnabled(self.theme.font_main_outline) + self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline) + self.calculateLines() def onShadowCheckCheckBoxStateChanged(self, state): """ Change state as Shadow check box changed """ - if state == QtCore.Qt.Checked: - self.theme.font_main_shadow = True - else: - self.theme.font_main_shadow = False - self.shadowColorButton.setEnabled(self.theme.font_main_shadow) - self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow) - self.calculateLines() + if self.updateThemeAllowed: + if state == QtCore.Qt.Checked: + self.theme.font_main_shadow = True + else: + self.theme.font_main_shadow = False + self.shadowColorButton.setEnabled(self.theme.font_main_shadow) + self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow) + self.calculateLines() def onMainPositionCheckBoxStateChanged(self, value): """ From 8252e504e191078676ea62723bb2b9fbe092b1ca Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 23 Jan 2011 14:08:49 +0000 Subject: [PATCH 06/17] Preserve replacement backgrounds - start --- openlp/core/lib/htmlbuilder.py | 7 ++++-- openlp/core/ui/maindisplay.py | 44 +++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 86056f4b5..83f941d11 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -297,6 +297,7 @@ body { function show_text_complete(){ return (text_opacity()==1); } + @@ -314,7 +315,7 @@ body { """ -def build_html(item, screen, alert, islive): +def build_html(item, screen, alert, islive, background): """ Build the full web paged structure for display @@ -332,7 +333,9 @@ def build_html(item, screen, alert, islive): theme = item.themedata webkitvers = webkit_version() # Image generated and poked in - if item.bg_image_bytes: + if background: + image = u'src="data:image/png;base64,%s"' % background + elif item.bg_image_bytes: image = u'src="data:image/png;base64,%s"' % item.bg_image_bytes else: image = u'style="display:none;"' diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index cfad9cd91..e9ef449fa 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -67,7 +67,7 @@ class MainDisplay(DisplayWidget): self.isLive = live self.alertTab = None self.hideMode = None - self.override_image = None + self.override = {} mainIcon = build_icon(u':/icon/openlp-logo-16x16.png') self.setWindowIcon(mainIcon) self.retranslateUi() @@ -112,7 +112,7 @@ class MainDisplay(DisplayWidget): self.page = self.webView.page() self.frame = self.page.mainFrame() QtCore.QObject.connect(self.webView, - QtCore.SIGNAL(u'loadFinished(bool)'), self.isLoaded) + QtCore.SIGNAL(u'loadFinished(bool)'), self.isWebLoaded) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.frame.setScrollBarPolicy(QtCore.Qt.Vertical, @@ -138,14 +138,14 @@ class MainDisplay(DisplayWidget): painter_image.begin(initialFrame) painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white) painter_image.drawImage( - (self.screens.current[u'size'].width() - + (self.screens.current[u'size'].width() - splash_image.width()) / 2, (self.screens.current[u'size'].height() - splash_image.height()) / 2, splash_image) serviceItem = ServiceItem() serviceItem.bg_image_bytes = image_to_byte(initialFrame) self.webView.setHtml(build_html(serviceItem, self.screen, - self.parent.alertTab, self.isLive)) + self.parent.alertTab, self.isLive, None)) self.initialFrame = True # To display or not to display? if not self.screen[u'primary']: @@ -163,7 +163,7 @@ class MainDisplay(DisplayWidget): """ log.debug(u'text to display') # Wait for the webview to update before displaying text. - while not self.loaded: + while not self.webLoaded: Receiver.send_message(u'openlp_process_events') self.frame.evaluateJavaScript(u'show_text("%s")' % \ slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')) @@ -205,7 +205,9 @@ class MainDisplay(DisplayWidget): """ self.imageManager.add_image(name, path) self.image(name) - self.override_image = name + if hasattr(self, u'serviceItem'): + self.override[u'image'] = name + self.override[u'theme'] = self.serviceItem.themedata.theme_name def image(self, name): """ @@ -315,7 +317,7 @@ class MainDisplay(DisplayWidget): Loads and starts a video to run with the option of sound """ log.debug(u'video') - self.loaded = True + self.webLoaded = True vol = float(volume)/float(10) if isBackground or not self.usePhonon: js = u'show_video("init", "%s", %s, true); show_video("play");' % \ @@ -335,12 +337,12 @@ class MainDisplay(DisplayWidget): Receiver.send_message(u'maindisplay_active') return self.preview() - def isLoaded(self): + def isWebLoaded(self): """ Called by webView event to show display is fully loaded """ - log.debug(u'loaded') - self.loaded = True + log.debug(u'Webloaded') + self.webLoaded = True def preview(self): """ @@ -359,7 +361,7 @@ class MainDisplay(DisplayWidget): Receiver.send_message(u'openlp_process_events') # Wait for the webview to update before geting the preview. # Important otherwise first preview will miss the background ! - while not self.loaded: + while not self.webLoaded: Receiver.send_message(u'openlp_process_events') # if was hidden keep it hidden if self.isLive: @@ -381,18 +383,32 @@ class MainDisplay(DisplayWidget): HTML to the display """ log.debug(u'buildHtml') - self.loaded = False + self.webLoaded = False self.initialFrame = False self.serviceItem = serviceItem + background = None + # We have an image override so keep the image till the theme changes + if self.override: + if self.override[u'theme'] != \ + serviceItem.themedata.theme_name: + Receiver.send_message(u'live_theme_changed') + self.override = {} + else: + background = self.imageManager. \ + get_image_bytes(self.override[u'image']) + # We have an video override so allow it to be stopped + if self.override and u'video' in self.override: + Receiver.send_message(u'video_background_replaced') + self.override = {} if self.serviceItem.themedata.background_filename: self.serviceItem.bg_image_bytes = self.imageManager. \ get_image_bytes(self.serviceItem.themedata.theme_name) html = build_html(self.serviceItem, self.screen, self.parent.alertTab, - self.isLive) + self.isLive, background) log.debug(u'buildHtml - pre setHtml') self.webView.setHtml(html) log.debug(u'buildHtml - post setHtml') - if serviceItem.foot_text and serviceItem.foot_text: + if serviceItem.foot_text: self.footer(serviceItem.foot_text) # if was hidden keep it hidden if self.hideMode and self.isLive: From 40717797927f8fcc8588f793977e40314cf70205 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 23 Jan 2011 14:33:50 +0000 Subject: [PATCH 07/17] Added the option to disable the update check on start up. (I think it defualts to false) --- openlp.pyw | 7 +++++-- openlp/core/ui/generaltab.py | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 017e12774..8d20080c9 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -194,7 +194,10 @@ class OpenLP(QtGui.QApplication): # now kill the splashscreen self.splash.finish(self.mainWindow) self.mainWindow.repaint() - VersionThread(self.mainWindow, app_version).start() + update_check = QtCore.QSettings().value( + u'general/update check', QtCore.QVariant(True)).toBool() + if update_check: + VersionThread(self.mainWindow, app_version).start() return self.exec_() def hookException(self, exctype, value, traceback): @@ -280,4 +283,4 @@ if __name__ == u'__main__': """ Instantiate and run the application. """ - main() \ No newline at end of file + main() diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 773637481..686abcaaa 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -113,6 +113,9 @@ class GeneralTab(SettingsTab): self.showSplashCheckBox = QtGui.QCheckBox(self.startupGroupBox) self.showSplashCheckBox.setObjectName(u'showSplashCheckBox') self.startupLayout.addWidget(self.showSplashCheckBox) + self.checkForUpdatesCheckBox = QtGui.QCheckBox(self.startupGroupBox) + self.checkForUpdatesCheckBox.setObjectName(u'checkForUpdatesCheckBox') + self.startupLayout.addWidget(self.checkForUpdatesCheckBox) self.leftLayout.addWidget(self.startupGroupBox) self.settingsGroupBox = QtGui.QGroupBox(self.leftColumn) self.settingsGroupBox.setObjectName(u'settingsGroupBox') @@ -249,6 +252,8 @@ class GeneralTab(SettingsTab): 'Automatically open the last service')) self.showSplashCheckBox.setText( translate('OpenLP.GeneralTab', 'Show the splash screen')) + self.checkForUpdatesCheckBox.setText( + translate('OpenLP.GeneralTab', 'Check for updates')) self.settingsGroupBox.setTitle( translate('OpenLP.GeneralTab', 'Application Settings')) self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab', @@ -317,6 +322,8 @@ class GeneralTab(SettingsTab): QtCore.QVariant(False)).toBool()) self.showSplashCheckBox.setChecked(settings.value(u'show splash', QtCore.QVariant(True)).toBool()) + self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check', + QtCore.QVariant(True)).toBool()) self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview', QtCore.QVariant(False)).toBool()) self.timeoutSpinBox.setValue(settings.value(u'loop delay', @@ -363,6 +370,8 @@ class GeneralTab(SettingsTab): QtCore.QVariant(self.autoOpenCheckBox.isChecked())) settings.setValue(u'show splash', QtCore.QVariant(self.showSplashCheckBox.isChecked())) + settings.setValue(u'update check', + QtCore.QVariant(self.checkForUpdatesCheckBox.isChecked())) settings.setValue(u'save prompt', QtCore.QVariant(self.saveCheckServiceCheckBox.isChecked())) settings.setValue(u'auto preview', From 33a924a243f12d2fdcec6451ecd30271deadab1f Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 23 Jan 2011 15:36:15 +0000 Subject: [PATCH 08/17] Preserve replacement backgrounds - finish --- openlp/core/lib/htmlbuilder.py | 1 - openlp/core/ui/maindisplay.py | 13 ++++++++----- openlp/plugins/images/lib/mediaitem.py | 11 +++++++++-- openlp/plugins/media/lib/mediaitem.py | 11 ++++++++++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 83f941d11..ea830855c 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -297,7 +297,6 @@ body { function show_text_complete(){ return (text_opacity()==1); } - diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e9ef449fa..c0e5dd509 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -318,6 +318,9 @@ class MainDisplay(DisplayWidget): """ log.debug(u'video') self.webLoaded = True + # We are running a background theme + self.override[u'theme'] = u'' + self.override[u'video'] = True vol = float(volume)/float(10) if isBackground or not self.usePhonon: js = u'show_video("init", "%s", %s, true); show_video("play");' % \ @@ -389,17 +392,17 @@ class MainDisplay(DisplayWidget): background = None # We have an image override so keep the image till the theme changes if self.override: - if self.override[u'theme'] != \ + # We have an video override so allow it to be stopped + if u'video' in self.override: + Receiver.send_message(u'video_background_replaced') + self.override = {} + elif self.override[u'theme'] != \ serviceItem.themedata.theme_name: Receiver.send_message(u'live_theme_changed') self.override = {} else: background = self.imageManager. \ get_image_bytes(self.override[u'image']) - # We have an video override so allow it to be stopped - if self.override and u'video' in self.override: - Receiver.send_message(u'video_background_replaced') - self.override = {} if self.serviceItem.themedata.background_filename: self.serviceItem.bg_image_bytes = self.imageManager. \ get_image_bytes(self.serviceItem.themedata.theme_name) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index bd84219fb..4f976bd51 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ ItemCapabilities, SettingsManager, translate, check_item_selected, \ - check_directory_exists + check_directory_exists, Receiver from openlp.core.ui import criticalErrorMessageBox from openlp.core.utils import AppLocation, delete_file, get_images_filter @@ -44,7 +44,6 @@ class ImageListView(BaseListWithDnD): self.PluginName = u'Images' BaseListWithDnD.__init__(self, parent) - class ImageMediaItem(MediaManagerItem): """ This is the custom media manager item for images. @@ -57,6 +56,8 @@ class ImageMediaItem(MediaManagerItem): # be instanced by the base MediaManagerItem. self.ListViewWithDnD_class = ImageListView MediaManagerItem.__init__(self, parent, self, icon) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged) def retranslateUi(self): self.OnNewPrompt = translate('ImagePlugin.MediaItem', @@ -193,6 +194,12 @@ class ImageMediaItem(MediaManagerItem): self.resetAction.setVisible(False) self.parent.liveController.display.resetImage() + def liveThemeChanged(self): + """ + Triggered by the change of theme in the slide controller + """ + self.resetAction.setVisible(False) + def onReplaceClick(self): """ Called to replace Live backgound with the image selected. diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 121fa80a0..1b5d6b8d8 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -30,7 +30,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ - ItemCapabilities, SettingsManager, translate, check_item_selected + ItemCapabilities, SettingsManager, translate, check_item_selected, Receiver from openlp.core.ui import criticalErrorMessageBox log = logging.getLogger(__name__) @@ -58,6 +58,9 @@ class MediaMediaItem(MediaManagerItem): MediaManagerItem.__init__(self, parent, self, icon) self.singleServiceItem = False self.serviceItemIconName = u':/media/image_clapperboard.png' + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'video_background_replaced'), + self.videobackgroundReplaced) def retranslateUi(self): self.OnNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') @@ -99,6 +102,12 @@ class MediaMediaItem(MediaManagerItem): self.resetAction.setVisible(False) self.parent.liveController.display.resetVideo() + def videobackgroundReplaced(self): + """ + Triggered by main display on change of serviceitem + """ + self.resetAction.setVisible(False) + def onReplaceClick(self): """ Called to replace Live backgound with the media selected. From 323cb4f001fee3e0d08e35f2330f73ae261919a6 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 23 Jan 2011 15:55:59 +0000 Subject: [PATCH 09/17] Description of check box changed --- openlp/core/ui/generaltab.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 686abcaaa..edace883f 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -253,7 +253,7 @@ class GeneralTab(SettingsTab): self.showSplashCheckBox.setText( translate('OpenLP.GeneralTab', 'Show the splash screen')) self.checkForUpdatesCheckBox.setText( - translate('OpenLP.GeneralTab', 'Check for updates')) + translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) self.settingsGroupBox.setTitle( translate('OpenLP.GeneralTab', 'Application Settings')) self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab', From ed2d7355ed1e7375cd9c6d962c62f430ff589672 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 24 Jan 2011 17:26:13 +0000 Subject: [PATCH 10/17] Miss a reset --- openlp/core/ui/maindisplay.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index c0e5dd509..3dfde8640 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -248,6 +248,7 @@ class MainDisplay(DisplayWidget): self.displayImage(self.serviceItem.bg_image_bytes) else: self.displayImage(None) + self.override = {} # Update the preview frame. Receiver.send_message(u'maindisplay_active') @@ -264,6 +265,7 @@ class MainDisplay(DisplayWidget): self.phononActive = False else: self.frame.evaluateJavaScript(u'show_video("close");') + self.override = {} # Update the preview frame. Receiver.send_message(u'maindisplay_active') From 03fc07cabf8dc38483e91ef8716cbfc675919813 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 25 Jan 2011 01:19:57 +0000 Subject: [PATCH 11/17] Fix for NGÜ bible --- openlp/plugins/bibles/resources/bibleserver.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/resources/bibleserver.csv b/openlp/plugins/bibles/resources/bibleserver.csv index c0d109f97..942d43116 100644 --- a/openlp/plugins/bibles/resources/bibleserver.csv +++ b/openlp/plugins/bibles/resources/bibleserver.csv @@ -19,7 +19,7 @@ IBS-fordítás (Új Károli), KAR King James Version, KJV Luther 1984, LUT Septuaginta, LXX -Neue Genfer Übersetzung, NGÜ +Neue Genfer Übersetzung, NGU New International Readers Version, NIRV New International Version, NIV Neues Leben, NL From c0eccc4b857e2bbbb38bc2fb48dbeea6fae3ed28 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Tue, 25 Jan 2011 04:42:15 +0000 Subject: [PATCH 12/17] Fix theme editing --- openlp/core/lib/mediamanageritem.py | 10 +++------- openlp/core/ui/themeform.py | 18 +++++------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 5799a3f41..9565a9b37 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -98,13 +98,9 @@ class MediaManagerItem(QtGui.QWidget): visible_title = self.plugin.getString(StringContent.VisibleName) self.title = unicode(visible_title[u'title']) self.settingsSection = self.plugin.name.lower() - if isinstance(icon, QtGui.QIcon): - self.icon = icon - elif isinstance(icon, basestring): - self.icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - else: - self.icon = None + self.icon = None + if icon: + self.icon = build_icon(icon) self.toolbar = None self.remoteTriggered = None self.serviceItemIconName = None diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 60c1b97bc..43f1034f4 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -55,7 +55,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.thememanager = parent self.setupUi(self) self.registerFields() - self.accepted = False self.updateThemeAllowed = True QtCore.QObject.connect(self.backgroundComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), @@ -120,14 +119,12 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.QObject.connect(self.mainFontComboBox, QtCore.SIGNAL(u'activated(int)'), self.calculateLines) - QtCore.QObject.connect(self, QtCore.SIGNAL(u'accepted()'), self.accept) def setDefaults(self): """ Set up display at start of theme edit. """ self.restart() - self.accepted = False self.setBackgroundPageValues() self.setMainAreaPageValues() self.setFooterAreaPageValues() @@ -448,9 +445,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Background gradient Combo box has changed. """ - self.theme.background_direction = \ - BackgroundGradientType.to_string(index) - self.setBackgroundPageValues() + if self.updateThemeAllowed: + self.theme.background_direction = \ + BackgroundGradientType.to_string(index) + self.setBackgroundPageValues() def onColorButtonClicked(self): """ @@ -562,13 +560,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Lets save the them as Finish has been pressed """ - # Some reason getting double submission. - # Hack to stop it for now. - if self.accepted: - return # Save the theme name - self.theme.theme_name = \ - unicode(self.field(u'name').toString()) + self.theme.theme_name = unicode(self.field(u'name').toString()) if not self.theme.theme_name: criticalErrorMessageBox( translate('OpenLP.ThemeForm', 'Theme Name Missing'), @@ -592,7 +585,6 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): if not self.edit_mode and \ not self.thememanager.checkIfThemeExists(self.theme.theme_name): return - self.accepted = True self.thememanager.saveTheme(self.theme, saveFrom, saveTo) return QtGui.QDialog.accept(self) From f484286f8a0eff4a63793ed474ae5c1304579bbb Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 02:43:16 +0000 Subject: [PATCH 13/17] Few cleanups --- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/songs/lib/easislidesimport.py | 10 +++++----- openlp/plugins/songs/lib/importer.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 63c6954fb..85204ac7a 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -92,7 +92,7 @@ class BibleFormat(object): return None @staticmethod - def list(): + def get_formats_list(): """ Return a list of the supported Bible formats. """ diff --git a/openlp/plugins/songs/lib/easislidesimport.py b/openlp/plugins/songs/lib/easislidesimport.py index 64523fd3a..84e7a3841 100644 --- a/openlp/plugins/songs/lib/easislidesimport.py +++ b/openlp/plugins/songs/lib/easislidesimport.py @@ -314,11 +314,11 @@ class EasiSlidesImport(SongImport): pass def _listHas(self, lst, subitems): - for i in subitems: - if type(lst) == type({}) and lst.has_key(i): - lst = lst[i] - elif type(lst) == type([]) and i in lst: - lst = lst[i] + for subitem in subitems: + if isinstance(lst, dict) and lst.has_key(subitem): + lst = lst[subitem] + elif isinstance(lst, list) and subitem in lst: + lst = lst[subitem] else: return False return True diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 91d3d7e6f..6f566ff4f 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -105,7 +105,7 @@ class SongFormat(object): return None @staticmethod - def list(): + def get_formats_list(): """ Return a list of the supported song formats. """ From df9bd3b3a2cf37cdd7cca32f4111ec820e23fdba Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 16:05:55 +0000 Subject: [PATCH 14/17] Cleanup modified service messages --- openlp/core/ui/mainwindow.py | 15 +++------------ openlp/core/ui/servicemanager.py | 28 ++++++++++------------------ 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index db9d4f9d5..d8bedade3 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -563,10 +563,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.ServiceManagerContents.onLoadServiceClicked) QtCore.QObject.connect(self.FileSaveItem, QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.onSaveServiceClicked) + self.ServiceManagerContents.saveFile) QtCore.QObject.connect(self.FileSaveAsItem, QtCore.SIGNAL(u'triggered()'), - self.ServiceManagerContents.onSaveServiceAsClicked) + self.ServiceManagerContents.saveFileAs) # i18n set signals for languages QtCore.QObject.connect(self.AutoLanguageItem, QtCore.SIGNAL(u'toggled(bool)'), self.setAutoLanguage) @@ -807,15 +807,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): Hook to close the main window and display windows on exit """ if self.ServiceManagerContents.isModified(): - ret = QtGui.QMessageBox.question(self, - translate('OpenLP.MainWindow', 'Save Changes to Service?'), - translate('OpenLP.MainWindow', 'Your service has changed. ' - 'Do you want to save those changes?'), - QtGui.QMessageBox.StandardButtons( - QtGui.QMessageBox.Cancel | - QtGui.QMessageBox.Discard | - QtGui.QMessageBox.Save), - QtGui.QMessageBox.Save) + ret = self.ServiceManagerContents.saveModifiedService() if ret == QtGui.QMessageBox.Save: if self.ServiceManagerContents.saveFile(): self.cleanUp() @@ -847,7 +839,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.cleanUp() event.accept() - def cleanUp(self): """ Runs all the cleanup code before OpenLP shuts down diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d1a3e6762..7f1d6493e 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -108,7 +108,7 @@ class ServiceManager(QtGui.QWidget): translate('OpenLP.ServiceManager', 'Save Service'), u':/general/general_save.png', translate('OpenLP.ServiceManager', 'Save this service'), - self.onSaveServiceClicked) + self.saveFile) self.toolbar.addSeparator() self.themeLabel = QtGui.QLabel(translate('OpenLP.ServiceManager', 'Theme:'), self) @@ -361,12 +361,7 @@ class ServiceManager(QtGui.QWidget): Create a new service. """ if self.isModified(): - result = QtGui.QMessageBox.question(self.mainwindow, - translate('OpenLP.ServiceManager', 'Save Changes'), - translate('OpenLP.ServiceManager', 'The current service has ' - 'been modified, would you like to save it?'), - QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | - QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save) + result = self.saveModifiedService() if result == QtGui.QMessageBox.Cancel: return False elif result == QtGui.QMessageBox.Save: @@ -376,12 +371,7 @@ class ServiceManager(QtGui.QWidget): def onLoadServiceClicked(self): if self.isModified(): - result = QtGui.QMessageBox.question(self.mainwindow, - translate('OpenLP.ServiceManager', 'Save Changes'), - translate('OpenLP.ServiceManager', 'The current service has ' - 'been modified, would you like to save it?'), - QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | - QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save) + result = self.saveModifiedService() if result == QtGui.QMessageBox.Cancel: return False elif result == QtGui.QMessageBox.Save: @@ -397,11 +387,13 @@ class ServiceManager(QtGui.QWidget): split_filename(fileName)[0]) self.loadFile(fileName) - def onSaveServiceClicked(self): - self.saveFile() - - def onSaveServiceAsClicked(self): - self.saveFileAs() + def saveModifiedService(self): + return QtGui.QMessageBox.question(self.mainwindow, + translate('OpenLP.ServiceManager', 'Modified Service'), + translate('OpenLP.ServiceManager', 'The current service has ' + 'been modified. Would you like to save this service?'), + QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | + QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save) def onRecentServiceClicked(self): sender = self.sender() From 51812f21de24aae47772c927a0b8c9643fd4fb57 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 17:13:26 +0000 Subject: [PATCH 15/17] Stop redefining builtins and docstrings --- openlp/core/lib/spelltextedit.py | 42 ++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 82391a0b3..44180a25c 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -47,13 +47,16 @@ class SpellTextEdit(QtGui.QPlainTextEdit): # Default dictionary based on the current locale. if ENCHANT_AVAILABLE: try: - self.dict = enchant.Dict() + self.dictionary = enchant.Dict() except DictNotFoundError: - self.dict = enchant.Dict(u'en_US') + self.dictionary = enchant.Dict(u'en_US') self.highlighter = Highlighter(self.document()) - self.highlighter.setDict(self.dict) + self.highlighter.spellingDictionary = self.dictionary def mousePressEvent(self, event): + """ + Handle mouse clicks within the text edit region. + """ if event.button() == QtCore.Qt.RightButton: # Rewrite the mouse event to a left button event so the cursor is # moved to the location of the pointer. @@ -63,6 +66,9 @@ class SpellTextEdit(QtGui.QPlainTextEdit): QtGui.QPlainTextEdit.mousePressEvent(self, event) def contextMenuEvent(self, event): + """ + Provide the context menu for the text edit region. + """ popupMenu = self.createStandardContextMenu() # Select the word under the cursor. cursor = self.textCursor() @@ -74,10 +80,10 @@ class SpellTextEdit(QtGui.QPlainTextEdit): # suggestions if it is. if ENCHANT_AVAILABLE and self.textCursor().hasSelection(): text = unicode(self.textCursor().selectedText()) - if not self.dict.check(text): + if not self.dictionary.check(text): spell_menu = QtGui.QMenu(translate('OpenLP.SpellTextEdit', 'Spelling Suggestions')) - for word in self.dict.suggest(text): + for word in self.dictionary.suggest(text): action = SpellAction(word, spell_menu) action.correct.connect(self.correctWord) spell_menu.addAction(action) @@ -126,28 +132,32 @@ class SpellTextEdit(QtGui.QPlainTextEdit): cursor.insertText(html[u'start tag']) cursor.insertText(html[u'end tag']) -class Highlighter(QtGui.QSyntaxHighlighter): +class Highlighter(QtGui.QSyntaxHighlighter): + """ + Provides a text highlighter for pointing out spelling errors in text. + """ WORDS = u'(?iu)[\w\']+' def __init__(self, *args): QtGui.QSyntaxHighlighter.__init__(self, *args) - self.dict = None - - def setDict(self, dict): - self.dict = dict + self.spellingDictionary = None def highlightBlock(self, text): - if not self.dict: + """ + Highlight misspelt words in a block of text + """ + if not self.spellingDictionary: return text = unicode(text) - format = QtGui.QTextCharFormat() - format.setUnderlineColor(QtCore.Qt.red) - format.setUnderlineStyle(QtGui.QTextCharFormat.SpellCheckUnderline) + charFormat = QtGui.QTextCharFormat() + charFormat.setUnderlineColor(QtCore.Qt.red) + charFormat.setUnderlineStyle(QtGui.QTextCharFormat.SpellCheckUnderline) for word_object in re.finditer(self.WORDS, text): - if not self.dict.check(word_object.group()): + if not self.spellingDictionary.check(word_object.group()): self.setFormat(word_object.start(), - word_object.end() - word_object.start(), format) + word_object.end() - word_object.start(), charFormat) + class SpellAction(QtGui.QAction): """ From 934d26bd0adbee3cfdf6fe0c86c569e5fd3d814a Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 18:14:46 +0000 Subject: [PATCH 16/17] Cleanup superfluous functions and import halting --- openlp/plugins/custom/lib/mediaitem.py | 5 +---- openlp/plugins/images/lib/mediaitem.py | 3 --- openlp/plugins/songs/lib/mediaitem.py | 3 --- openlp/plugins/songs/lib/oooimport.py | 9 +++------ openlp/plugins/songs/lib/sofimport.py | 6 +++--- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 304773ea5..9b8115956 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -68,9 +68,6 @@ class CustomMediaItem(MediaManagerItem): QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'custom_preview'), self.onPreviewClick) - def requiredIcons(self): - MediaManagerItem.requiredIcons(self) - def initialise(self): self.loadCustomListView(self.manager.get_all_objects( CustomSlide, order_by_ref=CustomSlide.title)) @@ -182,4 +179,4 @@ class CustomMediaItem(MediaManagerItem): else: raw_footer.append(u'') service_item.raw_footer = raw_footer - return True \ No newline at end of file + return True diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index 4f976bd51..d55735188 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -220,6 +220,3 @@ class ImageMediaItem(MediaManagerItem): unicode(translate('ImagePlugin.MediaItem', 'There was a problem replacing your background, ' 'the image file "%s" no longer exists.')) % filename) - - def onPreviewClick(self): - MediaManagerItem.onPreviewClick(self) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 625f99f18..dc51f97f5 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -68,9 +68,6 @@ class SongMediaItem(MediaManagerItem): self.editItem = None self.whitespace = re.compile(r'\W+', re.UNICODE) - def requiredIcons(self): - MediaManagerItem.requiredIcons(self) - def addEndHeaderBar(self): self.addToolbarSeparator() ## Song Maintenance Button ## diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 45d1ce5b9..819a62d1e 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -66,11 +66,11 @@ class OooImport(SongImport): QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) def do_import(self): - self.abort = False + self.stop_import_flag = False self.import_wizard.progressBar.setMaximum(0) self.start_ooo() for filename in self.filenames: - if self.abort: + if self.stop_import_flag: self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return filename = unicode(filename) @@ -89,9 +89,6 @@ class OooImport(SongImport): self.import_wizard.incrementProgressBar(u'', 1) return True - def stop_import(self): - self.abort = True - def start_ooo(self): """ Start OpenOffice.org process @@ -180,7 +177,7 @@ class OooImport(SongImport): slides = doc.getDrawPages() text = u'' for slide_no in range(slides.getCount()): - if self.abort: + if self.stop_import_flag: self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return slide = slides.getByIndex(slide_no) diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 8475b0824..82b89141f 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -76,10 +76,10 @@ class SofImport(OooImport): OooImport.__init__(self, master_manager, **kwargs) def do_import(self): - self.abort = False + self.stop_import_flag = False self.start_ooo() for filename in self.filenames: - if self.abort: + if self.stop_import_flag: self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return filename = unicode(filename) @@ -101,7 +101,7 @@ class SofImport(OooImport): self.new_song() paragraphs = self.document.getText().createEnumeration() while paragraphs.hasMoreElements(): - if self.abort: + if self.stop_import_flag: self.import_wizard.incrementProgressBar(u'Import cancelled', 0) return paragraph = paragraphs.nextElement() From 0a52af1869cb20bad6eb339c1506e6f7261f93c8 Mon Sep 17 00:00:00 2001 From: Jon Tibble Date: Wed, 26 Jan 2011 18:35:11 +0000 Subject: [PATCH 17/17] Refactor OOo song imports --- openlp/plugins/songs/lib/oooimport.py | 18 ++++++++++++------ openlp/plugins/songs/lib/sofimport.py | 22 +++++----------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 819a62d1e..32315130a 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -77,18 +77,24 @@ class OooImport(SongImport): if os.path.isfile(filename): self.open_ooo_file(filename) if self.document: - if self.document.supportsService( - "com.sun.star.presentation.PresentationDocument"): - self.process_pres() - if self.document.supportsService( - "com.sun.star.text.TextDocument"): - self.process_doc() + self.process_ooo_document() self.close_ooo_file() self.close_ooo() self.import_wizard.progressBar.setMaximum(1) self.import_wizard.incrementProgressBar(u'', 1) return True + def process_ooo_document(self): + """ + Handle the import process for OpenOffice files. This method facilitates + allowing subclasses to handle specific types of OpenOffice files. + """ + if self.document.supportsService( + "com.sun.star.presentation.PresentationDocument"): + self.process_pres() + if self.document.supportsService("com.sun.star.text.TextDocument"): + self.process_doc() + def start_ooo(self): """ Start OpenOffice.org process diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 82b89141f..96a514f85 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -75,23 +75,11 @@ class SofImport(OooImport): """ OooImport.__init__(self, master_manager, **kwargs) - def do_import(self): - self.stop_import_flag = False - self.start_ooo() - for filename in self.filenames: - if self.stop_import_flag: - self.import_wizard.incrementProgressBar(u'Import cancelled', 0) - return - filename = unicode(filename) - if os.path.isfile(filename): - self.open_ooo_file(filename) - if self.document: - self.process_sof_file() - self.close_ooo_file() - self.close_ooo() - self.import_wizard.progressBar.setMaximum(1) - self.import_wizard.incrementProgressBar(u'', 1) - return True + def process_ooo_document(self): + """ + Handle the import process for SoF files. + """ + self.process_sof_file() def process_sof_file(self): """