From a7130ce666e82c2df9bbf036c9750cfc4faad08d Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Thu, 25 Jul 2013 19:58:09 +0100 Subject: [PATCH] fixed 1204629 in 2.0 also made it more robust by checking that the user selected a valid image file using the open dialog --- openlp/core/ui/themeform.py | 12 +++++++++++- openlp/core/utils/__init__.py | 15 +++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index b4440e038..3533a9aac 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -78,6 +78,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): QtCore.SIGNAL(u'clicked()'), self.onGradientEndButtonClicked) QtCore.QObject.connect(self.imageBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onImageBrowseButtonClicked) + + QtCore.QObject.connect(self.imageFileEdit, + QtCore.SIGNAL(u'editingFinished()'), self.onImageFileEditEditingFinished) + QtCore.QObject.connect(self.mainColorButton, QtCore.SIGNAL(u'clicked()'), self.onMainColorButtonClicked) QtCore.QObject.connect(self.outlineColorButton, @@ -233,7 +237,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): background_image = BackgroundType.to_string(BackgroundType.Image) if self.page(self.currentId()) == self.backgroundPage and \ self.theme.background_type == background_image and \ - is_not_image_file(self.imageFileEdit.text()): + is_not_image_file(self.theme.background_filename): QtGui.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), translate('OpenLP.ThemeWizard', 'You have not selected a ' @@ -545,6 +549,12 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): self.theme.background_filename = unicode(filename) self.setBackgroundPageValues() + def onImageFileEditEditingFinished(self): + """ + Background image path edited + """ + self.theme.background_filename = unicode(self.imageFileEdit.text()) + def onMainColorButtonClicked(self): self.theme.font_main_color = \ self._colorButton(self.theme.font_main_color) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index faef00a82..a33cd2604 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -371,15 +371,14 @@ def is_not_image_file(file_name): ``file_name`` File name to be checked. """ - if file_name.isEmpty(): - return True - else: - formats = [unicode(fmt).lower() - for fmt in QtGui.QImageReader.supportedImageFormats()] - file_part, file_extension = os.path.splitext(unicode(file_name)) - if file_extension[1:].lower() in formats and os.path.exists(file_name): - return False + if not file_name: return True + formats = [unicode(fmt).lower() + for fmt in QtGui.QImageReader.supportedImageFormats()] + file_part, file_extension = os.path.splitext(unicode(file_name)) + if file_extension[1:].lower() in formats and os.path.exists(file_name): + return False + return True def join_url(base, *args): """