More fixes to editor

This commit is contained in:
Tim Bentley 2010-11-08 06:11:04 +00:00
parent 0102500e47
commit 4360447a3b
3 changed files with 52 additions and 34 deletions

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'themedialog.ui' # Form implementation generated from reading ui file 'themedialog.ui'
# #
# Created: Thu Nov 4 18:12:37 2010 # Created: Mon Nov 8 06:09:19 2010
# by: PyQt4 UI code generator 4.7.4 # by: PyQt4 UI code generator 4.7.4
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -495,8 +495,8 @@ class Ui_ThemeDialog(object):
self.alignmentPage.setSubTitle(QtGui.QApplication.translate("ThemeDialog", "Allows additional display formatting information to be defined", None, QtGui.QApplication.UnicodeUTF8)) self.alignmentPage.setSubTitle(QtGui.QApplication.translate("ThemeDialog", "Allows additional display formatting information to be defined", None, QtGui.QApplication.UnicodeUTF8))
self.horizontalLabel.setText(QtGui.QApplication.translate("ThemeDialog", "Horizontal Align:", None, QtGui.QApplication.UnicodeUTF8)) self.horizontalLabel.setText(QtGui.QApplication.translate("ThemeDialog", "Horizontal Align:", None, QtGui.QApplication.UnicodeUTF8))
self.horizontalComboBox.setItemText(0, QtGui.QApplication.translate("ThemeDialog", "Left", None, QtGui.QApplication.UnicodeUTF8)) self.horizontalComboBox.setItemText(0, QtGui.QApplication.translate("ThemeDialog", "Left", None, QtGui.QApplication.UnicodeUTF8))
self.horizontalComboBox.setItemText(1, QtGui.QApplication.translate("ThemeDialog", "Center", None, QtGui.QApplication.UnicodeUTF8)) self.horizontalComboBox.setItemText(1, QtGui.QApplication.translate("ThemeDialog", "Right", None, QtGui.QApplication.UnicodeUTF8))
self.horizontalComboBox.setItemText(2, QtGui.QApplication.translate("ThemeDialog", "Right", None, QtGui.QApplication.UnicodeUTF8)) self.horizontalComboBox.setItemText(2, QtGui.QApplication.translate("ThemeDialog", "Center", None, QtGui.QApplication.UnicodeUTF8))
self.verticalLabel.setText(QtGui.QApplication.translate("ThemeDialog", "Vertcal Align:", None, QtGui.QApplication.UnicodeUTF8)) self.verticalLabel.setText(QtGui.QApplication.translate("ThemeDialog", "Vertcal Align:", None, QtGui.QApplication.UnicodeUTF8))
self.verticalComboBox.setItemText(0, QtGui.QApplication.translate("ThemeDialog", "Top", None, QtGui.QApplication.UnicodeUTF8)) self.verticalComboBox.setItemText(0, QtGui.QApplication.translate("ThemeDialog", "Top", None, QtGui.QApplication.UnicodeUTF8))
self.verticalComboBox.setItemText(1, QtGui.QApplication.translate("ThemeDialog", "Middle", None, QtGui.QApplication.UnicodeUTF8)) self.verticalComboBox.setItemText(1, QtGui.QApplication.translate("ThemeDialog", "Middle", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -48,20 +48,12 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
``parent`` ``parent``
The QWidget-derived parent of the wizard. The QWidget-derived parent of the wizard.
``manager``
The Bible manager.
``bibleplugin``
The Bible plugin.
""" """
# Do not translate as internal
QtGui.QWizard.__init__(self, parent) QtGui.QWizard.__init__(self, parent)
self.thememanager = parent self.thememanager = parent
self.setupUi(self) self.setupUi(self)
self.registerFields() self.registerFields()
self.finishButton = self.button(QtGui.QWizard.FinishButton) self.accepted = False
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
QtCore.QObject.connect(self.backgroundTypeComboBox, QtCore.QObject.connect(self.backgroundTypeComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'), QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onBackgroundComboBox) self.onBackgroundComboBox)
@ -101,12 +93,25 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
QtCore.QObject.connect(self.footerDefaultPositionCheckBox, QtCore.QObject.connect(self.footerDefaultPositionCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'), QtCore.SIGNAL(u'stateChanged(int)'),
self.onFooterDefaultPositionCheckBox) self.onFooterDefaultPositionCheckBox)
QtCore.QObject.connect(self,
QtCore.SIGNAL(u'currentIdChanged(int)'),
self.pageChanged)
def pageChanged(self, pageId):
"""
Detects Page changes and updates.
"""
if pageId == 6:
self.updateTheme()
frame = self.thememanager.generateImage(self.theme)
self.previewBoxLabel.setPixmap(QtGui.QPixmap.fromImage(frame))
def setDefaults(self): def setDefaults(self):
""" """
Set up display at start of theme edit. Set up display at start of theme edit.
""" """
self.restart() self.restart()
self.accepted = False
self.setBackgroundTabValues() self.setBackgroundTabValues()
self.setMainAreaTabValues() self.setMainAreaTabValues()
self.setFooterAreaTabValues() self.setFooterAreaTabValues()
@ -234,27 +239,20 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
return QtGui.QWizard.exec_(self) return QtGui.QWizard.exec_(self)
def initializePage(self, id): def initializePage(self, id):
if id == 0: """
Set up the pages for Initial run through dialog
"""
log.debug(u'initializePage %s' % id)
if id == 1:
self.setBackgroundTabValues() self.setBackgroundTabValues()
elif id == 1:
self.setMainAreaTabValues()
elif id == 2: elif id == 2:
self.setFooterAreaTabValues() self.setMainAreaTabValues()
elif id == 3: elif id == 3:
self.setAlignmentTabValues() self.setFooterAreaTabValues()
elif id == 4: elif id == 4:
self.setPositionTabValues() self.setAlignmentTabValues()
elif id == 5: elif id == 5:
frame = self.thememanager.generateImage(self.theme) self.setPositionTabValues()
self.previewBoxLabel.setPixmap(QtGui.QPixmap.fromImage(frame))
# def validateCurrentPage(self):
# """
# Handle Tab specific code when moving between Tabs.
# """
# # Preview Screen
# self.updateTheme()
# return True
def setBackgroundTabValues(self): def setBackgroundTabValues(self):
""" """
@ -395,6 +393,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
QtCore.QVariant(self.theme.font_footer_width)) QtCore.QVariant(self.theme.font_footer_width))
def setAlignmentTabValues(self): def setAlignmentTabValues(self):
"""
Define the Tab Alignments Page
"""
self.setField(u'horizontal', \ self.setField(u'horizontal', \
QtCore.QVariant(self.theme.display_horizontal_align)) QtCore.QVariant(self.theme.display_horizontal_align))
self.setField(u'vertical', \ self.setField(u'vertical', \
@ -425,6 +426,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
self.setBackgroundTabValues() self.setBackgroundTabValues()
def onColor1PushButtonClicked(self): def onColor1PushButtonClicked(self):
"""
Background / Gradient 1 Color button pushed.
"""
if self.theme.background_type == \ if self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Solid): BackgroundType.to_string(BackgroundType.Solid):
self.theme.background_color = \ self.theme.background_color = \
@ -435,11 +439,17 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
self.setBackgroundTabValues() self.setBackgroundTabValues()
def onColor2PushButtonClicked(self): def onColor2PushButtonClicked(self):
"""
Gradient 2 Color button pushed.
"""
self.theme.background_end_color = \ self.theme.background_end_color = \
self._colorButton(self.theme.background_end_color) self._colorButton(self.theme.background_end_color)
self.setBackgroundTabValues() self.setBackgroundTabValues()
def onImageBrowseButtonClicked(self): def onImageBrowseButtonClicked(self):
"""
Background Image button pushed.
"""
images_filter = get_images_filter() images_filter = get_images_filter()
images_filter = '%s;;%s (*.*) (*)' % (images_filter, images_filter = '%s;;%s (*.*) (*)' % (images_filter,
translate('OpenLP.ThemeForm', 'All Files')) translate('OpenLP.ThemeForm', 'All Files'))
@ -451,6 +461,9 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
self.setBackgroundTabValues() self.setBackgroundTabValues()
def onMainFontComboBox(self): def onMainFontComboBox(self):
"""
Main Font Combo box changed
"""
self.theme.font_main_name = self.mainFontComboBox.currentFont().family() self.theme.font_main_name = self.mainFontComboBox.currentFont().family()
def onMainColourPushButtonClicked(self): def onMainColourPushButtonClicked(self):
@ -478,6 +491,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
Update the theme object from the UI for fields not already updated Update the theme object from the UI for fields not already updated
when the are changed. when the are changed.
""" """
log.debug(u'updateTheme')
# main page # main page
self.theme.font_main_name = \ self.theme.font_main_name = \
unicode(self.mainFontComboBox.currentFont().family()) unicode(self.mainFontComboBox.currentFont().family())
@ -517,17 +531,21 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
self.verticalComboBox.currentIndex() self.verticalComboBox.currentIndex()
self.theme.display_slide_transition = \ self.theme.display_slide_transition = \
self.field(u'slideTransition').toBool() self.field(u'slideTransition').toBool()
# preview page
self.theme.theme_name = \
unicode(self.field(u'name').toString())
def accept(self): def accept(self):
""" """
Lets save the them as Finish has been pressed Lets save the them as Finish has been pressed
""" """
# Some reason getting double submission.
# Hack to stop it for now.
if self.accepted:
return
self.accepted = True
# Save the theme name
self.theme.theme_name = \
unicode(self.field(u'name').toString())
if not unicode(self.field(u'name').toString()): if not unicode(self.field(u'name').toString()):
return return
self.updateTheme()
save_from = None save_from = None
save_to = None save_to = None
if self.theme.background_type == \ if self.theme.background_type == \

View File

@ -591,12 +591,12 @@ p, li { white-space: pre-wrap; }
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Center</string> <string>Right</string>
</property> </property>
</item> </item>
<item> <item>
<property name="text"> <property name="text">
<string>Right</string> <string>Center</string>
</property> </property>
</item> </item>
</widget> </widget>