Head r846

This commit is contained in:
Jon Tibble 2010-06-14 19:22:08 +01:00
commit e71caf43e7
36 changed files with 577 additions and 273 deletions

View File

@ -22,3 +22,6 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`openlp` module contains all the project produced OpenLP functionality
"""

View File

@ -22,3 +22,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`core` module provides all core application functions
All the core functions of the OpenLP application including the GUI, settings,
logging and a plugin framework are contained within the openlp.core module.
"""

View File

@ -95,24 +95,24 @@ def build_icon(icon):
The icon to build. This can be a QIcon, a resource string in the form The icon to build. This can be a QIcon, a resource string in the form
``:/resource/file.png``, or a file location like ``/path/to/file.png``. ``:/resource/file.png``, or a file location like ``/path/to/file.png``.
""" """
ButtonIcon = None button_icon = None
if isinstance(icon, QtGui.QIcon): if isinstance(icon, QtGui.QIcon):
ButtonIcon = icon button_icon = icon
elif isinstance(icon, basestring): elif isinstance(icon, basestring):
ButtonIcon = QtGui.QIcon() button_icon = QtGui.QIcon()
if icon.startswith(u':/'): if icon.startswith(u':/'):
ButtonIcon.addPixmap( button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Off)
else: else:
ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)), button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
elif isinstance(icon, QtGui.QImage): elif isinstance(icon, QtGui.QImage):
ButtonIcon = QtGui.QIcon() button_icon = QtGui.QIcon()
ButtonIcon.addPixmap( button_icon.addPixmap(QtGui.QPixmap.fromImage(icon),
QtGui.QPixmap.fromImage(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
return ButtonIcon return button_icon
def contextMenuAction(base, icon, text, slot): def context_menu_action(base, icon, text, slot):
""" """
Utility method to help build context menus for plugins Utility method to help build context menus for plugins
""" """
@ -122,7 +122,7 @@ def contextMenuAction(base, icon, text, slot):
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot) QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
return action return action
def contextMenu(base, icon, text): def context_menu(base, icon, text):
""" """
Utility method to help build context menus for plugins Utility method to help build context menus for plugins
""" """
@ -130,7 +130,7 @@ def contextMenu(base, icon, text):
action.setIcon(build_icon(icon)) action.setIcon(build_icon(icon))
return action return action
def contextMenuSeparator(base): def context_menu_separator(base):
""" """
Add a separator to a context menu Add a separator to a context menu
""" """
@ -152,12 +152,12 @@ def resize_image(image, width, height):
realw = preview.width() realw = preview.width()
realh = preview.height() realh = preview.height()
# and move it to the centre of the preview space # and move it to the centre of the preview space
newImage = QtGui.QImage(width, height, new_image = QtGui.QImage(width, height,
QtGui.QImage.Format_ARGB32_Premultiplied) QtGui.QImage.Format_ARGB32_Premultiplied)
newImage.fill(QtCore.Qt.black) new_image.fill(QtCore.Qt.black)
painter = QtGui.QPainter(newImage) painter = QtGui.QPainter(new_image)
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
return newImage return new_image
class ThemeLevel(object): class ThemeLevel(object):

View File

@ -28,7 +28,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import contextMenuAction, contextMenuSeparator, \ from openlp.core.lib import context_menu_action, context_menu_separator, \
SettingsManager, OpenLPToolbar, ServiceItem, build_icon SettingsManager, OpenLPToolbar, ServiceItem, build_icon
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -271,34 +271,34 @@ class MediaManagerItem(QtGui.QWidget):
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
if self.hasEditIcon: if self.hasEditIcon:
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_edit.png', self.ListView, u':/general/general_edit.png',
u'%s %s' % (self.trUtf8('&Edit'), self.PluginNameVisible), u'%s %s' % (self.trUtf8('&Edit'), self.PluginNameVisible),
self.onEditClick)) self.onEditClick))
self.ListView.addAction(contextMenuSeparator(self.ListView)) self.ListView.addAction(context_menu_separator(self.ListView))
if self.hasDeleteIcon: if self.hasDeleteIcon:
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_delete.png', self.ListView, u':/general/general_delete.png',
u'%s %s' % (self.trUtf8('&Delete'), self.PluginNameVisible), u'%s %s' % (self.trUtf8('&Delete'), self.PluginNameVisible),
self.onDeleteClick)) self.onDeleteClick))
self.ListView.addAction(contextMenuSeparator(self.ListView)) self.ListView.addAction(context_menu_separator(self.ListView))
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_preview.png', self.ListView, u':/general/general_preview.png',
u'%s %s' % (self.trUtf8('&Preview'), self.PluginNameVisible), u'%s %s' % (self.trUtf8('&Preview'), self.PluginNameVisible),
self.onPreviewClick)) self.onPreviewClick))
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_live.png', self.ListView, u':/general/general_live.png',
self.trUtf8('&Show Live'), self.onLiveClick)) self.trUtf8('&Show Live'), self.onLiveClick))
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_add.png', self.ListView, u':/general/general_add.png',
self.trUtf8('&Add to Service'), self.onAddClick)) self.trUtf8('&Add to Service'), self.onAddClick))
if self.addToServiceItem: if self.addToServiceItem:
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/general/general_add.png', self.ListView, u':/general/general_add.png',
self.trUtf8('&Add to selected Service Item'), self.trUtf8('&Add to selected Service Item'),
self.onAddEditClick)) self.onAddEditClick))
@ -309,8 +309,7 @@ class MediaManagerItem(QtGui.QWidget):
def initialise(self): def initialise(self):
""" """
Implement this method in your descendent media manager item to Implement this method in your descendent media manager item to
do any UI or other initialisation. This method is called do any UI or other initialisation. This method is called automatically.
automatically.
""" """
pass pass
@ -351,8 +350,7 @@ class MediaManagerItem(QtGui.QWidget):
def validate(self, file, thumb): def validate(self, file, thumb):
""" """
Validates to see if the file still exists or Validates to see if the file still exists or thumbnail is up to date
thumbnail is up to date
""" """
if os.path.exists(file): if os.path.exists(file):
filedate = os.stat(file).st_mtime filedate = os.stat(file).st_mtime
@ -467,9 +465,9 @@ class MediaManagerItem(QtGui.QWidget):
""" """
service_item = ServiceItem(self.parent) service_item = ServiceItem(self.parent)
if self.ServiceItemIconName: if self.ServiceItemIconName:
service_item.addIcon(self.ServiceItemIconName) service_item.add_icon(self.ServiceItemIconName)
else: else:
service_item.addIcon( service_item.add_icon(
u':/media/media_' + self.PluginNameShort.lower() + u'.png') u':/media/media_' + self.PluginNameShort.lower() + u'.png')
if self.generateSlideData(service_item, item): if self.generateSlideData(service_item, item):
return service_item return service_item

View File

