2010-09-10 19:21:14 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-01-05 22:17:30 +00:00
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2012-12-29 20:56:56 +00:00
|
|
|
# Copyright (c) 2008-2013 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
|
2012-06-22 14:14:53 +00:00
|
|
|
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
2012-11-11 21:16:14 +00:00
|
|
|
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
2012-10-21 13:16:22 +00:00
|
|
|
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
|
|
|
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
|
|
|
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
2012-12-01 07:57:54 +00:00
|
|
|
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
2010-09-10 19:21:14 +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 #
|
|
|
|
###############################################################################
|
|
|
|
"""
|
|
|
|
The :mod:`presentationplugin` module provides the ability for OpenLP to display
|
|
|
|
presentations from a variety of document formats.
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
import logging
|
|
|
|
|
2013-01-10 20:41:16 +00:00
|
|
|
from PyQt4 import QtCore
|
|
|
|
|
2010-09-16 21:10:36 +00:00
|
|
|
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
2010-09-10 19:21:14 +00:00
|
|
|
from openlp.core.utils import AppLocation
|
2013-02-03 21:46:56 +00:00
|
|
|
from openlp.plugins.presentations.lib import PresentationController, PresentationMediaItem, PresentationTab
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2013-01-10 20:41:16 +00:00
|
|
|
__default_settings__ = {
|
2013-01-10 20:09:27 +00:00
|
|
|
u'presentations/override app': QtCore.Qt.Unchecked,
|
2013-01-16 11:33:32 +00:00
|
|
|
u'presentations/Impress': QtCore.Qt.Checked,
|
|
|
|
u'presentations/Powerpoint': QtCore.Qt.Checked,
|
2013-01-18 18:50:46 +00:00
|
|
|
u'presentations/Powerpoint Viewer': QtCore.Qt.Checked,
|
2013-01-18 19:24:06 +00:00
|
|
|
u'presentations/presentations files': []
|
2013-01-10 20:09:27 +00:00
|
|
|
}
|
2013-01-10 19:33:48 +00:00
|
|
|
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
class PresentationPlugin(Plugin):
|
|
|
|
"""
|
|
|
|
This plugin allowed a Presentation to be opened, controlled and displayed
|
|
|
|
on the output display. The plugin controls third party applications such
|
|
|
|
as OpenOffice.org Impress, Microsoft PowerPoint and the PowerPoint viewer
|
|
|
|
"""
|
|
|
|
log = logging.getLogger(u'PresentationPlugin')
|
|
|
|
|
2013-01-23 21:05:25 +00:00
|
|
|
def __init__(self):
|
2010-09-10 19:21:14 +00:00
|
|
|
"""
|
|
|
|
PluginPresentation constructor.
|
|
|
|
"""
|
|
|
|
log.debug(u'Initialised')
|
|
|
|
self.controllers = {}
|
2013-01-23 21:05:25 +00:00
|
|
|
Plugin.__init__(self, u'presentations', __default_settings__, __default_settings__)
|
2010-09-10 19:21:14 +00:00
|
|
|
self.weight = -8
|
2012-04-22 19:37:11 +00:00
|
|
|
self.iconPath = u':/plugins/plugin_presentations.png'
|
|
|
|
self.icon = build_icon(self.iconPath)
|
2010-09-10 19:21:14 +00:00
|
|
|
|
2011-12-07 20:25:12 +00:00
|
|
|
def createSettingsTab(self, parent):
|
2010-09-10 19:21:14 +00:00
|
|
|
"""
|
|
|
|
Create the settings Tab
|
|
|
|
"""
|
2010-09-16 21:10:36 +00:00
|
|
|
visible_name = self.getString(StringContent.VisibleName)
|
2013-01-05 22:17:30 +00:00
|
|
|
self.settingsTab = PresentationTab(parent, self.name, visible_name[u'title'], self.controllers, self.iconPath)
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
def initialise(self):
|
|
|
|
"""
|
|
|
|
Initialise the plugin. Determine which controllers are enabled
|
|
|
|
are start their processes.
|
|
|
|
"""
|
|
|
|
log.info(u'Presentations Initialising')
|
|
|
|
Plugin.initialise(self)
|
|
|
|
for controller in self.controllers:
|
|
|
|
if self.controllers[controller].enabled():
|
2011-02-04 21:35:57 +00:00
|
|
|
try:
|
|
|
|
self.controllers[controller].start_process()
|
2013-01-17 21:58:38 +00:00
|
|
|
except Exception:
|
2011-06-03 06:52:16 +00:00
|
|
|
log.warn(u'Failed to start controller process')
|
2011-02-04 21:35:57 +00:00
|
|
|
self.controllers[controller].available = False
|
2013-02-07 11:33:47 +00:00
|
|
|
self.mediaItem.build_file_mask_string()
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
def finalise(self):
|
|
|
|
"""
|
|
|
|
Finalise the plugin. Ask all the enabled presentation applications
|
|
|
|
to close down their applications and release resources.
|
|
|
|
"""
|
|
|
|
log.info(u'Plugin Finalise')
|
2011-10-03 20:12:57 +00:00
|
|
|
# Ask each controller to tidy up.
|
2010-09-10 19:21:14 +00:00
|
|
|
for key in self.controllers:
|
|
|
|
controller = self.controllers[key]
|
|
|
|
if controller.enabled():
|
|
|
|
controller.kill()
|
|
|
|
Plugin.finalise(self)
|
|
|
|
|
2011-12-07 20:25:12 +00:00
|
|
|
def createMediaManagerItem(self):
|
2010-09-10 19:21:14 +00:00
|
|
|
"""
|
|
|
|
Create the Media Manager List
|
|
|
|
"""
|
2011-12-08 17:55:12 +00:00
|
|
|
self.mediaItem = PresentationMediaItem(
|
2013-01-23 19:28:47 +00:00
|
|
|
self.main_window.mediaDockManager.media_dock, self, self.icon, self.controllers)
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
def registerControllers(self, controller):
|
|
|
|
"""
|
|
|
|
Register each presentation controller (Impress, PPT etc) and
|
|
|
|
store for later use
|
|
|
|
"""
|
|
|
|
self.controllers[controller.name] = controller
|
|
|
|
|
|
|
|
def checkPreConditions(self):
|
|
|
|
"""
|
|
|
|
Check to see if we have any presentation software available
|
|
|
|
If Not do not install the plugin.
|
|
|
|
"""
|
|
|
|
log.debug(u'checkPreConditions')
|
|
|
|
controller_dir = os.path.join(
|
|
|
|
AppLocation.get_directory(AppLocation.PluginsDir),
|
|
|
|
u'presentations', u'lib')
|
|
|
|
for filename in os.listdir(controller_dir):
|
2013-01-05 22:17:30 +00:00
|
|
|
if filename.endswith(u'controller.py') and not filename == 'presentationcontroller.py':
|
2010-09-10 19:21:14 +00:00
|
|
|
path = os.path.join(controller_dir, filename)
|
|
|
|
if os.path.isfile(path):
|
2013-01-05 22:17:30 +00:00
|
|
|
modulename = u'openlp.plugins.presentations.lib.' + os.path.splitext(filename)[0]
|
2010-09-10 19:21:14 +00:00
|
|
|
log.debug(u'Importing controller %s', modulename)
|
|
|
|
try:
|
|
|
|
__import__(modulename, globals(), locals(), [])
|
|
|
|
except ImportError:
|
2011-06-03 06:52:16 +00:00
|
|
|
log.warn(u'Failed to import %s on path %s',
|
2010-09-10 19:21:14 +00:00
|
|
|
modulename, path)
|
|
|
|
controller_classes = PresentationController.__subclasses__()
|
|
|
|
for controller_class in controller_classes:
|
|
|
|
controller = controller_class(self)
|
|
|
|
self.registerControllers(controller)
|
2012-04-16 07:02:24 +00:00
|
|
|
return bool(self.controllers)
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
def about(self):
|
|
|
|
"""
|
|
|
|
Return information about this plugin
|
|
|
|
"""
|
|
|
|
about_text = translate('PresentationPlugin', '<strong>Presentation '
|
|
|
|
'Plugin</strong><br />The presentation plugin provides the '
|
|
|
|
'ability to show presentations using a number of different '
|
|
|
|
'programs. The choice of available presentation programs is '
|
|
|
|
'available to the user in a drop down box.')
|
|
|
|
return about_text
|
|
|
|
|
2013-02-19 21:23:56 +00:00
|
|
|
def set_plugin_text_strings(self):
|
2010-09-10 19:21:14 +00:00
|
|
|
"""
|
|
|
|
Called to define all translatable texts of the plugin
|
|
|
|
"""
|
2010-09-15 17:55:27 +00:00
|
|
|
## Name PluginList ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Name] = {
|
2013-01-05 22:17:30 +00:00
|
|
|
u'singular': translate('PresentationPlugin', 'Presentation', 'name singular'),
|
|
|
|
u'plural': translate('PresentationPlugin', 'Presentations', 'name plural')
|
2010-09-10 19:21:14 +00:00
|
|
|
}
|
2010-09-15 17:55:27 +00:00
|
|
|
## Name for MediaDockManager, SettingsManager ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.VisibleName] = {
|
2013-01-05 22:17:30 +00:00
|
|
|
u'title': translate('PresentationPlugin', 'Presentations', 'container title')
|
2010-09-15 17:55:27 +00:00
|
|
|
}
|
2010-09-10 19:21:14 +00:00
|
|
|
# Middle Header Bar
|
2011-02-14 17:25:51 +00:00
|
|
|
tooltips = {
|
2013-01-05 22:17:30 +00:00
|
|
|
u'load': translate('PresentationPlugin', 'Load a new presentation.'),
|
2011-02-14 19:08:18 +00:00
|
|
|
u'import': u'',
|
|
|
|
u'new': u'',
|
|
|
|
u'edit': u'',
|
2013-01-05 22:17:30 +00:00
|
|
|
u'delete': translate('PresentationPlugin', 'Delete the selected presentation.'),
|
|
|
|
u'preview': translate('PresentationPlugin', 'Preview the selected presentation.'),
|
|
|
|
u'live': translate('PresentationPlugin', 'Send the selected presentation live.'),
|
|
|
|
u'service': translate('PresentationPlugin', 'Add the selected presentation to the service.')
|
2011-02-14 18:20:59 +00:00
|
|
|
}
|
|
|
|
self.setPluginUiTextStrings(tooltips)
|