diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index b10a13cde..e6525028a 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -111,6 +111,7 @@ def contextMenuSeparator(base): from eventreceiver import Receiver from settingsmanager import SettingsManager from pluginconfig import PluginConfig +from plugin import PluginStatus from plugin import Plugin from pluginmanager import PluginManager from settingstab import SettingsTab @@ -120,6 +121,7 @@ from serviceitem import ServiceItem from serviceitem import ServiceType from serviceitem import ServiceItem from toolbar import OpenLPToolbar +from dockwidget import OpenLPDockWidget from songxmlhandler import SongXMLBuilder, SongXMLParser from themexmlhandler import ThemeXML from renderer import Renderer diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py new file mode 100644 index 000000000..12088c0f3 --- /dev/null +++ b/openlp/core/lib/dockwidget.py @@ -0,0 +1,53 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 types +import logging + +from PyQt4 import QtCore, QtGui + +class OpenLPDockWidget(QtGui.QDockWidget): + """ + Custom DockWidget class to handle events + """ + def __init__(self, parent=None, name=None): + """ + Initialise the DockWidget + """ + QtGui.QDockWidget.__init__(self, parent) + self.parent = parent + if name is not None: + self.setObjectName(name) + self.log = logging.getLogger(u'OpenLPDockWidget') + self.log.debug(u'Init done') + + def closeEvent(self, event): + self.parent.settingsmanager.setUIItemVisibility( + self.objectName(), False) + event.accept() + + def resizeEvent(self, event): + if self.objectName() == u'MediaManagerDock': + if event.size().width() != event.oldSize().width(): + self.parent.settingsmanager.setDockbarLeft(event.size().width()) diff --git a/openlp/core/lib/eventreceiver.py b/openlp/core/lib/eventreceiver.py index 7f6caacc1..ff8e8f925 100644 --- a/openlp/core/lib/eventreceiver.py +++ b/openlp/core/lib/eventreceiver.py @@ -78,6 +78,8 @@ class EventReceiver(QtCore.QObject): ``{plugin}_stop`` Requests a plugin to handle a stop event + ``audit_live`` + Sends live song audit requests to the audit component """ global log log = logging.getLogger(u'EventReceiver') diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 7557348ca..b8e299211 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -178,8 +178,16 @@ class MediaManagerItem(QtGui.QWidget): """ # Add a toolbar self.addToolbar() - #Allow the plugin to define it's own header + #Allow the plugin to define buttons at start of bar self.addStartHeaderBar() + #Add the middle of the tool bar (pre defined) + self.addMiddleHeaderBar() + #Allow the plugin to define buttons at end of bar + self.addEndHeaderBar() + #Add the list view + self.addListViewToToolBar() + + def addMiddleHeaderBar(self): # Create buttons for the toolbar ## File Button ## if self.hasFileIcon: @@ -221,8 +229,8 @@ class MediaManagerItem(QtGui.QWidget): translate(self.TranslationContext, u'Add '+self.PluginTextShort+u' To Service'), translate(self.TranslationContext, u'Add the selected item(s) to the service'), u':/system/system_add.png', self.onAddClick, self.PluginTextShort+u'AddItem') - #Allow the plugin to define it's own header - self.addEndHeaderBar() + + def addListViewToToolBar(self): #Add the List widget self.ListView = self.ListViewWithDnD_class() self.ListView.uniformItemSizes = True diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 87c999b97..56914df9e 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -27,6 +27,13 @@ from PyQt4 import QtCore from openlp.core.lib import PluginConfig, Receiver +class PluginStatus(object): + """ + Defines the status of the plugin + """ + Active = 1 + Inactive = 2 + class Plugin(object): """ Base class for openlp plugins to inherit from. @@ -122,6 +129,7 @@ class Plugin(object): self.icon = None self.config = PluginConfig(self.name) self.weight = 0 + self.status = PluginStatus.Inactive # Set up logging self.log = logging.getLogger(self.name) self.preview_controller = plugin_helpers[u'preview'] @@ -166,6 +174,15 @@ class Plugin(object): """ pass + def add_tools_menu_item(self, tools_menu): + """ + Create a menu item and add it to the "Tools" menu. + + ``tools_menu`` + The Tools menu + """ + pass + def get_settings_tab(self): """ Create a tab for the settings window. diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index ecce6747b..2f21c9d7e 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -26,7 +26,7 @@ import os import sys import logging -from openlp.core.lib import Plugin +from openlp.core.lib import Plugin, PluginStatus class PluginManager(object): """ @@ -92,23 +92,20 @@ class PluginManager(object): log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, e.args[0]) plugin_classes = Plugin.__subclasses__() self.plugins = [] - self.plugin_list=[] plugin_objects = [] for p in plugin_classes: try: plugin = p(self.plugin_helpers) log.debug(u'Loaded plugin %s with helpers', unicode(p)) - plugin_objects.append(plugin) except TypeError: log.error(u'loaded plugin %s has no helpers', unicode(p)) plugins_list = sorted(plugin_objects, self.order_by_weight) for plugin in plugins_list: - pList = {u'plugin': plugin, u'status': u'Inactive'} if plugin.check_pre_conditions(): log.debug(u'Plugin %s active', unicode(plugin.name)) - pList[u'status'] = u'Active' - self.plugins.append(pList) + plugin.status = PluginStatus.Active + self.plugins.append(plugin) def order_by_weight(self, x, y): """ @@ -131,11 +128,11 @@ class PluginManager(object): The Media Manager itself. """ for plugin in self.plugins: - if plugin[u'status'] == u'Active': - media_manager_item = plugin[u'plugin'].get_media_manager_item() + if plugin.status == PluginStatus.Active: + media_manager_item = plugin.get_media_manager_item() if media_manager_item is not None: - log.debug(u'Inserting media manager item from %s' % plugin[u'plugin'].name) - mediatoolbox.addItem(media_manager_item, plugin[u'plugin'].icon, media_manager_item.title) + log.debug(u'Inserting media manager item from %s' % plugin.name) + mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title) def hook_settings_tabs(self, settingsform=None): """ @@ -147,12 +144,12 @@ class PluginManager(object): Defaults to *None*. The settings form to add tabs to. """ for plugin in self.plugins: - settings_tab = plugin[u'plugin'].get_settings_tab() + settings_tab = plugin.get_settings_tab() if settings_tab is not None: - log.debug(u'Inserting settings tab item from %s' % plugin[u'plugin'].name) + log.debug(u'Inserting settings tab item from %s' % plugin.name) settingsform.addTab(settings_tab) else: - log.debug(u'No settings in %s' % plugin[u'plugin'].name) + log.debug(u'No settings in %s' % plugin.name) def hook_import_menu(self, import_menu): """ @@ -163,8 +160,8 @@ class PluginManager(object): The Import menu. """ for plugin in self.plugins: - if plugin[u'status'] == u'Active': - plugin[u'plugin'].add_import_menu_item(import_menu) + if plugin.status == PluginStatus.Active: + plugin.add_import_menu_item(import_menu) def hook_export_menu(self, export_menu): """ @@ -175,8 +172,20 @@ class PluginManager(object): The Export menu. """ for plugin in self.plugins: - if plugin[u'status'] == u'Active': - plugin[u'plugin'].add_export_menu_item(export_menu) + if plugin.status == PluginStatus.Active: + plugin.add_export_menu_item(export_menu) + + def hook_tools_menu(self, tools_menu): + """ + Loop through all the plugins and give them an opportunity to add an + item to the tools menu. + + ``tools_menu`` + The Tools menu. + """ + for plugin in self.plugins: + if plugin.status == PluginStatus.Active: + plugin.add_tools_menu_item(tools_menu) def initialise_plugins(self): """ @@ -184,8 +193,8 @@ class PluginManager(object): initialise themselves. """ for plugin in self.plugins: - if plugin[u'status'] == u'Active': - plugin[u'plugin'].initialise() + if plugin.status == PluginStatus.Active: + plugin.initialise() def finalise_plugins(self): """ @@ -193,5 +202,5 @@ class PluginManager(object): clean themselves up """ for plugin in self.plugins: - if plugin[u'status'] == u'Active': - plugin[u'plugin'].finalise() + if plugin.status == PluginStatus.Active: + plugin.finalise() diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 36ff6a61a..324ffcb08 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -234,7 +234,7 @@ class RenderManager(object): realh = preview.height() # and move it to the centre of the preview space newImage = QtGui.QImage(w, h, QtGui.QImage.Format_ARGB32_Premultiplied) - newImage.fill(QtCore.Qt.transparent) + newImage.fill(QtCore.Qt.black) painter = QtGui.QPainter(newImage) painter.drawImage((w-realw) / 2, (h-realh) / 2, preview) return newImage diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 9585d11e1..40ddbd9da 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -58,6 +58,7 @@ class ServiceItem(object): self.shortname = hostplugin.name self.name = self.plugin.name self.title = u'' + self.audit = u'' self.items = [] self.iconic_representation = None self.raw_slides = None @@ -185,7 +186,8 @@ class ServiceItem(object): u'title':self.title, u'icon':self.icon, u'footer':self.raw_footer, - u'type':self.service_item_type + u'type':self.service_item_type, + u'audit':self.audit } oos_data = [] if self.service_item_type == ServiceType.Text: @@ -218,6 +220,7 @@ class ServiceItem(object): self.theme = header[u'theme'] self.addIcon(header[u'icon']) self.raw_footer = header[u'footer'] + self.audit = header[u'audit'] if self.service_item_type == ServiceType.Text: for slide in serviceitem[u'serviceitem'][u'data']: self.service_frames.append(slide) diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py index 464b42410..dff197100 100644 --- a/openlp/core/lib/settingsmanager.py +++ b/openlp/core/lib/settingsmanager.py @@ -62,17 +62,17 @@ class SettingsManager(object): self.showPreviewPanel = str_to_bool(ConfigHelper.get_config( u'user interface', u'display previewpanel', True)) - def toggleMediaManager(self, isVisible): - ConfigHelper.set_config(u'user interface', u'display mediamanager', - isVisible) - - def toggleServiceManager(self, isVisible): - ConfigHelper.set_config(u'user interface', u'display servicemanager', - isVisible) - - def toggleThemeManager(self, isVisible): - ConfigHelper.set_config(u'user interface', u'display thememanager', - isVisible) + def setUIItemVisibility(self, item=u'', isVisible=True): + if item != u'': + if item == u'ThemeManagerDock': + ConfigHelper.set_config('user interface', + u'display thememanager', isVisible) + elif item == u'ServiceManagerDock': + ConfigHelper.set_config('user interface', + u'display servicemanager', isVisible) + elif item == u'MediaManagerDock': + ConfigHelper.set_config('user interface', + u'display mediamanager', isVisible) def togglePreviewPanel(self, isVisible): ConfigHelper.set_config(u'user interface', u'display previewpanel', diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 67644643b..572994982 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -31,20 +31,11 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ ServiceManager, ThemeManager, MainDisplay, SlideController, \ PluginForm from openlp.core.lib import translate, Plugin, MediaManagerItem, \ - SettingsTab, RenderManager, PluginConfig, str_to_bool, \ + SettingsTab, RenderManager, PluginConfig, str_to_bool, OpenLPDockWidget, \ SettingsManager, PluginManager, Receiver from openlp.core.utils import ConfigHelper -class mediaDock(QtGui.QDockWidget): - def __init__(self, parent=None, name=None): - QtGui.QDockWidget.__init__(self, parent) - self.parent = parent - - def resizeEvent(self, resizeEvent): - if resizeEvent.size().width() != resizeEvent.oldSize().width(): - self.parent.settingsmanager.setDockbarLeft(resizeEvent.size().width()) - class Ui_MainWindow(object): def setupUi(self, MainWindow): """ @@ -116,7 +107,7 @@ class Ui_MainWindow(object): self.DefaultThemeLabel.setObjectName(u'DefaultThemeLabel') self.StatusBar.addPermanentWidget(self.DefaultThemeLabel) # Create the MediaManager - self.MediaManagerDock = mediaDock(MainWindow) + self.MediaManagerDock = OpenLPDockWidget(MainWindow) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(u':/system/system_mediamanager.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) @@ -146,7 +137,7 @@ class Ui_MainWindow(object): QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock) self.MediaManagerDock.setVisible(self.settingsmanager.showMediaManager) # Create the service manager - self.ServiceManagerDock = QtGui.QDockWidget(MainWindow) + self.ServiceManagerDock = OpenLPDockWidget(MainWindow) ServiceManagerIcon = QtGui.QIcon() ServiceManagerIcon.addPixmap( QtGui.QPixmap(u':/system/system_servicemanager.png'), @@ -164,7 +155,7 @@ class Ui_MainWindow(object): self.ServiceManagerDock.setVisible( self.settingsmanager.showServiceManager) # Create the theme manager - self.ThemeManagerDock = QtGui.QDockWidget(MainWindow) + self.ThemeManagerDock = OpenLPDockWidget(MainWindow) ThemeManagerIcon = QtGui.QIcon() ThemeManagerIcon.addPixmap( QtGui.QPixmap(u':/system/system_thememanager.png'), @@ -519,6 +510,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'update_global_theme'), self.defaultThemeChanged) + QtCore.QObject.connect(self.FileNewItem, + QtCore.SIGNAL(u'triggered()'), + self.ServiceManagerContents.onNewService) + QtCore.QObject.connect(self.FileOpenItem, + QtCore.SIGNAL(u'triggered()'), + self.ServiceManagerContents.onLoadService) + QtCore.QObject.connect(self.FileSaveItem, + QtCore.SIGNAL(u'triggered()'), + self.ServiceManagerContents.onQuickSaveService) + QtCore.QObject.connect(self.FileSaveAsItem, + QtCore.SIGNAL(u'triggered()'), + self.ServiceManagerContents.onSaveService) #warning cyclic dependency #RenderManager needs to call ThemeManager and #ThemeManager needs to call RenderManager @@ -545,6 +548,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.plugin_manager.hook_import_menu(self.FileImportMenu) # Call the hook method to pull in export menus. self.plugin_manager.hook_export_menu(self.FileExportMenu) + # Call the hook method to pull in tools menus. + self.plugin_manager.hook_tools_menu(self.ToolsMenu) # Call the initialise method to setup plugins. log.info(u'initialise plugins') self.plugin_manager.initialise_plugins() @@ -663,20 +668,23 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): def defaultThemeChanged(self, theme): self.DefaultThemeLabel.setText(self.defaultThemeText + theme) - def toggleMediaManager(self): - mediaBool = self.MediaManagerDock.isVisible() - self.MediaManagerDock.setVisible(not mediaBool) - self.settingsmanager.toggleMediaManager(not mediaBool) + def toggleMediaManager(self, visible): + if self.MediaManagerDock.isVisible() != visible: + self.MediaManagerDock.setVisible(visible) + self.settingsmanager.setUIItemVisibility( + self.MediaManagerDock.objectName(), visible) - def toggleServiceManager(self): - serviceBool = self.ServiceManagerDock.isVisible() - self.ServiceManagerDock.setVisible(not serviceBool) - self.settingsmanager.toggleServiceManager(not serviceBool) + def toggleServiceManager(self, visible): + if self.ServiceManagerDock.isVisible() != visible: + self.ServiceManagerDock.setVisible(visible) + self.settingsmanager.setUIItemVisibility( + self.ServiceManagerDock.objectName(), visible) - def toggleThemeManager(self): - themeBool = self.ThemeManagerDock.isVisible() - self.ThemeManagerDock.setVisible(not themeBool) - self.settingsmanager.toggleThemeManager(not themeBool) + def toggleThemeManager(self, visible): + if self.ThemeManagerDock.isVisible() != visible: + self.ThemeManagerDock.setVisible(visible) + self.settingsmanager.setUIItemVisibility( + self.ThemeManagerDock.objectName(), visible) def togglePreviewPanel(self): previewBool = self.PreviewController.Panel.isVisible() diff --git a/openlp/core/ui/plugindialoglistform.py b/openlp/core/ui/plugindialoglistform.py index 595e22cec..55effb9de 100644 --- a/openlp/core/ui/plugindialoglistform.py +++ b/openlp/core/ui/plugindialoglistform.py @@ -9,7 +9,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import translate +from openlp.core.lib import translate, PluginStatus class PluginForm(QtGui.QDialog): global log @@ -63,11 +63,14 @@ class PluginForm(QtGui.QDialog): for plugin in self.parent.plugin_manager.plugins: row = self.PluginViewList.rowCount() self.PluginViewList.setRowCount(row + 1) - item1 = QtGui.QTableWidgetItem(plugin[u'plugin'].name) + item1 = QtGui.QTableWidgetItem(plugin.name) item1.setTextAlignment(QtCore.Qt.AlignVCenter) - item2 = QtGui.QTableWidgetItem(plugin[u'plugin'].version) + item2 = QtGui.QTableWidgetItem(plugin.version) item2.setTextAlignment(QtCore.Qt.AlignVCenter) - item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', plugin[u'status'])) + if plugin.status == PluginStatus.Active: + item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', u'Active')) + else: + item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', u'Inactive')) item3.setTextAlignment(QtCore.Qt.AlignVCenter) self.PluginViewList.setItem(row, 0, item1) self.PluginViewList.setItem(row, 1, item2) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ab112e758..efe82cdc3 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -100,6 +100,7 @@ class ServiceManager(QtGui.QWidget): self.parent = parent self.serviceItems = [] self.serviceName = u'' + self.isNew = True self.Layout = QtGui.QVBoxLayout(self) self.Layout.setSpacing(0) self.Layout.setMargin(0) @@ -319,6 +320,7 @@ class ServiceManager(QtGui.QWidget): self.ServiceManagerList.clear() self.serviceItems = [] self.serviceName = u'' + self.isNew = True self.parent.OosChanged(True, self.serviceName) def onDeleteFromService(self): @@ -361,21 +363,28 @@ class ServiceManager(QtGui.QWidget): if serviceItem == itemcount and serviceItemCount == count: self.ServiceManagerList.setCurrentItem(treewidgetitem1) - def onSaveService(self): + def onSaveService(self, quick=False): """ Save the current service in a zip file This file contains * An ood which is a pickle of the service items * All image, presentation and video files needed to run the service. """ - filename = QtGui.QFileDialog.getSaveFileName(self, + if not quick or self.isNew: + filename = QtGui.QFileDialog.getSaveFileName(self, u'Save Order of Service',self.config.get_last_dir() ) - filename = unicode(filename) + else: + filename = self.config.get_last_dir() if filename != u'': + splittedFile = filename.split(u'.') + if splittedFile[-1] != u'oos': + filename = filename + u'.oos' + filename = unicode(filename) + self.isNew = False self.config.set_last_dir(filename) service = [] servicefile= filename + u'.ood' - zip = zipfile.ZipFile(unicode(filename) + u'.oos', 'w') + zip = zipfile.ZipFile(unicode(filename), 'w') for item in self.serviceItems: service.append({u'serviceitem':item[u'data'].get_oos_repr()}) if item[u'data'].service_item_type == ServiceType.Image or \ @@ -393,7 +402,12 @@ class ServiceManager(QtGui.QWidget): os.remove(servicefile) except: pass #if not present do not worry - self.parent.OosChanged(True, filename + u'.oos') + name = filename.split(os.path.sep) + self.serviceName = name[-1] + self.parent.OosChanged(True, self.serviceName) + + def onQuickSaveService(self): + self.onSaveService(True) def onLoadService(self): """ @@ -412,6 +426,7 @@ class ServiceManager(QtGui.QWidget): zip = zipfile.ZipFile(unicode(filename)) filexml = None themename = None + for file in zip.namelist(): names = file.split(os.path.sep) file_to = os.path.join(self.servicePath, @@ -437,8 +452,9 @@ class ServiceManager(QtGui.QWidget): #if not present do not worry pass except: - log.error(u'Problem processing oos load %s', sys.exc_info()[0]) + log.exception(u'Problem loading a service file') pass + self.isNew = False self.serviceName = name[len(name) - 1] self.parent.OosChanged(True, self.serviceName) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 33c652389..45068a42d 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -314,6 +314,7 @@ class SlideController(QtGui.QWidget): self.onSlideSelected() self.PreviewListWidget.setFocus() log.info(u'Display Rendering took %4s' % (time.time() - before)) + Receiver().send_message(u'audit_live', self.serviceitem.audit) log.debug(u'displayServiceManagerItems End') #Screen event methods @@ -382,22 +383,28 @@ class SlideController(QtGui.QWidget): def onStartLoop(self): """ - Go to the last slide. + Start the timer loop running and store the timer id """ if self.PreviewListWidget.rowCount() > 1: self.timer_id = self.startTimer(int(self.DelaySpinBox.value()) * 1000) def onStopLoop(self): """ - Go to the last slide. + Stop the timer loop running """ self.killTimer(self.timer_id) def timerEvent(self, event): + """ + If the timer event is for this window select next slide + """ if event.timerId() == self.timer_id: self.onSlideSelectedNext() def onGoLive(self): + """ + If preview copy slide item to live + """ row = self.PreviewListWidget.currentRow() if row > -1 and row < self.PreviewListWidget.rowCount(): self.parent.LiveController.addServiceManagerItem(self.commandItem, row) diff --git a/openlp/plugins/audit/__init__.py b/openlp/plugins/audit/__init__.py new file mode 100644 index 000000000..df3741192 --- /dev/null +++ b/openlp/plugins/audit/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### diff --git a/openlp/plugins/audit/auditplugin.py b/openlp/plugins/audit/auditplugin.py new file mode 100644 index 000000000..b0ad33a70 --- /dev/null +++ b/openlp/plugins/audit/auditplugin.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 datetime import date + +from openlp.core.lib import Plugin, Receiver, translate +from openlp.plugins.audit.lib import AuditTab + +class AuditPlugin(Plugin): + global log + log = logging.getLogger(u'AuditPlugin') + log.info(u'Audit Plugin loaded') + + def __init__(self, plugin_helpers): + # Call the parent constructor + Plugin.__init__(self, u'Audit', u'1.9.0', plugin_helpers) + self.weight = -4 + # Create the plugin icon + self.icon = QtGui.QIcon() + self.icon.addPixmap(QtGui.QPixmap(u':/media/media_image.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.auditfile = None + + def check_pre_conditions(self): + """ + Check to see if auditing is required + """ + log.debug('check_pre_conditions') + #Lets see if audit is required + if int(self.config.get_config(u'startup', 0)) == QtCore.Qt.Checked: + return True + else: + return False + + def add_tools_menu_item(self, tools_menu): + """ + Give the Audit 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. + """ + AuditIcon = QtGui.QIcon() + AuditIcon.addPixmap(QtGui.QPixmap(u':/tools/tools_alert.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.ToolsAuditItem = QtGui.QAction(tools_menu) + self.ToolsAuditItem.setIcon(AuditIcon) + self.ToolsAuditItem.setCheckable(True) + self.ToolsAuditItem.setChecked(False) + self.ToolsAuditItem.setText(translate(u'AuditPlugin', u'A&udit')) + self.ToolsAuditItem.setStatusTip( + translate(u'AuditPlugin', u'Start/Stop live song auditing')) + self.ToolsAuditItem.setShortcut(translate(u'AuditPlugin', u'F4')) + self.ToolsAuditItem.setObjectName(u'ToolsAuditItem') + tools_menu.addSeparator() + tools_menu.addAction(self.ToolsAuditItem) + # Signals and slots + QtCore.QObject.connect(self.ToolsAuditItem, + QtCore.SIGNAL(u'visibilityChanged(bool)'), + self.ToolsAuditItem.setChecked) + QtCore.QObject.connect(self.ToolsAuditItem, + QtCore.SIGNAL(u'triggered(bool)'), + self.toggleAuditState) + + def get_settings_tab(self): + self.AuditTab = AuditTab() + return self.AuditTab + + def initialise(self): + log.info(u'Plugin Initialising') + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit) + self.auditFile = open(u'openlp.aud', 'a') + self.auditActive = False + + def toggleAuditState(self): + self.auditActive = not self.auditActive + + def onReceiveAudit(self, auditData): + if self.auditActive: + self.auditFile.write(u'%s,%s\n' % (date.today(), auditData)) + self.auditFile.flush() + + def finalise(self): + log.debug(u'Finalise') + if self.auditFile is not None: + self.auditFile.close() diff --git a/openlp/plugins/audit/lib/__init__.py b/openlp/plugins/audit/lib/__init__.py new file mode 100644 index 000000000..9db18d784 --- /dev/null +++ b/openlp/plugins/audit/lib/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +from audittab import AuditTab diff --git a/openlp/plugins/audit/lib/audittab.py b/openlp/plugins/audit/lib/audittab.py new file mode 100644 index 000000000..ac3d545ef --- /dev/null +++ b/openlp/plugins/audit/lib/audittab.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # +# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import SettingsTab, str_to_bool, translate, Receiver + +class AuditTab(SettingsTab): + """ + AuditTab is the Audit settings tab in the settings dialog. + """ + def __init__(self): + SettingsTab.__init__(self, translate(u'AuditTab', u'Audit'), u'Audit') + + def setupUi(self): + self.setObjectName(u'AuditTab') + self.AuditLayout = QtGui.QFormLayout(self) + self.AuditLayout.setObjectName(u'AuditLayout') + self.AuditModeGroupBox = QtGui.QGroupBox(self) + self.AuditModeGroupBox.setObjectName(u'AuditModeGroupBox') + self.AuditModeLayout = QtGui.QVBoxLayout(self.AuditModeGroupBox) + self.AuditModeLayout.setSpacing(8) + self.AuditModeLayout.setMargin(8) + self.AuditModeLayout.setObjectName(u'AuditModeLayout') + self.AuditPortSpinBox = QtGui.QSpinBox(self.AuditModeGroupBox) + self.AuditPortSpinBox.setObjectName(u'AuditPortSpinBox') + self.AuditPortSpinBox.setMaximum(32767) + self.AuditModeLayout.addWidget(self.AuditPortSpinBox) + self.AuditActive = QtGui.QCheckBox(self.AuditModeGroupBox) + self.AuditActive.setObjectName(u'AuditPortSpinBox') + self.AuditModeLayout.addWidget(self.AuditActive) + self.WarningLabel = QtGui.QLabel(self.AuditModeGroupBox) + self.WarningLabel.setObjectName(u'WarningLabel') + self.AuditModeLayout.addWidget(self.WarningLabel) + self.AuditLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AuditModeGroupBox) + + def retranslateUi(self): + self.AuditModeGroupBox.setTitle(translate(u'AuditTab', u'Audit File')) + self.AuditActive.setText(translate(u'AuditTab', 'Audit available:')) + self.WarningLabel.setText(translate(u'AuditTab', u'A restart is needed for this change to become effective')) + + def load(self): + self.AuditPortSpinBox.setValue(int(self.config.get_config(u'Audit port', 4316))) + self.AuditActive.setChecked(int(self.config.get_config(u'startup', 0))) + + def save(self): + self.config.set_config(u'Audit port', unicode(self.AuditPortSpinBox.value())) + self.config.set_config(u'startup', unicode(self.AuditActive.checkState())) + diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index ca320fa6e..684034fba 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -192,7 +192,8 @@ class BibleManager(object): nbible.save_meta(u'proxypass', proxypass) return True else: - log.debug(u'register_http_file_bible %s not created already exists', biblename) + log.debug(u'register_http_file_bible %s not created already exists', + biblename) return False def register_csv_file_bible(self, biblename, booksfile, versefile): @@ -201,34 +202,46 @@ class BibleManager(object): If the database exists it is deleted and the database is reloaded from scratch. """ - log.debug(u'register_CSV_file_bible %s,%s,%s', biblename, booksfile, versefile) + log.debug(u'register_CSV_file_bible %s,%s,%s', + biblename, booksfile, versefile) if self._is_new_bible(biblename): - nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible - nbible.create_tables() # Create Database - self.bible_db_cache[biblename] = nbible # cache the database for use later - bcsv = BibleCSVImpl(nbible) # create the loader and pass in the database + # Create new Bible + nbible = BibleDBImpl(self.biblePath, biblename, self.config) + # Create database + nbible.create_tables() + # Cache the database for use later + self.bible_db_cache[biblename] = nbible + # Create the loader and pass in the database + bcsv = BibleCSVImpl(nbible) bcsv.load_data(booksfile, versefile, self.dialogobject) return True else: - log.debug(u'register_csv_file_bible %s not created already exists', biblename) + log.debug(u'register_csv_file_bible %s not created already exists', + biblename) return False def register_osis_file_bible(self, biblename, osisfile): """ - Method to load a bible from a osis xml file extracted from Sword bible viewer. - If the database exists it is deleted and the database is reloaded - from scratch. + Method to load a bible from a osis xml file extracted from Sword bible + viewer. If the database exists it is deleted and the database is + reloaded from scratch. """ log.debug(u'register_OSIS_file_bible %s , %s', biblename, osisfile) if self._is_new_bible(biblename): - nbible = BibleDBImpl(self.biblePath, biblename, self.config) # Create new Bible - nbible.create_tables() # Create Database - self.bible_db_cache[biblename] = nbible # cache the database for use later - bcsv = BibleOSISImpl(self.biblePath, nbible) # create the loader and pass in the database + # Create new Bible + nbible = BibleDBImpl(self.biblePath, biblename, self.config) + # Create Database + nbible.create_tables() + # Cache the database for use later + self.bible_db_cache[biblename] = nbible + # Create the loader and pass in the database + bcsv = BibleOSISImpl(self.biblePath, nbible) bcsv.load_data(osisfile, self.dialogobject) return True else: - log.debug(u'register_OSIS_file_bible %s , %s not created already exists', biblename, osisfile) + log.debug( + u'register_OSIS_file_bible %s , %s not created already exists', + biblename, osisfile) return False def get_bibles(self, mode=BibleMode.Full): @@ -271,7 +284,8 @@ c book and chapterMaxBibleBookVerses """ log.debug(u'get_book_verse_count %s,%s,%s', bible, book, chapter) - return self.bible_db_cache[bible].get_max_bible_book_verses(book, chapter) + return self.bible_db_cache[bible].get_max_bible_book_verses( + book, chapter) def get_verse_from_text(self, bible, versetext): """ @@ -285,7 +299,8 @@ c """ Saves the bibles meta data """ - log.debug(u'save_meta data %s,%s, %s,%s', bible, version, copyright, permissions) + log.debug(u'save_meta data %s,%s, %s,%s', + bible, version, copyright, permissions) self.bible_db_cache[bible].save_meta(u'Version', version) self.bible_db_cache[bible].save_meta(u'Copyright', copyright) self.bible_db_cache[bible].save_meta(u'Permissions', permissions) @@ -297,7 +312,8 @@ c log.debug(u'get_meta %s,%s', bible, key) return self.bible_db_cache[bible].get_meta(key) - def get_verse_text(self, bible, bookname, schapter, echapter, sverse, everse=0): + def get_verse_text(self, bible, bookname, schapter, echapter, sverse, + everse=0): """ Returns a list of verses for a given Book, Chapter and ranges of verses. If the end verse(everse) is less then the start verse(sverse) @@ -311,8 +327,10 @@ c text = [] self.media.setQuickMsg1(u'') self.media.setQuickMsg2(u'') - log.debug(u'get_verse_text %s,%s,%s,%s,%s,%s', bible, bookname, schapter, echapter, sverse, everse) - # check to see if book/chapter exists fow HTTP bibles and load cache if necessary + log.debug(u'get_verse_text %s,%s,%s,%s,%s,%s', + bible, bookname, schapter, echapter, sverse, everse) + # check to see if book/chapter exists fow HTTP bibles and load cache + # if necessary if self.bible_http_cache[bible] is not None: book= self.bible_db_cache[bible].get_bible_book(bookname) if book == None: @@ -320,49 +338,61 @@ c log.debug(u'get_verse_text : new book') for chapter in range(schapter, echapter + 1): self.media.setQuickMsg2(u'%s: %s'% (bookname, chapter)) - search_results = self.bible_http_cache [bible].get_bible_chapter(bible, 0, bookname, chapter) + search_results = \ + self.bible_http_cache[bible].get_bible_chapter( + bible, 0, bookname, chapter) if search_results.has_verselist() : - ## We have found a book of the bible lets check to see if it was there. - ## By reusing the returned book name we get a correct book. - ## For example it is possible to request ac and get Acts back. + ## We have found a book of the bible lets check to see + ## if it was there. By reusing the returned book name + ## we get a correct book. For example it is possible + ## to request ac and get Acts back. bookname = search_results.get_book() # check to see if book/chapter exists - book= self.bible_db_cache[bible].get_bible_book(bookname) + book = self.bible_db_cache[bible].get_bible_book( + bookname) if book == None: ## Then create book, chapter and text - book = self.bible_db_cache[bible].create_book(bookname, \ - self.book_abbreviations[bookname], \ - self.book_testaments[bookname]) - log.debug(u'New http book %s , %s, %s', book, book.id, book.name) - self.bible_db_cache[bible].create_chapter(book.id, \ - search_results.get_chapter(),\ - search_results.get_verselist()) + book = self.bible_db_cache[bible].create_book( + bookname, self.book_abbreviations[bookname], + self.book_testaments[bookname]) + log.debug(u'New http book %s , %s, %s', + book, book.id, book.name) + self.bible_db_cache[bible].create_chapter( + book.id, search_results.get_chapter(), + search_results.get_verselist()) else: ## Book exists check chapter and texts only. - v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter) + v = self.bible_db_cache[bible].get_bible_chapter( + book.id, chapter) if v == None: - self.media.setQuickMsg2(u'%s: %s'%(bookname, chapter)) - self.bible_db_cache[bible].create_chapter(book.id, \ - chapter, \ - search_results.get_verselist()) + self.media.setQuickMsg2(u'%s: %s'% ( + bookname, chapter)) + self.bible_db_cache[bible].create_chapter( + book.id, chapter, + search_results.get_verselist()) else: log.debug(u'get_verse_text : old book') for chapter in range(schapter, echapter + 1): - v = self.bible_db_cache[bible].get_bible_chapter(book.id, chapter) + v = self.bible_db_cache[bible].get_bible_chapter( + book.id, chapter) if v == None: try: self.media.setQuickMsg1(u'Downloading') - self.media.setQuickMsg2(u'%s: %s'% (bookname, chapter)) - search_results = self.bible_http_cache [bible].get_bible_chapter(bible, book.id, bookname, chapter) + self.media.setQuickMsg2(u'%s: %s'% \ + (bookname, chapter)) + search_results = \ + self.bible_http_cache[bible].get_bible_chapter( + bible, book.id, bookname, chapter) if search_results.has_verselist(): - self.bible_db_cache[bible].create_chapter(book.id, \ - search_results.get_chapter(),\ - search_results.get_verselist()) - except : - log.error(u'Errow thrown %s', sys.exc_info()[1]) + self.bible_db_cache[bible].create_chapter( + book.id, search_results.get_chapter(), + search_results.get_verselist()) + except: + log.exception(u'Problem getting scripture online') #Now get verses from database if schapter == echapter: - text = self.bible_db_cache[bible].get_bible_text(bookname, schapter, sverse, everse) + text = self.bible_db_cache[bible].get_bible_text(bookname, + schapter, sverse, everse) else: for i in range (schapter, echapter + 1): if i == schapter: @@ -375,7 +405,8 @@ c start = 1 end = self.get_book_verse_count(bible, bookname, i) - txt = self.bible_db_cache[bible].get_bible_text(bookname, i, start, end) + txt = self.bible_db_cache[bible].get_bible_text( + bookname, i, start, end) text.extend(txt) return text diff --git a/openlp/plugins/presentations/lib/impresscontroller.py b/openlp/plugins/presentations/lib/impresscontroller.py index 905b62def..a8650df00 100644 --- a/openlp/plugins/presentations/lib/impresscontroller.py +++ b/openlp/plugins/presentations/lib/impresscontroller.py @@ -23,8 +23,8 @@ Place, Suite 330, Boston, MA 02111-1307 USA # http://www.oooforum.org/forum/viewtopic.phtml?t=5252 # http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations # http://mail.python.org/pipermail/python-win32/2008-January/006676.html -#http://www.linuxjournal.com/content/starting-stopping-and-connecting-openoffice-python -#http://nxsy.org/comparing-documents-with-openoffice-and-python +# http://www.linuxjournal.com/content/starting-stopping-and-connecting-openoffice-python +# http://nxsy.org/comparing-documents-with-openoffice-and-python import logging import os , subprocess @@ -80,8 +80,9 @@ class ImpressController(object): """ Called when a presentation is added to the SlideController. It builds the environment, starts communcations with the background - OpenOffice task started earlier. If OpenOffice is not present is ts started. - Once the environment is available the presentation is loaded and started. + OpenOffice task started earlier. If OpenOffice is not present is is + started. Once the environment is available the presentation is loaded + and started. ``presentation`` The file name of the presentatios to the run. @@ -98,19 +99,22 @@ class ImpressController(object): try: properties = [] properties = tuple(properties) - self.document = desktop.loadComponentFromURL(url, "_blank", 0, properties) + self.document = desktop.loadComponentFromURL( + url, "_blank", 0, properties) self.presentation = self.document.getPresentation() self.presentation.start() - self.xSlideShowController = desktop.getCurrentComponent().Presentation.getController() + self.xSlideShowController = \ + desktop.getCurrentComponent().Presentation.getController() except: - log.error(u'Failed reason %s' % sys.exc_info()) + log.exception(u'Failed to load presentation') def getUNODesktop(self): log.debug(u'getUNODesktop') ctx = None loop = 0 context = uno.getComponentContext() - resolver = context.ServiceManager.createInstanceWithContext(u'com.sun.star.bridge.UnoUrlResolver', context) + resolver = context.ServiceManager.createInstanceWithContext( + u'com.sun.star.bridge.UnoUrlResolver', context) while ctx == None and loop < 3: try: ctx = resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') @@ -119,10 +123,11 @@ class ImpressController(object): loop += 1 try: smgr = ctx.ServiceManager - desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", ctx ) + desktop = smgr.createInstanceWithContext( + "com.sun.star.frame.Desktop", ctx ) return desktop except: - log.error(u'Failed reason %s' % sys.exc_info()) + log.exception(u'Failed to get UNO desktop') return None def getCOMDesktop(self): @@ -132,7 +137,7 @@ class ImpressController(object): desktop = smgr.createInstance( "com.sun.star.frame.Desktop") return desktop except: - log.error(u'Failed reason %s' % sys.exc_info()) + log.exception(u'Failed to get COM desktop') return None def closePresentation(self): diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 5c2c07d3d..d76e9a493 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -29,8 +29,8 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, MediaManagerItem -from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, \ - ImpressController +from openlp.plugins.presentations.lib import PresentationMediaItem, \ + PresentationTab, ImpressController try: from openlp.plugins.presentations.lib import PowerpointController except: @@ -64,7 +64,8 @@ class PresentationPlugin(Plugin): """ Create the Media Manager List """ - self.media_item = PresentationMediaItem(self, self.icon, u'Presentations', self.controllers) + self.media_item = PresentationMediaItem( + self, self.icon, u'Presentations', self.controllers) return self.media_item def registerControllers(self, handle, controller): @@ -77,7 +78,8 @@ class PresentationPlugin(Plugin): """ log.debug('check_pre_conditions') #Lets see if Impress is required (Default is Not wanted) - if int(self.config.get_config(u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: + if int(self.config.get_config( + u'Impress', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: try: if os.name == u'nt': #Check to see if we are Win32 @@ -88,25 +90,27 @@ class PresentationPlugin(Plugin): openoffice = ImpressController() self.registerControllers(u'Impress', openoffice) except: - log.error(u'Reason : %s', sys.exc_info()) + log.exception(u'Failed to set up plugin for Impress') #Lets see if Powerpoint is required (Default is Not wanted) - if int(self.config.get_config(u'Powerpoint', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: + if int(self.config.get_config( + u'Powerpoint', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: try: #Check to see if we are Win32 from win32com.client import Dispatch powerpoint = PowerpointController() self.registerControllers(u'Powerpoint', powerpoint) except: - log.error(u'Reason : %s', sys.exc_info()) + log.exception(u'Failed to set up plugin for Powerpoint') #Lets see if Powerpoint Viewer is required (Default is Not wanted) - if int(self.config.get_config(u'Powerpoint Viewer', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: + if int(self.config.get_config( + u'Powerpoint Viewer', QtCore.Qt.Unchecked)) == QtCore.Qt.Checked: try: #Check to see if we are Win32 from win32com.client import Dispatch powerpoint = PowerpointController() self.registerControllers(u'Powerpoint Viewer', powerpoint) except: - log.error(u'Reason : %s', sys.exc_info()) + log.exception(u'Failed to set up plugin for Powerpoint Viewer') #If we have no available controllers disable plugin if len(self.controllers) > 0: return True diff --git a/openlp/plugins/songs/lib/manager.py b/openlp/plugins/songs/lib/manager.py index b4f89ec18..53a6c6af8 100644 --- a/openlp/plugins/songs/lib/manager.py +++ b/openlp/plugins/songs/lib/manager.py @@ -51,7 +51,8 @@ class SongManager(): self.db_url = u'' db_type = self.config.get_config(u'db type', u'sqlite') if db_type == u'sqlite': - self.db_url = u'sqlite:///%s/songs.sqlite' % self.config.get_data_path() + self.db_url = u'sqlite:///%s/songs.sqlite' % \ + self.config.get_data_path() else: self.db_url = db_type + 'u://' + \ self.config.get_config(u'db username') + u':' + \ @@ -88,7 +89,8 @@ class SongManager(): """ Searches the song authors for keywords. """ - return self.session.query(Author).filter(Author.display_name.like(u'%' + keywords + u'%')).order_by(Author.display_name.asc()).all() + return self.session.query(Author).filter(Author.display_name.like( + u'%' + keywords + u'%')).order_by(Author.display_name.asc()).all() def get_song(self, id=None): """ @@ -109,7 +111,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not save song to song database') return False def delete_song(self, songid): @@ -120,8 +122,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) - print u'Errow thrown ', sys.exc_info()[1] + log.exception(u'Could not delete song from song database') return False def get_authors(self): @@ -146,7 +147,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not save author to song database') return False def delete_author(self, authorid): @@ -160,7 +161,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not delete author from song database') return False def get_topics(self): @@ -185,7 +186,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not save topic to song database') return False def delete_topic(self, topicid): @@ -199,7 +200,7 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not delete topic from song database') return False def get_books(self): @@ -224,7 +225,7 @@ class SongManager(): return True except Exception, e: self.session.rollback() - log.error(u'Errow thrown %s', e.args[0]) + log.exception(u'Could not save book to song database') return False def delete_book(self, bookid): @@ -238,5 +239,6 @@ class SongManager(): return True except: self.session.rollback() - log.error(u'Errow thrown %s', sys.exc_info()[1]) + log.exception(u'Could not delete book from song database') return False + diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 9e65616e7..cce5cf8a8 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -269,17 +269,12 @@ class SongMediaItem(MediaManagerItem): self.parent.songmanager.delete_song(item_id) row = self.ListView.row(item) self.ListView.takeItem(row) -# -# def onSongPreviewClick(self): -# service_item = ServiceItem(self.parent) -# service_item.addIcon(u':/media/media_song.png') -# self.generateSlideData(service_item) -# self.parent.preview_controller.addServiceItem(service_item) def generateSlideData(self, service_item): raw_slides =[] raw_footer = [] author_list = u'' + author_audit = [] ccl = u'' item = self.ListView.currentItem() if item is None: @@ -302,6 +297,7 @@ class SongMediaItem(MediaManagerItem): if len(author_list) > 1: author_list = author_list + u', ' author_list = author_list + unicode(author.display_name) + author_audit.append(unicode(author.display_name)) if song.ccli_number == None or len(song.ccli_number) == 0: ccl = self.parent.settings.GeneralTab.CCLNumber else: @@ -312,16 +308,5 @@ class SongMediaItem(MediaManagerItem): raw_footer.append(unicode( translate(u'SongMediaItem', u'CCL Licence: ') + ccl )) service_item.raw_footer = raw_footer + service_item.audit = [service_item.title, author_audit, ccl] return True - -# def onSongLiveClick(self): -# service_item = ServiceItem(self.parent) -# service_item.addIcon(u':/media/media_song.png') -# self.generateSlideData(service_item) -# self.parent.live_controller.addServiceItem(service_item) -# -# def onSongAddClick(self): -# service_item = ServiceItem(self.parent) -# service_item.addIcon( u':/media/media_song.png') -# self.generateSlideData(service_item) -# self.parent.service_manager.addServiceItem(service_item) diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index 83c88c3e5..096c27dfe 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -49,6 +49,10 @@ import_remove.png import_load.png + + audit_start.png + audit_stop.png + export_selectall.png export_remove.png