@ -22,7 +22,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
Provide plugin management
"""
import os import os
import sys import sys
import logging import logging

View File

@ -22,6 +22,10 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`serviceitem` provides the service item functionality including the
type and capability of an item.
"""
import logging import logging
import os import os
@ -43,6 +47,9 @@ class ServiceItemType(object):
Command = 3 Command = 3
class ItemCapabilities(object): class ItemCapabilities(object):
"""
Provides an enumeration of a serviceitem's capabilities
"""
AllowsPreview = 1 AllowsPreview = 1
AllowsEdit = 2 AllowsEdit = 2
AllowsMaintain = 3 AllowsMaintain = 3
@ -66,9 +73,10 @@ class ServiceItem(object):
The plugin that this service item belongs to. The plugin that this service item belongs to.
""" """
if plugin: if plugin:
self.RenderManager = plugin.render_manager self.render_manager = plugin.render_manager
self.name = plugin.name self.name = plugin.name
self.title = u'' self.title = u''
self.shortname = u''
self.audit = u'' self.audit = u''
self.items = [] self.items = []
self.iconic_representation = None self.iconic_representation = None
@ -83,14 +91,27 @@ class ServiceItem(object):
self.capabilities = [] self.capabilities = []
self.is_valid = True self.is_valid = True
self.cache = [] self.cache = []
self.icon = None
def add_capability(self, capability): def add_capability(self, capability):
"""
Add an ItemCapability to a ServiceItem
``capability``
The capability to add
"""
self.capabilities.append(capability) self.capabilities.append(capability)
def is_capable(self, capability): def is_capable(self, capability):
"""
Tell the caller if a ServiceItem has a capability
``capability``
The capability to test for
"""
return capability in self.capabilities return capability in self.capabilities
def addIcon(self, icon): def add_icon(self, icon):
""" """
Add an icon to the service item. This is used when displaying the Add an icon to the service item. This is used when displaying the
service item in the service manager. service item in the service manager.
@ -112,12 +133,12 @@ class ServiceItem(object):
if self.service_item_type == ServiceItemType.Text: if self.service_item_type == ServiceItemType.Text:
log.debug(u'Formatting slides') log.debug(u'Formatting slides')
if self.theme is None: if self.theme is None:
self.RenderManager.set_override_theme(None) self.render_manager.set_override_theme(None)
else: else:
self.RenderManager.set_override_theme(self.theme) self.render_manager.set_override_theme(self.theme)
for slide in self._raw_frames: for slide in self._raw_frames:
before = time.time() before = time.time()
formated = self.RenderManager.format_slide(slide[u'raw_slide']) formated = self.render_manager.format_slide(slide[u'raw_slide'])
for format in formated: for format in formated:
lines = u'' lines = u''
title = u'' title = u''
@ -132,9 +153,8 @@ class ServiceItem(object):
log.log(15, u'Formatting took %4s' % (time.time() - before)) log.log(15, u'Formatting took %4s' % (time.time() - before))
elif self.service_item_type == ServiceItemType.Image: elif self.service_item_type == ServiceItemType.Image:
for slide in self._raw_frames: for slide in self._raw_frames:
slide[u'image'] = \ slide[u'image'] = resize_image(slide[u'image'],
resize_image(slide[u'image'], self.RenderManager.width, self.render_manager.width, self.render_manager.height)
self.RenderManager.height)
elif self.service_item_type == ServiceItemType.Command: elif self.service_item_type == ServiceItemType.Command:
pass pass
else: else:
@ -148,19 +168,19 @@ class ServiceItem(object):
""" """
log.debug(u'render individual') log.debug(u'render individual')
if self.theme is None: if self.theme is None:
self.RenderManager.set_override_theme(None) self.render_manager.set_override_theme(None)
else: else:
self.RenderManager.set_override_theme(self.theme) self.render_manager.set_override_theme(self.theme)
format = self._display_frames[row][u'text'].split(u'\n') format = self._display_frames[row][u'text'].split(u'\n')
#if screen blank then do not display footer #if screen blank then do not display footer
if self.cache[row] is not None: if self.cache[row] is not None:
frame = self.cache[row] frame = self.cache[row]
else: else:
if format[0]: if format[0]:
frame = self.RenderManager.generate_slide(format, frame = self.render_manager.generate_slide(format,
self.raw_footer) self.raw_footer)
else: else:
frame = self.RenderManager.generate_slide(format, u'') frame = self.render_manager.generate_slide(format, u'')
self.cache[row] = frame self.cache[row] = frame
return frame return frame
@ -181,7 +201,7 @@ class ServiceItem(object):
self._raw_frames.append( self._raw_frames.append(
{u'title': title, u'image': image, u'path': path}) {u'title': title, u'image': image, u'path': path})
def add_from_text(self, title, raw_slide, verseTag=None): def add_from_text(self, title, raw_slide, verse_tag=None):
""" """
Add a text slide to the service item. Add a text slide to the service item.
@ -194,7 +214,7 @@ class ServiceItem(object):
self.service_item_type = ServiceItemType.Text self.service_item_type = ServiceItemType.Text
title = title.split(u'\n')[0] title = title.split(u'\n')[0]
self._raw_frames.append( self._raw_frames.append(
{u'title': title, u'raw_slide': raw_slide, u'verseTag':verseTag}) {u'title': title, u'raw_slide': raw_slide, u'verseTag':verse_tag})
def add_from_command(self, path, file_name, image): def add_from_command(self, path, file_name, image):
""" """
@ -261,7 +281,7 @@ class ServiceItem(object):
self.service_item_type = header[u'type'] self.service_item_type = header[u'type']
self.shortname = header[u'plugin'] self.shortname = header[u'plugin']
self.theme = header[u'theme'] self.theme = header[u'theme']
self.addIcon(header[u'icon']) self.add_icon(header[u'icon'])
self.raw_footer = header[u'footer'] self.raw_footer = header[u'footer']
self.audit = header[u'audit'] self.audit = header[u'audit']
self.notes = header[u'notes'] self.notes = header[u'notes']
@ -304,22 +324,40 @@ class ServiceItem(object):
return self._uuid != other._uuid return self._uuid != other._uuid
def is_media(self): def is_media(self):
"""
Confirms if the ServiceItem is media
"""
return ItemCapabilities.RequiresMedia in self.capabilities return ItemCapabilities.RequiresMedia in self.capabilities
def is_command(self): def is_command(self):
"""
Confirms if the ServiceItem is a command
"""
return self.service_item_type == ServiceItemType.Command return self.service_item_type == ServiceItemType.Command
def is_image(self): def is_image(self):
"""
Confirms if the ServiceItem is an image
"""
return self.service_item_type == ServiceItemType.Image return self.service_item_type == ServiceItemType.Image
def uses_file(self): def uses_file(self):
"""
Confirms if the ServiceItem uses a file
"""
return self.service_item_type == ServiceItemType.Image or \ return self.service_item_type == ServiceItemType.Image or \
self.service_item_type == ServiceItemType.Command self.service_item_type == ServiceItemType.Command
def is_text(self): def is_text(self):
"""
Confirms if the ServiceItem is text
"""
return self.service_item_type == ServiceItemType.Text return self.service_item_type == ServiceItemType.Text
def get_frames(self): def get_frames(self):
"""
Returns the frames for the ServiceItem
"""
if self.service_item_type == ServiceItemType.Text: if self.service_item_type == ServiceItemType.Text:
return self._display_frames return self._display_frames
else: else:

View File

