Fix two small but nasty bugs. Screen width must be > 0 and an image theme must be a file

bzr-revno: 2149
This commit is contained in:
Tim Bentley 2013-07-11 21:46:43 +01:00
commit 8b21731f72
3 changed files with 20 additions and 4 deletions

View File

@ -92,14 +92,14 @@ class GeneralTab(SettingsTab):
self.monitorLayout.addWidget(self.customWidthLabel, 3, 3)
self.customWidthValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
self.customWidthValueEdit.setObjectName(u'customWidthValueEdit')
self.customWidthValueEdit.setMaximum(9999)
self.customWidthValueEdit.setRange(1, 9999)
self.monitorLayout.addWidget(self.customWidthValueEdit, 4, 3)
self.customHeightLabel = QtGui.QLabel(self.monitorGroupBox)
self.customHeightLabel.setObjectName(u'customHeightLabel')
self.monitorLayout.addWidget(self.customHeightLabel, 3, 4)
self.customHeightValueEdit = QtGui.QSpinBox(self.monitorGroupBox)
self.customHeightValueEdit.setObjectName(u'customHeightValueEdit')
self.customHeightValueEdit.setMaximum(9999)
self.customHeightValueEdit.setRange(1, 9999)
self.monitorLayout.addWidget(self.customHeightValueEdit, 4, 4)
self.displayOnMonitorCheck = QtGui.QCheckBox(self.monitorGroupBox)
self.displayOnMonitorCheck.setObjectName(u'monitorComboBox')

View File

@ -36,7 +36,7 @@ from openlp.core.lib import Receiver, translate
from openlp.core.lib.theme import BackgroundType, BackgroundGradientType
from openlp.core.lib.ui import UiStrings, 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__)
@ -233,7 +233,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 \
self.imageFileEdit.text().isEmpty():
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 '

View File

@ -364,6 +364,22 @@ def get_images_filter():
visible_formats, actual_formats)
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 = [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):
"""