2009-02-04 20:16:56 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
"""
|
|
|
|
OpenLP - Open Source Lyrics Projection
|
|
|
|
Copyright (c) 2008 Raoul Snyman
|
2009-05-02 11:16:08 +00:00
|
|
|
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
|
2009-02-04 20:16:56 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
"""
|
2009-05-02 11:16:08 +00:00
|
|
|
import logging
|
2009-05-04 13:48:12 +00:00
|
|
|
import time
|
2009-05-20 20:17:20 +00:00
|
|
|
from openlp.core.lib import buildIcon
|
|
|
|
from PyQt4 import QtCore, QtGui
|
2009-05-13 19:47:25 +00:00
|
|
|
|
2009-05-02 11:16:08 +00:00
|
|
|
class ServiceItem():
|
2009-02-04 20:16:56 +00:00
|
|
|
"""
|
|
|
|
The service item is a base class for the plugins to use to interact with
|
2009-02-10 20:47:16 +00:00
|
|
|
the service manager, the slide controller, and the projection screen
|
|
|
|
compositor.
|
2009-02-04 20:16:56 +00:00
|
|
|
"""
|
2009-05-02 11:16:08 +00:00
|
|
|
global log
|
|
|
|
log=logging.getLogger(u'ServiceItem')
|
|
|
|
log.info(u'Service Item created')
|
2009-02-04 20:16:56 +00:00
|
|
|
|
2009-03-04 21:54:00 +00:00
|
|
|
def __init__(self, hostplugin):
|
2009-02-10 20:47:16 +00:00
|
|
|
"""
|
|
|
|
Init Method
|
|
|
|
"""
|
2009-05-02 11:16:08 +00:00
|
|
|
self.plugin = hostplugin
|
|
|
|
self.shortname = hostplugin.name
|
2009-05-02 18:56:27 +00:00
|
|
|
self.title = u''
|
2009-05-02 11:16:08 +00:00
|
|
|
self.items = []
|
|
|
|
self.iconic_representation = None
|
|
|
|
self.raw_slides = None
|
2009-05-22 18:30:25 +00:00
|
|
|
self.frame_titles = []
|
|
|
|
self.command_files = []
|
2009-05-02 11:16:08 +00:00
|
|
|
self.frames = []
|
|
|
|
self.raw_footer = None
|
|
|
|
self.theme = None
|
2009-05-17 15:24:02 +00:00
|
|
|
log.debug(u'Service item created for %s ', self.shortname)
|
2009-06-05 19:00:57 +00:00
|
|
|
self.service_frames = []
|
2009-05-02 11:16:08 +00:00
|
|
|
|
2009-05-02 18:56:27 +00:00
|
|
|
def addIcon(self, icon):
|
2009-05-13 19:47:25 +00:00
|
|
|
self.iconic_representation = buildIcon(icon)
|
2009-05-02 18:56:27 +00:00
|
|
|
|
2009-02-04 20:16:56 +00:00
|
|
|
def render(self):
|
|
|
|
"""
|
2009-05-04 13:48:12 +00:00
|
|
|
The render method is what renders the frames for the screen.
|
2009-02-04 20:16:56 +00:00
|
|
|
"""
|
2009-05-02 11:16:08 +00:00
|
|
|
log.debug(u'Render called')
|
|
|
|
if self.theme == None:
|
2009-06-01 17:50:37 +00:00
|
|
|
self.plugin.render_manager.set_override_theme(None)
|
2009-05-02 11:16:08 +00:00
|
|
|
else:
|
2009-06-01 17:50:37 +00:00
|
|
|
self.plugin.render_manager.set_override_theme(self.theme)
|
2009-05-04 13:48:12 +00:00
|
|
|
log.debug(u'Formatting slides')
|
2009-06-05 19:00:57 +00:00
|
|
|
if self.service_item_type == u'text':
|
|
|
|
for slide in self.service_frames:
|
|
|
|
formated = self.plugin.render_manager.format_slide(slide[u'raw_slide'])
|
2009-06-02 16:25:36 +00:00
|
|
|
for format in formated:
|
|
|
|
frame = self.plugin.render_manager.generate_slide(format, self.raw_footer)
|
2009-06-05 19:00:57 +00:00
|
|
|
self.frames.append({u'title': slide[u'title'], u'image': frame})
|
|
|
|
elif self.service_item_type == u'command':
|
|
|
|
self.frames = self.service_frames
|
|
|
|
self.service_frames = []
|
|
|
|
elif self.service_item_type == u'image':
|
|
|
|
self.frames = self.service_frames
|
|
|
|
self.service_frames = []
|
2009-05-22 18:30:25 +00:00
|
|
|
else:
|
2009-06-05 19:00:57 +00:00
|
|
|
assert(0 , u'Invalid value rendere :%s' % self.service_item_type)
|
|
|
|
|
|
|
|
def add_from_image(self, frame_title, image):
|
|
|
|
self.service_item_type = u'image'
|
|
|
|
self.service_frames.append({u'title': frame_title, u'image': image})
|
|
|
|
|
|
|
|
def add_from_text(self, frame_title, raw_slide):
|
|
|
|
self.service_item_type = u'text'
|
|
|
|
frame_title = frame_title.split(u'\n')[0]
|
|
|
|
self.service_frames.append({u'title': frame_title, u'raw_slide': raw_slide})
|
|
|
|
|
|
|
|
def add_from_command(self, frame_title, command):
|
|
|
|
self.service_item_type = u'command'
|
|
|
|
self.service_frames.append({u'title': frame_title, u'command': command})
|
2009-05-02 11:16:08 +00:00
|
|
|
|
2009-02-04 20:16:56 +00:00
|
|
|
|
2009-02-10 20:47:16 +00:00
|
|
|
|
|
|
|
def get_oos_repr(self):
|
|
|
|
"""
|
|
|
|
This method returns some text which can be saved into the OOS
|
|
|
|
file to represent this item
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
|
|
def set_from_oos(self, oostext):
|
|
|
|
"""
|
|
|
|
This method takes some oostext (passed from the ServiceManager)
|
|
|
|
and parses it into the data actually required
|
|
|
|
"""
|
|
|
|
pass
|
|
|
|
|
2009-05-02 11:16:08 +00:00
|
|
|
def set_from_plugin(self):
|
2009-02-10 20:47:16 +00:00
|
|
|
"""
|
|
|
|
Takes data from the plugin media chooser
|
|
|
|
"""
|
2009-03-04 21:54:00 +00:00
|
|
|
pass
|