Presentations - service item handling

This commit is contained in:
Tim Bentley 2009-09-05 14:30:09 +01:00
parent f4a8d8b52a
commit 3784838a36
9 changed files with 66 additions and 7 deletions

View File

@ -54,6 +54,10 @@ class EventReceiver(QtCore.QObject):
``request_spin_delay`` ``request_spin_delay``
Requests a spin delay Requests a spin delay
``{plugin}_start``
Requests a plugin to start a external program
Path and file provided in message
""" """
global log global log
log = logging.getLogger(u'EventReceiver') log = logging.getLogger(u'EventReceiver')

View File

@ -51,6 +51,7 @@ class ServiceItem(object):
if hostplugin is not None: if hostplugin is not None:
self.RenderManager = self.plugin.render_manager self.RenderManager = self.plugin.render_manager
self.shortname = hostplugin.name self.shortname = hostplugin.name
self.name = self.plugin.name
self.title = u'' self.title = u''
self.items = [] self.items = []
self.iconic_representation = None self.iconic_representation = None
@ -158,6 +159,7 @@ class ServiceItem(object):
file to represent this item. file to represent this item.
""" """
oos_header = { oos_header = {
u'name': self.name.lower(),
u'plugin': self.shortname, u'plugin': self.shortname,
u'theme':self.theme, u'theme':self.theme,
u'title':self.title, u'title':self.title,
@ -190,6 +192,7 @@ class ServiceItem(object):
""" """
header = serviceitem[u'serviceitem'][u'header'] header = serviceitem[u'serviceitem'][u'header']
self.title = header[u'title'] self.title = header[u'title']
self.name = header[u'name']
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']

View File

@ -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 Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import os import os
import sys
import logging import logging
import cPickle import cPickle
import zipfile import zipfile
@ -409,6 +410,7 @@ class ServiceManager(QtGui.QWidget):
#if not present do not worry #if not present do not worry
pass pass
except: except:
log.error(u'Problem processing oos load %s', sys.exc_info()[0])
pass pass
self.serviceName = name[len(name) - 1] self.serviceName = name[len(name) - 1]
self.parent.OosChanged(True, self.serviceName) self.parent.OosChanged(True, self.serviceName)

View File

@ -231,7 +231,11 @@ class SlideController(QtGui.QWidget):
log.debug(u'addServiceItem') log.debug(u'addServiceItem')
item.render() item.render()
self.enableToolBar(item) 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): def addServiceManagerItem(self, item, slideno):
""" """
@ -241,7 +245,11 @@ class SlideController(QtGui.QWidget):
""" """
log.debug(u'addServiceItem') log.debug(u'addServiceItem')
self.enableToolBar(item) 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): def displayServiceManagerItems(self, serviceitem, slideno):
""" """

View File

@ -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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from impresscontroller import ImpressController
from messagelistener import MessageListener
from mediaitem import PresentationMediaItem from mediaitem import PresentationMediaItem
from presentationtab import PresentationTab from presentationtab import PresentationTab
from impresscontroller import impressController
__all__ = ['PresentationMediaItem', 'PresentationTab', 'impressController']
__all__ = ['PresentationMediaItem', 'PresentationTab',
'ImpressController', 'MessageListener']

View File

@ -34,7 +34,7 @@ import uno
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate from openlp.core.lib import translate
class impressController(object): class ImpressController(object):
global log global log
log = logging.getLogger(u'ImpressController') log = logging.getLogger(u'ImpressController')

View File

@ -22,6 +22,7 @@ import os
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD 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 # We have to explicitly create separate classes for each plugin
# in order for DnD to the Service manager to work correctly. # in order for DnD to the Service manager to work correctly.
@ -54,6 +55,7 @@ class PresentationMediaItem(MediaManagerItem):
# be instanced by the base MediaManagerItem # be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = PresentationListView self.ListViewWithDnD_class = PresentationListView
MediaManagerItem.__init__(self, parent, icon, title) MediaManagerItem.__init__(self, parent, icon, title)
self.message_listener = MessageListener(controllers)
def addHeaderBar(self): def addHeaderBar(self):
self.PresentationWidget = QtGui.QWidget(self) self.PresentationWidget = QtGui.QWidget(self)

View File

@ -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

View File

@ -25,7 +25,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, MediaManagerItem 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): class PresentationPlugin(Plugin):
@ -71,7 +71,7 @@ class PresentationPlugin(Plugin):
try: try:
#Check to see if we have uno installed #Check to see if we have uno installed
import uno import uno
openoffice = impressController() openoffice = ImpressController()
self.registerControllers(u'Impress', openoffice) self.registerControllers(u'Impress', openoffice)
except: except:
log.error(u'Reason : %s', sys.exc_info()[0]) log.error(u'Reason : %s', sys.exc_info()[0])