@ -22,6 +22,20 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`songxmlhandler` module provides the XML functionality for songs
The basic XML is of the format::
<?xml version="1.0" encoding="UTF-8"?>
<song version="1.0">
<lyrics language="en">
<verse type="chorus" label="1">
<![CDATA[ ... ]]>
</verse>
</lyrics>
</song>
"""
import logging import logging
@ -34,17 +48,6 @@ log = logging.getLogger(__name__)
class SongXMLBuilder(object): class SongXMLBuilder(object):
""" """
This class builds the XML used to describe songs. This class builds the XML used to describe songs.
The basic XML looks like this::
<?xml version="1.0" encoding="UTF-8"?>
<song version="1.0">
<lyrics language="en">
<verse type="chorus" label="1">
<![CDATA[ ... ]]>
</verse>
</lyrics>
</song>
""" """
log.info(u'SongXMLBuilder Loaded') log.info(u'SongXMLBuilder Loaded')
@ -113,17 +116,6 @@ class SongXMLBuilder(object):
class SongXMLParser(object): class SongXMLParser(object):
""" """
A class to read in and parse a song's XML. A class to read in and parse a song's XML.
The basic XML looks like this::
<?xml version="1.0" encoding="UTF-8"?>
<song version="1.0">
<lyrics language="en">
<verse type="chorus" label="1">
<![CDATA[ ... ]]>
</verse>
</lyrics>
</song>
""" """
log.info(u'SongXMLParser Loaded') log.info(u'SongXMLParser Loaded')

View File

@ -41,7 +41,7 @@ class XmlRootClass(object):
(element.tag, val) = self.post_tag_hook(element.tag, val) (element.tag, val) = self.post_tag_hook(element.tag, val)
""" """
def _setFromXml(self, xml, root_tag): def _set_from_xml(self, xml, root_tag):
""" """
Set song properties from given xml content. Set song properties from given xml content.

View File

@ -22,6 +22,12 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
OpenLP version 1 theme handling
Provides reference data, a default v1 XML theme and class wrapper for
processing version 1 themes in OpenLP version 2.
"""
from xml.etree.ElementTree import ElementTree, XML from xml.etree.ElementTree import ElementTree, XML
from PyQt4 import QtGui from PyQt4 import QtGui
@ -54,51 +60,106 @@ BLANK_STYLE_XML = \
''' '''
class Theme(object): class Theme(object):
"""
Provide a class wrapper storing data from an XML theme
``name``
Theme name
``BackgroundMode``
The behaviour of the background. Valid modes are:
- 0 - Transparent
- 1 - Opaque
``BackgroundType``
The content of the background. Valid types are:
- 0 - solid color
- 1 - gradient color
- 2 - image
``BackgroundParameter1``
Extra information about the background. The contents of this attribute
depend on the BackgroundType:
- image: image filename
- gradient: start color
- solid: color
``BackgroundParameter2``
Extra information about the background. The contents of this attribute
depend on the BackgroundType:
- image: border color
- gradient: end color
- solid: N/A
``BackgroundParameter3``
Extra information about the background. The contents of this attribute
depend on the BackgroundType:
- image: N/A
- gradient: The direction of the gradient. Valid entries are:
- 0 -> vertical
- 1 -> horizontal
- solid: N/A
``FontName``
Name of the font to use for the main font.
``FontColor``
The color for the main font
``FontProportion``
The size of the main font
``FontUnits``
The units for FontProportion, either <pixels> or <points>
``Shadow``
The shadow type to apply to the main font.
- 0 - no shadow
- non-zero - use shadow
``ShadowColor``
Color for the shadow
``Outline``
The outline to apply to the main font
- 0 - no outline
- non-zero - use outline
``OutlineColor``
Color for the outline (or None if Outline is 0)
``HorizontalAlign``
The horizontal alignment to apply to text. Valid alignments are:
- 0 - left align
- 1 - right align
- 2 - centre align
``VerticalAlign``
The vertical alignment to apply to the text. Valid alignments are:
- 0 - top align
- 1 - bottom align
- 2 - centre align
``WrapStyle``
The wrap style to apply to the text. Valid styles are:
- 0 - normal
- 1 - lyrics
"""
def __init__(self, xml): def __init__(self, xml):
""" stores the info about a theme """
attributes: Initialise a theme with data from xml
name : theme name
BackgroundMode : 1 - Transparent ``xml``
1 - Opaque The data to initialise the theme with
BackgroundType : 0 - solid color
1 - gradient color
2 - image
BackgroundParameter1 : for image - filename
for gradient - start color
for solid - color
BackgroundParameter2 : for image - border colour
for gradient - end color
for solid - N/A
BackgroundParameter3 : for image - N/A
for gradient - 0 -> vertical, 1 -> horizontal
FontName : name of font to use
FontColor : color for main font
FontProportion : size of font
FontUnits : whether size of font is in <pixels> or <points>
Shadow : 0 - no shadow, non-zero use shadow
ShadowColor : color for drop shadow
Outline : 0 - no outline, non-zero use outline
OutlineColor : color for outline (or None for no outline)
HorizontalAlign : 0 - left align
1 - right align
2 - centre align
VerticalAlign : 0 - top align
1 - bottom align
2 - centre align
WrapStyle : 0 - normal
1 - lyrics
""" """
# init to defaults # init to defaults
self._set_from_XML(BLANK_STYLE_XML) self._set_from_xml(BLANK_STYLE_XML)
self._set_from_XML(xml) self._set_from_xml(xml)
def _get_as_string(self): def _get_as_string(self):
"""
Return single line string representation of a theme
"""
theme_strings = [] theme_strings = []
keys = dir(self) keys = dir(self)
keys.sort() keys.sort()
@ -108,10 +169,16 @@ class Theme(object):
return u''.join(theme_strings) return u''.join(theme_strings)
def _set_from_XML(self, xml): def _set_from_XML(self, xml):
"""
Set theme class attributes with data from XML
``xml``
The data to apply to the theme
"""
root = ElementTree(element=XML(xml)) root = ElementTree(element=XML(xml))
iter = root.getiterator() xml_iter = root.getiterator()
for element in iter: for element in xml_iter:
delphiColorChange = False delphi_color_change = False
if element.tag != u'Theme': if element.tag != u'Theme':
element_text = element.text element_text = element.text
val = 0 val = 0
@ -127,7 +194,7 @@ class Theme(object):
pass pass
elif DELPHI_COLORS.has_key(element_text): elif DELPHI_COLORS.has_key(element_text):
val = DELPHI_COLORS[element_text] val = DELPHI_COLORS[element_text]
delphiColorChange = True delphi_color_change = True
else: else:
try: try:
val = int(element_text) val = int(element_text)
@ -137,7 +204,7 @@ class Theme(object):
(element.tag.find(u'BackgroundParameter') == 0 and (element.tag.find(u'BackgroundParameter') == 0 and
type(val) == type(0))): type(val) == type(0))):
# convert to a wx.Colour # convert to a wx.Colour
if not delphiColorChange: if not delphi_color_change:
val = QtGui.QColor( val = QtGui.QColor(
val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF) val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF)
else: else:
@ -146,8 +213,12 @@ class Theme(object):
setattr(self, element.tag, val) setattr(self, element.tag, val)
def __str__(self): def __str__(self):
"""
Provide Python string representation for the class (multiline output)
"""
theme_strings = [] theme_strings = []
for key in dir(self): for key in dir(self):
if key[0:1] != u'_': if key[0:1] != u'_':
theme_strings.append(u'%30s : %s' % (key, getattr(self, key))) theme_strings.append(u'%30s : %s' % (key, getattr(self, key)))
return u'\n'.join(theme_strings) return u'\n'.join(theme_strings)

View File

