Theme wizard start

This commit is contained in:
Tim Bentley 2010-10-03 08:42:02 +01:00
parent 25a4ff7880
commit fc092ed919
6 changed files with 1437 additions and 661 deletions

View File

@ -427,3 +427,52 @@ class ThemeXML(object):
s1 = re.sub(u'(.)([A-Z][a-z]+)', r'\1_\2', name)
return re.sub(u'([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
def build_xml_from_attrs(self, ):
"""
Build the XML from the varables in the object
"""
if self.background_type == u'solid':
self.add_background_solid(
unicode(self.background_color))
elif self.background_type == u'gradient':
self.add_background_gradient(
unicode(self.background_start_color),
unicode(self.background_end_color),
self.background_direction)
else:
filename = \
os.path.split(unicode(self.background_filename))[1]
self.add_background_image(filename)
self.add_font(unicode(self.font_main_name),
unicode(self.font_main_color),
unicode(self.font_main_proportion),
unicode(self.font_main_override), u'main',
unicode(self.font_main_weight),
unicode(self.font_main_italics),
unicode(self.font_main_line_adjustment),
unicode(self.font_main_x),
unicode(self.font_main_y),
unicode(self.font_main_width),
unicode(self.font_main_height))
self.add_font(unicode(self.font_footer_name),
unicode(self.font_footer_color),
unicode(self.font_footer_proportion),
unicode(self.font_footer_override), u'footer',
unicode(self.font_footer_weight),
unicode(self.font_footer_italics),
0, # line adjustment
unicode(self.font_footer_x),
unicode(self.font_footer_y),
unicode(self.font_footer_width),
unicode(self.font_footer_height))
self.add_display(unicode(self.display_shadow),
unicode(self.display_shadow_color),
unicode(self.display_outline),
unicode(self.display_outline_color),
unicode(self.display_horizontal_align),
unicode(self.display_vertical_align),
unicode(self.display_wrap_style),
unicode(self.display_slide_transition),
unicode(self.display_shadow_size),
unicode(self.display_outline_size))

View File

@ -37,6 +37,7 @@ class HideMode(object):
Theme = 2
Screen = 3
from themewizardform import ThemeWizardForm
from filerenameform import FileRenameForm
from maindisplay import MainDisplay
from slidecontroller import HideMode

View File

@ -32,7 +32,7 @@ import logging
from xml.etree.ElementTree import ElementTree, XML
from PyQt4 import QtCore, QtGui
from openlp.core.ui import AmendThemeForm, FileRenameForm
from openlp.core.ui import AmendThemeForm, FileRenameForm, ThemeWizardForm
from openlp.core.theme import Theme
from openlp.core.lib import OpenLPToolbar, context_menu_action, \
ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \
@ -54,6 +54,7 @@ class ThemeManager(QtGui.QWidget):
self.layout.setSpacing(0)
self.layout.setMargin(0)
self.amendThemeForm = AmendThemeForm(self)
self.themeWizardForm = ThemeWizardForm(self)
self.fileRenameForm = FileRenameForm(self)
self.toolbar = OpenLPToolbar(self)
self.toolbar.addToolbarButton(
@ -215,9 +216,10 @@ class ThemeManager(QtGui.QWidget):
editing form for the user to make their customisations.
"""
theme = self.createThemeFromXml(self.baseTheme(), self.path)
self.amendThemeForm.loadTheme(theme)
#self.amendThemeForm.loadTheme(theme)
self.saveThemeName = u''
self.amendThemeForm.exec_()
self.themeWizardForm.theme = theme
self.themeWizardForm.exec_()
def onRenameTheme(self):
"""
@ -243,66 +245,25 @@ class ThemeManager(QtGui.QWidget):
self.saveThemeName = u''
if self.fileRenameForm.exec_():
newThemeName = unicode(self.fileRenameForm.FileNameEdit.text())
oldThemeData = self.getThemeData(oldThemeName)
self.cloneThemeData(oldThemeData, newThemeName)
themeData = self.getThemeData(oldThemeName)
self.cloneThemeData(themeData, newThemeName)
self.loadThemes()
def cloneThemeData(self, oldThemeData, newThemeName):
def cloneThemeData(self, themeData, newThemeName):
"""
Takes a theme and makes a new copy of it as well as saving it.
"""
log.debug(u'cloneThemeData')
new_theme = ThemeXML()
new_theme.new_document(newThemeName)
save_from = None
themeData.new_document(newThemeName)
themeData.build_xml_from_attrs()
save_to = None
if oldThemeData.background_type == u'solid':
new_theme.add_background_solid(
unicode(oldThemeData.background_color))
elif oldThemeData.background_type == u'gradient':
new_theme.add_background_gradient(
unicode(oldThemeData.background_start_color),
unicode(oldThemeData.background_end_color),
oldThemeData.background_direction)
else:
filename = \
os.path.split(unicode(oldThemeData.background_filename))[1]
new_theme.add_background_image(filename)
save_to = os.path.join(self.path, theme_name, filename)
save_from = oldThemeData.background_filename
new_theme.add_font(unicode(oldThemeData.font_main_name),
unicode(oldThemeData.font_main_color),
unicode(oldThemeData.font_main_proportion),
unicode(oldThemeData.font_main_override), u'main',
unicode(oldThemeData.font_main_weight),
unicode(oldThemeData.font_main_italics),
unicode(oldThemeData.font_main_line_adjustment),
unicode(oldThemeData.font_main_x),
unicode(oldThemeData.font_main_y),
unicode(oldThemeData.font_main_width),
unicode(oldThemeData.font_main_height))
new_theme.add_font(unicode(oldThemeData.font_footer_name),
unicode(oldThemeData.font_footer_color),
unicode(oldThemeData.font_footer_proportion),
unicode(oldThemeData.font_footer_override), u'footer',
unicode(oldThemeData.font_footer_weight),
unicode(oldThemeData.font_footer_italics),
0, # line adjustment
unicode(oldThemeData.font_footer_x),
unicode(oldThemeData.font_footer_y),
unicode(oldThemeData.font_footer_width),
unicode(oldThemeData.font_footer_height))
new_theme.add_display(unicode(oldThemeData.display_shadow),
unicode(oldThemeData.display_shadow_color),
unicode(oldThemeData.display_outline),
unicode(oldThemeData.display_outline_color),
unicode(oldThemeData.display_horizontal_align),
unicode(oldThemeData.display_vertical_align),
unicode(oldThemeData.display_wrap_style),
unicode(oldThemeData.display_slide_transition),
unicode(oldThemeData.display_shadow_size),
unicode(oldThemeData.display_outline_size))
theme = new_theme.extract_xml()
pretty_theme = new_theme.extract_formatted_xml()
save_from = None
if themeData.background_type == u'image':
save_to = os.path.join(self.path, newThemeName,
os.path.split(unicode(themeData.background_filename))[1])
save_from = themeData.background_filename
theme = themeData.extract_xml()
pretty_theme =themeData.extract_formatted_xml()
self.saveTheme(newThemeName, theme, pretty_theme, save_from, save_to)
def onEditTheme(self):
@ -321,10 +282,12 @@ class ThemeManager(QtGui.QWidget):
unicode(item.data(QtCore.Qt.UserRole).toString()))
if theme.background_type == u'image':
self.oldBackgroundImage = theme.background_filename
self.amendThemeForm.loadTheme(theme)
#self.amendThemeForm.loadTheme(theme)
self.saveThemeName = unicode(
item.data(QtCore.Qt.UserRole).toString())
self.amendThemeForm.exec_()
#self.amendThemeForm.exec_()
self.themeWizardForm.theme = theme
self.themeWizardForm.exec_()
def onDeleteTheme(self):
"""

View File

@ -0,0 +1,467 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'themewizard.ui'
#
# Created: Sat Oct 2 08:13:48 2010
# by: PyQt4 UI code generator 4.7.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_ThemeWizard(object):
def setupUi(self, ThemeWizard):
ThemeWizard.setObjectName("ThemeWizard")
ThemeWizard.resize(550, 386)
ThemeWizard.setModal(True)
ThemeWizard.setWizardStyle(QtGui.QWizard.ModernStyle)
ThemeWizard.setOptions(QtGui.QWizard.NoBackButtonOnStartPage)
self.welcomePage = QtGui.QWizardPage()
self.welcomePage.setTitle("")
self.welcomePage.setSubTitle("")
self.welcomePage.setObjectName("welcomePage")
self.WelcomeLayout = QtGui.QHBoxLayout(self.welcomePage)
self.WelcomeLayout.setSpacing(8)
self.WelcomeLayout.setMargin(0)
self.WelcomeLayout.setObjectName("WelcomeLayout")
self.importBibleImage = QtGui.QLabel(self.welcomePage)
self.importBibleImage.setMinimumSize(QtCore.QSize(163, 0))
self.importBibleImage.setMaximumSize(QtCore.QSize(163, 16777215))
self.importBibleImage.setLineWidth(0)
self.importBibleImage.setText("")
self.importBibleImage.setPixmap(QtGui.QPixmap(":/wizards/wizard_importbible.bmp"))
self.importBibleImage.setIndent(0)
self.importBibleImage.setObjectName("importBibleImage")
self.WelcomeLayout.addWidget(self.importBibleImage)
self.welcomePageLayout = QtGui.QVBoxLayout()
self.welcomePageLayout.setSpacing(8)
self.welcomePageLayout.setObjectName("welcomePageLayout")
self.titleLabel = QtGui.QLabel(self.welcomePage)
self.titleLabel.setObjectName("titleLabel")
self.welcomePageLayout.addWidget(self.titleLabel)
spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
self.welcomePageLayout.addItem(spacerItem)
self.informationLabel = QtGui.QLabel(self.welcomePage)
self.informationLabel.setWordWrap(True)
self.informationLabel.setMargin(10)
self.informationLabel.setObjectName("informationLabel")
self.welcomePageLayout.addWidget(self.informationLabel)
spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.welcomePageLayout.addItem(spacerItem1)
self.WelcomeLayout.addLayout(self.welcomePageLayout)
ThemeWizard.addPage(self.welcomePage)
self.backgroundPage = QtGui.QWizardPage()
self.backgroundPage.setObjectName("backgroundPage")
self.backgroundLayout = QtGui.QFormLayout(self.backgroundPage)
self.backgroundLayout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow)
self.backgroundLayout.setLabelAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.backgroundLayout.setMargin(20)
self.backgroundLayout.setSpacing(8)
self.backgroundLayout.setObjectName("backgroundLayout")
self.backgroundTypeLabel = QtGui.QLabel(self.backgroundPage)
self.backgroundTypeLabel.setObjectName("backgroundTypeLabel")
self.backgroundLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.backgroundTypeLabel)
self.backgroundTypeComboBox = QtGui.QComboBox(self.backgroundPage)
self.backgroundTypeComboBox.setObjectName("backgroundTypeComboBox")
self.backgroundTypeComboBox.addItem("")
self.backgroundTypeComboBox.addItem("")
self.backgroundTypeComboBox.addItem("")
self.backgroundLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.backgroundTypeComboBox)
self.color1Label = QtGui.QLabel(self.backgroundPage)
self.color1Label.setObjectName("color1Label")
self.backgroundLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.color1Label)
self.color1PushButton = QtGui.QPushButton(self.backgroundPage)
self.color1PushButton.setText("")
self.color1PushButton.setObjectName("color1PushButton")
self.backgroundLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.color1PushButton)
self.color2Label = QtGui.QLabel(self.backgroundPage)
self.color2Label.setObjectName("color2Label")
self.backgroundLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.color2Label)
self.color2PushButton = QtGui.QPushButton(self.backgroundPage)
self.color2PushButton.setText("")
self.color2PushButton.setObjectName("color2PushButton")
self.backgroundLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.color2PushButton)
self.imageLabel = QtGui.QLabel(self.backgroundPage)
self.imageLabel.setObjectName("imageLabel")
self.backgroundLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.imageLabel)
self.imageLayout = QtGui.QHBoxLayout()
self.imageLayout.setSpacing(8)
self.imageLayout.setObjectName("imageLayout")
self.imageLineEdit = QtGui.QLineEdit(self.backgroundPage)
self.imageLineEdit.setObjectName("imageLineEdit")
self.imageLayout.addWidget(self.imageLineEdit)
self.imageBrowseButton = QtGui.QToolButton(self.backgroundPage)
self.imageBrowseButton.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/general/general_open.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.imageBrowseButton.setIcon(icon)
self.imageBrowseButton.setObjectName("imageBrowseButton")
self.imageLayout.addWidget(self.imageBrowseButton)
self.backgroundLayout.setLayout(3, QtGui.QFormLayout.FieldRole, self.imageLayout)
self.gradientLabel = QtGui.QLabel(self.backgroundPage)
self.gradientLabel.setObjectName("gradientLabel")
self.backgroundLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.gradientLabel)
self.gradientComboBox = QtGui.QComboBox(self.backgroundPage)
self.gradientComboBox.setObjectName("gradientComboBox")
self.gradientComboBox.addItem("")
self.gradientComboBox.addItem("")
self.gradientComboBox.addItem("")
self.backgroundLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.gradientComboBox)
ThemeWizard.addPage(self.backgroundPage)
self.mainAreaPage = QtGui.QWizardPage()
self.mainAreaPage.setObjectName("mainAreaPage")
self.mainAreaLayout = QtGui.QFormLayout(self.mainAreaPage)
self.mainAreaLayout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow)
self.mainAreaLayout.setContentsMargins(50, 20, 20, 20)
self.mainAreaLayout.setSpacing(8)
self.mainAreaLayout.setObjectName("mainAreaLayout")
self.mainFontLabel = QtGui.QLabel(self.mainAreaPage)
self.mainFontLabel.setObjectName("mainFontLabel")
self.mainAreaLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.mainFontLabel)
self.mainFontComboBox = QtGui.QFontComboBox(self.mainAreaPage)
self.mainFontComboBox.setObjectName("mainFontComboBox")
self.mainAreaLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.mainFontComboBox)
self.mainColorLabel = QtGui.QLabel(self.mainAreaPage)
self.mainColorLabel.setObjectName("mainColorLabel")
self.mainAreaLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.mainColorLabel)
self.mainColorPushButton = QtGui.QPushButton(self.mainAreaPage)
self.mainColorPushButton.setText("")
self.mainColorPushButton.setObjectName("mainColorPushButton")
self.mainAreaLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.mainColorPushButton)
self.mainSizeLabel = QtGui.QLabel(self.mainAreaPage)
self.mainSizeLabel.setObjectName("mainSizeLabel")
self.mainAreaLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.mainSizeLabel)
self.mainSizeLayout = QtGui.QHBoxLayout()
self.mainSizeLayout.setSpacing(8)
self.mainSizeLayout.setMargin(0)
self.mainSizeLayout.setObjectName("mainSizeLayout")
self.mainSizeSpinBox = QtGui.QSpinBox(self.mainAreaPage)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.mainSizeSpinBox.sizePolicy().hasHeightForWidth())
self.mainSizeSpinBox.setSizePolicy(sizePolicy)
self.mainSizeSpinBox.setMinimumSize(QtCore.QSize(70, 0))
self.mainSizeSpinBox.setMaximum(999)
self.mainSizeSpinBox.setProperty("value", 16)
self.mainSizeSpinBox.setObjectName("mainSizeSpinBox")
self.mainSizeLayout.addWidget(self.mainSizeSpinBox)
self.mainLineCountLabel = QtGui.QLabel(self.mainAreaPage)
self.mainLineCountLabel.setObjectName("mainLineCountLabel")
self.mainSizeLayout.addWidget(self.mainLineCountLabel)
self.mainAreaLayout.setLayout(2, QtGui.QFormLayout.FieldRole, self.mainSizeLayout)
self.mainOutlineCheckBox = QtGui.QCheckBox(self.mainAreaPage)
self.mainOutlineCheckBox.setObjectName("mainOutlineCheckBox")
self.mainAreaLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.mainOutlineCheckBox)
self.mainOutlineColorPushButton = QtGui.QPushButton(self.mainAreaPage)
self.mainOutlineColorPushButton.setEnabled(False)
self.mainOutlineColorPushButton.setText("")
self.mainOutlineColorPushButton.setObjectName("mainOutlineColorPushButton")
self.mainAreaLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.mainOutlineColorPushButton)
self.mainShadowCheckBox = QtGui.QCheckBox(self.mainAreaPage)
self.mainShadowCheckBox.setObjectName("mainShadowCheckBox")
self.mainAreaLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.mainShadowCheckBox)
self.mainShadowColorPushButton = QtGui.QPushButton(self.mainAreaPage)
self.mainShadowColorPushButton.setEnabled(False)
self.mainShadowColorPushButton.setText("")
self.mainShadowColorPushButton.setObjectName("mainShadowColorPushButton")
self.mainAreaLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.mainShadowColorPushButton)
ThemeWizard.addPage(self.mainAreaPage)
self.footerAreaPage = QtGui.QWizardPage()
self.footerAreaPage.setObjectName("footerAreaPage")
self.footerLayout = QtGui.QFormLayout(self.footerAreaPage)
self.footerLayout.setFieldGrowthPolicy(QtGui.QFormLayout.ExpandingFieldsGrow)
self.footerLayout.setContentsMargins(50, 20, 20, 20)
self.footerLayout.setSpacing(8)
self.footerLayout.setObjectName("footerLayout")
self.footerFontLabel = QtGui.QLabel(self.footerAreaPage)
self.footerFontLabel.setObjectName("footerFontLabel")
self.footerLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.footerFontLabel)
self.footerFontComboBox = QtGui.QFontComboBox(self.footerAreaPage)
self.footerFontComboBox.setObjectName("footerFontComboBox")
self.footerLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.footerFontComboBox)
self.footerColorLabel = QtGui.QLabel(self.footerAreaPage)
self.footerColorLabel.setObjectName("footerColorLabel")
self.footerLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.footerColorLabel)
self.footerColorPushButton = QtGui.QPushButton(self.footerAreaPage)
self.footerColorPushButton.setText("")
self.footerColorPushButton.setObjectName("footerColorPushButton")
self.footerLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.footerColorPushButton)
self.footerSizeLabel = QtGui.QLabel(self.footerAreaPage)
self.footerSizeLabel.setObjectName("footerSizeLabel")
self.footerLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.footerSizeLabel)
self.footerSizeSpinBox = QtGui.QSpinBox(self.footerAreaPage)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.footerSizeSpinBox.sizePolicy().hasHeightForWidth())
self.footerSizeSpinBox.setSizePolicy(sizePolicy)
self.footerSizeSpinBox.setMinimumSize(QtCore.QSize(70, 0))
self.footerSizeSpinBox.setMaximum(999)
self.footerSizeSpinBox.setProperty("value", 10)
self.footerSizeSpinBox.setObjectName("footerSizeSpinBox")
self.footerLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.footerSizeSpinBox)
self.footerOutlineCheckBox = QtGui.QCheckBox(self.footerAreaPage)
self.footerOutlineCheckBox.setObjectName("footerOutlineCheckBox")
self.footerLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.footerOutlineCheckBox)
self.footerOutlineColorPushButton = QtGui.QPushButton(self.footerAreaPage)
self.footerOutlineColorPushButton.setEnabled(False)
self.footerOutlineColorPushButton.setText("")
self.footerOutlineColorPushButton.setObjectName("footerOutlineColorPushButton")
self.footerLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.footerOutlineColorPushButton)
self.footerShadowCheckBox = QtGui.QCheckBox(self.footerAreaPage)
self.footerShadowCheckBox.setObjectName("footerShadowCheckBox")
self.footerLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.footerShadowCheckBox)
self.footerShadowColorPushButton = QtGui.QPushButton(self.footerAreaPage)
self.footerShadowColorPushButton.setEnabled(False)
self.footerShadowColorPushButton.setText("")
self.footerShadowColorPushButton.setObjectName("footerShadowColorPushButton")
self.footerLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.footerShadowColorPushButton)
ThemeWizard.addPage(self.footerAreaPage)
self.areaPositionPage = QtGui.QWizardPage()
self.areaPositionPage.setObjectName("areaPositionPage")
self.gridLayout_2 = QtGui.QGridLayout(self.areaPositionPage)
self.gridLayout_2.setMargin(20)
self.gridLayout_2.setSpacing(8)
self.gridLayout_2.setObjectName("gridLayout_2")
self.mainPositionGroupBox = QtGui.QGroupBox(self.areaPositionPage)
self.mainPositionGroupBox.setMinimumSize(QtCore.QSize(248, 0))
self.mainPositionGroupBox.setObjectName("mainPositionGroupBox")
self.mainPositionLayout = QtGui.QFormLayout(self.mainPositionGroupBox)
self.mainPositionLayout.setMargin(8)
self.mainPositionLayout.setSpacing(8)
self.mainPositionLayout.setObjectName("mainPositionLayout")
self.mainDefaultPositionCheckBox = QtGui.QCheckBox(self.mainPositionGroupBox)
self.mainDefaultPositionCheckBox.setChecked(True)
self.mainDefaultPositionCheckBox.setTristate(False)
self.mainDefaultPositionCheckBox.setObjectName("mainDefaultPositionCheckBox")
self.mainPositionLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.mainDefaultPositionCheckBox)
self.nainXLabel = QtGui.QLabel(self.mainPositionGroupBox)
self.nainXLabel.setObjectName("nainXLabel")
self.mainPositionLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.nainXLabel)
self.mainXSpinBox = QtGui.QSpinBox(self.mainPositionGroupBox)
self.mainXSpinBox.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.mainXSpinBox.sizePolicy().hasHeightForWidth())
self.mainXSpinBox.setSizePolicy(sizePolicy)
self.mainXSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.mainXSpinBox.setMaximum(9999)
self.mainXSpinBox.setProperty("value", 0)
self.mainXSpinBox.setObjectName("mainXSpinBox")
self.mainPositionLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.mainXSpinBox)
self.mainYSpinBox = QtGui.QSpinBox(self.mainPositionGroupBox)
self.mainYSpinBox.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.mainYSpinBox.sizePolicy().hasHeightForWidth())
self.mainYSpinBox.setSizePolicy(sizePolicy)
self.mainYSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.mainYSpinBox.setMaximum(9999)
self.mainYSpinBox.setObjectName("mainYSpinBox")
self.mainPositionLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.mainYSpinBox)
self.mainYLabel = QtGui.QLabel(self.mainPositionGroupBox)
self.mainYLabel.setObjectName("mainYLabel")
self.mainPositionLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.mainYLabel)
self.mainWidthSpinBox = QtGui.QSpinBox(self.mainPositionGroupBox)
self.mainWidthSpinBox.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.mainWidthSpinBox.sizePolicy().hasHeightForWidth())
self.mainWidthSpinBox.setSizePolicy(sizePolicy)
self.mainWidthSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.mainWidthSpinBox.setMaximum(9999)
self.mainWidthSpinBox.setObjectName("mainWidthSpinBox")
self.mainPositionLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.mainWidthSpinBox)
self.mainWidthLabel = QtGui.QLabel(self.mainPositionGroupBox)
self.mainWidthLabel.setObjectName("mainWidthLabel")
self.mainPositionLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.mainWidthLabel)
self.mainHeightSpinBox = QtGui.QSpinBox(self.mainPositionGroupBox)
self.mainHeightSpinBox.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.mainHeightSpinBox.sizePolicy().hasHeightForWidth())
self.mainHeightSpinBox.setSizePolicy(sizePolicy)
self.mainHeightSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.mainHeightSpinBox.setMaximum(9999)
self.mainHeightSpinBox.setObjectName("mainHeightSpinBox")
self.mainPositionLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.mainHeightSpinBox)
self.mainHeightLabel = QtGui.QLabel(self.mainPositionGroupBox)
self.mainHeightLabel.setObjectName("mainHeightLabel")
self.mainPositionLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.mainHeightLabel)
self.gridLayout_2.addWidget(self.mainPositionGroupBox, 1, 0, 1, 1)
self.footerPositionGroupBox = QtGui.QGroupBox(self.areaPositionPage)
self.footerPositionGroupBox.setMinimumSize(QtCore.QSize(248, 0))
self.footerPositionGroupBox.setObjectName("footerPositionGroupBox")
self.footerPositionLayout = QtGui.QFormLayout(self.footerPositionGroupBox)
self.footerPositionLayout.setMargin(8)
self.footerPositionLayout.setSpacing(8)
self.footerPositionLayout.setObjectName("footerPositionLayout")
self.footerXLabel = QtGui.QLabel(self.footerPositionGroupBox)
self.footerXLabel.setObjectName("footerXLabel")
self.footerPositionLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.footerXLabel)
self.footerXSpinBox = QtGui.QSpinBox(self.footerPositionGroupBox)
self.footerXSpinBox.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.footerXSpinBox.sizePolicy().hasHeightForWidth())
self.footerXSpinBox.setSizePolicy(sizePolicy)
self.footerXSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.footerXSpinBox.setMaximum(9999)
self.footerXSpinBox.setProperty("value", 0)
self.footerXSpinBox.setObjectName("footerXSpinBox")
self.footerPositionLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.footerXSpinBox)
self.footerYLabel = QtGui.QLabel(self.footerPositionGroupBox)
self.footerYLabel.setObjectName("footerYLabel")
self.footerPositionLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.footerYLabel)
self.footerYSpinBox = QtGui.QSpinBox(self.footerPositionGroupBox)
self.footerYSpinBox.setEnabled(False)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.footerYSpinBox.sizePolicy().hasHeightForWidth())
self.footerYSpinBox.setSizePolicy(sizePolicy)
self.footerYSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.footerYSpinBox.setMaximum(9999)
self.footerYSpinBox.setProperty("value", 0)
self.footerYSpinBox.setObjectName("footerYSpinBox")
self.footerPositionLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.footerYSpinBox)
self.footerWidthLabel = QtGui.QLabel(self.footerPositionGroupBox)
self.footerWidthLabel.setObjectName("footerWidthLabel")
self.footerPositionLayout.setWidget(3, QtGui.QFormLayout.LabelRole, self.footerWidthLabel)
self.footerWidthSpinBox = QtGui.QSpinBox(self.footerPositionGroupBox)
self.footerWidthSpinBox.setEnabled(False)
self.footerWidthSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.footerWidthSpinBox.setMaximum(9999)
self.footerWidthSpinBox.setObjectName("footerWidthSpinBox")
self.footerPositionLayout.setWidget(3, QtGui.QFormLayout.FieldRole, self.footerWidthSpinBox)
self.footerHeightLabel = QtGui.QLabel(self.footerPositionGroupBox)
self.footerHeightLabel.setObjectName("footerHeightLabel")
self.footerPositionLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.footerHeightLabel)
self.footerHeightSpinBox = QtGui.QSpinBox(self.footerPositionGroupBox)
self.footerHeightSpinBox.setEnabled(False)
self.footerHeightSpinBox.setMinimumSize(QtCore.QSize(78, 0))
self.footerHeightSpinBox.setMaximum(9999)
self.footerHeightSpinBox.setObjectName("footerHeightSpinBox")
self.footerPositionLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.footerHeightSpinBox)
self.footerDefaultPositionCheckBox = QtGui.QCheckBox(self.footerPositionGroupBox)
self.footerDefaultPositionCheckBox.setChecked(True)
self.footerDefaultPositionCheckBox.setObjectName("footerDefaultPositionCheckBox")
self.footerPositionLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.footerDefaultPositionCheckBox)
self.gridLayout_2.addWidget(self.footerPositionGroupBox, 1, 1, 1, 1)
ThemeWizard.addPage(self.areaPositionPage)
self.previewPage = QtGui.QWizardPage()
self.previewPage.setObjectName("previewPage")
self.previewLayout = QtGui.QGridLayout(self.previewPage)
self.previewLayout.setMargin(20)
self.previewLayout.setSpacing(8)
self.previewLayout.setObjectName("previewLayout")
self.themeNameLabel = QtGui.QLabel(self.previewPage)
self.themeNameLabel.setTextFormat(QtCore.Qt.PlainText)
self.themeNameLabel.setObjectName("themeNameLabel")
self.previewLayout.addWidget(self.themeNameLabel, 0, 0, 1, 1)
self.previewLabel = QtGui.QLabel(self.previewPage)
self.previewLabel.setAlignment(QtCore.Qt.AlignCenter)
self.previewLabel.setObjectName("previewLabel")
self.previewLayout.addWidget(self.previewLabel, 2, 0, 1, 2)
self.themeNameEdit = QtGui.QLineEdit(self.previewPage)
self.themeNameEdit.setObjectName("themeNameEdit")
self.previewLayout.addWidget(self.themeNameEdit, 0, 1, 1, 1)
self.previewBoxLayout = QtGui.QHBoxLayout()
self.previewBoxLayout.setSpacing(0)
self.previewBoxLayout.setContentsMargins(0, 0, -1, -1)
self.previewBoxLayout.setObjectName("previewBoxLayout")
spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.previewBoxLayout.addItem(spacerItem2)
self.previewBoxLabel = QtGui.QLabel(self.previewPage)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.previewBoxLabel.sizePolicy().hasHeightForWidth())
self.previewBoxLabel.setSizePolicy(sizePolicy)
self.previewBoxLabel.setMinimumSize(QtCore.QSize(300, 200))
self.previewBoxLabel.setFrameShape(QtGui.QFrame.WinPanel)
self.previewBoxLabel.setFrameShadow(QtGui.QFrame.Sunken)
self.previewBoxLabel.setLineWidth(1)
self.previewBoxLabel.setText("")
self.previewBoxLabel.setScaledContents(True)
self.previewBoxLabel.setObjectName("previewBoxLabel")
self.previewBoxLayout.addWidget(self.previewBoxLabel)
spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.previewBoxLayout.addItem(spacerItem3)
self.previewLayout.addLayout(self.previewBoxLayout, 3, 0, 1, 2)
ThemeWizard.addPage(self.previewPage)
self.themeNameLabel.setBuddy(self.themeNameEdit)
self.retranslateUi(ThemeWizard)
QtCore.QMetaObject.connectSlotsByName(ThemeWizard)
def retranslateUi(self, ThemeWizard):
ThemeWizard.setWindowTitle(QtGui.QApplication.translate("ThemeWizard", "Theme Wizard", None, QtGui.QApplication.UnicodeUTF8))
self.titleLabel.setText(QtGui.QApplication.translate("ThemeWizard", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'Sans Serif\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-size:14pt; font-weight:600;\">Welcome to the Theme Wizard</span></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
self.informationLabel.setText(QtGui.QApplication.translate("ThemeWizard", "This wizard will help you to maintain Themes . Click the next button below to start the process by setting up your background.", None, QtGui.QApplication.UnicodeUTF8))
self.backgroundPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Set Up Background", None, QtGui.QApplication.UnicodeUTF8))
self.backgroundPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "Set up your theme\'s background according to the parameters below.", None, QtGui.QApplication.UnicodeUTF8))
self.backgroundTypeLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Background type:", None, QtGui.QApplication.UnicodeUTF8))
self.backgroundTypeComboBox.setItemText(0, QtGui.QApplication.translate("ThemeWizard", "Solid Color", None, QtGui.QApplication.UnicodeUTF8))
self.backgroundTypeComboBox.setItemText(1, QtGui.QApplication.translate("ThemeWizard", "Gradient", None, QtGui.QApplication.UnicodeUTF8))
self.backgroundTypeComboBox.setItemText(2, QtGui.QApplication.translate("ThemeWizard", "Image", None, QtGui.QApplication.UnicodeUTF8))
self.color1Label.setText(QtGui.QApplication.translate("ThemeWizard", "<Color1>", None, QtGui.QApplication.UnicodeUTF8))
self.color2Label.setText(QtGui.QApplication.translate("ThemeWizard", "<Color2>", None, QtGui.QApplication.UnicodeUTF8))
self.imageLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Image:", None, QtGui.QApplication.UnicodeUTF8))
self.gradientLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Gradient:", None, QtGui.QApplication.UnicodeUTF8))
self.gradientComboBox.setItemText(0, QtGui.QApplication.translate("ThemeWizard", "Horizontal", None, QtGui.QApplication.UnicodeUTF8))
self.gradientComboBox.setItemText(1, QtGui.QApplication.translate("ThemeWizard", "Vertical", None, QtGui.QApplication.UnicodeUTF8))
self.gradientComboBox.setItemText(2, QtGui.QApplication.translate("ThemeWizard", "Circular", None, QtGui.QApplication.UnicodeUTF8))
self.mainAreaPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Main Area Font Details", None, QtGui.QApplication.UnicodeUTF8))
self.mainAreaPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "Define the font and display characteristics for the Display text", None, QtGui.QApplication.UnicodeUTF8))
self.mainFontLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Font:", None, QtGui.QApplication.UnicodeUTF8))
self.mainColorLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Color:", None, QtGui.QApplication.UnicodeUTF8))
self.mainSizeLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Size:", None, QtGui.QApplication.UnicodeUTF8))
self.mainSizeSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8))
self.mainLineCountLabel.setText(QtGui.QApplication.translate("ThemeWizard", "(%d lines per silde)", None, QtGui.QApplication.UnicodeUTF8))
self.mainOutlineCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Outline:", None, QtGui.QApplication.UnicodeUTF8))
self.mainShadowCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Shadow:", None, QtGui.QApplication.UnicodeUTF8))
self.footerAreaPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Footer Area Font Details", None, QtGui.QApplication.UnicodeUTF8))
self.footerAreaPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "Define the font and display characteristics for the Footer text", None, QtGui.QApplication.UnicodeUTF8))
self.footerFontLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Font:", None, QtGui.QApplication.UnicodeUTF8))
self.footerColorLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Color:", None, QtGui.QApplication.UnicodeUTF8))
self.footerSizeLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Size:", None, QtGui.QApplication.UnicodeUTF8))
self.footerSizeSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "pt", None, QtGui.QApplication.UnicodeUTF8))
self.footerOutlineCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Outline:", None, QtGui.QApplication.UnicodeUTF8))
self.footerShadowCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Shadow:", None, QtGui.QApplication.UnicodeUTF8))
self.areaPositionPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Output Area Locations", None, QtGui.QApplication.UnicodeUTF8))
self.areaPositionPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "Allows you to change and move the Main and Footer areas.", None, QtGui.QApplication.UnicodeUTF8))
self.mainPositionGroupBox.setTitle(QtGui.QApplication.translate("ThemeWizard", "&Main Area", None, QtGui.QApplication.UnicodeUTF8))
self.mainDefaultPositionCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "&Use default location", None, QtGui.QApplication.UnicodeUTF8))
self.nainXLabel.setText(QtGui.QApplication.translate("ThemeWizard", "X position:", None, QtGui.QApplication.UnicodeUTF8))
self.mainXSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "px", None, QtGui.QApplication.UnicodeUTF8))
self.mainYSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "px", None, QtGui.QApplication.UnicodeUTF8))
self.mainYLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Y position:", None, QtGui.QApplication.UnicodeUTF8))
self.mainWidthSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "px", None, QtGui.QApplication.UnicodeUTF8))
self.mainWidthLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Width:", None, QtGui.QApplication.UnicodeUTF8))
self.mainHeightSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "px", None, QtGui.QApplication.UnicodeUTF8))
self.mainHeightLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Height:", None, QtGui.QApplication.UnicodeUTF8))
self.footerPositionGroupBox.setTitle(QtGui.QApplication.translate("ThemeWizard", "Footer Area", None, QtGui.QApplication.UnicodeUTF8))
self.footerXLabel.setText(QtGui.QApplication.translate("ThemeWizard", "X position:", None, QtGui.QApplication.UnicodeUTF8))
self.footerXSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "px", None, QtGui.QApplication.UnicodeUTF8))
self.footerYLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Y position:", None, QtGui.QApplication.UnicodeUTF8))
self.footerYSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "px", None, QtGui.QApplication.UnicodeUTF8))
self.footerWidthLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Width:", None, QtGui.QApplication.UnicodeUTF8))
self.footerWidthSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "px", None, QtGui.QApplication.UnicodeUTF8))
self.footerHeightLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Height:", None, QtGui.QApplication.UnicodeUTF8))
self.footerHeightSpinBox.setSuffix(QtGui.QApplication.translate("ThemeWizard", "px", None, QtGui.QApplication.UnicodeUTF8))
self.footerDefaultPositionCheckBox.setText(QtGui.QApplication.translate("ThemeWizard", "Use default location", None, QtGui.QApplication.UnicodeUTF8))
self.previewPage.setTitle(QtGui.QApplication.translate("ThemeWizard", "Save and Preview", None, QtGui.QApplication.UnicodeUTF8))
self.previewPage.setSubTitle(QtGui.QApplication.translate("ThemeWizard", "View the theme and save it replacing the current one or change the name to create a new theme", None, QtGui.QApplication.UnicodeUTF8))
self.themeNameLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Theme name:", None, QtGui.QApplication.UnicodeUTF8))
self.previewLabel.setText(QtGui.QApplication.translate("ThemeWizard", "Preview", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -0,0 +1,210 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
# Carsten Tinggaard, Frode Woldsund #
# --------------------------------------------------------------------------- #
# This program is free software; you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation; version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate
from themewizard import Ui_ThemeWizard
log = logging.getLogger(__name__)
class ThemeWizardForm(QtGui.QWizard, Ui_ThemeWizard):
"""
This is the Bible Import Wizard, which allows easy importing of Bibles
into OpenLP from other formats like OSIS, CSV and OpenSong.
"""
log.info(u'ThemeWizardForm loaded')
def __init__(self, parent):
"""
Instantiate the wizard, and run any extra setup we need to.
``parent``
The QWidget-derived parent of the wizard.
``manager``
The Bible manager.
``bibleplugin``
The Bible plugin.
"""
# Do not translate as internal
self.backgrounds = [u'solid', u'gradient', u'image']
self.gradients = [u'horizontal', u'vertical', u'circular']
QtGui.QWizard.__init__(self, parent)
self.setupUi(self)
self.registerFields()
self.finishButton = self.button(QtGui.QWizard.FinishButton)
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
QtCore.QObject.connect(self.backgroundTypeComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onBackgroundComboBox)
QtCore.QObject.connect(self.gradientComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onGradientComboBox)
QtCore.QObject.connect(self.color1PushButton,
QtCore.SIGNAL(u'pressed()'),
self.onColor1PushButtonClicked)
QtCore.QObject.connect(self.color2PushButton,
QtCore.SIGNAL(u'pressed()'),
self.onColor2PushButtonClicked)
QtCore.QObject.connect(self.imageBrowseButton,
QtCore.SIGNAL(u'pressed()'),
self.onimageBrowseButtonClicked)
def exec_(self):
"""
Run the wizard.
"""
self.setDefaults()
return QtGui.QWizard.exec_(self)
def validateCurrentPage(self):
"""
Validate the current page before moving on to the next page.
"""
print "CURRENT id", self.currentId()
# Background Screen
if self.currentId() == 0:
print self.field(u'background_type').toString()
self.paintBackgroundScreen()
return True
def paintBackgroundScreen(self):
if self.theme.background_type == u'solid':
self.setField(u'background_type', QtCore.QVariant(0))
self.color1PushButton.setVisible(True)
self.color1Label.setVisible(True)
self.color1PushButton.setStyleSheet(u'background-color: %s' %
self.theme.background_color)
self.color1Label.setText(
translate('OpenLP.AmendThemeForm', 'Color:'))
self.color2PushButton.setVisible(False)
self.color2Label.setVisible(False)
self.gradientLabel.setVisible(False)
self.gradientComboBox.setVisible(False)
self.imageLabel.setVisible(False)
self.imageLineEdit.setVisible(False)
self.imageBrowseButton.setVisible(False)
self.imageLineEdit.setText(u'')
elif self.theme.background_type == u'gradient':
self.setField(u'background_type', QtCore.QVariant(1))
self.color1PushButton.setVisible(True)
self.color1Label.setVisible(True)
self.color1PushButton.setStyleSheet(u'background-color: %s' %
self.theme.background_start_color)
self.color1Label.setText(
translate('OpenLP.AmendThemeForm', 'First color:'))
self.color2PushButton.setVisible(True)
self.color2Label.setVisible(True)
self.color2PushButton.setStyleSheet(u'background-color: %s' %
self.theme.background_end_color)
self.color2Label.setText(
translate('OpenLP.AmendThemeForm', 'Second color:'))
self.gradientLabel.setVisible(True)
self.gradientComboBox.setVisible(True)
self.imageLabel.setVisible(False)
self.imageLineEdit.setVisible(False)
self.imageBrowseButton.setVisible(False)
self.imageLineEdit.setText(u'')
else:
self.setField(u'background_type', QtCore.QVariant(2))
self.color1PushButton.setVisible(False)
self.color1Label.setVisible(False)
self.color2PushButton.setVisible(False)
self.color2Label.setVisible(False)
self.gradientLabel.setVisible(False)
self.gradientComboBox.setVisible(False)
self.imageLineEdit.setVisible(True)
self.imageLabel.setVisible(True)
self.imageBrowseButton.setVisible(True)
self.imageLineEdit.setText(self.theme.background_filename)
if self.theme.background_direction == u'horizontal':
self.setField(u'gradient', QtCore.QVariant(0))
elif self.theme.background_direction == u'vertical':
self.setField(u'gradient', QtCore.QVariant(1))
else:
self.setField(u'gradient', QtCore.QVariant(2))
def setDefaults(self):
self.restart()
self.paintBackgroundScreen()
def registerFields(self):
self.welcomePage.registerField(
u'background_type', self.backgroundTypeComboBox)
self.welcomePage.registerField(
u'color_1', self.color1PushButton)
self.welcomePage.registerField(
u'color_2', self.color2PushButton)
self.welcomePage.registerField(
u'background_image', self.imageLineEdit)
self.welcomePage.registerField(
u'gradient', self.gradientComboBox)
def onBackgroundComboBox(self, index):
self.theme.background_type = self.backgrounds[index]
self.paintBackgroundScreen()
def onGradientComboBox(self, index):
self.theme.background_direction = self.gradients[index]
self.paintBackgroundScreen()
def onColor1PushButtonClicked(self):
if self.theme.background_type == u'solid':
self.theme.background_color = \
self._colorButtonPushed(self.theme.background_color)
else:
self.theme.background_start_color = \
self._colorButtonPushed(self.theme.background_start_color)
self.paintBackgroundScreen()
def onColor2PushButtonClicked(self):
self.theme.background_end_color = \
self._colorButtonPushed(self.theme.background_end_color)
self.paintBackgroundScreen()
def onimageBrowseButtonClicked(self):
images_filter = get_images_filter()
images_filter = '%s;;%s (*.*) (*)' % (images_filter,
translate('OpenLP.AmendThemeForm', 'All Files'))
filename = QtGui.QFileDialog.getOpenFileName(self,
translate('OpenLP.AmendThemeForm', 'Select Image'), u'',
images_filter)
if filename:
self.theme.background_filename = filename
self.paintBackgroundScreen()
def _colorButtonPushed(self, field):
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(field), self)
if new_color.isValid():
field = new_color.name()
return field

File diff suppressed because it is too large Load Diff