From 8b65992307a9a785ce297fbf31aad512bcb5c443 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 17 Sep 2009 19:24:13 +0100 Subject: [PATCH] requested cleanups 1 --- openlp/core/lib/plugin.py | 9 +++ openlp/core/lib/pluginmanager.py | 12 ++++ openlp/core/ui/mainwindow.py | 2 + openlp/plugins/audit/auditplugin.py | 52 +++++++++++--- openlp/plugins/audit/lib/__init__.py | 1 - openlp/plugins/audit/lib/mediaitem.py | 94 -------------------------- resources/images/audit_start.png | Bin 3046 -> 0 bytes resources/images/audit_stop.png | Bin 3253 -> 0 bytes 8 files changed, 67 insertions(+), 103 deletions(-) delete mode 100644 openlp/plugins/audit/lib/mediaitem.py delete mode 100644 resources/images/audit_start.png delete mode 100644 resources/images/audit_stop.png 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 1a741be174be6c42ccb2d1efd81c9ad13fb56a06..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3046 zcmV zUQ9Hj*WFUf%mgitWTcsuMCxG?MFD}CXZB~dXZgMN&U-w~Ih-%g<=*e-b7tlb1a>=n z7Nh~NyzBr-0t4GPQ-zfP!lsvj;0H`Pb$r%AO|7S0wl6GB)Six!HhJ7D_Ac(%x~N9ilZ2@%cbZS(8X*!}wz_9yDIVSjU!y}jXYh-!|ucTnCh zw?)t#_ZHF~-VLO?#JB-D)bnXf?o{eU&U3`^%;sB(iylYG1HGOhFZA3?o`_Ku;r#+0k*8pFO3}v60F6Hxr__t9S9ME|Y6=M+aWN$& zv1nqGa<|RrI@vT?ciNt&ju(r-?cA^3uuOtrTa0>6{0hLDuB3^>FgL0FO??1t3%Jb` zhq;hDFlnAZb8Ci@MSHebwVdvp2edz_$DX0SLA`B?>mqSdQWHyviyj^1(Rjs}NnTc$ z6i=Q)@TK4^!ES_@A@u;!eRKy5(Vi%+)>fw` zcjm!w_Q}e4u?j&~mF=c+m|v>(rVIoXvC*bvfR6o^Lh-)<4X@tH75iget9?Qoj9Fb9 zhDq}rns*$aJ-jPs$#_RS52(j>T`8en>gi!U~Mj*t*t-E_QbYfU{kF!#WDUTCG%@J_c}9LW8&qpuNJBD&7L9 zkFOacPQqu!m?~BRh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IzP$pgJ|$O}Ci$@72Pbl{Ls_b1l?001I-R9JLVZ)S9NVRB^v0C?If oFE7{2%*!rLPAo{(%P&d?05;eLSP)anTmS$707*qoM6N<$f_Agk>;M1& diff --git a/resources/images/audit_stop.png b/resources/images/audit_stop.png deleted file mode 100644 index 0dfaa6af3480a572db50909deb7afefadc875a8c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3253 zcmV;m3`+BfP)@mzELLftg^JKsJi!_J?Cn#{sa2= zty*8Ls=Mm$I%}V^tF+=+WJ-WEv`SpCBVFR7Ipmb=GwyI97h;0h9WqQ|W5WA|_lqwu z2Kz7iFXn8dC}_~ed6Xg;FkYCgcp(!p0)LO_3K`E)vCz7%zJxoh>kdX}XTp=ilfPQj zdB}gsf9Y<4+6Eb7?RS(<`Pk3J?3cWb5Y9?ms6~v#r^zR~CE@gzGDH~yA7;phkD9`2 zq8>&)G|5u8TMt zSNPGERxn_NOCKB2s7vRnkUD z3#W1$w_z>l5uhz}hwflGzsbEMUx$u)e)0UmdCkv!zwrBo-M+azxa3yJtrb&#tGFC{ zIrjBd8WA2F9-En`+xTsM`)ZsP&U0ASMSrk5K=?J%DNV9R%;FFELy_e;YQJE=@LU}3 z`hWBP_FY`k@i+3`$cxYISF>Q?f`Nvv^;B=DH?;X8!^0k?wqQ(0Yey??(IFH`Y&by` zQ~@iB1c>BmJPlv+aO5C|bo5v3ik)n+r_vMB6EHt|bn1}QA;zSOV~P@r68h)Xd-i^^ z_mjW2JDzr2a9kJ}XUq;p1*5JsDL>F3BzrV+M(>Q?$yr^ZB16Uhw#bzXY8r+jn& zg@*Em@?~dDpd95Z_h{P7t|C{_($(2MjUIQiAk%Fs%{Ud>1Os5UivagW_ScB9s}>vqEJgxnY!?)uF2 zSxJcoUtnrr>eOzI6Ig%+F}++(dYm37>TtMYd&hRA7An0=F9QfV&N$9U4|KFS+5mdW zUSuxIwhglllP*x&l(t9Zc9($vUHl||l0IOZHckT~Td&n?0rrHR4?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