@ -22,6 +22,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`ui` module provides the core user interface for OpenLP
"""
class HideMode(object): class HideMode(object):
""" """

View File

@ -239,12 +239,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onFontMainColorPushButtonClicked(self): def onFontMainColorPushButtonClicked(self):
self.theme.font_main_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.font_main_color), self).name() QtGui.QColor(self.theme.font_main_color), self)
if new_color.isValid():
self.FontMainColorPushButton.setStyleSheet( self.theme.font_main_color = new_color.name()
u'background-color: %s' % unicode(self.theme.font_main_color)) self.FontMainColorPushButton.setStyleSheet(
self.previewTheme() u'background-color: %s' % unicode(self.theme.font_main_color))
self.previewTheme()
def onFontMainSizeSpinBoxChanged(self): def onFontMainSizeSpinBoxChanged(self):
if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value(): if self.theme.font_main_proportion != self.FontMainSizeSpinBox.value():
@ -332,11 +333,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onFontFooterColorPushButtonClicked(self): def onFontFooterColorPushButtonClicked(self):
self.theme.font_footer_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.font_footer_color), self).name() QtGui.QColor(self.theme.font_footer_color), self)
self.FontFooterColorPushButton.setStyleSheet( if new_color.isValid():
'background-color: %s' % unicode(self.theme.font_footer_color)) self.theme.font_footer_color = new_color.name()
self.previewTheme() self.FontFooterColorPushButton.setStyleSheet(
u'background-color: %s' % unicode(self.theme.font_footer_color))
self.previewTheme()
def onFontFooterSizeSpinBoxChanged(self): def onFontFooterSizeSpinBoxChanged(self):
if self.theme.font_footer_proportion != \ if self.theme.font_footer_proportion != \
@ -431,24 +434,29 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
def onColor1PushButtonClicked(self): def onColor1PushButtonClicked(self):
if self.theme.background_type == u'solid': if self.theme.background_type == u'solid':
self.theme.background_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.background_color), self).name() QtGui.QColor(self.theme.background_color), self)
self.Color1PushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.background_color)) self.theme.background_color = new_color.name()
self.Color1PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_color))
else: else:
self.theme.background_startColor = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.background_startColor), self).name() QtGui.QColor(self.theme.background_startColor), self)
self.Color1PushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % \ self.theme.background_startColor = new_color.name()
self.Color1PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_startColor)) unicode(self.theme.background_startColor))
self.previewTheme() self.previewTheme()
def onColor2PushButtonClicked(self): def onColor2PushButtonClicked(self):
self.theme.background_endColor = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.background_endColor), self).name() QtGui.QColor(self.theme.background_endColor), self)
self.Color2PushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.background_endColor)) self.theme.background_endColor = new_color.name()
self.previewTheme() self.Color2PushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.background_endColor))
self.previewTheme()
# #
#Other Tab #Other Tab
@ -472,11 +480,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onOutlineColorPushButtonClicked(self): def onOutlineColorPushButtonClicked(self):
self.theme.display_outline_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.display_outline_color), self).name() QtGui.QColor(self.theme.display_outline_color), self)
self.OutlineColorPushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.display_outline_color)) self.theme.display_outline_color = new_color.name()
self.previewTheme() self.OutlineColorPushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.display_outline_color))
self.previewTheme()
def onShadowCheckBoxChanged(self, value): def onShadowCheckBoxChanged(self, value):
if value == 2: # checked if value == 2: # checked
@ -495,11 +505,13 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
self.previewTheme() self.previewTheme()
def onShadowColorPushButtonClicked(self): def onShadowColorPushButtonClicked(self):
self.theme.display_shadow_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.theme.display_shadow_color), self).name() QtGui.QColor(self.theme.display_shadow_color), self)
self.ShadowColorPushButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % unicode(self.theme.display_shadow_color)) self.theme.display_shadow_color = new_color.name()
self.previewTheme() self.ShadowColorPushButton.setStyleSheet(u'background-color: %s' %
unicode(self.theme.display_shadow_color))
self.previewTheme()
def onHorizontalComboBoxSelected(self, currentIndex): def onHorizontalComboBoxSelected(self, currentIndex):
self.theme.display_horizontalAlign = currentIndex self.theme.display_horizontalAlign = currentIndex

View File

@ -29,16 +29,19 @@ from openlp.core.lib import SettingsTab, Receiver, translate
class DisplayTab(SettingsTab): class DisplayTab(SettingsTab):
""" """
Class documentation goes here. Provide the UI for managing display related settings
""" """
def __init__(self, screens): def __init__(self, screens):
""" """
Constructor Initialise the display tab from a SettingsTab
""" """
self.screens = screens self.screens = screens
SettingsTab.__init__(self, u'Display') SettingsTab.__init__(self, u'Display')
def setupUi(self): def setupUi(self):
"""
Set up the UI widgets to show the settings
"""
self.tabTitleVisible = translate(u'DisplayTab', u'Displays') self.tabTitleVisible = translate(u'DisplayTab', u'Displays')
self.layoutWidget = QtGui.QWidget(self) self.layoutWidget = QtGui.QWidget(self)
self.layoutWidget.setGeometry(QtCore.QRect(0, 40, 241, 79)) self.layoutWidget.setGeometry(QtCore.QRect(0, 40, 241, 79))
@ -158,6 +161,9 @@ class DisplayTab(SettingsTab):
QtCore.SIGNAL(u'stateChanged(int)'), self.onOverrideCheckBoxChanged) QtCore.SIGNAL(u'stateChanged(int)'), self.onOverrideCheckBoxChanged)
def retranslateUi(self): def retranslateUi(self):
"""
Provide i18n support for this UI
"""
self.setWindowTitle(translate(u'DisplayTab', u'Amend Display Settings')) self.setWindowTitle(translate(u'DisplayTab', u'Amend Display Settings'))
self.CurrentGroupBox.setTitle( self.CurrentGroupBox.setTitle(
translate(u'DisplayTab', u'Default Settings')) translate(u'DisplayTab', u'Default Settings'))
@ -179,6 +185,9 @@ class DisplayTab(SettingsTab):
translate(u'DisplayTab', u'Override Output Display')) translate(u'DisplayTab', u'Override Output Display'))
def load(self): def load(self):
"""
Load current display settings
"""
settings = QtCore.QSettings() settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection) settings.beginGroup(self.settingsSection)
self.Xpos.setText(unicode(self.screens.current[u'size'].x())) self.Xpos.setText(unicode(self.screens.current[u'size'].x()))
@ -209,6 +218,9 @@ class DisplayTab(SettingsTab):
self.amend_display = True self.amend_display = True
def save(self): def save(self):
"""
Save chosen settings
"""
settings = QtCore.QSettings() settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection) settings.beginGroup(self.settingsSection)
settings.setValue('x position', QtCore.QVariant(self.XposEdit.text())) settings.setValue('x position', QtCore.QVariant(self.XposEdit.text()))

View File

@ -133,7 +133,6 @@ class MainDisplay(DisplayWidget):
self.display_alert = QtGui.QLabel(self) self.display_alert = QtGui.QLabel(self)
self.display_alert.setScaledContents(True) self.display_alert.setScaledContents(True)
self.primary = True self.primary = True
self.displayBlank = False
self.blankFrame = None self.blankFrame = None
self.frame = None self.frame = None
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -280,15 +279,15 @@ class MainDisplay(DisplayWidget):
self.display_alert.setPixmap(frame) self.display_alert.setPixmap(frame)
self.moveToTop() self.moveToTop()
def frameView(self, frame, transition=False): def frameView(self, frame, transition=False, display=True):
""" """
Called from a slide controller to display a frame Called from a slide controller to display a frame
if the alert is in progress the alert is added on top if the alert is in progress the alert is added on top
``frame`` ``frame``
Image frame to be rendered Image frame to be rendered
""" """
log.debug(u'frameView %d' % (self.displayBlank)) log.debug(u'frameView %d' % (display))
if not self.displayBlank: if display:
if transition: if transition:
if self.frame is not None: if self.frame is not None:
self.display_text.setPixmap( self.display_text.setPixmap(
@ -314,8 +313,7 @@ class MainDisplay(DisplayWidget):
self.setVisible(True) self.setVisible(True)
self.showFullScreen() self.showFullScreen()
else: else:
self.waitingFrame = frame self.storeText = QtGui.QPixmap.fromImage(frame[u'main'])
self.waitingFrameTrans = transition
class VideoDisplay(Phonon.VideoWidget): class VideoDisplay(Phonon.VideoWidget):
""" """

View File

@ -356,7 +356,7 @@ class Ui_MainWindow(object):
""" """
MainWindow.mainTitle = translate(u'MainWindow', u'OpenLP 2.0') MainWindow.mainTitle = translate(u'MainWindow', u'OpenLP 2.0')
MainWindow.language = translate(u'MainWindow', u'English') MainWindow.language = translate(u'MainWindow', u'English')
MainWindow.defaultThemeText = translate(u'MainWindow', MainWindow.defaultThemeText = translate(u'MainWindow',
u'Default Theme: ') u'Default Theme: ')
MainWindow.setWindowTitle(MainWindow.mainTitle) MainWindow.setWindowTitle(MainWindow.mainTitle)
self.FileMenu.setTitle(translate(u'MainWindow', u'&File')) self.FileMenu.setTitle(translate(u'MainWindow', u'&File'))
@ -456,7 +456,7 @@ class Ui_MainWindow(object):
u'Set the interface language to %1').arg(item.objectName())) u'Set the interface language to %1').arg(item.objectName()))
self.ToolsAddToolItem.setText(translate(u'MainWindow', u'Add &Tool...')) self.ToolsAddToolItem.setText(translate(u'MainWindow', u'Add &Tool...'))
self.ToolsAddToolItem.setStatusTip( self.ToolsAddToolItem.setStatusTip(
translate(u'MainWindow', translate(u'MainWindow',
u'Add an application to the list of tools')) u'Add an application to the list of tools'))
self.action_Preview_Panel.setText( self.action_Preview_Panel.setText(
translate(u'MainWindow', u'&Preview Pane')) translate(u'MainWindow', u'&Preview Pane'))
@ -652,15 +652,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
""" """
settings = QtCore.QSettings() settings = QtCore.QSettings()
settings.beginGroup(self.generalSettingsSection) settings.beginGroup(self.generalSettingsSection)
if settings.value(u'screen blank', QtCore.QVariant(False)).toBool() \ if settings.value(u'screen blank', QtCore.QVariant(False)).toBool():
and settings.value(u'blank warning', QtCore.QVariant(False)).toBool(): self.LiveController.mainDisplaySetBackground()
self.LiveController.onBlankDisplay(True) if settings.value(u'blank warning', QtCore.QVariant(False)).toBool():
QtGui.QMessageBox.question(self, QtGui.QMessageBox.question(self,
translate(u'MainWindow', u'OpenLP Main Display Blanked'), translate(u'MainWindow', u'OpenLP Main Display Blanked'),
translate(u'MainWindow', translate(u'MainWindow',
u'The Main Display has been blanked out'), u'The Main Display has been blanked out'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok),
QtGui.QMessageBox.Ok)
settings.endGroup() settings.endGroup()
def versionThread(self): def versionThread(self):

View File

@ -28,11 +28,25 @@ import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class MediaDockManager(object): class MediaDockManager(object):
"""
Provide a repository for MediaManagerItems
"""
def __init__(self, media_dock): def __init__(self, media_dock):
"""
Initialise the media dock
"""
self.media_dock = media_dock self.media_dock = media_dock
def add_dock(self, media_item, icon, weight): def add_dock(self, media_item, icon, weight):
"""
Add a MediaManagerItem to the dock
``media_item``
The item to add to the dock
``icon``
An icon for this dock item
"""
log.info(u'Adding %s dock' % media_item.title) log.info(u'Adding %s dock' % media_item.title)
self.media_dock.addItem(media_item, icon, media_item.title) self.media_dock.addItem(media_item, icon, media_item.title)
@ -53,6 +67,12 @@ class MediaDockManager(object):
self.media_dock.addItem(media_item, icon, media_item.title) self.media_dock.addItem(media_item, icon, media_item.title)
def remove_dock(self, name): def remove_dock(self, name):
"""
Removes a MediaManagerItem from the dock
``name``
The item to remove
"""
log.debug(u'remove %s dock' % name) log.debug(u'remove %s dock' % name)
for dock_index in range(0, self.media_dock.count()): for dock_index in range(0, self.media_dock.count()):
if self.media_dock.widget(dock_index): if self.media_dock.widget(dock_index):

View File

@ -22,7 +22,10 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`screen` module provides management functionality for a machines'
displays
"""
import logging import logging
import copy import copy
@ -46,12 +49,18 @@ class ScreenList(object):
self.monitor_number = 0 self.monitor_number = 0
def add_screen(self, screen): def add_screen(self, screen):
"""
Add a screen to the list of known screens
"""
if screen[u'primary']: if screen[u'primary']:
self.current = screen self.current = screen
self.screen_list.append(screen) self.screen_list.append(screen)
self.display_count += 1 self.display_count += 1
def screen_exists(self, number): def screen_exists(self, number):
"""
Confirms a screen is known
"""
for screen in self.screen_list: for screen in self.screen_list:
if screen[u'number'] == number: if screen[u'number'] == number:
return True return True

