From 3784838a36307cb2e176b7f0e74584c7f9c276e9 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 5 Sep 2009 14:30:09 +0100 Subject: [PATCH] Presentations - service item handling --- openlp/core/lib/eventreceiver.py | 4 ++ openlp/core/lib/serviceitem.py | 3 ++ openlp/core/ui/servicemanager.py | 2 + openlp/core/ui/slidecontroller.py | 12 +++++- openlp/plugins/presentations/lib/__init__.py | 7 +++- .../presentations/lib/impresscontroller.py | 2 +- openlp/plugins/presentations/lib/mediaitem.py | 2 + .../presentations/lib/messagelistener.py | 37 +++++++++++++++++++ .../presentations/presentationplugin.py | 4 +- 9 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 openlp/plugins/presentations/lib/messagelistener.py diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 15db0fead..a9c3579b1 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -54,6 +54,10 @@ class EventReceiver(QtCore.QObject): ``request_spin_delay`` Requests a spin delay + ``{plugin}_start`` + Requests a plugin to start a external program + Path and file provided in message + """ global log log = logging.getLogger(u'EventReceiver') diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 5c74cdbf1..eba0372b2 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -51,6 +51,7 @@ class ServiceItem(object): if hostplugin is not None: self.RenderManager = self.plugin.render_manager self.shortname = hostplugin.name + self.name = self.plugin.name self.title = u'' self.items = [] self.iconic_representation = None @@ -158,6 +159,7 @@ class ServiceItem(object): file to represent this item. """ oos_header = { + u'name': self.name.lower(), u'plugin': self.shortname, u'theme':self.theme, u'title':self.title, @@ -190,6 +192,7 @@ class ServiceItem(object): """ header = serviceitem[u'serviceitem'][u'header'] self.title = header[u'title'] + self.name = header[u'name'] self.service_item_type = header[u'type'] self.shortname = header[u'plugin'] self.theme = header[u'theme'] diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 5febca1c8..0b347c1cc 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -18,6 +18,7 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ import os +import sys import logging import cPickle import zipfile @@ -409,6 +410,7 @@ class ServiceManager(QtGui.QWidget): #if not present do not worry pass except: + log.error(u'Problem processing oos load %s', sys.exc_info()[0]) pass self.serviceName = name[len(name) - 1] self.parent.OosChanged(True, self.serviceName) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 30fb3aaeb..944161750 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -231,7 +231,11 @@ class SlideController(QtGui.QWidget): log.debug(u'addServiceItem') item.render() self.enableToolBar(item) - self.displayServiceManagerItems(item, 0) + if item.service_item_type == ServiceType.Command: + Receiver().send_message(u'%s_start'%item.name.lower(), \ + u'%s:%s:%s' % (item.shortname, item.service_item_path, item.service_frames[0][u'title'])) + else: + self.displayServiceManagerItems(item, 0) def addServiceManagerItem(self, item, slideno): """ @@ -241,7 +245,11 @@ class SlideController(QtGui.QWidget): """ log.debug(u'addServiceItem') self.enableToolBar(item) - self.displayServiceManagerItems(item, slideno) + if item.service_item_type == ServiceType.Command: + Receiver().send_message(u'%s_start'%item.name.lower(), \ + u'%s:%s:%s' % (item.shortname, item.service_item_path, item.service_frames[0][u'title'])) + else: + self.displayServiceManagerItems(item, slideno) def displayServiceManagerItems(self, serviceitem, slideno): """ diff --git a/openlp/plugins/presentations/lib/__init__.py b/openlp/plugins/presentations/lib/__init__.py index 4eb846020..2b5d0d266 100644 --- a/openlp/plugins/presentations/lib/__init__.py +++ b/openlp/plugins/presentations/lib/__init__.py @@ -17,8 +17,11 @@ 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 """ +from impresscontroller import ImpressController +from messagelistener import MessageListener from mediaitem import PresentationMediaItem from presentationtab import PresentationTab -from impresscontroller import impressController -__all__ = ['PresentationMediaItem', 'PresentationTab', 'impressController'] + +__all__ = ['PresentationMediaItem', 'PresentationTab', + 'ImpressController', 'MessageListener'] diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 9ccec1ee3..e737c1485 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -34,7 +34,7 @@ import uno from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -class impressController(object): +class ImpressController(object): global log log = logging.getLogger(u'ImpressController') diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 90f1bc580..96b64b6cb 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -22,6 +22,7 @@ import os from PyQt4 import QtCore, QtGui from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD +from openlp.plugins.presentations.lib import MessageListener # We have to explicitly create separate classes for each plugin # in order for DnD to the Service manager to work correctly. @@ -54,6 +55,7 @@ class PresentationMediaItem(MediaManagerItem): # be instanced by the base MediaManagerItem self.ListViewWithDnD_class = PresentationListView MediaManagerItem.__init__(self, parent, icon, title) + self.message_listener = MessageListener(controllers) def addHeaderBar(self): self.PresentationWidget = QtGui.QWidget(self) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py new file mode 100644 index 000000000..669781590 --- /dev/null +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 +""" +OpenLP - Open Source Lyrics Projection +Copyright (c) 2008 Raoul Snyman +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 +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 +import os + +from openlp.core.lib import Receiver +from openlp.plugins.presentations.lib import ImpressController + +class MessageListener(object): + """ + This is the Presentation listener who acts on events from the slide controller + and passes the messages on the the correct presentation handlers + """ + global log + log=logging.getLogger(u'MessageListener') + log.info(u'Message Listener loaded') + + def __init__(self, controllers): + self.controllers = controllers + print controllers diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 32dcf6f64..c53a30e1f 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -25,7 +25,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, MediaManagerItem -from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, impressController +from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, ImpressController class PresentationPlugin(Plugin): @@ -71,7 +71,7 @@ class PresentationPlugin(Plugin): try: #Check to see if we have uno installed import uno - openoffice = impressController() + openoffice = ImpressController() self.registerControllers(u'Impress', openoffice) except: log.error(u'Reason : %s', sys.exc_info()[0])