diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index 68d8cc216..007932f6e 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -38,7 +38,7 @@ from openlp.core.lib import UiStrings, Registry, translate from openlp.core.lib.theme import BackgroundType, BackgroundGradientType from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui import ThemeLayoutForm -from openlp.core.utils import get_images_filter +from openlp.core.utils import get_images_filter, is_not_image_file from themewizard import Ui_ThemeWizard log = logging.getLogger(__name__) @@ -178,7 +178,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 not self.imageFileEdit.text(): + self.theme.background_type == background_image and is_not_image_file(self.imageFileEdit.text()): QtGui.QMessageBox.critical(self, translate('OpenLP.ThemeWizard', 'Background Image Empty'), translate('OpenLP.ThemeWizard', 'You have not selected a ' 'background image. Please select one before continuing.')) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index bfd0b0740..fb06332f3 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -246,6 +246,23 @@ def get_images_filter(): return IMAGES_FILTER +def is_not_image_file(file_name): + """ + Validate that the file is not an image file. + + ``file_name`` + File name to be checked. + """ + if file_name.isEmpty(): + return True + else: + formats = [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 split_filename(path): """ Return a list of the parts in a given path.