View File

@ -32,13 +32,15 @@ log = logging.getLogger(__name__)
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import OpenLPToolbar, ServiceItem, contextMenuAction, \ from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \
Receiver, build_icon, ItemCapabilities, SettingsManager, translate Receiver, build_icon, ItemCapabilities, SettingsManager, translate
from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
class ServiceManagerList(QtGui.QTreeWidget): class ServiceManagerList(QtGui.QTreeWidget):
"""
Set up key bindings and mouse behaviour for the service list
"""
def __init__(self, parent=None, name=None): def __init__(self, parent=None, name=None):
QtGui.QTreeWidget.__init__(self, parent) QtGui.QTreeWidget.__init__(self, parent)
self.parent = parent self.parent = parent
@ -952,7 +954,7 @@ class ServiceManager(QtGui.QWidget):
self.ThemeComboBox.addItem(u'') self.ThemeComboBox.addItem(u'')
for theme in theme_list: for theme in theme_list:
self.ThemeComboBox.addItem(theme) self.ThemeComboBox.addItem(theme)
action = contextMenuAction( action = context_menu_action(
self.ServiceManagerList, self.ServiceManagerList,
None, None,
theme , self.onThemeChangeAction) theme , self.onThemeChangeAction)

View File

@ -22,7 +22,9 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`settingsform` provides a user interface for the OpenLP settings
"""
import logging import logging
from PyQt4 import QtGui from PyQt4 import QtGui
@ -33,8 +35,13 @@ from settingsdialog import Ui_SettingsDialog
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
"""
Provide the form to manipulate the settings for OpenLP
"""
def __init__(self, screens, mainWindow, parent=None): def __init__(self, screens, mainWindow, parent=None):
"""
Initialise the settings form
"""
QtGui.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
# General tab # General tab
@ -48,16 +55,25 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
self.addTab(u'Display', self.DisplayTab) self.addTab(u'Display', self.DisplayTab)
def addTab(self, name, tab): def addTab(self, name, tab):
"""
Add a tab to the form
"""
log.info(u'Adding %s tab' % tab.tabTitle) log.info(u'Adding %s tab' % tab.tabTitle)
self.SettingsTabWidget.addTab(tab, tab.tabTitleVisible) self.SettingsTabWidget.addTab(tab, tab.tabTitleVisible)
def insertTab(self, tab, location): def insertTab(self, tab, location):
"""
Add a tab to the form at a specific location
"""
log.debug(u'Inserting %s tab' % tab.tabTitle) log.debug(u'Inserting %s tab' % tab.tabTitle)
#13 : There are 3 tables currently and locations starts at -10 #13 : There are 3 tables currently and locations starts at -10
self.SettingsTabWidget.insertTab( self.SettingsTabWidget.insertTab(
location + 13, tab, tab.tabTitleVisible) location + 13, tab, tab.tabTitleVisible)
def removeTab(self, name): def removeTab(self, name):
"""
Remove a tab from the form
"""
log.debug(u'remove %s tab' % name) log.debug(u'remove %s tab' % name)
for tab_index in range(0, self.SettingsTabWidget.count()): for tab_index in range(0, self.SettingsTabWidget.count()):
if self.SettingsTabWidget.widget(tab_index): if self.SettingsTabWidget.widget(tab_index):
@ -65,10 +81,16 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
self.SettingsTabWidget.removeTab(tab_index) self.SettingsTabWidget.removeTab(tab_index)
def accept(self): def accept(self):
"""
Process the form saving the settings
"""
for tab_index in range(0, self.SettingsTabWidget.count()): for tab_index in range(0, self.SettingsTabWidget.count()):
self.SettingsTabWidget.widget(tab_index).save() self.SettingsTabWidget.widget(tab_index).save()
return QtGui.QDialog.accept(self) return QtGui.QDialog.accept(self)
def postSetUp(self): def postSetUp(self):
"""
Run any post-setup code for the tabs on the form
"""
for tab_index in range(0, self.SettingsTabWidget.count()): for tab_index in range(0, self.SettingsTabWidget.count()):
self.SettingsTabWidget.widget(tab_index).postSetUp() self.SettingsTabWidget.widget(tab_index).postSetUp()

View File

@ -120,6 +120,7 @@ class SlideController(QtGui.QWidget):
self.serviceItem = None self.serviceItem = None
self.Panel = QtGui.QWidget(parent.ControlSplitter) self.Panel = QtGui.QWidget(parent.ControlSplitter)
self.slideList = {} self.slideList = {}
self.canDisplay = True
# Layout for holding panel # Layout for holding panel
self.PanelLayout = QtGui.QVBoxLayout(self.Panel) self.PanelLayout = QtGui.QVBoxLayout(self.Panel)
self.PanelLayout.setSpacing(0) self.PanelLayout.setSpacing(0)
@ -651,6 +652,12 @@ class SlideController(QtGui.QWidget):
self.PreviewListWidget.selectRow(index) self.PreviewListWidget.selectRow(index)
self.onSlideSelected() self.onSlideSelected()
def mainDisplaySetBackground(self):
"""
Allow the main display to blank the main display at startup time
"""
self.blankButton.setChecked(True)
def onSlideBlank(self): def onSlideBlank(self):
""" """
Handle the slidecontroller blank event Handle the slidecontroller blank event
@ -670,6 +677,7 @@ class SlideController(QtGui.QWidget):
log.debug(u'onBlankDisplay %d' % checked) log.debug(u'onBlankDisplay %d' % checked)
self.hideButton.setChecked(False) self.hideButton.setChecked(False)
self.themeButton.setChecked(False) self.themeButton.setChecked(False)
self.canDisplay = not checked
QtCore.QSettings().setValue( QtCore.QSettings().setValue(
self.parent.generalSettingsSection + u'/screen blank', self.parent.generalSettingsSection + u'/screen blank',
QtCore.QVariant(checked)) QtCore.QVariant(checked))
@ -687,6 +695,7 @@ class SlideController(QtGui.QWidget):
log.debug(u'onThemeDisplay %d' % checked) log.debug(u'onThemeDisplay %d' % checked)
self.blankButton.setChecked(False) self.blankButton.setChecked(False)
self.hideButton.setChecked(False) self.hideButton.setChecked(False)
self.canDisplay = False
if checked: if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Theme) Receiver.send_message(u'maindisplay_hide', HideMode.Theme)
self.blankPlugin(True) self.blankPlugin(True)
@ -701,6 +710,7 @@ class SlideController(QtGui.QWidget):
log.debug(u'onHideDisplay %d' % checked) log.debug(u'onHideDisplay %d' % checked)
self.blankButton.setChecked(False) self.blankButton.setChecked(False)
self.themeButton.setChecked(False) self.themeButton.setChecked(False)
self.canDisplay = False
if checked: if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Screen) Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
self.hidePlugin(True) self.hidePlugin(True)
@ -710,7 +720,7 @@ class SlideController(QtGui.QWidget):
def blankPlugin(self, blank): def blankPlugin(self, blank):
""" """
Blank the display screen. Blank the display screen within a plugin if required.
""" """
if self.serviceItem is not None: if self.serviceItem is not None:
if blank: if blank:
@ -770,7 +780,7 @@ class SlideController(QtGui.QWidget):
log.log( log.log(
15, u'Slide Rendering took %4s' % (time.time() - before)) 15, u'Slide Rendering took %4s' % (time.time() - before))
if self.isLive: if self.isLive:
self.mainDisplay.frameView(frame, True) self.mainDisplay.frameView(frame, True, self.canDisplay)
self.selectedRow = row self.selectedRow = row
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix, Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix,
row) row)

View File

@ -33,9 +33,9 @@ from PyQt4 import QtCore, QtGui
from openlp.core.ui import AmendThemeForm from openlp.core.ui import AmendThemeForm
from openlp.core.theme import Theme from openlp.core.theme import Theme
from openlp.core.lib import OpenLPToolbar, contextMenuAction, \ from openlp.core.lib import OpenLPToolbar, context_menu_action, \
ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \ ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \
contextMenuSeparator, SettingsManager, translate context_menu_separator, SettingsManager, translate
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -81,27 +81,28 @@ class ThemeManager(QtGui.QWidget):
self.Layout.addWidget(self.ThemeListWidget) self.Layout.addWidget(self.ThemeListWidget)
self.ThemeListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ThemeListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuAction(self.ThemeListWidget, u':/themes/theme_edit.png', context_menu_action(self.ThemeListWidget,
u':/themes/theme_edit.png',
translate(u'ThemeManager', u'Edit a theme'), self.onEditTheme)) translate(u'ThemeManager', u'Edit a theme'), self.onEditTheme))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuSeparator(self.ThemeListWidget)) context_menu_separator(self.ThemeListWidget))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuAction(self.ThemeListWidget, context_menu_action(self.ThemeListWidget,
u':/general/general_delete.png', u':/general/general_delete.png',
translate(u'ThemeManager', u'Delete theme'), translate(u'ThemeManager', u'Delete theme'),
self.onDeleteTheme)) self.onDeleteTheme))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuAction(self.ThemeListWidget, context_menu_action(self.ThemeListWidget,
u':/general/general_export.png', u':/general/general_export.png',
translate(u'ThemeManager', u'Make Global'), translate(u'ThemeManager', u'Make Global'),
self.changeGlobalFromScreen)) self.changeGlobalFromScreen))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuAction(self.ThemeListWidget, context_menu_action(self.ThemeListWidget,
u':/general/general_export.png', u':/general/general_export.png',
translate(u'ThemeManager', u'Export theme'), translate(u'ThemeManager', u'Export theme'),
self.onExportTheme)) self.onExportTheme))
self.ThemeListWidget.addAction( self.ThemeListWidget.addAction(
contextMenuSeparator(self.ThemeListWidget)) context_menu_separator(self.ThemeListWidget))
#Signals #Signals
QtCore.QObject.connect(self.ThemeListWidget, QtCore.QObject.connect(self.ThemeListWidget,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
@ -121,6 +122,10 @@ class ThemeManager(QtGui.QWidget):
QtCore.QVariant(u'')).toString()) QtCore.QVariant(u'')).toString())
def changeGlobalFromTab(self, themeName): def changeGlobalFromTab(self, themeName):
"""
Change the global theme when it is changed through the Themes settings
tab
"""
log.debug(u'changeGlobalFromTab %s', themeName) log.debug(u'changeGlobalFromTab %s', themeName)
for count in range (0, self.ThemeListWidget.count()): for count in range (0, self.ThemeListWidget.count()):
#reset the old name #reset the old name
@ -136,6 +141,10 @@ class ThemeManager(QtGui.QWidget):
self.ThemeListWidget.item(count).setText(name) self.ThemeListWidget.item(count).setText(name)
def changeGlobalFromScreen(self, index = -1): def changeGlobalFromScreen(self, index = -1):
"""
Change the global theme when a theme is double clicked upon in the
Theme Manager list
"""
log.debug(u'changeGlobalFromScreen %s', index) log.debug(u'changeGlobalFromScreen %s', index)
selected_row = self.ThemeListWidget.currentRow() selected_row = self.ThemeListWidget.currentRow()
for count in range (0, self.ThemeListWidget.count()): for count in range (0, self.ThemeListWidget.count()):
@ -159,12 +168,20 @@ class ThemeManager(QtGui.QWidget):
self.pushThemes() self.pushThemes()
def onAddTheme(self): def onAddTheme(self):
"""
Loads a new theme with the default settings and then launches the theme
editing form for the user to make their customisations.
"""
theme = self.createThemeFromXml(self.baseTheme(), self.path) theme = self.createThemeFromXml(self.baseTheme(), self.path)
self.amendThemeForm.loadTheme(theme) self.amendThemeForm.loadTheme(theme)
self.saveThemeName = u'' self.saveThemeName = u''
self.amendThemeForm.exec_() self.amendThemeForm.exec_()
def onEditTheme(self): def onEditTheme(self):
"""
Loads the settings for the theme that is to be edited and launches the
theme editing form so the user can make their changes.
"""
item = self.ThemeListWidget.currentItem() item = self.ThemeListWidget.currentItem()
if item: if item:
theme = self.getThemeData( theme = self.getThemeData(
@ -175,6 +192,9 @@ class ThemeManager(QtGui.QWidget):
self.amendThemeForm.exec_() self.amendThemeForm.exec_()
def onDeleteTheme(self): def onDeleteTheme(self):
"""
Delete a theme
"""
self.global_theme = unicode(QtCore.QSettings().value( self.global_theme = unicode(QtCore.QSettings().value(
self.settingsSection + u'/global theme', self.settingsSection + u'/global theme',
QtCore.QVariant(u'')).toString()) QtCore.QVariant(u'')).toString())
@ -262,6 +282,11 @@ class ThemeManager(QtGui.QWidget):
zip.close() zip.close()
def onImportTheme(self): def onImportTheme(self):
"""
Opens a file dialog to select the theme file(s) to import before
attempting to extract OpenLP themes from those files. This process
will load both OpenLP version 1 and version 2 themes.
"""
files = QtGui.QFileDialog.getOpenFileNames( files = QtGui.QFileDialog.getOpenFileNames(
self, translate(u'ThemeManager', u'Select Theme Import File'), self, translate(u'ThemeManager', u'Select Theme Import File'),
SettingsManager.get_last_dir(self.settingsSection), u'Theme (*.*)') SettingsManager.get_last_dir(self.settingsSection), u'Theme (*.*)')
@ -311,12 +336,24 @@ class ThemeManager(QtGui.QWidget):
self.pushThemes() self.pushThemes()
def pushThemes(self): def pushThemes(self):
"""
Notify listeners that the theme list has been updated
"""
Receiver.send_message(u'theme_update_list', self.getThemes()) Receiver.send_message(u'theme_update_list', self.getThemes())
def getThemes(self): def getThemes(self):
"""
Return the list of loaded themes
"""
return self.themelist return self.themelist
def getThemeData(self, themename): def getThemeData(self, themename):
"""
Returns a theme object from an XML file
``themename``
Name of the theme to load from file
"""
log.debug(u'getthemedata for theme %s', themename) log.debug(u'getthemedata for theme %s', themename)
xml_file = os.path.join(self.path, unicode(themename), xml_file = os.path.join(self.path, unicode(themename),
unicode(themename) + u'.xml') unicode(themename) + u'.xml')
@ -326,6 +363,12 @@ class ThemeManager(QtGui.QWidget):
return self.createThemeFromXml(xml, self.path) return self.createThemeFromXml(xml, self.path)
def checkThemesExists(self, dir): def checkThemesExists(self, dir):
"""
Check a theme directory exists and if not create it
``dir``
Theme directory to make sure exists
"""
log.debug(u'check themes') log.debug(u'check themes')
if not os.path.exists(dir): if not os.path.exists(dir):
os.mkdir(dir) os.mkdir(dir)
@ -388,7 +431,10 @@ class ThemeManager(QtGui.QWidget):
def checkVersion1(self, xmlfile): def checkVersion1(self, xmlfile):
""" """
Am I a version 1 theme Check if a theme is from OpenLP version 1
``xmlfile``
Theme XML to check the version of
""" """
log.debug(u'checkVersion1 ') log.debug(u'checkVersion1 ')
theme = xmlfile theme = xmlfile
@ -400,9 +446,13 @@ class ThemeManager(QtGui.QWidget):
def migrateVersion122(self, xml_data): def migrateVersion122(self, xml_data):
""" """
Called by convert the xml data from version 1 format Convert the xml data from version 1 format to the current format.
to the current format.
New fields are defaulted but the new theme is useable New fields are loaded with defaults to provide a complete, working
theme containing all compatible customisations from the old theme.
``xml_data``
Version 1 theme to convert
""" """
theme = Theme(xml_data) theme = Theme(xml_data)
newtheme = ThemeXML() newtheme = ThemeXML()
@ -510,11 +560,20 @@ class ThemeManager(QtGui.QWidget):
return frame return frame
def getPreviewImage(self, theme): def getPreviewImage(self, theme):
"""
Return an image representing the look of the theme
``theme``
The theme to return the image for
"""
log.debug(u'getPreviewImage %s ', theme) log.debug(u'getPreviewImage %s ', theme)
image = os.path.join(self.path, theme + u'.png') image = os.path.join(self.path, theme + u'.png')
return image return image
def baseTheme(self): def baseTheme(self):
"""
Provide a base theme with sensible defaults
"""
log.debug(u'base theme created') log.debug(u'base theme created')
newtheme = ThemeXML() newtheme = ThemeXML()
newtheme.new_document(unicode(translate(u'ThemeManager', u'New Theme'))) newtheme.new_document(unicode(translate(u'ThemeManager', u'New Theme')))
@ -528,6 +587,12 @@ class ThemeManager(QtGui.QWidget):
return newtheme.extract_xml() return newtheme.extract_xml()
def createThemeFromXml(self, theme_xml, path): def createThemeFromXml(self, theme_xml, path):
"""
Return a theme object using information parsed from XML
``theme_xml``
The XML data to load into the theme
"""
theme = ThemeXML() theme = ThemeXML()
theme.parse(theme_xml) theme.parse(theme_xml)
self.cleanTheme(theme) self.cleanTheme(theme)
@ -535,6 +600,11 @@ class ThemeManager(QtGui.QWidget):
return theme return theme
def cleanTheme(self, theme): def cleanTheme(self, theme):
"""
Clean a theme loaded from an XML file by removing stray whitespace and
making sure parameters are the correct type for the theme object
attributes
"""
theme.background_color = theme.background_color.strip() theme.background_color = theme.background_color.strip()
theme.background_direction = theme.background_direction.strip() theme.background_direction = theme.background_direction.strip()
theme.background_endColor = theme.background_endColor.strip() theme.background_endColor = theme.background_endColor.strip()

View File

@ -22,13 +22,16 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`utils` module provides the utility libraries for OpenLP
"""
import os import os
import sys import sys
import logging import logging
import urllib2 import urllib2
from datetime import datetime
from datetime import datetime
from PyQt4 import QtCore from PyQt4 import QtCore
import openlp import openlp

