2010-10-03 07:42:02 +00:00
|
|
|
# -*- 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
|
2010-11-05 19:20:41 +00:00
|
|
|
import os
|
2010-10-03 07:42:02 +00:00
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
|
|
|
|
2010-11-18 17:46:47 +00:00
|
|
|
from openlp.core.lib import translate, BackgroundType, BackgroundGradientType
|
2010-11-05 19:20:41 +00:00
|
|
|
from openlp.core.utils import get_images_filter
|
2010-10-17 18:58:42 +00:00
|
|
|
from themedialog import Ui_ThemeDialog
|
2010-10-03 07:42:02 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2010-10-17 18:58:42 +00:00
|
|
|
class ThemeForm(QtGui.QWizard, Ui_ThemeDialog):
|
2010-10-03 07:42:02 +00:00
|
|
|
"""
|
|
|
|
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.
|
|
|
|
"""
|
|
|
|
QtGui.QWizard.__init__(self, parent)
|
2010-10-13 19:40:01 +00:00
|
|
|
self.thememanager = parent
|
2010-10-03 07:42:02 +00:00
|
|
|
self.setupUi(self)
|
|
|
|
self.registerFields()
|
2010-11-08 06:11:04 +00:00
|
|
|
self.accepted = False
|
2010-10-03 07:42:02 +00:00
|
|
|
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()'),
|
2010-10-05 19:52:28 +00:00
|
|
|
self.onImageBrowseButtonClicked)
|
2010-10-09 10:59:49 +00:00
|
|
|
QtCore.QObject.connect(self.mainColorPushButton,
|
|
|
|
QtCore.SIGNAL(u'pressed()'),
|
|
|
|
self.onMainColourPushButtonClicked)
|
|
|
|
QtCore.QObject.connect(self.outlineColorPushButton,
|
|
|
|
QtCore.SIGNAL(u'pressed()'),
|
|
|
|
self.onOutlineColourPushButtonClicked)
|
|
|
|
QtCore.QObject.connect(self.shadowColorPushButton,
|
|
|
|
QtCore.SIGNAL(u'pressed()'),
|
|
|
|
self.onShadowColourPushButtonClicked)
|
2010-10-11 16:14:36 +00:00
|
|
|
QtCore.QObject.connect(self.outlineCheckBox,
|
|
|
|
QtCore.SIGNAL(u'stateChanged(int)'),
|
|
|
|
self.onOutlineCheckCheckBoxChanged)
|
|
|
|
QtCore.QObject.connect(self.shadowCheckBox,
|
|
|
|
QtCore.SIGNAL(u'stateChanged(int)'),
|
|
|
|
self.onShadowCheckCheckBoxChanged)
|
|
|
|
QtCore.QObject.connect(self.footerColorPushButton,
|
|
|
|
QtCore.SIGNAL(u'pressed()'),
|
2010-10-13 19:40:01 +00:00
|
|
|
self.onFooterColourPushButtonClicked)
|
|
|
|
QtCore.QObject.connect(self.mainDefaultPositionCheckBox,
|
|
|
|
QtCore.SIGNAL(u'stateChanged(int)'),
|
|
|
|
self.onMainDefaultPositionCheckBox)
|
|
|
|
QtCore.QObject.connect(self.footerDefaultPositionCheckBox,
|
|
|
|
QtCore.SIGNAL(u'stateChanged(int)'),
|
|
|
|
self.onFooterDefaultPositionCheckBox)
|
2010-11-08 06:11:04 +00:00
|
|
|
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))
|
2010-10-11 16:14:36 +00:00
|
|
|
|
2010-11-05 19:20:41 +00:00
|
|
|
def setDefaults(self):
|
|
|
|
"""
|
|
|
|
Set up display at start of theme edit.
|
|
|
|
"""
|
|
|
|
self.restart()
|
2010-11-08 06:11:04 +00:00
|
|
|
self.accepted = False
|
2010-11-05 19:20:41 +00:00
|
|
|
self.setBackgroundTabValues()
|
|
|
|
self.setMainAreaTabValues()
|
|
|
|
self.setFooterAreaTabValues()
|
|
|
|
self.setAlignmentTabValues()
|
|
|
|
self.setPositionTabValues()
|
|
|
|
self.setPreviewTabValues()
|
|
|
|
|
|
|
|
def registerFields(self):
|
|
|
|
"""
|
|
|
|
Map field names to screen names,
|
|
|
|
"""
|
|
|
|
self.backgroundPage.registerField(
|
|
|
|
u'background_type', self.backgroundTypeComboBox)
|
|
|
|
self.backgroundPage.registerField(
|
|
|
|
u'color_1', self.color1PushButton)
|
|
|
|
self.backgroundPage.registerField(
|
|
|
|
u'color_2', self.color2PushButton)
|
|
|
|
self.backgroundPage.registerField(
|
|
|
|
u'background_image', self.imageLineEdit)
|
|
|
|
self.backgroundPage.registerField(
|
|
|
|
u'gradient', self.gradientComboBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'mainFontComboBox', self.mainFontComboBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'mainColorPushButton', self.mainColorPushButton)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'mainSizeSpinBox', self.mainSizeSpinBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'lineSpacingSpinBox', self.lineSpacingSpinBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'outlineCheckBox', self.outlineCheckBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'outlineColorPushButton', self.outlineColorPushButton)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'outlineSizeSpinBox', self.outlineSizeSpinBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'shadowCheckBox', self.shadowCheckBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'boldCheckBox', self.boldCheckBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'italicsCheckBox', self.italicsCheckBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'shadowColorPushButton', self.shadowColorPushButton)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'shadowSizeSpinBox', self.shadowSizeSpinBox)
|
|
|
|
self.mainAreaPage.registerField(
|
|
|
|
u'footerSizeSpinBox', self.footerSizeSpinBox)
|
2010-11-16 17:33:41 +00:00
|
|
|
# self.areaPositionPage.registerField(
|
|
|
|
# u'mainDefaultPosition', self.mainDefaultPositionCheckBox)
|
2010-11-05 19:20:41 +00:00
|
|
|
self.areaPositionPage.registerField(
|
|
|
|
u'mainPositionX', self.mainXSpinBox)
|
|
|
|
self.areaPositionPage.registerField(
|
|
|
|
u'mainPositionY', self.mainYSpinBox)
|
|
|
|
self.areaPositionPage.registerField(
|
|
|
|
u'mainPositionWidth', self.mainWidthSpinBox)
|
|
|
|
self.areaPositionPage.registerField(
|
|
|
|
u'mainPositionHeight', self.mainHeightSpinBox)
|
2010-11-16 17:33:41 +00:00
|
|
|
# self.areaPositionPage.registerField(
|
|
|
|
# u'footerDefaultPosition', self.footerDefaultPositionCheckBox)
|
2010-11-05 19:20:41 +00:00
|
|
|
self.areaPositionPage.registerField(
|
|
|
|
u'footerPositionX', self.footerXSpinBox)
|
|
|
|
self.areaPositionPage.registerField(
|
|
|
|
u'footerPositionY', self.footerYSpinBox)
|
|
|
|
self.areaPositionPage.registerField(
|
|
|
|
u'footerPositionWidth', self.footerWidthSpinBox)
|
|
|
|
self.areaPositionPage.registerField(
|
|
|
|
u'footerPositionHeight', self.footerHeightSpinBox)
|
|
|
|
self.backgroundPage.registerField(
|
|
|
|
u'horizontal', self.horizontalComboBox)
|
|
|
|
self.backgroundPage.registerField(
|
|
|
|
u'vertical', self.verticalComboBox)
|
|
|
|
self.backgroundPage.registerField(
|
|
|
|
u'slideTransition', self.transitionsCheckBox)
|
|
|
|
self.backgroundPage.registerField(
|
|
|
|
u'name', self.themeNameEdit)
|
|
|
|
|
2010-10-11 16:14:36 +00:00
|
|
|
def onOutlineCheckCheckBoxChanged(self, state):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2010-10-16 13:54:57 +00:00
|
|
|
Change state as Outline check box changed
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
2010-11-09 20:17:38 +00:00
|
|
|
if state == QtCore.Qt.Checked:
|
|
|
|
self.theme.font_main_outline = True
|
|
|
|
else:
|
|
|
|
self.theme.font_main_outline = False
|
|
|
|
self.outlineColorPushButton.setEnabled(self.theme.font_main_outline)
|
|
|
|
self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline)
|
2010-10-11 16:14:36 +00:00
|
|
|
|
|
|
|
def onShadowCheckCheckBoxChanged(self, state):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
|
|
|
Change state as Shadow check box changed
|
|
|
|
"""
|
2010-11-09 20:17:38 +00:00
|
|
|
if state == QtCore.Qt.Checked:
|
|
|
|
self.theme.font_main_shadow = True
|
|
|
|
else:
|
|
|
|
self.theme.font_main_shadow = False
|
|
|
|
self.shadowColorPushButton.setEnabled(self.theme.font_main_shadow)
|
|
|
|
self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow)
|
2010-10-03 07:42:02 +00:00
|
|
|
|
2010-10-16 07:21:24 +00:00
|
|
|
def onMainDefaultPositionCheckBox(self, value):
|
|
|
|
"""
|
|
|
|
Change state as Main Area Position check box changed
|
|
|
|
"""
|
|
|
|
if value == QtCore.Qt.Checked:
|
|
|
|
self.theme.font_main_override = False
|
|
|
|
else:
|
|
|
|
self.theme.font_main_override = True
|
|
|
|
self.mainXSpinBox.setEnabled(self.theme.font_main_override)
|
|
|
|
self.mainYSpinBox.setEnabled(self.theme.font_main_override)
|
|
|
|
self.mainHeightSpinBox.setEnabled(self.theme.font_main_override)
|
|
|
|
self.mainWidthSpinBox.setEnabled(self.theme.font_main_override)
|
|
|
|
|
|
|
|
def onFooterDefaultPositionCheckBox(self, value):
|
|
|
|
"""
|
|
|
|
Change state as Footer Area Position check box changed
|
|
|
|
"""
|
|
|
|
if value == QtCore.Qt.Checked:
|
|
|
|
self.theme.font_footer_override = False
|
|
|
|
else:
|
|
|
|
self.theme.font_footer_override = True
|
|
|
|
self.footerXSpinBox.setEnabled(self.theme.font_footer_override)
|
|
|
|
self.footerYSpinBox.setEnabled(self.theme.font_footer_override)
|
|
|
|
self.footerHeightSpinBox.setEnabled(self.theme.font_footer_override)
|
|
|
|
self.footerWidthSpinBox.setEnabled(self.theme.font_footer_override)
|
2010-10-13 19:40:01 +00:00
|
|
|
|
2010-10-03 07:42:02 +00:00
|
|
|
def exec_(self):
|
|
|
|
"""
|
|
|
|
Run the wizard.
|
|
|
|
"""
|
|
|
|
self.setDefaults()
|
|
|
|
return QtGui.QWizard.exec_(self)
|
|
|
|
|
2010-10-24 19:23:12 +00:00
|
|
|
def initializePage(self, id):
|
2010-11-08 06:11:04 +00:00
|
|
|
"""
|
|
|
|
Set up the pages for Initial run through dialog
|
|
|
|
"""
|
|
|
|
log.debug(u'initializePage %s' % id)
|
|
|
|
if id == 1:
|
2010-10-24 19:23:12 +00:00
|
|
|
self.setBackgroundTabValues()
|
|
|
|
elif id == 2:
|
2010-11-08 06:11:04 +00:00
|
|
|
self.setMainAreaTabValues()
|
2010-10-24 19:23:12 +00:00
|
|
|
elif id == 3:
|
2010-11-08 06:11:04 +00:00
|
|
|
self.setFooterAreaTabValues()
|
2010-10-24 19:23:12 +00:00
|
|
|
elif id == 4:
|
2010-11-08 06:11:04 +00:00
|
|
|
self.setAlignmentTabValues()
|
2010-10-24 19:23:12 +00:00
|
|
|
elif id == 5:
|
2010-11-08 06:11:04 +00:00
|
|
|
self.setPositionTabValues()
|
2010-10-03 07:42:02 +00:00
|
|
|
|
2010-10-05 19:52:28 +00:00
|
|
|
def setBackgroundTabValues(self):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
|
|
|
Handle the display and State of the background display tab.
|
|
|
|
"""
|
2010-10-09 06:48:54 +00:00
|
|
|
if self.theme.background_type == \
|
|
|
|
BackgroundType.to_string(BackgroundType.Solid):
|
2010-10-03 07:42:02 +00:00
|
|
|
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(
|
2010-11-04 17:03:52 +00:00
|
|
|
translate('OpenLP.ThemeForm', 'Color:'))
|
2010-10-03 07:42:02 +00:00
|
|
|
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'')
|
2010-10-09 06:48:54 +00:00
|
|
|
elif self.theme.background_type == \
|
|
|
|
BackgroundType.to_string(BackgroundType.Gradient):
|
2010-10-03 07:42:02 +00:00
|
|
|
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(
|
2010-11-04 17:03:52 +00:00
|
|
|
translate('OpenLP.ThemeForm', 'First color:'))
|
2010-10-03 07:42:02 +00:00
|
|
|
self.color2PushButton.setVisible(True)
|
|
|
|
self.color2Label.setVisible(True)
|
|
|
|
self.color2PushButton.setStyleSheet(u'background-color: %s' %
|
|
|
|
self.theme.background_end_color)
|
|
|
|
self.color2Label.setText(
|
2010-11-04 17:03:52 +00:00
|
|
|
translate('OpenLP.ThemeForm', 'Second color:'))
|
2010-10-03 07:42:02 +00:00
|
|
|
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)
|
2010-10-09 06:48:54 +00:00
|
|
|
if self.theme.background_direction == \
|
|
|
|
BackgroundGradientType.to_string(BackgroundGradientType.Horizontal):
|
2010-11-18 17:46:47 +00:00
|
|
|
self.setField(u'gradient', QtCore.QVariant(0))
|
2010-10-09 06:48:54 +00:00
|
|
|
elif self.theme.background_direction == \
|
|
|
|
BackgroundGradientType.to_string(BackgroundGradientType.Vertical):
|
2010-11-18 17:46:47 +00:00
|
|
|
self.setField(u'gradient', QtCore.QVariant(1))
|
2010-10-09 06:48:54 +00:00
|
|
|
elif self.theme.background_direction == \
|
|
|
|
BackgroundGradientType.to_string(BackgroundGradientType.Circular):
|
2010-11-18 17:46:47 +00:00
|
|
|
self.setField(u'gradient', QtCore.QVariant(2))
|
2010-10-09 06:48:54 +00:00
|
|
|
elif self.theme.background_direction == \
|
|
|
|
BackgroundGradientType.to_string(BackgroundGradientType.LeftTop):
|
2010-11-18 17:46:47 +00:00
|
|
|
self.setField(u'gradient', QtCore.QVariant(3))
|
2010-10-09 06:48:54 +00:00
|
|
|
else:
|
2010-11-18 17:46:47 +00:00
|
|
|
self.setField(u'gradient', QtCore.QVariant(4))
|
2010-10-03 07:42:02 +00:00
|
|
|
|
2010-10-16 07:21:24 +00:00
|
|
|
def setMainAreaTabValues(self):
|
|
|
|
"""
|
|
|
|
Handle the display and State of the Main Area tab.
|
|
|
|
"""
|
2010-10-13 19:40:01 +00:00
|
|
|
self.mainFontComboBox.setCurrentFont(
|
|
|
|
QtGui.QFont(self.theme.font_main_name))
|
2010-10-09 10:59:49 +00:00
|
|
|
self.mainColorPushButton.setStyleSheet(u'background-color: %s' %
|
2010-10-09 11:20:47 +00:00
|
|
|
self.theme.font_main_color)
|
|
|
|
self.setField(u'mainSizeSpinBox', \
|
2010-10-11 16:14:36 +00:00
|
|
|
QtCore.QVariant(self.theme.font_main_size))
|
2010-10-09 11:20:47 +00:00
|
|
|
self.setField(u'lineSpacingSpinBox', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_line_adjustment))
|
|
|
|
self.setField(u'outlineCheckBox', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_outline))
|
2010-10-09 10:59:49 +00:00
|
|
|
self.outlineColorPushButton.setStyleSheet(u'background-color: %s' %
|
2010-10-09 11:20:47 +00:00
|
|
|
self.theme.font_main_outline_color)
|
|
|
|
self.setField(u'outlineSizeSpinBox', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_outline_size))
|
|
|
|
self.setField(u'shadowCheckBox', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_shadow))
|
2010-10-09 10:59:49 +00:00
|
|
|
self.shadowColorPushButton.setStyleSheet(u'background-color: %s' %
|
2010-10-09 11:20:47 +00:00
|
|
|
self.theme.font_main_shadow_color)
|
|
|
|
self.setField(u'shadowSizeSpinBox', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_shadow_size))
|
2010-10-11 16:14:36 +00:00
|
|
|
self.setField(u'boldCheckBox', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_bold))
|
|
|
|
self.setField(u'italicsCheckBox', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_italics))
|
2010-11-09 20:17:38 +00:00
|
|
|
# Set up field states
|
|
|
|
if self.theme.font_main_outline:
|
|
|
|
self.setField(u'outlineCheckBox', QtCore.QVariant(False))
|
|
|
|
else:
|
|
|
|
self.setField(u'outlineCheckBox', QtCore.QVariant(True))
|
|
|
|
self.outlineColorPushButton.setEnabled(self.theme.font_main_outline)
|
|
|
|
self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline)
|
|
|
|
if self.theme.font_main_shadow:
|
|
|
|
self.setField(u'shadowCheckBox', QtCore.QVariant(False))
|
|
|
|
else:
|
|
|
|
self.setField(u'shadowCheckBox', QtCore.QVariant(True))
|
|
|
|
self.shadowColorPushButton.setEnabled(self.theme.font_main_shadow)
|
|
|
|
self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow)
|
2010-10-09 10:59:49 +00:00
|
|
|
|
|
|
|
def setFooterAreaTabValues(self):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
|
|
|
Handle the display and State of the Footer Area tab.
|
|
|
|
"""
|
2010-10-13 19:40:01 +00:00
|
|
|
self.footerFontComboBox.setCurrentFont(
|
|
|
|
QtGui.QFont(self.theme.font_main_name))
|
2010-10-11 16:14:36 +00:00
|
|
|
self.footerColorPushButton.setStyleSheet(u'background-color: %s' %
|
|
|
|
self.theme.font_footer_color)
|
|
|
|
self.setField(u'footerSizeSpinBox', \
|
|
|
|
QtCore.QVariant(self.theme.font_footer_size))
|
|
|
|
|
2010-10-09 10:59:49 +00:00
|
|
|
def setPositionTabValues(self):
|
2010-10-16 13:54:57 +00:00
|
|
|
"""
|
|
|
|
Handle the display and State of the Position tab.
|
|
|
|
"""
|
2010-11-16 17:33:41 +00:00
|
|
|
# Main Area
|
2010-10-16 07:21:24 +00:00
|
|
|
if self.theme.font_main_override:
|
2010-11-16 17:33:41 +00:00
|
|
|
self.mainDefaultPositionCheckBox.setChecked(False)
|
2010-10-16 07:21:24 +00:00
|
|
|
else:
|
2010-11-16 17:33:41 +00:00
|
|
|
self.mainDefaultPositionCheckBox.setChecked(True)
|
2010-10-13 20:19:38 +00:00
|
|
|
self.setField(u'mainPositionX', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_x))
|
|
|
|
self.setField(u'mainPositionY', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_y))
|
|
|
|
self.setField(u'mainPositionHeight', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_height))
|
|
|
|
self.setField(u'mainPositionWidth', \
|
|
|
|
QtCore.QVariant(self.theme.font_main_width))
|
2010-11-16 17:33:41 +00:00
|
|
|
# Footer
|
2010-10-16 07:21:24 +00:00
|
|
|
if self.theme.font_footer_override:
|
2010-11-16 17:33:41 +00:00
|
|
|
self.footerDefaultPositionCheckBox.setChecked(False)
|
2010-10-16 07:21:24 +00:00
|
|
|
else:
|
2010-11-16 17:33:41 +00:00
|
|
|
self.footerDefaultPositionCheckBox.setChecked(True)
|
2010-10-13 20:19:38 +00:00
|
|
|
self.setField(u'footerPositionX', \
|
|
|
|
QtCore.QVariant(self.theme.font_footer_x))
|
|
|
|
self.setField(u'footerPositionY', \
|
|
|
|
QtCore.QVariant(self.theme.font_footer_y))
|
|
|
|
self.setField(u'footerPositionHeight', \
|
|
|
|
QtCore.QVariant(self.theme.font_footer_height))
|
|
|
|
self.setField(u'footerPositionWidth', \
|
|
|
|
QtCore.QVariant(self.theme.font_footer_width))
|
2010-10-09 10:59:49 +00:00
|
|
|
|
2010-10-13 19:40:01 +00:00
|
|
|
def setAlignmentTabValues(self):
|
2010-11-08 06:11:04 +00:00
|
|
|
"""
|
|
|
|
Define the Tab Alignments Page
|
|
|
|
"""
|
2010-10-17 18:58:42 +00:00
|
|
|
self.setField(u'horizontal', \
|
|
|
|
QtCore.QVariant(self.theme.display_horizontal_align))
|
|
|
|
self.setField(u'vertical', \
|
|
|
|
QtCore.QVariant(self.theme.display_vertical_align))
|
2010-11-16 17:33:41 +00:00
|
|
|
self.setField(u'slideTransition', \
|
|
|
|
QtCore.QVariant(self.theme.display_slide_transition))
|
2010-10-17 18:58:42 +00:00
|
|
|
|
|
|
|
def setPreviewTabValues(self):
|
|
|
|
self.setField(u'name', QtCore.QVariant(self.theme.theme_name))
|
|
|
|
if len(self.theme.theme_name) > 1:
|
|
|
|
self.themeNameEdit.setEnabled(False)
|
2010-11-09 20:17:38 +00:00
|
|
|
else:
|
|
|
|
self.themeNameEdit.setEnabled(True)
|
2010-10-13 19:40:01 +00:00
|
|
|
|
2010-10-03 07:42:02 +00:00
|
|
|
def onBackgroundComboBox(self, index):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
|
|
|
Background style Combo box has changed.
|
|
|
|
"""
|
2010-10-09 06:48:54 +00:00
|
|
|
self.theme.background_type = BackgroundType.to_string(index)
|
2010-10-05 19:52:28 +00:00
|
|
|
self.setBackgroundTabValues()
|
2010-10-03 07:42:02 +00:00
|
|
|
|
|
|
|
def onGradientComboBox(self, index):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
|
|
|
Background gradient Combo box has changed.
|
|
|
|
"""
|
2010-10-09 06:48:54 +00:00
|
|
|
self.theme.background_direction = \
|
|
|
|
BackgroundGradientType.to_string(index)
|
2010-10-05 19:52:28 +00:00
|
|
|
self.setBackgroundTabValues()
|
2010-10-03 07:42:02 +00:00
|
|
|
|
|
|
|
def onColor1PushButtonClicked(self):
|
2010-11-08 06:11:04 +00:00
|
|
|
"""
|
|
|
|
Background / Gradient 1 Color button pushed.
|
|
|
|
"""
|
2010-10-09 06:48:54 +00:00
|
|
|
if self.theme.background_type == \
|
|
|
|
BackgroundType.to_string(BackgroundType.Solid):
|
2010-10-03 07:42:02 +00:00
|
|
|
self.theme.background_color = \
|
2010-10-05 19:52:28 +00:00
|
|
|
self._colorButton(self.theme.background_color)
|
2010-10-03 07:42:02 +00:00
|
|
|
else:
|
|
|
|
self.theme.background_start_color = \
|
2010-10-05 19:52:28 +00:00
|
|
|
self._colorButton(self.theme.background_start_color)
|
|
|
|
self.setBackgroundTabValues()
|
2010-10-03 07:42:02 +00:00
|
|
|
|
|
|
|
def onColor2PushButtonClicked(self):
|
2010-11-08 06:11:04 +00:00
|
|
|
"""
|
|
|
|
Gradient 2 Color button pushed.
|
|
|
|
"""
|
2010-10-03 07:42:02 +00:00
|
|
|
self.theme.background_end_color = \
|
2010-10-05 19:52:28 +00:00
|
|
|
self._colorButton(self.theme.background_end_color)
|
|
|
|
self.setBackgroundTabValues()
|
2010-10-03 07:42:02 +00:00
|
|
|
|
2010-10-05 19:52:28 +00:00
|
|
|
def onImageBrowseButtonClicked(self):
|
2010-11-08 06:11:04 +00:00
|
|
|
"""
|
|
|
|
Background Image button pushed.
|
|
|
|
"""
|
2010-10-03 07:42:02 +00:00
|
|
|
images_filter = get_images_filter()
|
|
|
|
images_filter = '%s;;%s (*.*) (*)' % (images_filter,
|
2010-11-04 17:03:52 +00:00
|
|
|
translate('OpenLP.ThemeForm', 'All Files'))
|
2010-10-03 07:42:02 +00:00
|
|
|
filename = QtGui.QFileDialog.getOpenFileName(self,
|
2010-11-04 17:03:52 +00:00
|
|
|
translate('OpenLP.ThemeForm', 'Select Image'), u'',
|
2010-10-03 07:42:02 +00:00
|
|
|
images_filter)
|
|
|
|
if filename:
|
2010-11-05 19:20:41 +00:00
|
|
|
self.theme.background_filename = unicode(filename)
|
2010-10-05 19:52:28 +00:00
|
|
|
self.setBackgroundTabValues()
|
2010-10-03 07:42:02 +00:00
|
|
|
|
2010-10-13 19:40:01 +00:00
|
|
|
def onMainFontComboBox(self):
|
2010-11-08 06:11:04 +00:00
|
|
|
"""
|
|
|
|
Main Font Combo box changed
|
|
|
|
"""
|
2010-10-13 19:40:01 +00:00
|
|
|
self.theme.font_main_name = self.mainFontComboBox.currentFont().family()
|
2010-10-09 10:59:49 +00:00
|
|
|
|
|
|
|
def onMainColourPushButtonClicked(self):
|
|
|
|
self.theme.font_main_color = \
|
|
|
|
self._colorButton(self.theme.font_main_color)
|
2010-10-11 16:14:36 +00:00
|
|
|
self.setMainAreaTabValues()
|
2010-10-09 10:59:49 +00:00
|
|
|
|
|
|
|
def onOutlineColourPushButtonClicked(self):
|
|
|
|
self.theme.font_main_outline_color = \
|
|
|
|
self._colorButton(self.theme.font_main_outline_color)
|
2010-10-11 16:14:36 +00:00
|
|
|
self.setMainAreaTabValues()
|
2010-10-09 10:59:49 +00:00
|
|
|
|
|
|
|
def onShadowColourPushButtonClicked(self):
|
|
|
|
self.theme.font_main_shadow_color = \
|
|
|
|
self._colorButton(self.theme.font_main_shadow_color)
|
2010-10-11 16:14:36 +00:00
|
|
|
self.setMainAreaTabValues()
|
|
|
|
|
|
|
|
def onFooterColourPushButtonClicked(self):
|
|
|
|
self.theme.font_footer_color = \
|
|
|
|
self._colorButton(self.theme.font_footer_color)
|
|
|
|
self.setFooterAreaTabValues()
|
2010-10-09 10:59:49 +00:00
|
|
|
|
2010-10-11 16:14:36 +00:00
|
|
|
def updateTheme(self):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
|
|
|
Update the theme object from the UI for fields not already updated
|
|
|
|
when the are changed.
|
|
|
|
"""
|
2010-11-08 06:11:04 +00:00
|
|
|
log.debug(u'updateTheme')
|
2010-10-13 19:40:01 +00:00
|
|
|
# main page
|
|
|
|
self.theme.font_main_name = \
|
2010-10-17 19:34:10 +00:00
|
|
|
unicode(self.mainFontComboBox.currentFont().family())
|
2010-10-13 19:40:01 +00:00
|
|
|
self.theme.font_main_size = \
|
2010-10-09 11:20:47 +00:00
|
|
|
self.field(u'mainSizeSpinBox').toInt()[0]
|
|
|
|
self.theme.font_main_line_adjustment = \
|
|
|
|
self.field(u'lineSpacingSpinBox').toInt()[0]
|
2010-11-05 19:20:41 +00:00
|
|
|
self.theme.font_main_outline_size = \
|
2010-10-09 11:20:47 +00:00
|
|
|
self.field(u'outlineSizeSpinBox').toInt()[0]
|
|
|
|
self.theme.font_main_shadow_size = \
|
|
|
|
self.field(u'shadowSizeSpinBox').toInt()[0]
|
2010-11-05 19:20:41 +00:00
|
|
|
self.theme.font_main_bold = \
|
2010-11-16 17:33:41 +00:00
|
|
|
self.field(u'boldCheckBox').toBool()
|
2010-11-05 19:20:41 +00:00
|
|
|
self.theme.font_main_italics = \
|
2010-11-16 17:33:41 +00:00
|
|
|
self.field(u'italicsCheckBox').toBool()
|
2010-10-13 19:40:01 +00:00
|
|
|
# footer page
|
|
|
|
self.theme.font_footer_name = \
|
2010-10-17 19:34:10 +00:00
|
|
|
unicode(self.footerFontComboBox.currentFont().family())
|
2010-10-13 19:40:01 +00:00
|
|
|
self.theme.font_footer_size = \
|
|
|
|
self.field(u'footerSizeSpinBox').toInt()[0]
|
2010-10-16 07:21:24 +00:00
|
|
|
# position page
|
|
|
|
self.theme.font_main_x = self.field(u'mainPositionX').toInt()[0]
|
|
|
|
self.theme.font_main_y = self.field(u'mainPositionY').toInt()[0]
|
|
|
|
self.theme.font_main_height = \
|
|
|
|
self.field(u'mainPositionHeight').toInt()[0]
|
|
|
|
self.theme.font_main_width = self.field(u'mainPositionWidth').toInt()[0]
|
|
|
|
self.theme.font_footer_x = self.field(u'footerPositionX').toInt()[0]
|
|
|
|
self.theme.font_footer_y = self.field(u'footerPositionY').toInt()[0]
|
|
|
|
self.theme.font_footer_height = \
|
|
|
|
self.field(u'footerPositionHeight').toInt()[0]
|
|
|
|
self.theme.font_footer_width = \
|
|
|
|
self.field(u'footerPositionWidth').toInt()[0]
|
2010-10-17 19:34:10 +00:00
|
|
|
# position page
|
|
|
|
self.theme.display_horizontal_align = \
|
|
|
|
self.horizontalComboBox.currentIndex()
|
|
|
|
self.theme.display_vertical_align = \
|
|
|
|
self.verticalComboBox.currentIndex()
|
|
|
|
self.theme.display_slide_transition = \
|
|
|
|
self.field(u'slideTransition').toBool()
|
2010-10-09 11:20:47 +00:00
|
|
|
|
2010-11-05 19:20:41 +00:00
|
|
|
def accept(self):
|
|
|
|
"""
|
|
|
|
Lets save the them as Finish has been pressed
|
|
|
|
"""
|
2010-11-08 06:11:04 +00:00
|
|
|
# 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())
|
2010-11-18 17:40:20 +00:00
|
|
|
if not self.theme.theme_name:
|
|
|
|
QtGui.QMessageBox.critical(self,
|
|
|
|
translate('OpenLP.ThemeForm', 'Theme Name Missing'),
|
|
|
|
translate('OpenLP.ThemeForm',
|
|
|
|
'There is no name for this theme. '
|
|
|
|
'Please enter one.'),
|
|
|
|
(QtGui.QMessageBox.Ok),
|
|
|
|
QtGui.QMessageBox.Ok)
|
2010-11-05 19:20:41 +00:00
|
|
|
return
|
|
|
|
save_from = None
|
|
|
|
save_to = None
|
|
|
|
if self.theme.background_type == \
|
|
|
|
BackgroundType.to_string(BackgroundType.Image):
|
|
|
|
filename = \
|
|
|
|
os.path.split(unicode(self.theme.background_filename))[1]
|
|
|
|
save_to = os.path.join(self.path, self.theme.theme_name, filename)
|
|
|
|
save_from = self.theme.background_filename
|
|
|
|
if self.thememanager.saveTheme(self.theme, save_from, save_to):
|
|
|
|
return QtGui.QDialog.accept(self)
|
|
|
|
|
2010-10-05 19:52:28 +00:00
|
|
|
def _colorButton(self, field):
|
2010-10-16 07:21:24 +00:00
|
|
|
"""
|
|
|
|
Handle Color buttons
|
|
|
|
"""
|
2010-10-03 07:42:02 +00:00
|
|
|
new_color = QtGui.QColorDialog.getColor(
|
|
|
|
QtGui.QColor(field), self)
|
|
|
|
if new_color.isValid():
|
|
|
|
field = new_color.name()
|
|
|
|
return field
|