forked from openlp/openlp
move translations from mediamanager to plugins with dict
This commit is contained in:
parent
fa328945d3
commit
d4cabf9693
@ -1,336 +1,336 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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:`lib` module contains most of the components and libraries that make
|
||||
OpenLP work.
|
||||
"""
|
||||
import logging
|
||||
import os.path
|
||||
import types
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# TODO make external and configurable in alpha 4 via a settings dialog
|
||||
html_expands = []
|
||||
|
||||
html_expands.append({u'desc':u'Red', u'start tag':u'{r}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:red">', \
|
||||
u'end tag':u'{/r}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Black', u'start tag':u'{b}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:black">', \
|
||||
u'end tag':u'{/b}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Blue', u'start tag':u'{bl}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:blue">', \
|
||||
u'end tag':u'{/bl}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Yellow', u'start tag':u'{y}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:yellow">', \
|
||||
u'end tag':u'{/y}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Green', u'start tag':u'{g}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:green">', \
|
||||
u'end tag':u'{/g}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Pink', u'start tag':u'{pk}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:#CC33CC">', \
|
||||
u'end tag':u'{/pk}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Orange', u'start tag':u'{o}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:#CC0033">', \
|
||||
u'end tag':u'{/o}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Purple', u'start tag':u'{pp}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:#9900FF">', \
|
||||
u'end tag':u'{/pp}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'White', u'start tag':u'{w}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:white">', \
|
||||
u'end tag':u'{/w}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Superscript', u'start tag':u'{su}', \
|
||||
u'start html':u'<sup>', \
|
||||
u'end tag':u'{/su}', u'end html':u'</sup>', \
|
||||
u'protected':True})
|
||||
html_expands.append({u'desc':u'Subscript', u'start tag':u'{sb}', \
|
||||
u'start html':u'<sub>', \
|
||||
u'end tag':u'{/sb}', u'end html':u'</sub>', \
|
||||
u'protected':True})
|
||||
html_expands.append({u'desc':u'Paragraph', u'start tag':u'{p}', \
|
||||
u'start html':u'<p>', \
|
||||
u'end tag':u'{/p}', u'end html':u'</p>', \
|
||||
u'protected':True})
|
||||
html_expands.append({u'desc':u'Bold', u'start tag':u'{st}', \
|
||||
u'start html':u'<strong>', \
|
||||
u'end tag':u'{/st}', \
|
||||
u'end html':u'</strong>', \
|
||||
u'protected':True})
|
||||
html_expands.append({u'desc':u'Italics', u'start tag':u'{it}', \
|
||||
u'start html':u'<em>', \
|
||||
u'end tag':u'{/it}', u'end html':u'</em>', \
|
||||
u'protected':True})
|
||||
|
||||
def translate(context, text, comment=None):
|
||||
"""
|
||||
A special shortcut method to wrap around the Qt4 translation functions.
|
||||
This abstracts the translation procedure so that we can change it if at a
|
||||
later date if necessary, without having to redo the whole of OpenLP.
|
||||
|
||||
``context``
|
||||
The translation context, used to give each string a context or a
|
||||
namespace.
|
||||
|
||||
``text``
|
||||
The text to put into the translation tables for translation.
|
||||
|
||||
``comment``
|
||||
An identifying string for when the same text is used in different roles
|
||||
within the same context.
|
||||
"""
|
||||
return QtCore.QCoreApplication.translate(context, text, comment)
|
||||
|
||||
def get_text_file_string(text_file):
|
||||
"""
|
||||
Open a file and return its content as unicode string. If the supplied file
|
||||
name is not a file then the function returns False. If there is an error
|
||||
loading the file or the content can't be decoded then the function will
|
||||
return None.
|
||||
|
||||
``textfile``
|
||||
The name of the file.
|
||||
"""
|
||||
if not os.path.isfile(text_file):
|
||||
return False
|
||||
file_handle = None
|
||||
content_string = None
|
||||
try:
|
||||
file_handle = open(text_file, u'r')
|
||||
content = file_handle.read()
|
||||
content_string = content.decode(u'utf-8')
|
||||
except (IOError, UnicodeError):
|
||||
log.exception(u'Failed to open text file %s' % text_file)
|
||||
finally:
|
||||
if file_handle:
|
||||
file_handle.close()
|
||||
return content_string
|
||||
|
||||
def str_to_bool(stringvalue):
|
||||
"""
|
||||
Convert a string version of a boolean into a real boolean.
|
||||
|
||||
``stringvalue``
|
||||
The string value to examine and convert to a boolean type.
|
||||
"""
|
||||
if isinstance(stringvalue, bool):
|
||||
return stringvalue
|
||||
return unicode(stringvalue).strip().lower() in (u'true', u'yes', u'y')
|
||||
|
||||
def build_icon(icon):
|
||||
"""
|
||||
Build a QIcon instance from an existing QIcon, a resource location, or a
|
||||
physical file location. If the icon is a QIcon instance, that icon is
|
||||
simply returned. If not, it builds a QIcon instance from the resource or
|
||||
file name.
|
||||
|
||||
``icon``
|
||||
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``.
|
||||
"""
|
||||
button_icon = QtGui.QIcon()
|
||||
if isinstance(icon, QtGui.QIcon):
|
||||
button_icon = icon
|
||||
elif isinstance(icon, basestring):
|
||||
if icon.startswith(u':/'):
|
||||
button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
|
||||
QtGui.QIcon.Off)
|
||||
else:
|
||||
button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
elif isinstance(icon, QtGui.QImage):
|
||||
button_icon.addPixmap(QtGui.QPixmap.fromImage(icon),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
return button_icon
|
||||
|
||||
def context_menu_action(base, icon, text, slot):
|
||||
"""
|
||||
Utility method to help build context menus for plugins
|
||||
|
||||
``base``
|
||||
The parent menu to add this menu item to
|
||||
|
||||
``icon``
|
||||
An icon for this action
|
||||
|
||||
``text``
|
||||
The text to display for this action
|
||||
|
||||
``slot``
|
||||
The code to run when this action is triggered
|
||||
"""
|
||||
action = QtGui.QAction(text, base)
|
||||
if icon:
|
||||
action.setIcon(build_icon(icon))
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||
return action
|
||||
|
||||
def context_menu(base, icon, text):
|
||||
"""
|
||||
Utility method to help build context menus for plugins
|
||||
|
||||
``base``
|
||||
The parent object to add this menu to
|
||||
|
||||
``icon``
|
||||
An icon for this menu
|
||||
|
||||
``text``
|
||||
The text to display for this menu
|
||||
"""
|
||||
action = QtGui.QMenu(text, base)
|
||||
action.setIcon(build_icon(icon))
|
||||
return action
|
||||
|
||||
def context_menu_separator(base):
|
||||
"""
|
||||
Add a separator to a context menu
|
||||
|
||||
``base``
|
||||
The menu object to add the separator to
|
||||
"""
|
||||
action = QtGui.QAction(u'', base)
|
||||
action.setSeparator(True)
|
||||
return action
|
||||
|
||||
def image_to_byte(image):
|
||||
"""
|
||||
Resize an image to fit on the current screen for the web and returns
|
||||
it as a byte stream.
|
||||
|
||||
``image``
|
||||
The image to converted.
|
||||
"""
|
||||
byte_array = QtCore.QByteArray()
|
||||
# use buffer to store pixmap into byteArray
|
||||
buffie = QtCore.QBuffer(byte_array)
|
||||
buffie.open(QtCore.QIODevice.WriteOnly)
|
||||
if isinstance(image, QtGui.QImage):
|
||||
pixmap = QtGui.QPixmap.fromImage(image)
|
||||
else:
|
||||
pixmap = QtGui.QPixmap(image)
|
||||
pixmap.save(buffie, "PNG")
|
||||
# convert to base64 encoding so does not get missed!
|
||||
return byte_array.toBase64()
|
||||
|
||||
def resize_image(image, width, height, background=QtCore.Qt.black):
|
||||
"""
|
||||
Resize an image to fit on the current screen.
|
||||
|
||||
``image``
|
||||
The image to resize.
|
||||
|
||||
``width``
|
||||
The new image width.
|
||||
|
||||
``height``
|
||||
The new image height.
|
||||
|
||||
``background``
|
||||
The background colour defaults to black.
|
||||
|
||||
"""
|
||||
preview = QtGui.QImage(image)
|
||||
if not preview.isNull():
|
||||
# Only resize if different size
|
||||
if preview.width() == width and preview.height == height:
|
||||
return preview
|
||||
preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation)
|
||||
realw = preview.width()
|
||||
realh = preview.height()
|
||||
# and move it to the centre of the preview space
|
||||
new_image = QtGui.QImage(width, height,
|
||||
QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||
new_image.fill(background)
|
||||
painter = QtGui.QPainter(new_image)
|
||||
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
|
||||
return new_image
|
||||
|
||||
def check_item_selected(list_widget, message):
|
||||
"""
|
||||
Check if a list item is selected so an action may be performed on it
|
||||
|
||||
``list_widget``
|
||||
The list to check for selected items
|
||||
|
||||
``message``
|
||||
The message to give the user if no item is selected
|
||||
"""
|
||||
if not list_widget.selectedIndexes():
|
||||
QtGui.QMessageBox.information(list_widget.parent(),
|
||||
translate('OpenLP.MediaManagerItem', 'No Items Selected'), message)
|
||||
return False
|
||||
return True
|
||||
|
||||
def clean_tags(text):
|
||||
"""
|
||||
Remove Tags from text for display
|
||||
"""
|
||||
text = text.replace(u'<br>', u'\n')
|
||||
for tag in html_expands:
|
||||
text = text.replace(tag[u'start tag'], u'')
|
||||
text = text.replace(tag[u'end tag'], u'')
|
||||
return text
|
||||
|
||||
def expand_tags(text):
|
||||
"""
|
||||
Expand tags HTML for display
|
||||
"""
|
||||
for tag in html_expands:
|
||||
text = text.replace(tag[u'start tag'], tag[u'start html'])
|
||||
text = text.replace(tag[u'end tag'], tag[u'end html'])
|
||||
return text
|
||||
|
||||
from spelltextedit import SpellTextEdit
|
||||
from eventreceiver import Receiver
|
||||
from settingsmanager import SettingsManager
|
||||
from plugin import PluginStatus, Plugin
|
||||
from pluginmanager import PluginManager
|
||||
from settingstab import SettingsTab
|
||||
from serviceitem import ServiceItem
|
||||
from serviceitem import ServiceItemType
|
||||
from serviceitem import ItemCapabilities
|
||||
from htmlbuilder import build_html, build_lyrics_format_css, \
|
||||
build_lyrics_outline_css
|
||||
from toolbar import OpenLPToolbar
|
||||
from dockwidget import OpenLPDockWidget
|
||||
from theme import ThemeLevel, ThemeXML
|
||||
from renderer import Renderer
|
||||
from rendermanager import RenderManager
|
||||
from mediamanageritem import MediaManagerItem
|
||||
from baselistwithdnd import BaseListWithDnD
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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:`lib` module contains most of the components and libraries that make
|
||||
OpenLP work.
|
||||
"""
|
||||
import logging
|
||||
import os.path
|
||||
import types
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# TODO make external and configurable in alpha 4 via a settings dialog
|
||||
html_expands = []
|
||||
|
||||
html_expands.append({u'desc':u'Red', u'start tag':u'{r}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:red">', \
|
||||
u'end tag':u'{/r}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Black', u'start tag':u'{b}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:black">', \
|
||||
u'end tag':u'{/b}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Blue', u'start tag':u'{bl}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:blue">', \
|
||||
u'end tag':u'{/bl}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Yellow', u'start tag':u'{y}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:yellow">', \
|
||||
u'end tag':u'{/y}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Green', u'start tag':u'{g}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:green">', \
|
||||
u'end tag':u'{/g}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Pink', u'start tag':u'{pk}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:#CC33CC">', \
|
||||
u'end tag':u'{/pk}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Orange', u'start tag':u'{o}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:#CC0033">', \
|
||||
u'end tag':u'{/o}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Purple', u'start tag':u'{pp}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:#9900FF">', \
|
||||
u'end tag':u'{/pp}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'White', u'start tag':u'{w}', \
|
||||
u'start html':u'<span style="-webkit-text-fill-color:white">', \
|
||||
u'end tag':u'{/w}', u'end html':u'</span>', \
|
||||
u'protected':False})
|
||||
html_expands.append({u'desc':u'Superscript', u'start tag':u'{su}', \
|
||||
u'start html':u'<sup>', \
|
||||
u'end tag':u'{/su}', u'end html':u'</sup>', \
|
||||
u'protected':True})
|
||||
html_expands.append({u'desc':u'Subscript', u'start tag':u'{sb}', \
|
||||
u'start html':u'<sub>', \
|
||||
u'end tag':u'{/sb}', u'end html':u'</sub>', \
|
||||
u'protected':True})
|
||||
html_expands.append({u'desc':u'Paragraph', u'start tag':u'{p}', \
|
||||
u'start html':u'<p>', \
|
||||
u'end tag':u'{/p}', u'end html':u'</p>', \
|
||||
u'protected':True})
|
||||
html_expands.append({u'desc':u'Bold', u'start tag':u'{st}', \
|
||||
u'start html':u'<strong>', \
|
||||
u'end tag':u'{/st}', \
|
||||
u'end html':u'</strong>', \
|
||||
u'protected':True})
|
||||
html_expands.append({u'desc':u'Italics', u'start tag':u'{it}', \
|
||||
u'start html':u'<em>', \
|
||||
u'end tag':u'{/it}', u'end html':u'</em>', \
|
||||
u'protected':True})
|
||||
|
||||
def translate(context, text, comment=None):
|
||||
"""
|
||||
A special shortcut method to wrap around the Qt4 translation functions.
|
||||
This abstracts the translation procedure so that we can change it if at a
|
||||
later date if necessary, without having to redo the whole of OpenLP.
|
||||
|
||||
``context``
|
||||
The translation context, used to give each string a context or a
|
||||
namespace.
|
||||
|
||||
``text``
|
||||
The text to put into the translation tables for translation.
|
||||
|
||||
``comment``
|
||||
An identifying string for when the same text is used in different roles
|
||||
within the same context.
|
||||
"""
|
||||
return QtCore.QCoreApplication.translate(context, text, comment)
|
||||
|
||||
def get_text_file_string(text_file):
|
||||
"""
|
||||
Open a file and return its content as unicode string. If the supplied file
|
||||
name is not a file then the function returns False. If there is an error
|
||||
loading the file or the content can't be decoded then the function will
|
||||
return None.
|
||||
|
||||
``textfile``
|
||||
The name of the file.
|
||||
"""
|
||||
if not os.path.isfile(text_file):
|
||||
return False
|
||||
file_handle = None
|
||||
content_string = None
|
||||
try:
|
||||
file_handle = open(text_file, u'r')
|
||||
content = file_handle.read()
|
||||
content_string = content.decode(u'utf-8')
|
||||
except (IOError, UnicodeError):
|
||||
log.exception(u'Failed to open text file %s' % text_file)
|
||||
finally:
|
||||
if file_handle:
|
||||
file_handle.close()
|
||||
return content_string
|
||||
|
||||
def str_to_bool(stringvalue):
|
||||
"""
|
||||
Convert a string version of a boolean into a real boolean.
|
||||
|
||||
``stringvalue``
|
||||
The string value to examine and convert to a boolean type.
|
||||
"""
|
||||
if isinstance(stringvalue, bool):
|
||||
return stringvalue
|
||||
return unicode(stringvalue).strip().lower() in (u'true', u'yes', u'y')
|
||||
|
||||
def build_icon(icon):
|
||||
"""
|
||||
Build a QIcon instance from an existing QIcon, a resource location, or a
|
||||
physical file location. If the icon is a QIcon instance, that icon is
|
||||
simply returned. If not, it builds a QIcon instance from the resource or
|
||||
file name.
|
||||
|
||||
``icon``
|
||||
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``.
|
||||
"""
|
||||
button_icon = QtGui.QIcon()
|
||||
if isinstance(icon, QtGui.QIcon):
|
||||
button_icon = icon
|
||||
elif isinstance(icon, basestring):
|
||||
if icon.startswith(u':/'):
|
||||
button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
|
||||
QtGui.QIcon.Off)
|
||||
else:
|
||||
button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
elif isinstance(icon, QtGui.QImage):
|
||||
button_icon.addPixmap(QtGui.QPixmap.fromImage(icon),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
return button_icon
|
||||
|
||||
def context_menu_action(base, icon, text, slot):
|
||||
"""
|
||||
Utility method to help build context menus for plugins
|
||||
|
||||
``base``
|
||||
The parent menu to add this menu item to
|
||||
|
||||
``icon``
|
||||
An icon for this action
|
||||
|
||||
``text``
|
||||
The text to display for this action
|
||||
|
||||
``slot``
|
||||
The code to run when this action is triggered
|
||||
"""
|
||||
action = QtGui.QAction(text, base)
|
||||
if icon:
|
||||
action.setIcon(build_icon(icon))
|
||||
QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
|
||||
return action
|
||||
|
||||
def context_menu(base, icon, text):
|
||||
"""
|
||||
Utility method to help build context menus for plugins
|
||||
|
||||
``base``
|
||||
The parent object to add this menu to
|
||||
|
||||
``icon``
|
||||
An icon for this menu
|
||||
|
||||
``text``
|
||||
The text to display for this menu
|
||||
"""
|
||||
action = QtGui.QMenu(text, base)
|
||||
action.setIcon(build_icon(icon))
|
||||
return action
|
||||
|
||||
def context_menu_separator(base):
|
||||
"""
|
||||
Add a separator to a context menu
|
||||
|
||||
``base``
|
||||
The menu object to add the separator to
|
||||
"""
|
||||
action = QtGui.QAction(u'', base)
|
||||
action.setSeparator(True)
|
||||
return action
|
||||
|
||||
def image_to_byte(image):
|
||||
"""
|
||||
Resize an image to fit on the current screen for the web and returns
|
||||
it as a byte stream.
|
||||
|
||||
``image``
|
||||
The image to converted.
|
||||
"""
|
||||
byte_array = QtCore.QByteArray()
|
||||
# use buffer to store pixmap into byteArray
|
||||
buffie = QtCore.QBuffer(byte_array)
|
||||
buffie.open(QtCore.QIODevice.WriteOnly)
|
||||
if isinstance(image, QtGui.QImage):
|
||||
pixmap = QtGui.QPixmap.fromImage(image)
|
||||
else:
|
||||
pixmap = QtGui.QPixmap(image)
|
||||
pixmap.save(buffie, "PNG")
|
||||
# convert to base64 encoding so does not get missed!
|
||||
return byte_array.toBase64()
|
||||
|
||||
def resize_image(image, width, height, background=QtCore.Qt.black):
|
||||
"""
|
||||
Resize an image to fit on the current screen.
|
||||
|
||||
``image``
|
||||
The image to resize.
|
||||
|
||||
``width``
|
||||
The new image width.
|
||||
|
||||
``height``
|
||||
The new image height.
|
||||
|
||||
``background``
|
||||
The background colour defaults to black.
|
||||
|
||||
"""
|
||||
preview = QtGui.QImage(image)
|
||||
if not preview.isNull():
|
||||
# Only resize if different size
|
||||
if preview.width() == width and preview.height == height:
|
||||
return preview
|
||||
preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation)
|
||||
realw = preview.width()
|
||||
realh = preview.height()
|
||||
# and move it to the centre of the preview space
|
||||
new_image = QtGui.QImage(width, height,
|
||||
QtGui.QImage.Format_ARGB32_Premultiplied)
|
||||
new_image.fill(background)
|
||||
painter = QtGui.QPainter(new_image)
|
||||
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
|
||||
return new_image
|
||||
|
||||
def check_item_selected(list_widget, message):
|
||||
"""
|
||||
Check if a list item is selected so an action may be performed on it
|
||||
|
||||
``list_widget``
|
||||
The list to check for selected items
|
||||
|
||||
``message``
|
||||
The message to give the user if no item is selected
|
||||
"""
|
||||
if not list_widget.selectedIndexes():
|
||||
QtGui.QMessageBox.information(list_widget.parent(),
|
||||
translate('OpenLP.MediaManagerItem', 'No Items Selected'), message)
|
||||
return False
|
||||
return True
|
||||
|
||||
def clean_tags(text):
|
||||
"""
|
||||
Remove Tags from text for display
|
||||
"""
|
||||
text = text.replace(u'<br>', u'\n')
|
||||
for tag in html_expands:
|
||||
text = text.replace(tag[u'start tag'], u'')
|
||||
text = text.replace(tag[u'end tag'], u'')
|
||||
return text
|
||||
|
||||
def expand_tags(text):
|
||||
"""
|
||||
Expand tags HTML for display
|
||||
"""
|
||||
for tag in html_expands:
|
||||
text = text.replace(tag[u'start tag'], tag[u'start html'])
|
||||
text = text.replace(tag[u'end tag'], tag[u'end html'])
|
||||
return text
|
||||
|
||||
from spelltextedit import SpellTextEdit
|
||||
from eventreceiver import Receiver
|
||||
from settingsmanager import SettingsManager
|
||||
from plugin import PluginStatus, StringType, Plugin
|
||||
from pluginmanager import PluginManager
|
||||
from settingstab import SettingsTab
|
||||
from serviceitem import ServiceItem
|
||||
from serviceitem import ServiceItemType
|
||||
from serviceitem import ItemCapabilities
|
||||
from htmlbuilder import build_html, build_lyrics_format_css, \
|
||||
build_lyrics_outline_css
|
||||
from toolbar import OpenLPToolbar
|
||||
from dockwidget import OpenLPDockWidget
|
||||
from theme import ThemeLevel, ThemeXML
|
||||
from renderer import Renderer
|
||||
from rendermanager import RenderManager
|
||||
from mediamanageritem import MediaManagerItem
|
||||
from baselistwithdnd import BaseListWithDnD
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,306 +1,319 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
"""
|
||||
Provide the generic plugin functionality for OpenLP plugins.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class PluginStatus(object):
|
||||
"""
|
||||
Defines the status of the plugin
|
||||
"""
|
||||
Active = 1
|
||||
Inactive = 0
|
||||
Disabled = -1
|
||||
|
||||
class Plugin(QtCore.QObject):
|
||||
"""
|
||||
Base class for openlp plugins to inherit from.
|
||||
|
||||
**Basic Attributes**
|
||||
|
||||
``name``
|
||||
The name that should appear in the plugins list.
|
||||
|
||||
``version``
|
||||
The version number of this iteration of the plugin.
|
||||
|
||||
``settingsSection``
|
||||
The namespace to store settings for the plugin.
|
||||
|
||||
``icon``
|
||||
An instance of QIcon, which holds an icon for this plugin.
|
||||
|
||||
``log``
|
||||
A log object used to log debugging messages. This is pre-instantiated.
|
||||
|
||||
``weight``
|
||||
A numerical value used to order the plugins.
|
||||
|
||||
**Hook Functions**
|
||||
|
||||
``checkPreConditions()``
|
||||
Provides the Plugin with a handle to check if it can be loaded.
|
||||
|
||||
``getMediaManagerItem()``
|
||||
Returns an instance of MediaManagerItem to be used in the Media Manager.
|
||||
|
||||
``addImportMenuItem(import_menu)``
|
||||
Add an item to the Import menu.
|
||||
|
||||
``addExportMenuItem(export_menu)``
|
||||
Add an item to the Export menu.
|
||||
|
||||
``getSettingsTab()``
|
||||
Returns an instance of SettingsTabItem to be used in the Settings
|
||||
dialog.
|
||||
|
||||
``addToMenu(menubar)``
|
||||
A method to add a menu item to anywhere in the menu, given the menu bar.
|
||||
|
||||
``handle_event(event)``
|
||||
A method use to handle events, given an Event object.
|
||||
|
||||
``about()``
|
||||
Used in the plugin manager, when a person clicks on the 'About' button.
|
||||
|
||||
"""
|
||||
log.info(u'loaded')
|
||||
|
||||
def __init__(self, name, version=None, plugin_helpers=None):
|
||||
"""
|
||||
This is the constructor for the plugin object. This provides an easy
|
||||
way for descendent plugins to populate common data. This method *must*
|
||||
be overridden, like so::
|
||||
|
||||
class MyPlugin(Plugin):
|
||||
def __init__(self):
|
||||
Plugin.__init(self, u'MyPlugin', u'0.1')
|
||||
|
||||
``name``
|
||||
Defaults to *None*. The name of the plugin.
|
||||
|
||||
``version``
|
||||
Defaults to *None*. The version of the plugin.
|
||||
|
||||
``plugin_helpers``
|
||||
Defaults to *None*. A list of helper objects.
|
||||
"""
|
||||
QtCore.QObject.__init__(self)
|
||||
self.name = name
|
||||
if version:
|
||||
self.version = version
|
||||
self.settingsSection = self.name.lower()
|
||||
self.icon = None
|
||||
self.weight = 0
|
||||
self.status = PluginStatus.Inactive
|
||||
# Set up logging
|
||||
self.log = logging.getLogger(self.name)
|
||||
self.previewController = plugin_helpers[u'preview']
|
||||
self.liveController = plugin_helpers[u'live']
|
||||
self.renderManager = plugin_helpers[u'render']
|
||||
self.serviceManager = plugin_helpers[u'service']
|
||||
self.settingsForm = plugin_helpers[u'settings form']
|
||||
self.mediadock = plugin_helpers[u'toolbox']
|
||||
self.pluginManager = plugin_helpers[u'pluginmanager']
|
||||
self.formparent = plugin_helpers[u'formparent']
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
|
||||
self.processAddServiceEvent)
|
||||
|
||||
def checkPreConditions(self):
|
||||
"""
|
||||
Provides the Plugin with a handle to check if it can be loaded.
|
||||
Failing Preconditions does not stop a settings Tab being created
|
||||
|
||||
Returns True or False.
|
||||
"""
|
||||
return True
|
||||
|
||||
def setStatus(self):
|
||||
"""
|
||||
Sets the status of the plugin
|
||||
"""
|
||||
self.status = QtCore.QSettings().value(
|
||||
self.settingsSection + u'/status',
|
||||
QtCore.QVariant(PluginStatus.Inactive)).toInt()[0]
|
||||
|
||||
def toggleStatus(self, new_status):
|
||||
"""
|
||||
Changes the status of the plugin and remembers it
|
||||
"""
|
||||
self.status = new_status
|
||||
QtCore.QSettings().setValue(
|
||||
self.settingsSection + u'/status', QtCore.QVariant(self.status))
|
||||
|
||||
def isActive(self):
|
||||
"""
|
||||
Indicates if the plugin is active
|
||||
|
||||
Returns True or False.
|
||||
"""
|
||||
return self.status == PluginStatus.Active
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
"""
|
||||
Construct a MediaManagerItem object with all the buttons and things
|
||||
you need, and return it for integration into openlp.org.
|
||||
"""
|
||||
pass
|
||||
|
||||
def addImportMenuItem(self, importMenu):
|
||||
"""
|
||||
Create a menu item and add it to the "Import" menu.
|
||||
|
||||
``importMenu``
|
||||
The Import menu.
|
||||
"""
|
||||
pass
|
||||
|
||||
def addExportMenuItem(self, exportMenu):
|
||||
"""
|
||||
Create a menu item and add it to the "Export" menu.
|
||||
|
||||
``exportMenu``
|
||||
The Export menu
|
||||
"""
|
||||
pass
|
||||
|
||||
def addToolsMenuItem(self, toolsMenu):
|
||||
"""
|
||||
Create a menu item and add it to the "Tools" menu.
|
||||
|
||||
``toolsMenu``
|
||||
The Tools menu
|
||||
"""
|
||||
pass
|
||||
|
||||
def getSettingsTab(self):
|
||||
"""
|
||||
Create a tab for the settings window.
|
||||
"""
|
||||
pass
|
||||
|
||||
def addToMenu(self, menubar):
|
||||
"""
|
||||
Add menu items to the menu, given the menubar.
|
||||
|
||||
``menubar``
|
||||
The application's menu bar.
|
||||
"""
|
||||
pass
|
||||
|
||||
def processAddServiceEvent(self, replace=False):
|
||||
"""
|
||||
Generic Drag and drop handler triggered from service_manager.
|
||||
"""
|
||||
log.debug(u'processAddServiceEvent event called for plugin %s' %
|
||||
self.name)
|
||||
if replace:
|
||||
self.mediaItem.onAddEditClick()
|
||||
else:
|
||||
self.mediaItem.onAddClick()
|
||||
|
||||
def about(self):
|
||||
"""
|
||||
Show a dialog when the user clicks on the 'About' button in the plugin
|
||||
manager.
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
u'Plugin.about needs to be defined by the plugin')
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
Called by the plugin Manager to initialise anything it needs.
|
||||
"""
|
||||
if self.mediaItem:
|
||||
self.mediaItem.initialise()
|
||||
self.insertToolboxItem()
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
Called by the plugin Manager to cleanup things.
|
||||
"""
|
||||
self.removeToolboxItem()
|
||||
|
||||
def removeToolboxItem(self):
|
||||
"""
|
||||
Called by the plugin to remove toolbar
|
||||
"""
|
||||
if self.mediaItem:
|
||||
self.mediadock.remove_dock(self.name)
|
||||
if self.settings_tab:
|
||||
self.settingsForm.removeTab(self.name)
|
||||
|
||||
def insertToolboxItem(self):
|
||||
"""
|
||||
Called by plugin to replace toolbar
|
||||
"""
|
||||
if self.mediaItem:
|
||||
self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight)
|
||||
if self.settings_tab:
|
||||
self.settingsForm.insertTab(self.settings_tab, self.weight)
|
||||
|
||||
def usesTheme(self, theme):
|
||||
"""
|
||||
Called to find out if a plugin is currently using a theme.
|
||||
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
return False
|
||||
|
||||
def renameTheme(self, oldTheme, newTheme):
|
||||
"""
|
||||
Renames a theme a plugin is using making the plugin use the new name.
|
||||
|
||||
``oldTheme``
|
||||
The name of the theme the plugin should stop using.
|
||||
|
||||
``newTheme``
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
pass
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
pass
|
||||
self.text = {}
|
||||
|
||||
def get_text(self, content):
|
||||
"""
|
||||
Called to retrieve a translated piece of text for menues, context menues, ...
|
||||
"""
|
||||
if self.text.has_key(content):
|
||||
return self.text[content]
|
||||
else:
|
||||
return self.name
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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 #
|
||||
###############################################################################
|
||||
"""
|
||||
Provide the generic plugin functionality for OpenLP plugins.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import Receiver
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class PluginStatus(object):
|
||||
"""
|
||||
Defines the status of the plugin
|
||||
"""
|
||||
Active = 1
|
||||
Inactive = 0
|
||||
Disabled = -1
|
||||
|
||||
class StringType(object):
|
||||
Name = u'name'
|
||||
Import = u'import'
|
||||
Load = u'load'
|
||||
New = u'new'
|
||||
Edit = u'edit'
|
||||
Delete = u'delete'
|
||||
Preview = u'preview'
|
||||
Live = u'live'
|
||||
Service = u'service'
|
||||
|
||||
class Plugin(QtCore.QObject):
|
||||
"""
|
||||
Base class for openlp plugins to inherit from.
|
||||
|
||||
**Basic Attributes**
|
||||
|
||||
``name``
|
||||
The name that should appear in the plugins list.
|
||||
|
||||
``version``
|
||||
The version number of this iteration of the plugin.
|
||||
|
||||
``settingsSection``
|
||||
The namespace to store settings for the plugin.
|
||||
|
||||
``icon``
|
||||
An instance of QIcon, which holds an icon for this plugin.
|
||||
|
||||
``log``
|
||||
A log object used to log debugging messages. This is pre-instantiated.
|
||||
|
||||
``weight``
|
||||
A numerical value used to order the plugins.
|
||||
|
||||
**Hook Functions**
|
||||
|
||||
``checkPreConditions()``
|
||||
Provides the Plugin with a handle to check if it can be loaded.
|
||||
|
||||
``getMediaManagerItem()``
|
||||
Returns an instance of MediaManagerItem to be used in the Media Manager.
|
||||
|
||||
``addImportMenuItem(import_menu)``
|
||||
Add an item to the Import menu.
|
||||
|
||||
``addExportMenuItem(export_menu)``
|
||||
Add an item to the Export menu.
|
||||
|
||||
``getSettingsTab()``
|
||||
Returns an instance of SettingsTabItem to be used in the Settings
|
||||
dialog.
|
||||
|
||||
``addToMenu(menubar)``
|
||||
A method to add a menu item to anywhere in the menu, given the menu bar.
|
||||
|
||||
``handle_event(event)``
|
||||
A method use to handle events, given an Event object.
|
||||
|
||||
``about()``
|
||||
Used in the plugin manager, when a person clicks on the 'About' button.
|
||||
|
||||
"""
|
||||
log.info(u'loaded')
|
||||
|
||||
def __init__(self, name, version=None, plugin_helpers=None):
|
||||
"""
|
||||
This is the constructor for the plugin object. This provides an easy
|
||||
way for descendent plugins to populate common data. This method *must*
|
||||
be overridden, like so::
|
||||
|
||||
class MyPlugin(Plugin):
|
||||
def __init__(self):
|
||||
Plugin.__init(self, u'MyPlugin', u'0.1')
|
||||
|
||||
``name``
|
||||
Defaults to *None*. The name of the plugin.
|
||||
|
||||
``version``
|
||||
Defaults to *None*. The version of the plugin.
|
||||
|
||||
``plugin_helpers``
|
||||
Defaults to *None*. A list of helper objects.
|
||||
"""
|
||||
QtCore.QObject.__init__(self)
|
||||
self.name = name
|
||||
self.set_plugin_strings()
|
||||
if version:
|
||||
self.version = version
|
||||
self.settingsSection = self.name.lower()
|
||||
self.icon = None
|
||||
self.weight = 0
|
||||
self.status = PluginStatus.Inactive
|
||||
# Set up logging
|
||||
self.log = logging.getLogger(self.name)
|
||||
self.previewController = plugin_helpers[u'preview']
|
||||
self.liveController = plugin_helpers[u'live']
|
||||
self.renderManager = plugin_helpers[u'render']
|
||||
self.serviceManager = plugin_helpers[u'service']
|
||||
self.settingsForm = plugin_helpers[u'settings form']
|
||||
self.mediadock = plugin_helpers[u'toolbox']
|
||||
self.pluginManager = plugin_helpers[u'pluginmanager']
|
||||
self.formparent = plugin_helpers[u'formparent']
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
|
||||
self.processAddServiceEvent)
|
||||
|
||||
def checkPreConditions(self):
|
||||
"""
|
||||
Provides the Plugin with a handle to check if it can be loaded.
|
||||
Failing Preconditions does not stop a settings Tab being created
|
||||
|
||||
Returns True or False.
|
||||
"""
|
||||
return True
|
||||
|
||||
def setStatus(self):
|
||||
"""
|
||||
Sets the status of the plugin
|
||||
"""
|
||||
self.status = QtCore.QSettings().value(
|
||||
self.settingsSection + u'/status',
|
||||
QtCore.QVariant(PluginStatus.Inactive)).toInt()[0]
|
||||
|
||||
def toggleStatus(self, new_status):
|
||||
"""
|
||||
Changes the status of the plugin and remembers it
|
||||
"""
|
||||
self.status = new_status
|
||||
QtCore.QSettings().setValue(
|
||||
self.settingsSection + u'/status', QtCore.QVariant(self.status))
|
||||
|
||||
def isActive(self):
|
||||
"""
|
||||
Indicates if the plugin is active
|
||||
|
||||
Returns True or False.
|
||||
"""
|
||||
return self.status == PluginStatus.Active
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
"""
|
||||
Construct a MediaManagerItem object with all the buttons and things
|
||||
you need, and return it for integration into openlp.org.
|
||||
"""
|
||||
pass
|
||||
|
||||
def addImportMenuItem(self, importMenu):
|
||||
"""
|
||||
Create a menu item and add it to the "Import" menu.
|
||||
|
||||
``importMenu``
|
||||
The Import menu.
|
||||
"""
|
||||
pass
|
||||
|
||||
def addExportMenuItem(self, exportMenu):
|
||||
"""
|
||||
Create a menu item and add it to the "Export" menu.
|
||||
|
||||
``exportMenu``
|
||||
The Export menu
|
||||
"""
|
||||
pass
|
||||
|
||||
def addToolsMenuItem(self, toolsMenu):
|
||||
"""
|
||||
Create a menu item and add it to the "Tools" menu.
|
||||
|
||||
``toolsMenu``
|
||||
The Tools menu
|
||||
"""
|
||||
pass
|
||||
|
||||
def getSettingsTab(self):
|
||||
"""
|
||||
Create a tab for the settings window.
|
||||
"""
|
||||
pass
|
||||
|
||||
def addToMenu(self, menubar):
|
||||
"""
|
||||
Add menu items to the menu, given the menubar.
|
||||
|
||||
``menubar``
|
||||
The application's menu bar.
|
||||
"""
|
||||
pass
|
||||
|
||||
def processAddServiceEvent(self, replace=False):
|
||||
"""
|
||||
Generic Drag and drop handler triggered from service_manager.
|
||||
"""
|
||||
log.debug(u'processAddServiceEvent event called for plugin %s' %
|
||||
self.name)
|
||||
if replace:
|
||||
self.mediaItem.onAddEditClick()
|
||||
else:
|
||||
self.mediaItem.onAddClick()
|
||||
|
||||
def about(self):
|
||||
"""
|
||||
Show a dialog when the user clicks on the 'About' button in the plugin
|
||||
manager.
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
u'Plugin.about needs to be defined by the plugin')
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
Called by the plugin Manager to initialise anything it needs.
|
||||
"""
|
||||
if self.mediaItem:
|
||||
self.mediaItem.initialise()
|
||||
self.insertToolboxItem()
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
Called by the plugin Manager to cleanup things.
|
||||
"""
|
||||
self.removeToolboxItem()
|
||||
|
||||
def removeToolboxItem(self):
|
||||
"""
|
||||
Called by the plugin to remove toolbar
|
||||
"""
|
||||
if self.mediaItem:
|
||||
self.mediadock.remove_dock(self.name)
|
||||
if self.settings_tab:
|
||||
self.settingsForm.removeTab(self.name)
|
||||
|
||||
def insertToolboxItem(self):
|
||||
"""
|
||||
Called by plugin to replace toolbar
|
||||
"""
|
||||
if self.mediaItem:
|
||||
self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight)
|
||||
if self.settings_tab:
|
||||
self.settingsForm.insertTab(self.settings_tab, self.weight)
|
||||
|
||||
def usesTheme(self, theme):
|
||||
"""
|
||||
Called to find out if a plugin is currently using a theme.
|
||||
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
return False
|
||||
|
||||
def renameTheme(self, oldTheme, newTheme):
|
||||
"""
|
||||
Renames a theme a plugin is using making the plugin use the new name.
|
||||
|
||||
``oldTheme``
|
||||
The name of the theme the plugin should stop using.
|
||||
|
||||
``newTheme``
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
pass
|
||||
|
||||
def getString(self, name):
|
||||
if name in self.strings:
|
||||
return self.strings[name]
|
||||
else:
|
||||
# do something here?
|
||||
return None
|
||||
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Plugin'
|
||||
self.name_lower = u'plugin'
|
||||
|
||||
self.strings = {}
|
||||
|
@ -1,84 +1,84 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class MediaDockManager(object):
|
||||
"""
|
||||
Provide a repository for MediaManagerItems
|
||||
"""
|
||||
def __init__(self, media_dock):
|
||||
"""
|
||||
Initialise the media dock
|
||||
"""
|
||||
self.media_dock = media_dock
|
||||
|
||||
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)
|
||||
self.media_dock.addItem(media_item, icon, media_item.title)
|
||||
|
||||
def insert_dock(self, media_item, icon, weight):
|
||||
"""
|
||||
This should insert a dock item at a given location
|
||||
This does not work as it gives a Segmentation error.
|
||||
For now add at end of stack if not present
|
||||
"""
|
||||
log.debug(u'Inserting %s dock' % media_item.title)
|
||||
match = False
|
||||
for dock_index in range(0, self.media_dock.count()):
|
||||
if self.media_dock.widget(dock_index).settingsSection == \
|
||||
media_item.parent.get_text('name_lower'):
|
||||
match = True
|
||||
break
|
||||
if not match:
|
||||
self.media_dock.addItem(media_item, icon, media_item.title)
|
||||
|
||||
def remove_dock(self, name):
|
||||
"""
|
||||
Removes a MediaManagerItem from the dock
|
||||
|
||||
``name``
|
||||
The item to remove
|
||||
"""
|
||||
log.debug(u'remove %s dock' % name)
|
||||
for dock_index in range(0, self.media_dock.count()):
|
||||
if self.media_dock.widget(dock_index):
|
||||
log.debug(u'%s %s' % (name, self.media_dock.widget(dock_index).settingsSection))
|
||||
if self.media_dock.widget(dock_index).settingsSection == \
|
||||
name:
|
||||
self.media_dock.widget(dock_index).hide()
|
||||
self.media_dock.removeItem(dock_index)
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class MediaDockManager(object):
|
||||
"""
|
||||
Provide a repository for MediaManagerItems
|
||||
"""
|
||||
def __init__(self, media_dock):
|
||||
"""
|
||||
Initialise the media dock
|
||||
"""
|
||||
self.media_dock = media_dock
|
||||
|
||||
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)
|
||||
self.media_dock.addItem(media_item, icon, media_item.title)
|
||||
|
||||
def insert_dock(self, media_item, icon, weight):
|
||||
"""
|
||||
This should insert a dock item at a given location
|
||||
This does not work as it gives a Segmentation error.
|
||||
For now add at end of stack if not present
|
||||
"""
|
||||
log.debug(u'Inserting %s dock' % media_item.title)
|
||||
match = False
|
||||
for dock_index in range(0, self.media_dock.count()):
|
||||
if self.media_dock.widget(dock_index).settingsSection == \
|
||||
media_item.parent.name_lower:
|
||||
match = True
|
||||
break
|
||||
if not match:
|
||||
self.media_dock.addItem(media_item, icon, media_item.title)
|
||||
|
||||
def remove_dock(self, name):
|
||||
"""
|
||||
Removes a MediaManagerItem from the dock
|
||||
|
||||
``name``
|
||||
The item to remove
|
||||
"""
|
||||
log.debug(u'remove %s dock' % name)
|
||||
for dock_index in range(0, self.media_dock.count()):
|
||||
if self.media_dock.widget(dock_index):
|
||||
log.debug(u'%s %s' % (name, self.media_dock.widget(dock_index).settingsSection))
|
||||
if self.media_dock.widget(dock_index).settingsSection == \
|
||||
name:
|
||||
self.media_dock.widget(dock_index).hide()
|
||||
self.media_dock.removeItem(dock_index)
|
||||
|
@ -1,138 +1,141 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import PluginStatus, translate
|
||||
from plugindialog import Ui_PluginViewDialog
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.parent = parent
|
||||
self.activePlugin = None
|
||||
self.programaticChange = False
|
||||
self.setupUi(self)
|
||||
self.load()
|
||||
self._clearDetails()
|
||||
# Right, now let's put some signals and slots together!
|
||||
QtCore.QObject.connect(
|
||||
self.pluginListWidget,
|
||||
QtCore.SIGNAL(u'itemSelectionChanged()'),
|
||||
self.onPluginListWidgetSelectionChanged)
|
||||
QtCore.QObject.connect(
|
||||
self.statusComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
self.onStatusComboBoxChanged)
|
||||
|
||||
def load(self):
|
||||
"""
|
||||
Load the plugin details into the screen
|
||||
"""
|
||||
self.pluginListWidget.clear()
|
||||
for plugin in self.parent.plugin_manager.plugins:
|
||||
item = QtGui.QListWidgetItem(self.pluginListWidget)
|
||||
# We do this just to make 100% sure the status is an integer as
|
||||
# sometimes when it's loaded from the config, it isn't cast to int.
|
||||
plugin.status = int(plugin.status)
|
||||
# Set the little status text in brackets next to the plugin name.
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Inactive)'))
|
||||
if plugin.status == PluginStatus.Active:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Active)'))
|
||||
elif plugin.status == PluginStatus.Inactive:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Inactive)'))
|
||||
elif plugin.status == PluginStatus.Disabled:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Disabled)'))
|
||||
item.setText(status_text % plugin.get_text('name_more'))
|
||||
# If the plugin has an icon, set it!
|
||||
if plugin.icon:
|
||||
item.setIcon(plugin.icon)
|
||||
self.pluginListWidget.addItem(item)
|
||||
|
||||
def _clearDetails(self):
|
||||
self.statusComboBox.setCurrentIndex(-1)
|
||||
self.versionNumberLabel.setText(u'')
|
||||
self.aboutTextBrowser.setHtml(u'')
|
||||
self.statusComboBox.setEnabled(False)
|
||||
|
||||
def _setDetails(self):
|
||||
log.debug('PluginStatus: %s', str(self.activePlugin.status))
|
||||
self.versionNumberLabel.setText(self.activePlugin.version)
|
||||
self.aboutTextBrowser.setHtml(self.activePlugin.about())
|
||||
self.programaticChange = True
|
||||
status = 1
|
||||
if self.activePlugin.status == PluginStatus.Active:
|
||||
status = 0
|
||||
self.statusComboBox.setCurrentIndex(status)
|
||||
self.statusComboBox.setEnabled(True)
|
||||
self.programaticChange = False
|
||||
|
||||
def onPluginListWidgetSelectionChanged(self):
|
||||
if self.pluginListWidget.currentItem() is None:
|
||||
self._clearDetails()
|
||||
return
|
||||
plugin_name_more = self.pluginListWidget.currentItem().text().split(u' ')[0]
|
||||
self.activePlugin = None
|
||||
for plugin in self.parent.plugin_manager.plugins:
|
||||
if plugin.get_text('name_more') == plugin_name_more:
|
||||
self.activePlugin = plugin
|
||||
break
|
||||
if self.activePlugin:
|
||||
self._setDetails()
|
||||
else:
|
||||
self._clearDetails()
|
||||
|
||||
def onStatusComboBoxChanged(self, status):
|
||||
if self.programaticChange:
|
||||
return
|
||||
if status == 0:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Active)
|
||||
self.activePlugin.initialise()
|
||||
else:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
||||
self.activePlugin.finalise()
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Inactive)'))
|
||||
if self.activePlugin.status == PluginStatus.Active:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Active)'))
|
||||
elif self.activePlugin.status == PluginStatus.Inactive:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Inactive)'))
|
||||
elif self.activePlugin.status == PluginStatus.Disabled:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Disabled)'))
|
||||
self.pluginListWidget.currentItem().setText(
|
||||
status_text % self.activePlugin.get_text('name_more'))
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import PluginStatus, StringType, translate
|
||||
from plugindialog import Ui_PluginViewDialog
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class PluginForm(QtGui.QDialog, Ui_PluginViewDialog):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.parent = parent
|
||||
self.activePlugin = None
|
||||
self.programaticChange = False
|
||||
self.setupUi(self)
|
||||
self.load()
|
||||
self._clearDetails()
|
||||
# Right, now let's put some signals and slots together!
|
||||
QtCore.QObject.connect(
|
||||
self.pluginListWidget,
|
||||
QtCore.SIGNAL(u'itemSelectionChanged()'),
|
||||
self.onPluginListWidgetSelectionChanged)
|
||||
QtCore.QObject.connect(
|
||||
self.statusComboBox,
|
||||
QtCore.SIGNAL(u'currentIndexChanged(int)'),
|
||||
self.onStatusComboBoxChanged)
|
||||
|
||||
def load(self):
|
||||
"""
|
||||
Load the plugin details into the screen
|
||||
"""
|
||||
self.pluginListWidget.clear()
|
||||
for plugin in self.parent.plugin_manager.plugins:
|
||||
item = QtGui.QListWidgetItem(self.pluginListWidget)
|
||||
# We do this just to make 100% sure the status is an integer as
|
||||
# sometimes when it's loaded from the config, it isn't cast to int.
|
||||
plugin.status = int(plugin.status)
|
||||
# Set the little status text in brackets next to the plugin name.
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Inactive)'))
|
||||
if plugin.status == PluginStatus.Active:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Active)'))
|
||||
elif plugin.status == PluginStatus.Inactive:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Inactive)'))
|
||||
elif plugin.status == PluginStatus.Disabled:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Disabled)'))
|
||||
nameString = plugin.getString(StringType.Name)
|
||||
item.setText(status_text % nameString[u'plural'])
|
||||
# If the plugin has an icon, set it!
|
||||
if plugin.icon:
|
||||
item.setIcon(plugin.icon)
|
||||
self.pluginListWidget.addItem(item)
|
||||
|
||||
def _clearDetails(self):
|
||||
self.statusComboBox.setCurrentIndex(-1)
|
||||
self.versionNumberLabel.setText(u'')
|
||||
self.aboutTextBrowser.setHtml(u'')
|
||||
self.statusComboBox.setEnabled(False)
|
||||
|
||||
def _setDetails(self):
|
||||
log.debug('PluginStatus: %s', str(self.activePlugin.status))
|
||||
self.versionNumberLabel.setText(self.activePlugin.version)
|
||||
self.aboutTextBrowser.setHtml(self.activePlugin.about())
|
||||
self.programaticChange = True
|
||||
status = 1
|
||||
if self.activePlugin.status == PluginStatus.Active:
|
||||
status = 0
|
||||
self.statusComboBox.setCurrentIndex(status)
|
||||
self.statusComboBox.setEnabled(True)
|
||||
self.programaticChange = False
|
||||
|
||||
def onPluginListWidgetSelectionChanged(self):
|
||||
if self.pluginListWidget.currentItem() is None:
|
||||
self._clearDetails()
|
||||
return
|
||||
plugin_name_more = self.pluginListWidget.currentItem().text().split(u' ')[0]
|
||||
self.activePlugin = None
|
||||
for plugin in self.parent.plugin_manager.plugins:
|
||||
nameString = plugin.getString(StringType.Name)
|
||||
if nameString[u'plural'] == plugin_name_more:
|
||||
self.activePlugin = plugin
|
||||
break
|
||||
if self.activePlugin:
|
||||
self._setDetails()
|
||||
else:
|
||||
self._clearDetails()
|
||||
|
||||
def onStatusComboBoxChanged(self, status):
|
||||
if self.programaticChange:
|
||||
return
|
||||
if status == 0:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Active)
|
||||
self.activePlugin.initialise()
|
||||
else:
|
||||
self.activePlugin.toggleStatus(PluginStatus.Inactive)
|
||||
self.activePlugin.finalise()
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Inactive)'))
|
||||
if self.activePlugin.status == PluginStatus.Active:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Active)'))
|
||||
elif self.activePlugin.status == PluginStatus.Inactive:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Inactive)'))
|
||||
elif self.activePlugin.status == PluginStatus.Disabled:
|
||||
status_text = unicode(
|
||||
translate('OpenLP.PluginForm', '%s (Disabled)'))
|
||||
nameString = self.activePlugin.getString(StringType.Name)
|
||||
self.pluginListWidget.currentItem().setText(
|
||||
status_text % nameString[u'plural'])
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,132 +1,117 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab
|
||||
from openlp.plugins.alerts.lib.db import init_schema
|
||||
from openlp.plugins.alerts.forms import AlertForm
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class AlertsPlugin(Plugin):
|
||||
log.info(u'Alerts Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_translations()
|
||||
Plugin.__init__(self, u'Alerts', u'1.9.2', plugin_helpers)
|
||||
self.weight = -3
|
||||
self.icon = build_icon(u':/plugins/plugin_alerts.png')
|
||||
self.alertsmanager = AlertsManager(self)
|
||||
self.manager = Manager(u'alerts', init_schema)
|
||||
self.alertForm = AlertForm(self)
|
||||
|
||||
def getSettingsTab(self):
|
||||
"""
|
||||
Return the settings tab for the Alerts plugin
|
||||
"""
|
||||
self.alertsTab = AlertsTab(self)
|
||||
return self.alertsTab
|
||||
|
||||
def addToolsMenuItem(self, tools_menu):
|
||||
"""
|
||||
Give the alerts plugin the opportunity to add items to the
|
||||
**Tools** menu.
|
||||
|
||||
``tools_menu``
|
||||
The actual **Tools** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
log.info(u'add tools menu')
|
||||
self.toolsAlertItem = QtGui.QAction(tools_menu)
|
||||
self.toolsAlertItem.setIcon(build_icon(u':/plugins/plugin_alerts.png'))
|
||||
self.toolsAlertItem.setObjectName(u'toolsAlertItem')
|
||||
self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
|
||||
self.toolsAlertItem.setStatusTip(
|
||||
translate('AlertsPlugin', 'Show an alert message.'))
|
||||
self.toolsAlertItem.setShortcut(u'F7')
|
||||
self.serviceManager.parent.ToolsMenu.addAction(self.toolsAlertItem)
|
||||
QtCore.QObject.connect(self.toolsAlertItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onAlertsTrigger)
|
||||
self.toolsAlertItem.setVisible(False)
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'Alerts Initialising')
|
||||
Plugin.initialise(self)
|
||||
self.toolsAlertItem.setVisible(True)
|
||||
self.liveController.alertTab = self.alertsTab
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Alerts Finalising')
|
||||
Plugin.finalise(self)
|
||||
self.toolsAlertItem.setVisible(False)
|
||||
|
||||
def toggleAlertsState(self):
|
||||
self.alertsActive = not self.alertsActive
|
||||
QtCore.QSettings().setValue(self.settingsSection + u'/active',
|
||||
QtCore.QVariant(self.alertsActive))
|
||||
|
||||
def onAlertsTrigger(self):
|
||||
self.alertForm.loadList()
|
||||
self.alertForm.exec_()
|
||||
|
||||
def about(self):
|
||||
about_text = translate('AlertsPlugin', '<strong>Alerts Plugin</strong>'
|
||||
'<br />The alert plugin controls the displaying of nursery alerts '
|
||||
'on the display screen')
|
||||
return about_text
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Alerts'
|
||||
self.name_lower = u'alerts'
|
||||
self.text = {}
|
||||
# for context menu
|
||||
# elf.text['context_edit'] = translate('AlertsPlugin', '&Edit Song')
|
||||
# elf.text['context_delete'] = translate('AlertsPlugin', '&Delete Song')
|
||||
# elf.text['context_preview'] = translate('AlertsPlugin', '&Preview Song')
|
||||
# elf.text['context_live'] = translate('AlertsPlugin', '&Show Live')
|
||||
# # forHeaders in mediamanagerdock
|
||||
# elf.text['import'] = translate('AlertsPlugin', 'Import a Song')
|
||||
# elf.text['file'] = translate('AlertsPlugin', 'Load a new Song')
|
||||
# elf.text['new'] = translate('AlertsPlugin', 'Add a new Song')
|
||||
# elf.text['edit'] = translate('AlertsPlugin', 'Edit the selected Song')
|
||||
# elf.text['delete'] = translate('AlertsPlugin', 'Delete the selected Song')
|
||||
# elf.text['delete_more'] = translate('AlertsPlugin', 'Delete the selected Songs')
|
||||
# elf.text['preview'] = translate('AlertsPlugin', 'Preview the selected Song')
|
||||
# elf.text['preview_more'] = translate('AlertsPlugin', 'Preview the selected Songs')
|
||||
# elf.text['live'] = translate('AlertsPlugin', 'Send the selected Song live')
|
||||
# elf.text['live_more'] = translate('AlertsPlugin', 'Send the selected Songs live')
|
||||
# elf.text['service'] = translate('AlertsPlugin', 'Add the selected Song to the service')
|
||||
# elf.text['service_more'] = translate('AlertsPlugin', 'Add the selected Songs to the service')
|
||||
# # for names in mediamanagerdock and pluginlist
|
||||
self.text['name'] = translate('AlertsPlugin', 'Alert')
|
||||
self.text['name_more'] = translate('AlertsPlugin', 'Alerts')
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, StringType, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab
|
||||
from openlp.plugins.alerts.lib.db import init_schema
|
||||
from openlp.plugins.alerts.forms import AlertForm
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class AlertsPlugin(Plugin):
|
||||
log.info(u'Alerts Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_strings()
|
||||
Plugin.__init__(self, u'Alerts', u'1.9.2', plugin_helpers)
|
||||
self.weight = -3
|
||||
self.icon = build_icon(u':/plugins/plugin_alerts.png')
|
||||
self.alertsmanager = AlertsManager(self)
|
||||
self.manager = Manager(u'alerts', init_schema)
|
||||
self.alertForm = AlertForm(self)
|
||||
|
||||
def getSettingsTab(self):
|
||||
"""
|
||||
Return the settings tab for the Alerts plugin
|
||||
"""
|
||||
self.alertsTab = AlertsTab(self)
|
||||
return self.alertsTab
|
||||
|
||||
def addToolsMenuItem(self, tools_menu):
|
||||
"""
|
||||
Give the alerts plugin the opportunity to add items to the
|
||||
**Tools** menu.
|
||||
|
||||
``tools_menu``
|
||||
The actual **Tools** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
log.info(u'add tools menu')
|
||||
self.toolsAlertItem = QtGui.QAction(tools_menu)
|
||||
self.toolsAlertItem.setIcon(build_icon(u':/plugins/plugin_alerts.png'))
|
||||
self.toolsAlertItem.setObjectName(u'toolsAlertItem')
|
||||
self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
|
||||
self.toolsAlertItem.setStatusTip(
|
||||
translate('AlertsPlugin', 'Show an alert message.'))
|
||||
self.toolsAlertItem.setShortcut(u'F7')
|
||||
self.serviceManager.parent.ToolsMenu.addAction(self.toolsAlertItem)
|
||||
QtCore.QObject.connect(self.toolsAlertItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onAlertsTrigger)
|
||||
self.toolsAlertItem.setVisible(False)
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'Alerts Initialising')
|
||||
Plugin.initialise(self)
|
||||
self.toolsAlertItem.setVisible(True)
|
||||
self.liveController.alertTab = self.alertsTab
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Alerts Finalising')
|
||||
Plugin.finalise(self)
|
||||
self.toolsAlertItem.setVisible(False)
|
||||
|
||||
def toggleAlertsState(self):
|
||||
self.alertsActive = not self.alertsActive
|
||||
QtCore.QSettings().setValue(self.settingsSection + u'/active',
|
||||
QtCore.QVariant(self.alertsActive))
|
||||
|
||||
def onAlertsTrigger(self):
|
||||
self.alertForm.loadList()
|
||||
self.alertForm.exec_()
|
||||
|
||||
def about(self):
|
||||
about_text = translate('AlertsPlugin', '<strong>Alerts Plugin</strong>'
|
||||
'<br />The alert plugin controls the displaying of nursery alerts '
|
||||
'on the display screen')
|
||||
return about_text
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Alerts'
|
||||
self.name_lower = u'alerts'
|
||||
|
||||
self.strings = {}
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.strings[StringType.Name] = {
|
||||
u'singular': translate('AlertsPlugin', 'Alert'),
|
||||
u'plural': translate('AlertsPlugin', 'Alerts')
|
||||
}
|
||||
|
@ -1,147 +1,170 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, build_icon, translate
|
||||
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class BiblePlugin(Plugin):
|
||||
log.info(u'Bible Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_translations()
|
||||
Plugin.__init__(self, u'Bibles', u'1.9.2', plugin_helpers)
|
||||
self.weight = -9
|
||||
self.icon_path = u':/plugins/plugin_bibles.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
self.manager = None
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'bibles Initialising')
|
||||
if self.manager is None:
|
||||
self.manager = BibleManager(self)
|
||||
Plugin.initialise(self)
|
||||
self.importBibleItem.setVisible(True)
|
||||
self.exportBibleItem.setVisible(True)
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Plugin Finalise')
|
||||
Plugin.finalise(self)
|
||||
self.importBibleItem.setVisible(False)
|
||||
self.exportBibleItem.setVisible(False)
|
||||
|
||||
def getSettingsTab(self):
|
||||
return BiblesTab(self.name)
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
# Create the BibleManagerItem object.
|
||||
return BibleMediaItem(self, self.icon, self.name)
|
||||
|
||||
def addImportMenuItem(self, import_menu):
|
||||
self.importBibleItem = QtGui.QAction(import_menu)
|
||||
self.importBibleItem.setObjectName(u'importBibleItem')
|
||||
import_menu.addAction(self.importBibleItem)
|
||||
self.importBibleItem.setText(
|
||||
translate('BiblesPlugin', '&Bible'))
|
||||
# signals and slots
|
||||
QtCore.QObject.connect(self.importBibleItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick)
|
||||
self.importBibleItem.setVisible(False)
|
||||
|
||||
def addExportMenuItem(self, export_menu):
|
||||
self.exportBibleItem = QtGui.QAction(export_menu)
|
||||
self.exportBibleItem.setObjectName(u'exportBibleItem')
|
||||
export_menu.addAction(self.exportBibleItem)
|
||||
self.exportBibleItem.setText(translate(
|
||||
'BiblesPlugin', '&Bible'))
|
||||
self.exportBibleItem.setVisible(False)
|
||||
|
||||
def onBibleImportClick(self):
|
||||
if self.mediaItem:
|
||||
self.mediaItem.onImportClick()
|
||||
|
||||
def about(self):
|
||||
about_text = translate('BiblesPlugin', '<strong>Bible Plugin</strong>'
|
||||
'<br />The Bible plugin provides the ability to display bible '
|
||||
'verses from different sources during the service.')
|
||||
return about_text
|
||||
|
||||
def usesTheme(self, theme):
|
||||
"""
|
||||
Called to find out if the bible plugin is currently using a theme.
|
||||
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
if self.settings_tab.bible_theme == theme:
|
||||
return True
|
||||
return False
|
||||
|
||||
def renameTheme(self, oldTheme, newTheme):
|
||||
"""
|
||||
Rename the theme the bible plugin is using making the plugin use the
|
||||
new name.
|
||||
|
||||
``oldTheme``
|
||||
The name of the theme the plugin should stop using. Unused for
|
||||
this particular plugin.
|
||||
|
||||
``newTheme``
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
self.settings_tab.bible_theme = newTheme
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Bibles'
|
||||
self.name_lower = u'bibles'
|
||||
self.text = {}
|
||||
#for context menu
|
||||
self.text['context_edit'] = translate('BiblesPlugin', '&Edit Bible')
|
||||
self.text['context_delete'] = translate('BiblesPlugin', '&Delete Bible')
|
||||
self.text['context_preview'] = translate('BiblesPlugin', '&Preview Bible')
|
||||
self.text['context_live'] = translate('BiblesPlugin', '&Show Live')
|
||||
# forHeaders in mediamanagerdock
|
||||
self.text['import'] = translate('BiblesPlugin', 'Import a Bible')
|
||||
self.text['load'] = translate('BiblesPlugin', 'Load a new Bible')
|
||||
self.text['new'] = translate('BiblesPlugin', 'Add a new Bible')
|
||||
self.text['edit'] = translate('BiblesPlugin', 'Edit the selected Bible')
|
||||
self.text['delete'] = translate('BiblesPlugin', 'Delete the selected Bible')
|
||||
self.text['delete_more'] = translate('BiblesPlugin', 'Delete the selected Bibles')
|
||||
self.text['preview'] = translate('BiblesPlugin', 'Preview the selected Bible')
|
||||
self.text['preview_more'] = translate('BiblesPlugin', 'Preview the selected Bibles')
|
||||
self.text['live'] = translate('BiblesPlugin', 'Send the selected Bible live')
|
||||
self.text['live_more'] = translate('BiblesPlugin', 'Send the selected Bibles live')
|
||||
self.text['service'] = translate('BiblesPlugin', 'Add the selected Verse to the service')
|
||||
self.text['service_more'] = translate('BiblesPlugin', 'Add the selected Verses to the service')
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.text['name'] = translate('BiblesPlugin', 'Bible')
|
||||
self.text['name_more'] = translate('BiblesPlugin', 'Bibles')
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, StringType, build_icon, translate
|
||||
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class BiblePlugin(Plugin):
|
||||
log.info(u'Bible Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_strings()
|
||||
Plugin.__init__(self, u'Bibles', u'1.9.2', plugin_helpers)
|
||||
self.weight = -9
|
||||
self.icon_path = u':/plugins/plugin_bibles.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
self.manager = None
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'bibles Initialising')
|
||||
if self.manager is None:
|
||||
self.manager = BibleManager(self)
|
||||
Plugin.initialise(self)
|
||||
self.importBibleItem.setVisible(True)
|
||||
self.exportBibleItem.setVisible(True)
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Plugin Finalise')
|
||||
Plugin.finalise(self)
|
||||
self.importBibleItem.setVisible(False)
|
||||
self.exportBibleItem.setVisible(False)
|
||||
|
||||
def getSettingsTab(self):
|
||||
return BiblesTab(self.name)
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
# Create the BibleManagerItem object.
|
||||
return BibleMediaItem(self, self.icon, self.name)
|
||||
|
||||
def addImportMenuItem(self, import_menu):
|
||||
self.importBibleItem = QtGui.QAction(import_menu)
|
||||
self.importBibleItem.setObjectName(u'importBibleItem')
|
||||
import_menu.addAction(self.importBibleItem)
|
||||
self.importBibleItem.setText(
|
||||
translate('BiblesPlugin', '&Bible'))
|
||||
# signals and slots
|
||||
QtCore.QObject.connect(self.importBibleItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick)
|
||||
self.importBibleItem.setVisible(False)
|
||||
|
||||
def addExportMenuItem(self, export_menu):
|
||||
self.exportBibleItem = QtGui.QAction(export_menu)
|
||||
self.exportBibleItem.setObjectName(u'exportBibleItem')
|
||||
export_menu.addAction(self.exportBibleItem)
|
||||
self.exportBibleItem.setText(translate(
|
||||
'BiblesPlugin', '&Bible'))
|
||||
self.exportBibleItem.setVisible(False)
|
||||
|
||||
def onBibleImportClick(self):
|
||||
if self.mediaItem:
|
||||
self.mediaItem.onImportClick()
|
||||
|
||||
def about(self):
|
||||
about_text = translate('BiblesPlugin', '<strong>Bible Plugin</strong>'
|
||||
'<br />The Bible plugin provides the ability to display bible '
|
||||
'verses from different sources during the service.')
|
||||
return about_text
|
||||
|
||||
def usesTheme(self, theme):
|
||||
"""
|
||||
Called to find out if the bible plugin is currently using a theme.
|
||||
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
if self.settings_tab.bible_theme == theme:
|
||||
return True
|
||||
return False
|
||||
|
||||
def renameTheme(self, oldTheme, newTheme):
|
||||
"""
|
||||
Rename the theme the bible plugin is using making the plugin use the
|
||||
new name.
|
||||
|
||||
``oldTheme``
|
||||
The name of the theme the plugin should stop using. Unused for
|
||||
this particular plugin.
|
||||
|
||||
``newTheme``
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
self.settings_tab.bible_theme = newTheme
|
||||
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Bibles'
|
||||
self.name_lower = u'Bibles'
|
||||
|
||||
self.strings = {}
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.strings[StringType.Name] = {
|
||||
u'singular': translate('BiblesPlugin', 'Bible'),
|
||||
u'plural': translate('BiblesPlugin', 'Bibles')
|
||||
}
|
||||
|
||||
# Middle Header Bar
|
||||
## Import Button ##
|
||||
self.strings[StringType.Import] = {
|
||||
u'title': translate('BiblesPlugin', 'Import'),
|
||||
u'tooltip': translate('BiblesPlugin', 'Import a Bible')
|
||||
}
|
||||
## New Button ##
|
||||
self.strings[StringType.New] = {
|
||||
u'title': translate('BiblesPlugin', 'Add'),
|
||||
u'tooltip': translate('BiblesPlugin', 'Add a new Bible')
|
||||
}
|
||||
## Edit Button ##
|
||||
self.strings[StringType.Edit] = {
|
||||
u'title': translate('BiblesPlugin', 'Edit'),
|
||||
u'tooltip': translate('BiblesPlugin', 'Edit the selected Bible')
|
||||
}
|
||||
## Delete Button ##
|
||||
self.strings[StringType.Delete] = {
|
||||
u'title': translate('BiblesPlugin', 'Delete'),
|
||||
u'tooltip': translate('BiblesPlugin', 'Delete the selected Bible')
|
||||
}
|
||||
## Preview ##
|
||||
self.strings[StringType.Preview] = {
|
||||
u'title': translate('BiblesPlugin', 'Preview'),
|
||||
u'tooltip': translate('BiblesPlugin', 'Preview the selected Bible')
|
||||
}
|
||||
## Live Button ##
|
||||
self.strings[StringType.Live] = {
|
||||
u'title': translate('BiblesPlugin', 'Live'),
|
||||
u'tooltip': translate('BiblesPlugin', 'Send the selected Bible live')
|
||||
}
|
||||
## Add to service Button ##
|
||||
self.strings[StringType.Service] = {
|
||||
u'title': translate('BiblesPlugin', 'Service'),
|
||||
u'tooltip': translate('BiblesPlugin', 'Add the selected Bible to the service')
|
||||
}
|
||||
|
@ -1,127 +1,154 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from forms import EditCustomForm
|
||||
|
||||
from openlp.core.lib import Plugin, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.plugins.custom.lib import CustomMediaItem, CustomTab
|
||||
from openlp.plugins.custom.lib.db import CustomSlide, init_schema
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class CustomPlugin(Plugin):
|
||||
"""
|
||||
This plugin enables the user to create, edit and display
|
||||
custom slide shows. Custom shows are divided into slides.
|
||||
Each show is able to have it's own theme.
|
||||
Custom shows are designed to replace the use of songs where
|
||||
the songs plugin has become restrictive. Examples could be
|
||||
Welcome slides, Bible Reading information, Orders of service.
|
||||
"""
|
||||
log.info(u'Custom Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_translations()
|
||||
Plugin.__init__(self, u'Custom', u'1.9.2', plugin_helpers)
|
||||
self.weight = -5
|
||||
self.custommanager = Manager(u'custom', init_schema)
|
||||
self.edit_custom_form = EditCustomForm(self.custommanager)
|
||||
self.icon_path = u':/plugins/plugin_custom.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
|
||||
def getSettingsTab(self):
|
||||
return CustomTab(self.name)
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
# Create the CustomManagerItem object
|
||||
return CustomMediaItem(self, self.icon, self.name)
|
||||
|
||||
def about(self):
|
||||
about_text = translate('CustomPlugin', '<strong>Custom Plugin</strong>'
|
||||
'<br />The custom plugin provides the ability to set up custom '
|
||||
'text slides that can be displayed on the screen the same way '
|
||||
'songs are. This plugin provides greater freedom over the songs '
|
||||
'plugin.')
|
||||
return about_text
|
||||
|
||||
def usesTheme(self, theme):
|
||||
"""
|
||||
Called to find out if the custom plugin is currently using a theme.
|
||||
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
if self.custommanager.get_all_objects(CustomSlide,
|
||||
CustomSlide.theme_name == theme):
|
||||
return True
|
||||
return False
|
||||
|
||||
def renameTheme(self, oldTheme, newTheme):
|
||||
"""
|
||||
Renames a theme the custom plugin is using making the plugin use the
|
||||
new name.
|
||||
|
||||
``oldTheme``
|
||||
The name of the theme the plugin should stop using.
|
||||
|
||||
``newTheme``
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
customsUsingTheme = self.custommanager.get_all_objects(CustomSlide,
|
||||
CustomSlide.theme_name == oldTheme)
|
||||
for custom in customsUsingTheme:
|
||||
custom.theme_name = newTheme
|
||||
self.custommanager.save_object(custom)
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Custom'
|
||||
self.name_lower = u'custom'
|
||||
self.text = {}
|
||||
#for context menu
|
||||
self.text['context_edit'] = translate('CustomsPlugin', '&Edit Custom')
|
||||
self.text['context_delete'] = translate('CustomsPlugin', '&Delete Custom')
|
||||
self.text['context_preview'] = translate('CustomsPlugin', '&Preview Custom')
|
||||
self.text['context_live'] = translate('CustomsPlugin', '&Show Live')
|
||||
# forHeaders in mediamanagerdock
|
||||
self.text['import'] = translate('CustomsPlugin', 'Import a Custom')
|
||||
self.text['load'] = translate('CustomsPlugin', 'Load a new Custom')
|
||||
self.text['new'] = translate('CustomsPlugin', 'Add a new Custom')
|
||||
self.text['edit'] = translate('CustomsPlugin', 'Edit the selected Custom')
|
||||
self.text['delete'] = translate('CustomsPlugin', 'Delete the selected Custom')
|
||||
self.text['delete_more'] = translate('CustomsPlugin', 'Delete the selected Custom')
|
||||
self.text['preview'] = translate('CustomsPlugin', 'Preview the selected Custom')
|
||||
self.text['preview_more'] = translate('CustomsPlugin', 'Preview the selected Custom')
|
||||
self.text['live'] = translate('CustomsPlugin', 'Send the selected Custom live')
|
||||
self.text['live_more'] = translate('CustomsPlugin', 'Send the selected Custom live')
|
||||
self.text['service'] = translate('CustomsPlugin', 'Add the selected Custom to the service')
|
||||
self.text['service_more'] = translate('CustomsPlugin', 'Add the selected Custom to the service')
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.text['name'] = translate('CustomsPlugin', 'Custom')
|
||||
self.text['name_more'] = translate('CustomsPlugin', 'Custom')
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from forms import EditCustomForm
|
||||
|
||||
from openlp.core.lib import Plugin, StringType, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.plugins.custom.lib import CustomMediaItem, CustomTab
|
||||
from openlp.plugins.custom.lib.db import CustomSlide, init_schema
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class CustomPlugin(Plugin):
|
||||
"""
|
||||
This plugin enables the user to create, edit and display
|
||||
custom slide shows. Custom shows are divided into slides.
|
||||
Each show is able to have it's own theme.
|
||||
Custom shows are designed to replace the use of Customs where
|
||||
the Customs plugin has become restrictive. Examples could be
|
||||
Welcome slides, Bible Reading information, Orders of service.
|
||||
"""
|
||||
log.info(u'Custom Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_strings()
|
||||
Plugin.__init__(self, u'Custom', u'1.9.2', plugin_helpers)
|
||||
self.weight = -5
|
||||
self.custommanager = Manager(u'custom', init_schema)
|
||||
self.edit_custom_form = EditCustomForm(self.custommanager)
|
||||
self.icon_path = u':/plugins/plugin_custom.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
|
||||
def getSettingsTab(self):
|
||||
return CustomTab(self.name)
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
# Create the CustomManagerItem object
|
||||
return CustomMediaItem(self, self.icon, self.name)
|
||||
|
||||
def about(self):
|
||||
about_text = translate('CustomPlugin', '<strong>Custom Plugin</strong>'
|
||||
'<br />The custom plugin provides the ability to set up custom '
|
||||
'text slides that can be displayed on the screen the same way '
|
||||
'Customs are. This plugin provides greater freedom over the Customs '
|
||||
'plugin.')
|
||||
return about_text
|
||||
|
||||
def usesTheme(self, theme):
|
||||
"""
|
||||
Called to find out if the custom plugin is currently using a theme.
|
||||
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
if self.custommanager.get_all_objects(CustomSlide,
|
||||
CustomSlide.theme_name == theme):
|
||||
return True
|
||||
return False
|
||||
|
||||
def renameTheme(self, oldTheme, newTheme):
|
||||
"""
|
||||
Renames a theme the custom plugin is using making the plugin use the
|
||||
new name.
|
||||
|
||||
``oldTheme``
|
||||
The name of the theme the plugin should stop using.
|
||||
|
||||
``newTheme``
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
customsUsingTheme = self.custommanager.get_all_objects(CustomSlide,
|
||||
CustomSlide.theme_name == oldTheme)
|
||||
for custom in customsUsingTheme:
|
||||
custom.theme_name = newTheme
|
||||
self.custommanager.save_object(custom)
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Custom'
|
||||
self.name_lower = u'custom'
|
||||
|
||||
self.strings = {}
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.strings[StringType.Name] = {
|
||||
u'singular': translate('CustomsPlugin', 'Custom'),
|
||||
u'plural': translate('CustomsPlugin', 'Customs')
|
||||
}
|
||||
|
||||
# Middle Header Bar
|
||||
## Import Button ##
|
||||
self.strings[StringType.Import] = {
|
||||
u'title': translate('CustomsPlugin', 'Import'),
|
||||
u'tooltip': translate('CustomsPlugin', 'Import a Custom')
|
||||
}
|
||||
## Load Button ##
|
||||
self.strings[StringType.Load] = {
|
||||
u'title': translate('CustomsPlugin', 'Load'),
|
||||
u'tooltip': translate('CustomsPlugin', 'Load a new Custom')
|
||||
}
|
||||
## New Button ##
|
||||
self.strings[StringType.New] = {
|
||||
u'title': translate('CustomsPlugin', 'Add'),
|
||||
u'tooltip': translate('CustomsPlugin', 'Add a new Custom')
|
||||
}
|
||||
## Edit Button ##
|
||||
self.strings[StringType.Edit] = {
|
||||
u'title': translate('CustomsPlugin', 'Edit'),
|
||||
u'tooltip': translate('CustomsPlugin', 'Edit the selected Custom')
|
||||
}
|
||||
## Delete Button ##
|
||||
self.strings[StringType.Delete] = {
|
||||
u'title': translate('CustomsPlugin', 'Delete'),
|
||||
u'tooltip': translate('CustomsPlugin', 'Delete the selected Custom')
|
||||
}
|
||||
## Preview ##
|
||||
self.strings[StringType.Preview] = {
|
||||
u'title': translate('CustomsPlugin', 'Preview'),
|
||||
u'tooltip': translate('CustomsPlugin', 'Preview the selected Custom')
|
||||
}
|
||||
## Live Button ##
|
||||
self.strings[StringType.Live] = {
|
||||
u'title': translate('CustomsPlugin', 'Live'),
|
||||
u'tooltip': translate('CustomsPlugin', 'Send the selected Custom live')
|
||||
}
|
||||
## Add to service Button ##
|
||||
self.strings[StringType.Service] = {
|
||||
u'title': translate('CustomsPlugin', 'Service'),
|
||||
u'tooltip': translate('CustomsPlugin', 'Add the selected Custom to the service')
|
||||
}
|
||||
|
@ -1,89 +1,111 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from openlp.core.lib import Plugin, build_icon, translate
|
||||
from openlp.plugins.images.lib import ImageMediaItem
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class ImagePlugin(Plugin):
|
||||
log.info(u'Image Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_translations()
|
||||
Plugin.__init__(self, u'Images', u'1.9.2', plugin_helpers)
|
||||
self.weight = -7
|
||||
self.icon_path = u':/plugins/plugin_images.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
# Create the MediaManagerItem object
|
||||
return ImageMediaItem(self, self.icon, self.name)
|
||||
|
||||
def about(self):
|
||||
about_text = translate('ImagePlugin', '<strong>Image Plugin</strong>'
|
||||
'<br />The image plugin provides displaying of images.<br />One '
|
||||
'of the distinguishing features of this plugin is the ability to '
|
||||
'group a number of images together in the service manager, making '
|
||||
'the displaying of multiple images easier. This plugin can also '
|
||||
'make use of OpenLP\'s "timed looping" feature to create a slide '
|
||||
'show that runs automatically. In addition to this, images from '
|
||||
'the plugin can be used to override the current theme\'s '
|
||||
'background, which renders text-based items like songs with the '
|
||||
'selected image as a background instead of the background '
|
||||
'provided by the theme.')
|
||||
return about_text
|
||||
# rimach
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Images'
|
||||
self.name_lower = u'images'
|
||||
self.text = {}
|
||||
#for context menu
|
||||
self.text['context_edit'] = translate('ImagePlugin', '&Edit Image')
|
||||
self.text['context_delete'] = translate('ImagePlugin', '&Delete Image')
|
||||
self.text['context_preview'] = translate('ImagePlugin', '&Preview Image')
|
||||
self.text['context_live'] = translate('ImagePlugin', '&Show Live')
|
||||
# forHeaders in mediamanagerdock
|
||||
self.text['import'] = translate('ImagePlugin', 'Import a Image')
|
||||
self.text['load'] = translate('ImagePlugin', 'Load a new Image')
|
||||
self.text['new'] = translate('ImagePlugin', 'Add a new Image')
|
||||
self.text['edit'] = translate('ImagePlugin', 'Edit the selected Image')
|
||||
self.text['delete'] = translate('ImagePlugin', 'Delete the selected Image')
|
||||
self.text['delete_more'] = translate('ImagePlugin', 'Delete the selected Images')
|
||||
self.text['preview'] = translate('ImagePlugin', 'Preview the selected Image')
|
||||
self.text['preview_more'] = translate('ImagePlugin', 'Preview the selected Images')
|
||||
self.text['live'] = translate('ImagePlugin', 'Send the selected Image live')
|
||||
self.text['live_more'] = translate('ImagePlugin', 'Send the selected Images live')
|
||||
self.text['service'] = translate('ImagePlugin', 'Add the selected Image to the service')
|
||||
self.text['service_more'] = translate('ImagePlugin', 'Add the selected Images to the service')
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.text['name'] = translate('ImagePlugin', 'Image')
|
||||
self.text['name_more'] = translate('ImagePlugin', 'Images')
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from openlp.core.lib import Plugin, StringType, build_icon, translate
|
||||
from openlp.plugins.images.lib import ImageMediaItem
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class ImagePlugin(Plugin):
|
||||
log.info(u'Image Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_strings()
|
||||
Plugin.__init__(self, u'Images', u'1.9.2', plugin_helpers)
|
||||
self.weight = -7
|
||||
self.icon_path = u':/plugins/plugin_images.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
# Create the MediaManagerItem object
|
||||
return ImageMediaItem(self, self.icon, self.name)
|
||||
|
||||
def about(self):
|
||||
about_text = translate('ImagePlugin', '<strong>Image Plugin</strong>'
|
||||
'<br />The image plugin provides displaying of images.<br />One '
|
||||
'of the distinguishing features of this plugin is the ability to '
|
||||
'group a number of images together in the service manager, making '
|
||||
'the displaying of multiple images easier. This plugin can also '
|
||||
'make use of OpenLP\'s "timed looping" feature to create a slide '
|
||||
'show that runs automatically. In addition to this, images from '
|
||||
'the plugin can be used to override the current theme\'s '
|
||||
'background, which renders text-based items like Images with the '
|
||||
'selected image as a background instead of the background '
|
||||
'provided by the theme.')
|
||||
return about_text
|
||||
# rimach
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Images'
|
||||
self.name_lower = u'images'
|
||||
|
||||
self.strings = {}
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.strings[StringType.Name] = {
|
||||
u'singular': translate('ImagePlugin', 'Image'),
|
||||
u'plural': translate('ImagePlugin', 'Images')
|
||||
}
|
||||
|
||||
# Middle Header Bar
|
||||
## Load Button ##
|
||||
self.strings[StringType.Load] = {
|
||||
u'title': translate('ImagePlugin', 'Load'),
|
||||
u'tooltip': translate('ImagePlugin', 'Load a new Image')
|
||||
}
|
||||
## New Button ##
|
||||
self.strings[StringType.New] = {
|
||||
u'title': translate('ImagePlugin', 'Add'),
|
||||
u'tooltip': translate('ImagePlugin', 'Add a new Image')
|
||||
}
|
||||
## Edit Button ##
|
||||
self.strings[StringType.Edit] = {
|
||||
u'title': translate('ImagePlugin', 'Edit'),
|
||||
u'tooltip': translate('ImagePlugin', 'Edit the selected Image')
|
||||
}
|
||||
## Delete Button ##
|
||||
self.strings[StringType.Delete] = {
|
||||
u'title': translate('ImagePlugin', 'Delete'),
|
||||
u'tooltip': translate('ImagePlugin', 'Delete the selected Image')
|
||||
}
|
||||
## Preview ##
|
||||
self.strings[StringType.Preview] = {
|
||||
u'title': translate('ImagePlugin', 'Preview'),
|
||||
u'tooltip': translate('ImagePlugin', 'Preview the selected Image')
|
||||
}
|
||||
## Live Button ##
|
||||
self.strings[StringType.Live] = {
|
||||
u'title': translate('ImagePlugin', 'Live'),
|
||||
u'tooltip': translate('ImagePlugin', 'Send the selected Image live')
|
||||
}
|
||||
## Add to service Button ##
|
||||
self.strings[StringType.Service] = {
|
||||
u'title': translate('ImagePlugin', 'Service'),
|
||||
u'tooltip': translate('ImagePlugin', 'Add the selected Image to the service')
|
||||
}
|
||||
|
@ -1,107 +1,129 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
from openlp.core.lib import Plugin, build_icon, translate
|
||||
from openlp.plugins.media.lib import MediaMediaItem
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class MediaPlugin(Plugin):
|
||||
log.info(u'%s MediaPlugin loaded', __name__)
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_translations()
|
||||
Plugin.__init__(self, u'Media', u'1.9.2', plugin_helpers)
|
||||
self.weight = -6
|
||||
self.icon_path = u':/plugins/plugin_media.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
# passed with drag and drop messages
|
||||
self.dnd_id = u'Media'
|
||||
self.audio_list = u''
|
||||
self.video_list = u''
|
||||
for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
|
||||
mimetype = unicode(mimetype)
|
||||
type = mimetype.split(u'audio/x-')
|
||||
self.audio_list, mimetype = self._addToList(self.audio_list,
|
||||
type, mimetype)
|
||||
type = mimetype.split(u'audio/')
|
||||
self.audio_list, mimetype = self._addToList(self.audio_list,
|
||||
type, mimetype)
|
||||
type = mimetype.split(u'video/x-')
|
||||
self.video_list, mimetype = self._addToList(self.video_list,
|
||||
type, mimetype)
|
||||
type = mimetype.split(u'video/')
|
||||
self.video_list, mimetype = self._addToList(self.video_list,
|
||||
type, mimetype)
|
||||
|
||||
def _addToList(self, list, value, type):
|
||||
if len(value) == 2:
|
||||
if list.find(value[1]) == -1:
|
||||
list += u'*.%s ' % value[1]
|
||||
self.serviceManager.supportedSuffixes(value[1])
|
||||
type = u''
|
||||
return list, type
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
# Create the MediaManagerItem object
|
||||
return MediaMediaItem(self, self.icon, self.name)
|
||||
|
||||
def about(self):
|
||||
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'
|
||||
'<br />The media plugin provides playback of audio and video.')
|
||||
return about_text
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Media'
|
||||
self.name_lower = u'media'
|
||||
self.text = {}
|
||||
#for context menu
|
||||
self.text['context_edit'] = translate('MediaPlugin', '&Edit Media')
|
||||
self.text['context_delete'] = translate('MediaPlugin', '&Delete Media')
|
||||
self.text['context_preview'] = translate('MediaPlugin', '&Preview Media')
|
||||
self.text['context_live'] = translate('MediaPlugin', '&Show Live')
|
||||
# forHeaders in mediamanagerdock
|
||||
self.text['import'] = translate('MediaPlugin', 'Import a Media')
|
||||
self.text['load'] = translate('MediaPlugin', 'Load a new Media')
|
||||
self.text['new'] = translate('MediaPlugin', 'Add a new Media')
|
||||
self.text['edit'] = translate('MediaPlugin', 'Edit the selected Media')
|
||||
self.text['delete'] = translate('MediaPlugin', 'Delete the selected Media')
|
||||
self.text['delete_more'] = translate('MediaPlugin', 'Delete the selected Media')
|
||||
self.text['preview'] = translate('MediaPlugin', 'Preview the selected Media')
|
||||
self.text['preview_more'] = translate('MediaPlugin', 'Preview the selected Media')
|
||||
self.text['live'] = translate('MediaPlugin', 'Send the selected Media live')
|
||||
self.text['live_more'] = translate('MediaPlugin', 'Send the selected Media live')
|
||||
self.text['service'] = translate('MediaPlugin', 'Add the selected Media to the service')
|
||||
self.text['service_more'] = translate('MediaPlugin', 'Add the selected Media to the service')
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.text['name'] = translate('MediaPlugin', 'Media')
|
||||
self.text['name_more'] = translate('MediaPlugin', 'Media')
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4.phonon import Phonon
|
||||
|
||||
from openlp.core.lib import Plugin, StringType, build_icon, translate
|
||||
from openlp.plugins.media.lib import MediaMediaItem
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class MediaPlugin(Plugin):
|
||||
log.info(u'%s MediaPlugin loaded', __name__)
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_strings()
|
||||
Plugin.__init__(self, u'Media', u'1.9.2', plugin_helpers)
|
||||
self.weight = -6
|
||||
self.icon_path = u':/plugins/plugin_media.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
# passed with drag and drop messages
|
||||
self.dnd_id = u'Media'
|
||||
self.audio_list = u''
|
||||
self.video_list = u''
|
||||
for mimetype in Phonon.BackendCapabilities.availableMimeTypes():
|
||||
mimetype = unicode(mimetype)
|
||||
type = mimetype.split(u'audio/x-')
|
||||
self.audio_list, mimetype = self._addToList(self.audio_list,
|
||||
type, mimetype)
|
||||
type = mimetype.split(u'audio/')
|
||||
self.audio_list, mimetype = self._addToList(self.audio_list,
|
||||
type, mimetype)
|
||||
type = mimetype.split(u'video/x-')
|
||||
self.video_list, mimetype = self._addToList(self.video_list,
|
||||
type, mimetype)
|
||||
type = mimetype.split(u'video/')
|
||||
self.video_list, mimetype = self._addToList(self.video_list,
|
||||
type, mimetype)
|
||||
|
||||
def _addToList(self, list, value, type):
|
||||
if len(value) == 2:
|
||||
if list.find(value[1]) == -1:
|
||||
list += u'*.%s ' % value[1]
|
||||
self.serviceManager.supportedSuffixes(value[1])
|
||||
type = u''
|
||||
return list, type
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
# Create the MediaManagerItem object
|
||||
return MediaMediaItem(self, self.icon, self.name)
|
||||
|
||||
def about(self):
|
||||
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'
|
||||
'<br />The media plugin provides playback of audio and video.')
|
||||
return about_text
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Media'
|
||||
self.name_lower = u'media'
|
||||
|
||||
self.strings = {}
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.strings[StringType.Name] = {
|
||||
u'singular': translate('MediaPlugin', 'Media'),
|
||||
u'plural': translate('MediaPlugin', 'Medias')
|
||||
}
|
||||
|
||||
# Middle Header Bar
|
||||
## Load Button ##
|
||||
self.strings[StringType.Load] = {
|
||||
u'title': translate('MediaPlugin', 'Load'),
|
||||
u'tooltip': translate('MediaPlugin', 'Load a new Media')
|
||||
}
|
||||
## New Button ##
|
||||
self.strings[StringType.New] = {
|
||||
u'title': translate('MediaPlugin', 'Add'),
|
||||
u'tooltip': translate('MediaPlugin', 'Add a new Media')
|
||||
}
|
||||
## Edit Button ##
|
||||
self.strings[StringType.Edit] = {
|
||||
u'title': translate('MediaPlugin', 'Edit'),
|
||||
u'tooltip': translate('MediaPlugin', 'Edit the selected Media')
|
||||
}
|
||||
## Delete Button ##
|
||||
self.strings[StringType.Delete] = {
|
||||
u'title': translate('MediaPlugin', 'Delete'),
|
||||
u'tooltip': translate('MediaPlugin', 'Delete the selected Media')
|
||||
}
|
||||
## Preview ##
|
||||
self.strings[StringType.Preview] = {
|
||||
u'title': translate('MediaPlugin', 'Preview'),
|
||||
u'tooltip': translate('MediaPlugin', 'Preview the selected Media')
|
||||
}
|
||||
## Live Button ##
|
||||
self.strings[StringType.Live] = {
|
||||
u'title': translate('MediaPlugin', 'Live'),
|
||||
u'tooltip': translate('MediaPlugin', 'Send the selected Media live')
|
||||
}
|
||||
## Add to service Button ##
|
||||
self.strings[StringType.Service] = {
|
||||
u'title': translate('MediaPlugin', 'Service'),
|
||||
u'tooltip': translate('MediaPlugin', 'Add the selected Media to the service')
|
||||
}
|
||||
|
@ -1,174 +1,187 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from openlp.core.lib import Plugin, build_icon, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.plugins.presentations.lib import PresentationController, \
|
||||
PresentationMediaItem, PresentationTab
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
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')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
"""
|
||||
PluginPresentation constructor.
|
||||
"""
|
||||
log.debug(u'Initialised')
|
||||
self.controllers = {}
|
||||
self.set_plugin_translations()
|
||||
Plugin.__init__(self, u'Presentations', u'1.9.2', plugin_helpers)
|
||||
self.weight = -8
|
||||
self.icon_path = u':/plugins/plugin_presentations.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
|
||||
def getSettingsTab(self):
|
||||
"""
|
||||
Create the settings Tab
|
||||
"""
|
||||
return PresentationTab(self.name, self.controllers)
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
Initialise the plugin. Determine which controllers are enabled
|
||||
are start their processes.
|
||||
"""
|
||||
log.info(u'Presentations Initialising')
|
||||
Plugin.initialise(self)
|
||||
self.insertToolboxItem()
|
||||
for controller in self.controllers:
|
||||
if self.controllers[controller].enabled():
|
||||
self.controllers[controller].start_process()
|
||||
self.mediaItem.buildFileMaskString()
|
||||
|
||||
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')
|
||||
#Ask each controller to tidy up
|
||||
for key in self.controllers:
|
||||
controller = self.controllers[key]
|
||||
if controller.enabled():
|
||||
controller.kill()
|
||||
Plugin.finalise(self)
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
"""
|
||||
Create the Media Manager List
|
||||
"""
|
||||
return PresentationMediaItem(
|
||||
self, self.icon, self.name, self.controllers)
|
||||
|
||||
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):
|
||||
if filename.endswith(u'controller.py') and \
|
||||
not filename == 'presentationcontroller.py':
|
||||
path = os.path.join(controller_dir, filename)
|
||||
if os.path.isfile(path):
|
||||
modulename = u'openlp.plugins.presentations.lib.' + \
|
||||
os.path.splitext(filename)[0]
|
||||
log.debug(u'Importing controller %s', modulename)
|
||||
try:
|
||||
__import__(modulename, globals(), locals(), [])
|
||||
except ImportError:
|
||||
log.exception(u'Failed to import %s on path %s',
|
||||
modulename, path)
|
||||
controller_classes = PresentationController.__subclasses__()
|
||||
for controller_class in controller_classes:
|
||||
controller = controller_class(self)
|
||||
self.registerControllers(controller)
|
||||
if self.controllers:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
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
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Presentations'
|
||||
self.name_lower = u'presentations'
|
||||
self.text = {}
|
||||
#for context menu
|
||||
self.text['context_edit'] = translate('PresentationPlugin', '&Edit Presentation')
|
||||
self.text['context_delete'] = translate('PresentationPlugin', '&Delete Presentation')
|
||||
self.text['context_preview'] = translate('PresentationPlugin', '&Preview Presentation')
|
||||
self.text['context_live'] = translate('PresentationPlugin', '&Show Live')
|
||||
# forHeaders in mediamanagerdock
|
||||
self.text['import'] = translate('PresentationPlugin', 'Import a Presentation')
|
||||
self.text['load'] = translate('PresentationPlugin', 'Load a new Presentation')
|
||||
self.text['new'] = translate('PresentationPlugin', 'Add a new Presentation')
|
||||
self.text['edit'] = translate('PresentationPlugin', 'Edit the selected Presentation')
|
||||
self.text['delete'] = translate('PresentationPlugin', 'Delete the selected Presentation')
|
||||
self.text['delete_more'] = translate('PresentationPlugin', 'Delete the selected Presentations')
|
||||
self.text['preview'] = translate('PresentationPlugin', 'Preview the selected Presentation')
|
||||
self.text['preview_more'] = translate('PresentationPlugin', 'Preview the selected Presentations')
|
||||
self.text['live'] = translate('PresentationPlugin', 'Send the selected Presentation live')
|
||||
self.text['live_more'] = translate('PresentationPlugin', 'Send the selected Presentations live')
|
||||
self.text['service'] = translate('PresentationPlugin', 'Add the selected Presentation to the service')
|
||||
self.text['service_more'] = translate('PresentationPlugin', 'Add the selected Presentations to the service')
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.text['name'] = translate('PresentationPlugin', 'Presentation')
|
||||
self.text['name_more'] = translate('PresentationPlugin', 'Presentations')
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from openlp.core.lib import Plugin, StringType, build_icon, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.plugins.presentations.lib import PresentationController, \
|
||||
PresentationMediaItem, PresentationTab
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
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')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
"""
|
||||
PluginPresentation constructor.
|
||||
"""
|
||||
log.debug(u'Initialised')
|
||||
self.controllers = {}
|
||||
self.set_plugin_strings()
|
||||
Plugin.__init__(self, u'Presentations', u'1.9.2', plugin_helpers)
|
||||
self.weight = -8
|
||||
self.icon_path = u':/plugins/plugin_presentations.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
|
||||
def getSettingsTab(self):
|
||||
"""
|
||||
Create the settings Tab
|
||||
"""
|
||||
return PresentationTab(self.name, self.controllers)
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
Initialise the plugin. Determine which controllers are enabled
|
||||
are start their processes.
|
||||
"""
|
||||
log.info(u'Presentations Initialising')
|
||||
Plugin.initialise(self)
|
||||
self.insertToolboxItem()
|
||||
for controller in self.controllers:
|
||||
if self.controllers[controller].enabled():
|
||||
self.controllers[controller].start_process()
|
||||
self.mediaItem.buildFileMaskString()
|
||||
|
||||
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')
|
||||
#Ask each controller to tidy up
|
||||
for key in self.controllers:
|
||||
controller = self.controllers[key]
|
||||
if controller.enabled():
|
||||
controller.kill()
|
||||
Plugin.finalise(self)
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
"""
|
||||
Create the Media Manager List
|
||||
"""
|
||||
return PresentationMediaItem(
|
||||
self, self.icon, self.name, self.controllers)
|
||||
|
||||
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):
|
||||
if filename.endswith(u'controller.py') and \
|
||||
not filename == 'presentationcontroller.py':
|
||||
path = os.path.join(controller_dir, filename)
|
||||
if os.path.isfile(path):
|
||||
modulename = u'openlp.plugins.presentations.lib.' + \
|
||||
os.path.splitext(filename)[0]
|
||||
log.debug(u'Importing controller %s', modulename)
|
||||
try:
|
||||
__import__(modulename, globals(), locals(), [])
|
||||
except ImportError:
|
||||
log.exception(u'Failed to import %s on path %s',
|
||||
modulename, path)
|
||||
controller_classes = PresentationController.__subclasses__()
|
||||
for controller_class in controller_classes:
|
||||
controller = controller_class(self)
|
||||
self.registerControllers(controller)
|
||||
if self.controllers:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
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
|
||||
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Presentations'
|
||||
self.name_lower = u'presentations'
|
||||
|
||||
self.strings = {}
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.strings[StringType.Name] = {
|
||||
u'singular': translate('PresentationPlugin', 'Presentation'),
|
||||
u'plural': translate('PresentationPlugin', 'Presentations')
|
||||
}
|
||||
|
||||
# Middle Header Bar
|
||||
## Load Button ##
|
||||
self.strings[StringType.Load] = {
|
||||
u'title': translate('PresentationPlugin', 'Load'),
|
||||
u'tooltip': translate('PresentationPlugin', 'Load a new Presentation')
|
||||
}
|
||||
## Delete Button ##
|
||||
self.strings[StringType.Delete] = {
|
||||
u'title': translate('PresentationPlugin', 'Delete'),
|
||||
u'tooltip': translate('PresentationPlugin', 'Delete the selected Presentation')
|
||||
}
|
||||
## Preview ##
|
||||
self.strings[StringType.Preview] = {
|
||||
u'title': translate('PresentationPlugin', 'Preview'),
|
||||
u'tooltip': translate('PresentationPlugin', 'Preview the selected Presentation')
|
||||
}
|
||||
## Live Button ##
|
||||
self.strings[StringType.Live] = {
|
||||
u'title': translate('PresentationPlugin', 'Live'),
|
||||
u'tooltip': translate('PresentationPlugin', 'Send the selected Presentation live')
|
||||
}
|
||||
## Add to service Button ##
|
||||
self.strings[StringType.Service] = {
|
||||
u'title': translate('PresentationPlugin', 'Service'),
|
||||
u'tooltip': translate('PresentationPlugin', 'Add the selected Presentation to the service')
|
||||
}
|
||||
|
@ -1,108 +1,93 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from openlp.core.lib import Plugin, translate, build_icon
|
||||
from openlp.plugins.remotes.lib import RemoteTab, HttpServer
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class RemotesPlugin(Plugin):
|
||||
log.info(u'Remote Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
"""
|
||||
remotes constructor
|
||||
"""
|
||||
self.set_plugin_translations()
|
||||
Plugin.__init__(self, u'Remotes', u'1.9.2', plugin_helpers)
|
||||
self.icon = build_icon(u':/plugins/plugin_remote.png')
|
||||
self.weight = -1
|
||||
self.server = None
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
Initialise the remotes plugin, and start the http server
|
||||
"""
|
||||
log.debug(u'initialise')
|
||||
Plugin.initialise(self)
|
||||
self.insertToolboxItem()
|
||||
self.server = HttpServer(self)
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
Tidy up and close down the http server
|
||||
"""
|
||||
log.debug(u'finalise')
|
||||
Plugin.finalise(self)
|
||||
if self.server:
|
||||
self.server.close()
|
||||
|
||||
def getSettingsTab(self):
|
||||
"""
|
||||
Create the settings Tab
|
||||
"""
|
||||
return RemoteTab(self.name)
|
||||
|
||||
def about(self):
|
||||
"""
|
||||
Information about this plugin
|
||||
"""
|
||||
about_text = translate('RemotePlugin', '<strong>Remote Plugin</strong>'
|
||||
'<br />The remote plugin provides the ability to send messages to '
|
||||
'a running version of OpenLP on a different computer via a web '
|
||||
'browser or through the remote API.')
|
||||
return about_text
|
||||
# rimach
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Remotes'
|
||||
self.name_lower = u'remotes'
|
||||
self.text = {}
|
||||
#for context menu
|
||||
# self.text['context_edit'] = translate('RemotePlugin', '&Edit Remotes')
|
||||
# self.text['context_delete'] = translate('RemotePlugin', '&Delete Remotes')
|
||||
# self.text['context_preview'] = translate('RemotePlugin', '&Preview Remotes')
|
||||
# self.text['context_live'] = translate('RemotePlugin', '&Show Live')
|
||||
# # forHeaders in mediamanagerdock
|
||||
# self.text['import'] = translate('RemotePlugin', 'Import a Remotes')
|
||||
# self.text['file'] = translate('RemotePlugin', 'Load a new Remotes')
|
||||
# self.text['new'] = translate('RemotePlugin', 'Add a new Remotes')
|
||||
# self.text['edit'] = translate('RemotePlugin', 'Edit the selected Remotes')
|
||||
# self.text['delete'] = translate('RemotePlugin', 'Delete the selected Remotes')
|
||||
# self.text['delete_more'] = translate('RemotePlugin', 'Delete the selected Remotes')
|
||||
# self.text['preview'] = translate('RemotePlugin', 'Preview the selected Remotes')
|
||||
# self.text['preview_more'] = translate('RemotePlugin', 'Preview the selected Remotes')
|
||||
# self.text['live'] = translate('RemotePlugin', 'Send the selected Remotes live')
|
||||
# self.text['live_more'] = translate('RemotePlugin', 'Send the selected Remotes live')
|
||||
# self.text['service'] = translate('RemotePlugin', 'Add the selected Remotes to the service')
|
||||
# self.text['service_more'] = translate('RemotePlugin', 'Add the selected Remotes to the service')
|
||||
# # for names in mediamanagerdock and pluginlist
|
||||
self.text['name'] = translate('RemotePlugin', 'Remote')
|
||||
self.text['name_more'] = translate('RemotePlugin', 'Remotes')
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from openlp.core.lib import Plugin, StringType, translate, build_icon
|
||||
from openlp.plugins.remotes.lib import RemoteTab, HttpServer
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class RemotesPlugin(Plugin):
|
||||
log.info(u'Remote Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
"""
|
||||
remotes constructor
|
||||
"""
|
||||
self.set_plugin_strings()
|
||||
Plugin.__init__(self, u'Remotes', u'1.9.2', plugin_helpers)
|
||||
self.icon = build_icon(u':/plugins/plugin_remote.png')
|
||||
self.weight = -1
|
||||
self.server = None
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
Initialise the remotes plugin, and start the http server
|
||||
"""
|
||||
log.debug(u'initialise')
|
||||
Plugin.initialise(self)
|
||||
self.insertToolboxItem()
|
||||
self.server = HttpServer(self)
|
||||
|
||||
def finalise(self):
|
||||
"""
|
||||
Tidy up and close down the http server
|
||||
"""
|
||||
log.debug(u'finalise')
|
||||
Plugin.finalise(self)
|
||||
if self.server:
|
||||
self.server.close()
|
||||
|
||||
def getSettingsTab(self):
|
||||
"""
|
||||
Create the settings Tab
|
||||
"""
|
||||
return RemoteTab(self.name)
|
||||
|
||||
def about(self):
|
||||
"""
|
||||
Information about this plugin
|
||||
"""
|
||||
about_text = translate('RemotePlugin', '<strong>Remote Plugin</strong>'
|
||||
'<br />The remote plugin provides the ability to send messages to '
|
||||
'a running version of OpenLP on a different computer via a web '
|
||||
'browser or through the remote API.')
|
||||
return about_text
|
||||
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Remotes'
|
||||
self.name_lower = u'remotes'
|
||||
|
||||
self.strings = {}
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.strings[StringType.Name] = {
|
||||
u'singular': translate('RemotePlugin', 'Remote'),
|
||||
u'plural': translate('RemotePlugin', 'Remotes')
|
||||
}
|
||||
|
@ -1,178 +1,196 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.plugins.songs.lib import SongMediaItem, SongsTab
|
||||
from openlp.plugins.songs.lib.db import init_schema, Song
|
||||
from openlp.plugins.songs.lib.importer import SongFormat
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class SongsPlugin(Plugin):
|
||||
"""
|
||||
This is the number 1 plugin, if importance were placed on any
|
||||
plugins. This plugin enables the user to create, edit and display
|
||||
songs. Songs are divided into verses, and the verse order can be
|
||||
specified. Authors, topics and song books can be assigned to songs
|
||||
as well.
|
||||
"""
|
||||
log.info(u'Song Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
"""
|
||||
Create and set up the Songs plugin.
|
||||
"""
|
||||
self.set_plugin_translations()
|
||||
Plugin.__init__(self, u'Songs', u'1.9.2', plugin_helpers)
|
||||
self.weight = -10
|
||||
self.manager = Manager(u'songs', init_schema)
|
||||
self.icon_path = u':/plugins/plugin_songs.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
|
||||
def getSettingsTab(self):
|
||||
return SongsTab(self.name)
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'Songs Initialising')
|
||||
Plugin.initialise(self)
|
||||
self.mediaItem.displayResultsSong(
|
||||
self.manager.get_all_objects(Song, order_by_ref=Song.title))
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
"""
|
||||
Create the MediaManagerItem object, which is displaed in the
|
||||
Media Manager.
|
||||
"""
|
||||
return SongMediaItem(self, self.icon, self.name)
|
||||
|
||||
def addImportMenuItem(self, import_menu):
|
||||
"""
|
||||
Give the Songs plugin the opportunity to add items to the
|
||||
**Import** menu.
|
||||
|
||||
``import_menu``
|
||||
The actual **Import** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
# Main song import menu item - will eventually be the only one
|
||||
self.SongImportItem = QtGui.QAction(import_menu)
|
||||
self.SongImportItem.setObjectName(u'SongImportItem')
|
||||
self.SongImportItem.setText(translate(
|
||||
'SongsPlugin', '&Song'))
|
||||
self.SongImportItem.setToolTip(translate('SongsPlugin',
|
||||
'Import songs using the import wizard.'))
|
||||
import_menu.addAction(self.SongImportItem)
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(self.SongImportItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onSongImportItemClicked)
|
||||
|
||||
def addExportMenuItem(self, export_menu):
|
||||
"""
|
||||
Give the Songs plugin the opportunity to add items to the
|
||||
**Export** menu.
|
||||
|
||||
``export_menu``
|
||||
The actual **Export** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
# No menu items for now.
|
||||
pass
|
||||
|
||||
def onSongImportItemClicked(self):
|
||||
if self.mediaItem:
|
||||
self.mediaItem.onImportClick()
|
||||
|
||||
def about(self):
|
||||
about_text = translate('SongsPlugin', '<strong>Songs Plugin</strong>'
|
||||
'<br />The songs plugin provides the ability to display and '
|
||||
'manage songs.')
|
||||
return about_text
|
||||
|
||||
def usesTheme(self, theme):
|
||||
"""
|
||||
Called to find out if the song plugin is currently using a theme.
|
||||
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
if self.manager.get_all_objects(Song, Song.theme_name == theme):
|
||||
return True
|
||||
return False
|
||||
|
||||
def renameTheme(self, oldTheme, newTheme):
|
||||
"""
|
||||
Renames a theme the song plugin is using making the plugin use the new
|
||||
name.
|
||||
|
||||
``oldTheme``
|
||||
The name of the theme the plugin should stop using.
|
||||
|
||||
``newTheme``
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
songsUsingTheme = self.manager.get_all_objects(Song,
|
||||
Song.theme_name == oldTheme)
|
||||
for song in songsUsingTheme:
|
||||
song.theme_name = newTheme
|
||||
self.custommanager.save_object(song)
|
||||
|
||||
def importSongs(self, format, **kwargs):
|
||||
class_ = SongFormat.get_class(format)
|
||||
importer = class_(self.manager, **kwargs)
|
||||
importer.register(self.mediaItem.import_wizard)
|
||||
return importer
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Songs'
|
||||
self.name_lower = u'songs'
|
||||
self.text = {}
|
||||
#for context menu
|
||||
self.text['context_edit'] = translate('SongsPlugin', '&Edit Song')
|
||||
self.text['context_delete'] = translate('SongsPlugin', '&Delete Song')
|
||||
self.text['context_preview'] = translate('SongsPlugin', '&Preview Song')
|
||||
self.text['context_live'] = translate('SongsPlugin', '&Show Live')
|
||||
# forHeaders in mediamanagerdock
|
||||
self.text['import'] = translate('SongsPlugin', 'Import a Song')
|
||||
self.text['load'] = translate('SongsPlugin', 'Load a new Song')
|
||||
self.text['new'] = translate('SongsPlugin', 'Add a new Song')
|
||||
self.text['edit'] = translate('SongsPlugin', 'Edit the selected Song')
|
||||
self.text['delete'] = translate('SongsPlugin', 'Delete the selected Song')
|
||||
self.text['delete_more'] = translate('SongsPlugin', 'Delete the selected Songs')
|
||||
self.text['preview'] = translate('SongsPlugin', 'Preview the selected Song')
|
||||
self.text['preview_more'] = translate('SongsPlugin', 'Preview the selected Songs')
|
||||
self.text['live'] = translate('SongsPlugin', 'Send the selected Song live')
|
||||
self.text['live_more'] = translate('SongsPlugin', 'Send the selected Songs live')
|
||||
self.text['service'] = translate('SongsPlugin', 'Add the selected Song to the service')
|
||||
self.text['service_more'] = translate('SongsPlugin', 'Add the selected Songs to the service')
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.text['name'] = translate('SongsPlugin', 'Song')
|
||||
self.text['name_more'] = translate('SongsPlugin', 'Songs')
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, StringType, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.plugins.songs.lib import SongMediaItem, SongsTab
|
||||
from openlp.plugins.songs.lib.db import init_schema, Song
|
||||
from openlp.plugins.songs.lib.importer import SongFormat
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class SongsPlugin(Plugin):
|
||||
"""
|
||||
This is the number 1 plugin, if importance were placed on any
|
||||
plugins. This plugin enables the user to create, edit and display
|
||||
songs. Songs are divided into verses, and the verse order can be
|
||||
specified. Authors, topics and song books can be assigned to songs
|
||||
as well.
|
||||
"""
|
||||
log.info(u'Song Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
"""
|
||||
Create and set up the Songs plugin.
|
||||
"""
|
||||
self.set_plugin_strings()
|
||||
Plugin.__init__(self, u'Songs', u'1.9.2', plugin_helpers)
|
||||
self.weight = -10
|
||||
self.manager = Manager(u'songs', init_schema)
|
||||
self.icon_path = u':/plugins/plugin_songs.png'
|
||||
self.icon = build_icon(self.icon_path)
|
||||
|
||||
def getSettingsTab(self):
|
||||
return SongsTab(self.name)
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'Songs Initialising')
|
||||
Plugin.initialise(self)
|
||||
self.mediaItem.displayResultsSong(
|
||||
self.manager.get_all_objects(Song, order_by_ref=Song.title))
|
||||
|
||||
def getMediaManagerItem(self):
|
||||
"""
|
||||
Create the MediaManagerItem object, which is displaed in the
|
||||
Media Manager.
|
||||
"""
|
||||
return SongMediaItem(self, self.icon, self.name)
|
||||
|
||||
def addImportMenuItem(self, import_menu):
|
||||
"""
|
||||
Give the Songs plugin the opportunity to add items to the
|
||||
**Import** menu.
|
||||
|
||||
``import_menu``
|
||||
The actual **Import** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
# Main song import menu item - will eventually be the only one
|
||||
self.SongImportItem = QtGui.QAction(import_menu)
|
||||
self.SongImportItem.setObjectName(u'SongImportItem')
|
||||
self.SongImportItem.setText(translate(
|
||||
'SongsPlugin', '&Song'))
|
||||
self.SongImportItem.setToolTip(translate('SongsPlugin',
|
||||
'Import songs using the import wizard.'))
|
||||
import_menu.addAction(self.SongImportItem)
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(self.SongImportItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onSongImportItemClicked)
|
||||
|
||||
def addExportMenuItem(self, export_menu):
|
||||
"""
|
||||
Give the Songs plugin the opportunity to add items to the
|
||||
**Export** menu.
|
||||
|
||||
``export_menu``
|
||||
The actual **Export** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
# No menu items for now.
|
||||
pass
|
||||
|
||||
def onSongImportItemClicked(self):
|
||||
if self.mediaItem:
|
||||
self.mediaItem.onImportClick()
|
||||
|
||||
def about(self):
|
||||
about_text = translate('SongsPlugin', '<strong>Songs Plugin</strong>'
|
||||
'<br />The songs plugin provides the ability to display and '
|
||||
'manage songs.')
|
||||
return about_text
|
||||
|
||||
def usesTheme(self, theme):
|
||||
"""
|
||||
Called to find out if the song plugin is currently using a theme.
|
||||
|
||||
Returns True if the theme is being used, otherwise returns False.
|
||||
"""
|
||||
if self.manager.get_all_objects(Song, Song.theme_name == theme):
|
||||
return True
|
||||
return False
|
||||
|
||||
def renameTheme(self, oldTheme, newTheme):
|
||||
"""
|
||||
Renames a theme the song plugin is using making the plugin use the new
|
||||
name.
|
||||
|
||||
``oldTheme``
|
||||
The name of the theme the plugin should stop using.
|
||||
|
||||
``newTheme``
|
||||
The new name the plugin should now use.
|
||||
"""
|
||||
songsUsingTheme = self.manager.get_all_objects(Song,
|
||||
Song.theme_name == oldTheme)
|
||||
for song in songsUsingTheme:
|
||||
song.theme_name = newTheme
|
||||
self.custommanager.save_object(song)
|
||||
|
||||
def importSongs(self, format, **kwargs):
|
||||
class_ = SongFormat.get_class(format)
|
||||
importer = class_(self.manager, **kwargs)
|
||||
importer.register(self.mediaItem.import_wizard)
|
||||
return importer
|
||||
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'Songs'
|
||||
self.name_lower = u'songs'
|
||||
|
||||
self.strings = {}
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.strings[StringType.Name] = {
|
||||
u'singular': translate('SongsPlugin', 'Song'),
|
||||
u'plural': translate('SongsPlugin', 'Songs')
|
||||
}
|
||||
|
||||
# Middle Header Bar
|
||||
## New Button ##
|
||||
self.strings[StringType.New] = {
|
||||
u'title': translate('SongsPlugin', 'Add'),
|
||||
u'tooltip': translate('SongsPlugin', 'Add a new Song')
|
||||
}
|
||||
## Edit Button ##
|
||||
self.strings[StringType.Edit] = {
|
||||
u'title': translate('SongsPlugin', 'Edit'),
|
||||
u'tooltip': translate('SongsPlugin', 'Edit the selected Song')
|
||||
}
|
||||
## Delete Button ##
|
||||
self.strings[StringType.Delete] = {
|
||||
u'title': translate('SongsPlugin', 'Delete'),
|
||||
u'tooltip': translate('SongsPlugin', 'Delete the selected Song')
|
||||
}
|
||||
## Preview ##
|
||||
self.strings[StringType.Preview] = {
|
||||
u'title': translate('SongsPlugin', 'Preview'),
|
||||
u'tooltip': translate('SongsPlugin', 'Preview the selected Song')
|
||||
}
|
||||
## Live Button ##
|
||||
self.strings[StringType.Live] = {
|
||||
u'title': translate('SongsPlugin', 'Live'),
|
||||
u'tooltip': translate('SongsPlugin', 'Send the selected Song live')
|
||||
}
|
||||
## Add to service Button ##
|
||||
self.strings[StringType.Service] = {
|
||||
u'title': translate('SongsPlugin', 'Service'),
|
||||
u'tooltip': translate('SongsPlugin', 'Add the selected Song to the service')
|
||||
}
|
||||
|
@ -1,194 +1,179 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, Receiver, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.plugins.songusage.forms import SongUsageDetailForm, \
|
||||
SongUsageDeleteForm
|
||||
from openlp.plugins.songusage.lib.db import init_schema, SongUsageItem
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class SongUsagePlugin(Plugin):
|
||||
log.info(u'SongUsage Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_translations()
|
||||
Plugin.__init__(self, u'SongUsage', u'1.9.2', plugin_helpers)
|
||||
self.weight = -4
|
||||
self.icon = build_icon(u':/plugins/plugin_songusage.png')
|
||||
self.songusagemanager = None
|
||||
self.songusageActive = False
|
||||
|
||||
def addToolsMenuItem(self, tools_menu):
|
||||
"""
|
||||
Give the SongUsage plugin the opportunity to add items to the
|
||||
**Tools** menu.
|
||||
|
||||
``tools_menu``
|
||||
The actual **Tools** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
log.info(u'add tools menu')
|
||||
self.toolsMenu = tools_menu
|
||||
self.SongUsageMenu = QtGui.QMenu(tools_menu)
|
||||
self.SongUsageMenu.setObjectName(u'SongUsageMenu')
|
||||
self.SongUsageMenu.setTitle(translate(
|
||||
'SongUsagePlugin', '&Song Usage Tracking'))
|
||||
#SongUsage Delete
|
||||
self.SongUsageDelete = QtGui.QAction(tools_menu)
|
||||
self.SongUsageDelete.setText(translate('SongUsagePlugin',
|
||||
'&Delete Tracking Data'))
|
||||
self.SongUsageDelete.setStatusTip(translate('SongUsagePlugin',
|
||||
'Delete song usage data up to a specified date.'))
|
||||
self.SongUsageDelete.setObjectName(u'SongUsageDelete')
|
||||
#SongUsage Report
|
||||
self.SongUsageReport = QtGui.QAction(tools_menu)
|
||||
self.SongUsageReport.setText(
|
||||
translate('SongUsagePlugin', '&Extract Tracking Data'))
|
||||
self.SongUsageReport.setStatusTip(
|
||||
translate('SongUsagePlugin', 'Generate a report on song usage.'))
|
||||
self.SongUsageReport.setObjectName(u'SongUsageReport')
|
||||
#SongUsage activation
|
||||
self.SongUsageStatus = QtGui.QAction(tools_menu)
|
||||
self.SongUsageStatus.setCheckable(True)
|
||||
self.SongUsageStatus.setChecked(False)
|
||||
self.SongUsageStatus.setText(translate(
|
||||
'SongUsagePlugin', 'Toggle Tracking'))
|
||||
self.SongUsageStatus.setStatusTip(translate('SongUsagePlugin',
|
||||
'Toggle the tracking of song usage.'))
|
||||
self.SongUsageStatus.setShortcut(u'F4')
|
||||
self.SongUsageStatus.setObjectName(u'SongUsageStatus')
|
||||
#Add Menus together
|
||||
self.toolsMenu.addAction(self.SongUsageMenu.menuAction())
|
||||
self.SongUsageMenu.addAction(self.SongUsageStatus)
|
||||
self.SongUsageMenu.addSeparator()
|
||||
self.SongUsageMenu.addAction(self.SongUsageDelete)
|
||||
self.SongUsageMenu.addAction(self.SongUsageReport)
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(self.SongUsageStatus,
|
||||
QtCore.SIGNAL(u'visibilityChanged(bool)'),
|
||||
self.SongUsageStatus.setChecked)
|
||||
QtCore.QObject.connect(self.SongUsageStatus,
|
||||
QtCore.SIGNAL(u'triggered(bool)'),
|
||||
self.toggleSongUsageState)
|
||||
QtCore.QObject.connect(self.SongUsageDelete,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete)
|
||||
QtCore.QObject.connect(self.SongUsageReport,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onSongUsageReport)
|
||||
self.SongUsageMenu.menuAction().setVisible(False)
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'SongUsage Initialising')
|
||||
Plugin.initialise(self)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_live_started'),
|
||||
self.onReceiveSongUsage)
|
||||
self.SongUsageActive = QtCore.QSettings().value(
|
||||
self.settingsSection + u'/active',
|
||||
QtCore.QVariant(False)).toBool()
|
||||
self.SongUsageStatus.setChecked(self.SongUsageActive)
|
||||
if self.songusagemanager is None:
|
||||
self.songusagemanager = Manager(u'songusage', init_schema)
|
||||
self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager,
|
||||
self.formparent)
|
||||
self.SongUsagedetailform = SongUsageDetailForm(self, self.formparent)
|
||||
self.SongUsageMenu.menuAction().setVisible(True)
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Plugin Finalise')
|
||||
self.SongUsageMenu.menuAction().setVisible(False)
|
||||
#stop any events being processed
|
||||
self.SongUsageActive = False
|
||||
|
||||
def toggleSongUsageState(self):
|
||||
self.SongUsageActive = not self.SongUsageActive
|
||||
QtCore.QSettings().setValue(self.settingsSection + u'/active',
|
||||
QtCore.QVariant(self.SongUsageActive))
|
||||
|
||||
def onReceiveSongUsage(self, item):
|
||||
"""
|
||||
Song Usage for live song from SlideController
|
||||
"""
|
||||
audit = item[0].audit
|
||||
if self.SongUsageActive and audit:
|
||||
song_usage_item = SongUsageItem()
|
||||
song_usage_item.usagedate = datetime.today()
|
||||
song_usage_item.usagetime = datetime.now().time()
|
||||
song_usage_item.title = audit[0]
|
||||
song_usage_item.copyright = audit[2]
|
||||
song_usage_item.ccl_number = audit[3]
|
||||
song_usage_item.authors = u''
|
||||
for author in audit[1]:
|
||||
song_usage_item.authors += author + u' '
|
||||
self.songusagemanager.save_object(song_usage_item)
|
||||
|
||||
def onSongUsageDelete(self):
|
||||
self.SongUsagedeleteform.exec_()
|
||||
|
||||
def onSongUsageReport(self):
|
||||
self.SongUsagedetailform.initialise()
|
||||
self.SongUsagedetailform.exec_()
|
||||
|
||||
def about(self):
|
||||
about_text = translate('SongUsagePlugin', '<strong>SongUsage Plugin'
|
||||
'</strong><br />This plugin tracks the usage of songs in '
|
||||
'services.')
|
||||
return about_text
|
||||
|
||||
def set_plugin_translations(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'SongUsage'
|
||||
self.name_lower = u'songusage'
|
||||
self.text = {}
|
||||
# #for context menu
|
||||
# self.text['context_edit'] = translate('SongUsagePlugin', '&Edit SongUsage')
|
||||
# self.text['context_delete'] = translate('SongUsagePlugin', '&Delete SongUsage')
|
||||
# self.text['context_preview'] = translate('SongUsagePlugin', '&Preview SongUsage')
|
||||
# self.text['context_live'] = translate('SongUsagePlugin', '&Show Live')
|
||||
# # forHeaders in mediamanagerdock
|
||||
# self.text['import'] = translate('SongUsagePlugin', 'Import a SongUsage')
|
||||
# self.text['file'] = translate('SongUsagePlugin', 'Load a new SongUsage')
|
||||
# self.text['new'] = translate('SongUsagePlugin', 'Add a new SongUsage')
|
||||
# self.text['edit'] = translate('SongUsagePlugin', 'Edit the selected SongUsage')
|
||||
# self.text['delete'] = translate('SongUsagePlugin', 'Delete the selected SongUsage')
|
||||
# self.text['delete_more'] = translate('SongUsagePlugin', 'Delete the selected Songs')
|
||||
# self.text['preview'] = translate('SongUsagePlugin', 'Preview the selected SongUsage')
|
||||
# self.text['preview_more'] = translate('SongUsagePlugin', 'Preview the selected Songs')
|
||||
# self.text['live'] = translate('SongUsagePlugin', 'Send the selected SongUsage live')
|
||||
# self.text['live_more'] = translate('SongUsagePlugin', 'Send the selected Songs live')
|
||||
# self.text['service'] = translate('SongUsagePlugin', 'Add the selected SongUsage to the service')
|
||||
# self.text['service_more'] = translate('SongUsagePlugin', 'Add the selected Songs to the service')
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.text['name'] = translate('SongUsagePlugin', 'SongUsage')
|
||||
self.text['name_more'] = translate('SongUsagePlugin', 'Songs')
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2010 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
|
||||
# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
|
||||
# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
|
||||
# Carsten Tinggaard, Frode Woldsund #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# 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
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, StringType, Receiver, build_icon, translate
|
||||
from openlp.core.lib.db import Manager
|
||||
from openlp.plugins.songusage.forms import SongUsageDetailForm, \
|
||||
SongUsageDeleteForm
|
||||
from openlp.plugins.songusage.lib.db import init_schema, SongUsageItem
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
class SongUsagePlugin(Plugin):
|
||||
log.info(u'SongUsage Plugin loaded')
|
||||
|
||||
def __init__(self, plugin_helpers):
|
||||
self.set_plugin_strings()
|
||||
Plugin.__init__(self, u'SongUsage', u'1.9.2', plugin_helpers)
|
||||
self.weight = -4
|
||||
self.icon = build_icon(u':/plugins/plugin_songusage.png')
|
||||
self.songusagemanager = None
|
||||
self.songusageActive = False
|
||||
|
||||
def addToolsMenuItem(self, tools_menu):
|
||||
"""
|
||||
Give the SongUsage plugin the opportunity to add items to the
|
||||
**Tools** menu.
|
||||
|
||||
``tools_menu``
|
||||
The actual **Tools** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
log.info(u'add tools menu')
|
||||
self.toolsMenu = tools_menu
|
||||
self.SongUsageMenu = QtGui.QMenu(tools_menu)
|
||||
self.SongUsageMenu.setObjectName(u'SongUsageMenu')
|
||||
self.SongUsageMenu.setTitle(translate(
|
||||
'SongUsagePlugin', '&Song Usage Tracking'))
|
||||
#SongUsage Delete
|
||||
self.SongUsageDelete = QtGui.QAction(tools_menu)
|
||||
self.SongUsageDelete.setText(translate('SongUsagePlugin',
|
||||
'&Delete Tracking Data'))
|
||||
self.SongUsageDelete.setStatusTip(translate('SongUsagePlugin',
|
||||
'Delete song usage data up to a specified date.'))
|
||||
self.SongUsageDelete.setObjectName(u'SongUsageDelete')
|
||||
#SongUsage Report
|
||||
self.SongUsageReport = QtGui.QAction(tools_menu)
|
||||
self.SongUsageReport.setText(
|
||||
translate('SongUsagePlugin', '&Extract Tracking Data'))
|
||||
self.SongUsageReport.setStatusTip(
|
||||
translate('SongUsagePlugin', 'Generate a report on song usage.'))
|
||||
self.SongUsageReport.setObjectName(u'SongUsageReport')
|
||||
#SongUsage activation
|
||||
self.SongUsageStatus = QtGui.QAction(tools_menu)
|
||||
self.SongUsageStatus.setCheckable(True)
|
||||
self.SongUsageStatus.setChecked(False)
|
||||
self.SongUsageStatus.setText(translate(
|
||||
'SongUsagePlugin', 'Toggle Tracking'))
|
||||
self.SongUsageStatus.setStatusTip(translate('SongUsagePlugin',
|
||||
'Toggle the tracking of song usage.'))
|
||||
self.SongUsageStatus.setShortcut(u'F4')
|
||||
self.SongUsageStatus.setObjectName(u'SongUsageStatus')
|
||||
#Add Menus together
|
||||
self.toolsMenu.addAction(self.SongUsageMenu.menuAction())
|
||||
self.SongUsageMenu.addAction(self.SongUsageStatus)
|
||||
self.SongUsageMenu.addSeparator()
|
||||
self.SongUsageMenu.addAction(self.SongUsageDelete)
|
||||
self.SongUsageMenu.addAction(self.SongUsageReport)
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(self.SongUsageStatus,
|
||||
QtCore.SIGNAL(u'visibilityChanged(bool)'),
|
||||
self.SongUsageStatus.setChecked)
|
||||
QtCore.QObject.connect(self.SongUsageStatus,
|
||||
QtCore.SIGNAL(u'triggered(bool)'),
|
||||
self.toggleSongUsageState)
|
||||
QtCore.QObject.connect(self.SongUsageDelete,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete)
|
||||
QtCore.QObject.connect(self.SongUsageReport,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onSongUsageReport)
|
||||
self.SongUsageMenu.menuAction().setVisible(False)
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'SongUsage Initialising')
|
||||
Plugin.initialise(self)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'slidecontroller_live_started'),
|
||||
self.onReceiveSongUsage)
|
||||
self.SongUsageActive = QtCore.QSettings().value(
|
||||
self.settingsSection + u'/active',
|
||||
QtCore.QVariant(False)).toBool()
|
||||
self.SongUsageStatus.setChecked(self.SongUsageActive)
|
||||
if self.songusagemanager is None:
|
||||
self.songusagemanager = Manager(u'songusage', init_schema)
|
||||
self.SongUsagedeleteform = SongUsageDeleteForm(self.songusagemanager,
|
||||
self.formparent)
|
||||
self.SongUsagedetailform = SongUsageDetailForm(self, self.formparent)
|
||||
self.SongUsageMenu.menuAction().setVisible(True)
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Plugin Finalise')
|
||||
self.SongUsageMenu.menuAction().setVisible(False)
|
||||
#stop any events being processed
|
||||
self.SongUsageActive = False
|
||||
|
||||
def toggleSongUsageState(self):
|
||||
self.SongUsageActive = not self.SongUsageActive
|
||||
QtCore.QSettings().setValue(self.settingsSection + u'/active',
|
||||
QtCore.QVariant(self.SongUsageActive))
|
||||
|
||||
def onReceiveSongUsage(self, item):
|
||||
"""
|
||||
Song Usage for live song from SlideController
|
||||
"""
|
||||
audit = item[0].audit
|
||||
if self.SongUsageActive and audit:
|
||||
song_usage_item = SongUsageItem()
|
||||
song_usage_item.usagedate = datetime.today()
|
||||
song_usage_item.usagetime = datetime.now().time()
|
||||
song_usage_item.title = audit[0]
|
||||
song_usage_item.copyright = audit[2]
|
||||
song_usage_item.ccl_number = audit[3]
|
||||
song_usage_item.authors = u''
|
||||
for author in audit[1]:
|
||||
song_usage_item.authors += author + u' '
|
||||
self.songusagemanager.save_object(song_usage_item)
|
||||
|
||||
def onSongUsageDelete(self):
|
||||
self.SongUsagedeleteform.exec_()
|
||||
|
||||
def onSongUsageReport(self):
|
||||
self.SongUsagedetailform.initialise()
|
||||
self.SongUsagedetailform.exec_()
|
||||
|
||||
def about(self):
|
||||
about_text = translate('SongUsagePlugin', '<strong>SongUsage Plugin'
|
||||
'</strong><br />This plugin tracks the usage of songs in '
|
||||
'services.')
|
||||
return about_text
|
||||
|
||||
def set_plugin_strings(self):
|
||||
"""
|
||||
Called to define all translatable texts of the plugin
|
||||
"""
|
||||
self.name = u'SongUsage'
|
||||
self.name_lower = u'songusage'
|
||||
|
||||
self.strings = {}
|
||||
# for names in mediamanagerdock and pluginlist
|
||||
self.strings[StringType.Name] = {
|
||||
u'singular': translate('SongUsagePlugin', 'SongUsage'),
|
||||
u'plural': translate('SongUsagePlugin', 'SongUsage')
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
0
resources/images/about-new.bmp
Executable file → Normal file
0
resources/images/about-new.bmp
Executable file → Normal file
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Loading…
Reference in New Issue
Block a user