More renderer cleanups

More ThemeManager fixes
Sortout XML tag name errors
This commit is contained in:
Tim Bentley 2009-04-19 21:07:52 +01:00
parent 570a35ae65
commit cf2ad84e74
6 changed files with 39 additions and 21 deletions

View File

@ -19,11 +19,10 @@ Place, Suite 330, Boston, MA 02111-1307 USA
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib.render import Renderer
from settingsmanager import SettingsManager
from pluginmanager import PluginManager
__all__ = ['Renderer', 'SettingsManager', 'PluginManager', 'translate',
__all__ = ['SettingsManager', 'PluginManager', 'translate',
'fileToXML' ]
def translate(context, text):

View File

@ -3,7 +3,7 @@
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
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
@ -32,7 +32,8 @@ from toolbar import OpenLPToolbar
from songxmlhandler import SongXMLBuilder
from songxmlhandler import SongXMLParser
from themexmlhandler import ThemeXML
from openlp.core.lib.render import Renderer
__all__ = ['PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', 'EventType'
__all__ = ['Renderer','PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event', 'EventType'
'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder',
'SongXMLParser', 'EventManager', 'ThemeXML']

View File

@ -135,10 +135,10 @@ class Renderer:
p.fillRect(self._paint.rect(), QtGui.QColor(self._theme.background_color))
elif self._theme.background_type == u'gradient' : # gradient
gradient = None
if self._theme.background_direction == u'vertical':
if self._theme.background_direction == u'horizontal':
w = int(self._paint.width())/2
gradient = QtGui.QLinearGradient(w, 0, w, self._paint.height()) # vertical
elif self._theme.background_direction == u'horizontal':
elif self._theme.background_direction == u'vertical':
h = int(self._paint.height())/2
gradient = QtGui.QLinearGradient(0, h, self._paint.width(), h) # Horizontal
else:

View File

@ -104,12 +104,12 @@ class ThemeXML():
background.setAttribute(u'type', u'gradient')
self.theme.appendChild(background)
color = self.theme_xml.createElement(u'startcolor')
color = self.theme_xml.createElement(u'startColor')
bkc = self.theme_xml.createTextNode(startcolor)
color.appendChild(bkc)
background.appendChild(color)
color = self.theme_xml.createElement(u'endcolor')
color = self.theme_xml.createElement(u'endColor')
bkc = self.theme_xml.createTextNode(endcolor)
color.appendChild(bkc)
background.appendChild(color)

View File

@ -23,8 +23,8 @@ import os, os.path
from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import QColor, QFont
from openlp.core.lib import ThemeXML
from openlp.core.lib import Renderer
from openlp.core import fileToXML
from openlp.core import Renderer
from openlp.core import translate
from amendthemedialog import Ui_AmendThemeDialog
@ -75,6 +75,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme(self.theme)
def onGradientComboBoxSelected(self, currentIndex):
print "Changed ", currentIndex
if currentIndex == 0: # Horizontal
self.theme.background_direction = u'horizontal'
elif currentIndex == 1: # vertical
@ -95,20 +96,16 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def onBackgroundTypeComboBoxSelected(self, currentIndex):
if currentIndex == 0: # Solid
self.theme.background_type = u'solid'
if self.theme.background_direction == None: # never defined
self.theme.background_direction = u'horizontal'
if self.theme.background_startColor is None :
self.theme.background_startColor = u'#000000'
if self.theme.background_endColor is None :
self.theme.background_endColor = u'#000000'
if self.theme.background_color is None :
self.theme.background_color = u'#000000'
elif currentIndex == 1: # Gradient
self.theme.background_type = u'gradient'
if self.theme.background_direction == None: # never defined
self.theme.background_direction = u'horizontal'
self.onGradientComboBoxSelected(self.GradientComboBox.currentIndex())
if self.theme.background_startColor is None :
self.theme.background_startColor = u'#000000'
if self.theme.background_endColor is None :
self.theme.background_endColor = u'#000000'
self.theme.background_endColor = u'#ff0000'
else:
self.theme.background_type = u'image'
self.stateChanging(self.theme)
@ -167,7 +164,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def paintUi(self, theme):
print theme # leave as helpful for initial development
self.stateChanging(theme)
self.BackgroundTypeComboBox.setCurrentIndex(0)
if theme.background_type == u'solid':
self.BackgroundTypeComboBox.setCurrentIndex(0)
elif theme.background_type == u'gradient':
self.BackgroundTypeComboBox.setCurrentIndex(1)
else:
self.BackgroundTypeComboBox.setCurrentIndex(2)
self.BackgroundComboBox.setCurrentIndex(0)
self.GradientComboBox.setCurrentIndex(0)
self.MainFontColorPushButton.setStyleSheet(
@ -179,11 +182,16 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
if theme.background_type == u'solid':
self.Color1PushButton.setStyleSheet(
'background-color: %s' % str(theme.background_color))
self.Color1Label.setText(translate(u'ThemeManager', u'Background Font:'))
self.Color1Label.setText(translate(u'ThemeManager', u'Background Color:'))
self.Color1Label.setVisible(True)
self.Color1PushButton.setVisible(True)
self.Color2Label.setVisible(False)
self.Color2PushButton.setVisible(False)
self.ImageLabel.setVisible(False)
self.ImageLineEdit.setVisible(False)
self.ImageFilenameWidget.setVisible(False)
self.GradientLabel.setVisible(False)
self.GradientComboBox.setVisible(False)
elif theme.background_type == u'gradient':
self.Color1PushButton.setStyleSheet(
'background-color: %s' % str(theme.background_startColor))
@ -195,11 +203,21 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.Color1PushButton.setVisible(True)
self.Color2Label.setVisible(True)
self.Color2PushButton.setVisible(True)
self.ImageLabel.setVisible(False)
self.ImageLineEdit.setVisible(False)
self.ImageFilenameWidget.setVisible(False)
self.GradientLabel.setVisible(True)
self.GradientComboBox.setVisible(True)
else: # must be image
self.Color1Label.setVisible(False)
self.Color1PushButton.setVisible(False)
self.Color2Label.setVisible(False)
self.Color2PushButton.setVisible(False)
self.ImageLabel.setVisible(True)
self.ImageLineEdit.setVisible(True)
self.ImageFilenameWidget.setVisible(True)
self.GradientLabel.setVisible(False)
self.GradientComboBox.setVisible(False)
def previewTheme(self, theme):
frame = self.thememanager.generateImage(theme)

View File

@ -32,13 +32,13 @@ from PyQt4.QtGui import *
from openlp.core.ui import AmendThemeForm
from openlp.core import translate
from openlp.core import Renderer
from openlp.core.theme import Theme
from openlp.core.lib import Event
from openlp.core.lib import EventType
from openlp.core.lib import EventManager
from openlp.core.lib import OpenLPToolbar
from openlp.core.lib import ThemeXML
from openlp.core.lib import Renderer
from openlp.core.utils import ConfigHelper
@ -301,7 +301,7 @@ class ThemeManager(QWidget):
newtheme.add_background_solid(str(t.BackgroundParameter1.name()))
elif t.BackgroundType == 1:
direction = "vertical"
if t.BackgroundParameter1.name() == 1:
if t.BackgroundParameter3.name() == 1:
direction = "horizontal"
newtheme.add_background_gradient(str(t.BackgroundParameter1.name()), str(t.BackgroundParameter2.name()), direction)
else: