diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 87c999b97..a64b4938d 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -166,6 +166,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..4f0ae3742 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -178,6 +178,18 @@ class PluginManager(object): if plugin[u'status'] == u'Active': plugin[u'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[u'status'] == u'Active': + plugin[u'plugin'].add_tools_menu_item(tools_menu) + def initialise_plugins(self): """ Loop through all the plugins and give them an opportunity to diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 67644643b..f2a90f8fd 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -545,6 +545,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() diff --git a/openlp/plugins/audit/auditplugin.py b/openlp/plugins/audit/auditplugin.py index ac7972483..6ad0ef7d7 100644 --- a/openlp/plugins/audit/auditplugin.py +++ b/openlp/plugins/audit/auditplugin.py @@ -26,8 +26,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin -from openlp.plugins.audit.lib import AuditMediaItem, AuditTab +from openlp.core.lib import Plugin, Receiver, translate +from openlp.plugins.audit.lib import AuditTab class AuditPlugin(Plugin): global log @@ -55,19 +55,55 @@ class AuditPlugin(Plugin): 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. + """ + self.ToolsAuditItem = QtGui.QAction(tools_menu) + AuditIcon = QtGui.QIcon() + AuditIcon.addPixmap(QtGui.QPixmap(u':/tools/tools_alert.png'), + QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.ToolsAuditItem.setIcon(AuditIcon) + self.ToolsAuditItem.setObjectName(u'ToolsAuditItem') + self.ToolsAuditItem.setCheckable(True) + self.ToolsAuditItem.setChecked(True) + tools_menu.addSeparator() + tools_menu.addAction(self.ToolsAuditItem) + + 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')) +# + # Translations... +# # Signals and slots +# QtCore.QObject.connect(self.MediaManagerDock, +# QtCore.SIGNAL(u'visibilityChanged(bool)'), +# self.ViewMediaManagerItem.setChecked) +# QtCore.QObject.connect(self.ViewMediaManagerItem, +# QtCore.SIGNAL(u'triggered(bool)'), +# self.toggleMediaManager) + def get_settings_tab(self): self.AuditTab = AuditTab() return self.AuditTab - def get_media_manager_item(self): - # Create the MediaManagerItem object - self.media_item = AuditMediaItem(self, self.icon, u'Audit') - return self.media_item - 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.media_item.auditFile = self.auditfile + self.auditActive = False + + 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') diff --git a/openlp/plugins/audit/lib/__init__.py b/openlp/plugins/audit/lib/__init__.py index 544b1dec2..9db18d784 100644 --- a/openlp/plugins/audit/lib/__init__.py +++ b/openlp/plugins/audit/lib/__init__.py @@ -22,5 +22,4 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -from mediaitem import AuditMediaItem from audittab import AuditTab diff --git a/openlp/plugins/audit/lib/mediaitem.py b/openlp/plugins/audit/lib/mediaitem.py deleted file mode 100644 index a85a44599..000000000 --- a/openlp/plugins/audit/lib/mediaitem.py +++ /dev/null @@ -1,94 +0,0 @@ -# -*- 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 -import os -from datetime import date - -from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, translate, buildIcon, Receiver - -class AuditMediaItem(MediaManagerItem): - """ - This is the custom media manager item for Audits. - """ - global log - log = logging.getLogger(u'AuditMediaItem') - log.info(u'Audit Media Item loaded') - - def __init__(self, parent, icon, title): - self.TranslationContext = u'AuditPlugin' - self.PluginTextShort = u'Audit' - self.ConfigSection = u'Audits' - self.IconPath = u'Audit/Audit' - self.hasFileIcon = False - self.hasNewIcon = False - self.hasEditIcon = False - MediaManagerItem.__init__(self, parent, icon, title) - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit) - - def initialise(self): - self.Toolbar.actions[self.startMessage].setVisible(True) - self.Toolbar.actions[self.stopMessage].setVisible(False) - self.auditActive = False - - def addStartHeaderBar(self): - self.startMessage = translate(self.TranslationContext, u'Start Collecting') - self.addToolbarButton(self.startMessage, - translate(self.TranslationContext, u'Start collecting alert messages '), - u':audit/audit_start.png', self.onStartClick, u'AuditStartItem') - self.stopMessage = translate(self.TranslationContext, u'Stop Collecting') - self.addToolbarButton(self.stopMessage, - translate(self.TranslationContext, u'Stop collecting alert messages '), - u':audit/audit_stop.png', self.onStopClick, u'AuditStopItem') - - def addMiddleHeaderBar(self): - pass - - def addListViewToToolBar(self): - self.ListView = QtGui.QListWidget() - self.ListView.uniformItemSizes = True - self.ListView.setGeometry(QtCore.QRect(10, 100, 256, 591)) - self.ListView.setSpacing(1) - self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) - self.ListView.setAlternatingRowColors(True) - self.ListView.setDragEnabled(True) - self.ListView.setObjectName(u'AlertListView') - #Add tp PageLayout - self.PageLayout.addWidget(self.ListView) - - def onStartClick(self): - self.Toolbar.actions[self.startMessage].setVisible(False) - self.Toolbar.actions[self.stopMessage].setVisible(True) - self.auditActive = True - - def onStopClick(self): - self.Toolbar.actions[self.startMessage].setVisible(True) - self.Toolbar.actions[self.stopMessage].setVisible(False) - self.auditActive = False - - def onReceiveAudit(self, auditData): - if self.auditActive: - self.auditFile.write(u'%s,%s\n' % (date.today(), auditData)) diff --git a/resources/images/audit_start.png b/resources/images/audit_start.png deleted file mode 100644 index 1a741be17..000000000 Binary files a/resources/images/audit_start.png and /dev/null differ diff --git a/resources/images/audit_stop.png b/resources/images/audit_stop.png deleted file mode 100644 index 0dfaa6af3..000000000 Binary files a/resources/images/audit_stop.png and /dev/null differ