Fixed bug #1051971 where we were not validating that a background image was being selected.

Fixes: https://launchpad.net/bugs/1051971
This commit is contained in:
Raoul Snyman 2012-09-17 23:30:10 +02:00
parent 23a28d2152
commit 2591d24a41

View File

@ -157,7 +157,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
u'outlineColorButton', self.outlineColorButton) u'outlineColorButton', self.outlineColorButton)
self.mainAreaPage.registerField( self.mainAreaPage.registerField(
u'outlineSizeSpinBox', self.outlineSizeSpinBox) u'outlineSizeSpinBox', self.outlineSizeSpinBox)
self.mainAreaPage.registerField(u'shadowCheckBox', self.shadowCheckBox) self.mainAreaPage.registerField(
u'shadowCheckBox', self.shadowCheckBox)
self.mainAreaPage.registerField( self.mainAreaPage.registerField(
u'mainBoldCheckBox', self.mainBoldCheckBox) u'mainBoldCheckBox', self.mainBoldCheckBox)
self.mainAreaPage.registerField( self.mainAreaPage.registerField(
@ -168,8 +169,10 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
u'shadowSizeSpinBox', self.shadowSizeSpinBox) u'shadowSizeSpinBox', self.shadowSizeSpinBox)
self.mainAreaPage.registerField( self.mainAreaPage.registerField(
u'footerSizeSpinBox', self.footerSizeSpinBox) u'footerSizeSpinBox', self.footerSizeSpinBox)
self.areaPositionPage.registerField(u'mainPositionX', self.mainXSpinBox) self.areaPositionPage.registerField(
self.areaPositionPage.registerField(u'mainPositionY', self.mainYSpinBox) u'mainPositionX', self.mainXSpinBox)
self.areaPositionPage.registerField(
u'mainPositionY', self.mainYSpinBox)
self.areaPositionPage.registerField( self.areaPositionPage.registerField(
u'mainPositionWidth', self.mainWidthSpinBox) u'mainPositionWidth', self.mainWidthSpinBox)
self.areaPositionPage.registerField( self.areaPositionPage.registerField(
@ -202,7 +205,8 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
""" """
Updates the lines on a page on the wizard Updates the lines on a page on the wizard
""" """
self.mainLineCountLabel.setText(unicode(translate('OpenLP.ThemeForm', self.mainLineCountLabel.setText(unicode(translate(
'OpenLP.ThemeWizard',
'(approximately %d lines per slide)')) % int(lines)) '(approximately %d lines per slide)')) % int(lines))
def resizeEvent(self, event=None): def resizeEvent(self, event=None):
@ -224,6 +228,19 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.previewBoxLabel.setFixedSize(pixmapWidth + 2 * frameWidth, self.previewBoxLabel.setFixedSize(pixmapWidth + 2 * frameWidth,
pixmapHeight + 2 * frameWidth) pixmapHeight + 2 * frameWidth)
def validateCurrentPage(self):
if self.page(self.currentId()) == self.backgroundPage and \
self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Image) and \
unicode(self.imageFileEdit.text()) == u'':
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.'))
return False
else:
return True
def onCurrentIdChanged(self, pageId): def onCurrentIdChanged(self, pageId):
""" """
Detects Page changes and updates as appropriate. Detects Page changes and updates as appropriate.
@ -521,7 +538,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
images_filter = u'%s;;%s (*.*) (*)' % ( images_filter = u'%s;;%s (*.*) (*)' % (
images_filter, UiStrings().AllFiles) images_filter, UiStrings().AllFiles)
filename = QtGui.QFileDialog.getOpenFileName(self, filename = QtGui.QFileDialog.getOpenFileName(self,
translate('OpenLP.ThemeForm', 'Select Image'), u'', translate('OpenLP.ThemeWizard', 'Select Image'), u'',
images_filter) images_filter)
if filename: if filename:
self.theme.background_filename = unicode(filename) self.theme.background_filename = unicode(filename)
@ -603,14 +620,14 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
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: if not self.theme.theme_name:
critical_error_message_box( critical_error_message_box(
translate('OpenLP.ThemeForm', 'Theme Name Missing'), translate('OpenLP.ThemeWizard', 'Theme Name Missing'),
translate('OpenLP.ThemeForm', translate('OpenLP.ThemeWizard',
'There is no name for this theme. Please enter one.')) 'There is no name for this theme. Please enter one.'))
return return
if self.theme.theme_name == u'-1' or self.theme.theme_name == u'None': if self.theme.theme_name == u'-1' or self.theme.theme_name == u'None':
critical_error_message_box( critical_error_message_box(
translate('OpenLP.ThemeForm', 'Theme Name Invalid'), translate('OpenLP.ThemeWizard', 'Theme Name Invalid'),
translate('OpenLP.ThemeForm', translate('OpenLP.ThemeWizard',
'Invalid theme name. Please enter one.')) 'Invalid theme name. Please enter one.'))
return return
saveFrom = None saveFrom = None