View File

@ -22,3 +22,6 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`plugins` module provides all the project produced plugins
"""

View File

@ -22,3 +22,7 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`alerts` module provides the Alerts plugin for producing impromptu
on-screen announcements during a service
"""

View File

@ -32,11 +32,11 @@ from alertdialog import Ui_AlertDialog
class AlertForm(QtGui.QDialog, Ui_AlertDialog): class AlertForm(QtGui.QDialog, Ui_AlertDialog):
""" """
Class documentation goes here. Provide UI for the alert system
""" """
def __init__(self, manager, parent): def __init__(self, manager, parent):
""" """
Constructor Initialise the alert form
""" """
self.manager = manager self.manager = manager
self.parent = parent self.parent = parent
@ -103,6 +103,9 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
self.loadList() self.loadList()
def onSaveClick(self): def onSaveClick(self):
"""
Save an alert
"""
if self.item_id: if self.item_id:
alert = self.manager.get_object(AlertItem, self.item_id) alert = self.manager.get_object(AlertItem, self.item_id)
alert.text = unicode(self.AlertTextEdit.text()) alert.text = unicode(self.AlertTextEdit.text())
@ -113,7 +116,9 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
self.onNewClick() self.onNewClick()
def onTextChanged(self): def onTextChanged(self):
#Data has changed by editing it so potential storage required """
Enable save button when data has been changed by editing the form
"""
self.SaveButton.setEnabled(True) self.SaveButton.setEnabled(True)
def onDoubleClick(self): def onDoubleClick(self):

View File

@ -214,11 +214,13 @@ class AlertsTab(SettingsTab):
translate(u'AlertsPlugin.AlertsTab', u'Bottom')) translate(u'AlertsPlugin.AlertsTab', u'Bottom'))
def onBackgroundColorButtonClicked(self): def onBackgroundColorButtonClicked(self):
self.bg_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.bg_color), self).name() QtGui.QColor(self.bg_color), self)
self.BackgroundColorButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % self.bg_color) self.bg_color = new_color.name()
self.updateDisplay() self.BackgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color)
self.updateDisplay()
def onFontComboBoxClicked(self): def onFontComboBoxClicked(self):
self.updateDisplay() self.updateDisplay()
@ -227,11 +229,13 @@ class AlertsTab(SettingsTab):
self.location = location self.location = location
def onFontColorButtonClicked(self): def onFontColorButtonClicked(self):
self.font_color = QtGui.QColorDialog.getColor( new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.font_color), self).name() QtGui.QColor(self.font_color), self)
self.FontColorButton.setStyleSheet( if new_color.isValid():
u'background-color: %s' % self.font_color) self.font_color = new_color.name()
self.updateDisplay() self.FontColorButton.setStyleSheet(
u'background-color: %s' % self.font_color)
self.updateDisplay()
def onTimeoutSpinBoxChanged(self): def onTimeoutSpinBoxChanged(self):
self.timeout = self.TimeoutSpinBox.value() self.timeout = self.TimeoutSpinBox.value()

View File

@ -22,3 +22,7 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 # # with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
"""
The :mod:`bibles' modules provides the Bible plugin to enable OpenLP to display
scripture
"""

View File

@ -59,6 +59,7 @@ class BibleDB(QtCore.QObject):
""" """
log.info(u'BibleDB loaded') log.info(u'BibleDB loaded')
QtCore.QObject.__init__(self) QtCore.QObject.__init__(self)
self.bible_plugin = parent
if u'path' not in kwargs: if u'path' not in kwargs:
raise KeyError(u'Missing keyword argument "path".') raise KeyError(u'Missing keyword argument "path".')
if u'name' not in kwargs and u'file' not in kwargs: if u'name' not in kwargs and u'file' not in kwargs:

View File

@ -288,8 +288,7 @@ class CWExtract(BibleCommon):
``chapter`` ``chapter``
Chapter number Chapter number
""" """
log.debug(u'get_bible_chapter %s,%s,%s', log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter)
version, bookname, chapter)
urlbookname = bookname.replace(u' ', u'-') urlbookname = bookname.replace(u' ', u'-')
chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \ chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \
(version, urlbookname.lower(), chapter) (version, urlbookname.lower(), chapter)

View File

@ -29,7 +29,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
contextMenuAction, ItemCapabilities, SettingsManager, translate context_menu_action, ItemCapabilities, SettingsManager, translate
from openlp.core.utils import AppLocation from openlp.core.utils import AppLocation
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -54,6 +54,7 @@ class ImageMediaItem(MediaManagerItem):
# be instanced by the base MediaManagerItem # be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = ImageListView self.ListViewWithDnD_class = ImageListView
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.addToServiceItem = True
def initPluginNameVisible(self): def initPluginNameVisible(self):
self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image') self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image')
@ -73,7 +74,6 @@ class ImageMediaItem(MediaManagerItem):
self.hasFileIcon = True self.hasFileIcon = True
self.hasNewIcon = False self.hasNewIcon = False
self.hasEditIcon = False self.hasEditIcon = False
self.addToServiceItem = True
def initialise(self): def initialise(self):
log.debug(u'initialise') log.debug(u'initialise')
@ -93,7 +93,7 @@ class ImageMediaItem(MediaManagerItem):
MediaManagerItem.addListViewToToolBar(self) MediaManagerItem.addListViewToToolBar(self)
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ListView.addAction( self.ListView.addAction(
contextMenuAction( context_menu_action(
self.ListView, u':/slides/slide_blank.png', self.ListView, u':/slides/slide_blank.png',
translate(u'ImagePlugin.MediaItem', u'Replace Live Background'), translate(u'ImagePlugin.MediaItem', u'Replace Live Background'),
self.onReplaceClick)) self.onReplaceClick))

View File

@ -29,7 +29,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \ from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
ItemCapabilities, SettingsManager, contextMenuAction, Receiver, translate ItemCapabilities, SettingsManager, context_menu_action, Receiver, translate
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -77,7 +77,7 @@ class MediaMediaItem(MediaManagerItem):
MediaManagerItem.addListViewToToolBar(self) MediaManagerItem.addListViewToToolBar(self)
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
self.ListView.addAction( self.ListView.addAction(
contextMenuAction(self.ListView, u':/slides/slide_blank.png', context_menu_action(self.ListView, u':/slides/slide_blank.png',
translate(u'MediaPlugin.MediaItem', u'Replace Live Background'), translate(u'MediaPlugin.MediaItem', u'Replace Live Background'),
self.onReplaceClick)) self.onReplaceClick))

View File

@ -23,58 +23,6 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from openlp.core.lib import translate
class VerseType(object):
Verse = 0
Chorus = 1
Bridge = 2
PreChorus = 3
Intro = 4
Ending = 5
Other = 6
@staticmethod
def to_string(verse_type):
if verse_type == VerseType.Verse:
return translate(u'VerseType', u'Verse')
elif verse_type == VerseType.Chorus:
return translate(u'VerseType', u'Chorus')
elif verse_type == VerseType.Bridge:
return translate(u'VerseType', u'Bridge')
elif verse_type == VerseType.PreChorus:
return translate(u'VerseType', u'Pre-Chorus')
elif verse_type == VerseType.Intro:
return translate(u'VerseType', u'Intro')
elif verse_type == VerseType.Ending:
return translate(u'VerseType', u'Ending')
elif verse_type == VerseType.Other:
return translate(u'VerseType', u'Other')
@staticmethod
def from_string(verse_type):
verse_type = verse_type.lower()
if verse_type == unicode(VerseType.to_string(VerseType.Verse)).lower():
return VerseType.Verse
elif verse_type == \
unicode(VerseType.to_string(VerseType.Chorus)).lower():
return VerseType.Chorus
elif verse_type == \
unicode(VerseType.to_string(VerseType.Bridge)).lower():
return VerseType.Bridge
elif verse_type == \
unicode(VerseType.to_string(VerseType.PreChorus)).lower():
return VerseType.PreChorus
elif verse_type == \
unicode(VerseType.to_string(VerseType.Intro)).lower():
return VerseType.Intro
elif verse_type == \
unicode(VerseType.to_string(VerseType.Ending)).lower():
return VerseType.Ending
elif verse_type == \
unicode(VerseType.to_string(VerseType.Other)).lower():
return VerseType.Other
from authorsform import AuthorsForm from authorsform import AuthorsForm
from topicsform import TopicsForm from topicsform import TopicsForm
from songbookform import SongBookForm from songbookform import SongBookForm

View File

@ -26,7 +26,7 @@
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate from openlp.core.lib import translate
from openlp.plugins.songs.forms import VerseType from openlp.plugins.songs.lib import VerseType
class Ui_EditVerseDialog(object): class Ui_EditVerseDialog(object):
def setupUi(self, EditVerseDialog): def setupUi(self, EditVerseDialog):

View File

@ -28,7 +28,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.plugins.songs.forms import VerseType from openlp.plugins.songs.lib import VerseType
from editversedialog import Ui_EditVerseDialog from editversedialog import Ui_EditVerseDialog

View File

@ -31,7 +31,7 @@ class Ui_SongMaintenanceDialog(object):
def setupUi(self, SongMaintenanceDialog): def setupUi(self, SongMaintenanceDialog):
SongMaintenanceDialog.setObjectName(u'SongMaintenanceDialog') SongMaintenanceDialog.setObjectName(u'SongMaintenanceDialog')
SongMaintenanceDialog.setWindowModality(QtCore.Qt.ApplicationModal) SongMaintenanceDialog.setWindowModality(QtCore.Qt.ApplicationModal)
SongMaintenanceDialog.resize(486, 361) SongMaintenanceDialog.resize(582, 361)
self.DialogLayout = QtGui.QVBoxLayout(SongMaintenanceDialog) self.DialogLayout = QtGui.QVBoxLayout(SongMaintenanceDialog)
self.DialogLayout.setSpacing(8) self.DialogLayout.setSpacing(8)
self.DialogLayout.setMargin(8) self.DialogLayout.setMargin(8)
@ -50,10 +50,10 @@ class Ui_SongMaintenanceDialog(object):
sizePolicy.setHeightForWidth( sizePolicy.setHeightForWidth(
self.TypeListWidget.sizePolicy().hasHeightForWidth()) self.TypeListWidget.sizePolicy().hasHeightForWidth())
self.TypeListWidget.setSizePolicy(sizePolicy) self.TypeListWidget.setSizePolicy(sizePolicy)
self.TypeListWidget.setViewMode(QtGui.QListView.IconMode) self.TypeListWidget.setViewMode(QtGui.QListView.ListMode)
self.TypeListWidget.setIconSize(QtCore.QSize(112, 100)) self.TypeListWidget.setIconSize(QtCore.QSize(32, 32))
self.TypeListWidget.setMovement(QtGui.QListView.Static) self.TypeListWidget.setMovement(QtGui.QListView.Static)
self.TypeListWidget.setMaximumWidth(118) self.TypeListWidget.setMaximumWidth(172)
self.TypeListWidget.setSpacing(0) self.TypeListWidget.setSpacing(0)
self.TypeListWidget.setSortingEnabled(False) self.TypeListWidget.setSortingEnabled(False)
self.TypeListWidget.setUniformItemSizes(True) self.TypeListWidget.setUniformItemSizes(True)

View File

@ -23,10 +23,77 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from openlp.core.lib import translate
class VerseType(object):
"""
VerseType provides an enumeration for the tags that may be associated
with verses in songs.
"""
Verse = 0
Chorus = 1
Bridge = 2
PreChorus = 3
Intro = 4
Ending = 5
Other = 6
@staticmethod
def to_string(verse_type):
"""
Return a string for a given VerseType
``verse_type``
The type to return a string for
"""
if verse_type == VerseType.Verse:
return translate(u'VerseType', u'Verse')
elif verse_type == VerseType.Chorus:
return translate(u'VerseType', u'Chorus')
elif verse_type == VerseType.Bridge:
return translate(u'VerseType', u'Bridge')
elif verse_type == VerseType.PreChorus:
return translate(u'VerseType', u'Pre-Chorus')
elif verse_type == VerseType.Intro:
return translate(u'VerseType', u'Intro')
elif verse_type == VerseType.Ending:
return translate(u'VerseType', u'Ending')
elif verse_type == VerseType.Other:
return translate(u'VerseType', u'Other')
@staticmethod
def from_string(verse_type):
"""
Return the VerseType for a given string
``verse_type``
The string to return a VerseType for
"""
verse_type = verse_type.lower()
if verse_type == unicode(VerseType.to_string(VerseType.Verse)).lower():
return VerseType.Verse
elif verse_type == \
unicode(VerseType.to_string(VerseType.Chorus)).lower():
return VerseType.Chorus
elif verse_type == \
unicode(VerseType.to_string(VerseType.Bridge)).lower():
return VerseType.Bridge
elif verse_type == \
unicode(VerseType.to_string(VerseType.PreChorus)).lower():
return VerseType.PreChorus
elif verse_type == \
unicode(VerseType.to_string(VerseType.Intro)).lower():
return VerseType.Intro
elif verse_type == \
unicode(VerseType.to_string(VerseType.Ending)).lower():
return VerseType.Ending
elif verse_type == \
unicode(VerseType.to_string(VerseType.Other)).lower():
return VerseType.Other
from manager import SongManager from manager import SongManager
from songstab import SongsTab from songstab import SongsTab
from mediaitem import SongMediaItem from mediaitem import SongMediaItem
from sofimport import SofImport from sofimport import SofImport
from oooimport import OooImport from oooimport import OooImport
from songimport import SongImport from songimport import SongImport

View File

@ -334,7 +334,7 @@ class SongMediaItem(MediaManagerItem):
for verse in verseList: for verse in verseList:
verseTag = u'%s:%s' % ( verseTag = u'%s:%s' % (
verse[0][u'type'], verse[0][u'label']) verse[0][u'type'], verse[0][u'label'])
service_item.add_from_text(\ service_item.add_from_text(
verse[1][:30], unicode(verse[1]), verseTag) verse[1][:30], unicode(verse[1]), verseTag)
else: else:
#Loop through the verse list and expand the song accordingly. #Loop through the verse list and expand the song accordingly.
@ -346,8 +346,8 @@ class SongMediaItem(MediaManagerItem):
verse[0][u'type'][0] == order[0]: verse[0][u'type'][0] == order[0]:
verseTag = u'%s:%s' % \ verseTag = u'%s:%s' % \
(verse[0][u'type'], verse[0][u'label']) (verse[0][u'type'], verse[0][u'label'])
service_item.add_from_text\ service_item.add_from_text(
(verse[1][:30], verse[1], verseTag) verse[1][:30], verse[1], verseTag)
else: else:
verses = song.lyrics.split(u'\n\n') verses = song.lyrics.split(u'\n\n')
for slide in verses: for slide in verses: