Audit cleanup from last merge

This commit is contained in:
Tim Bentley 2009-09-18 11:47:57 +01:00
parent 66ec702dec
commit 8d04804865

View File

@ -25,6 +25,7 @@
import logging import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from datetime import date
from openlp.core.lib import Plugin, Receiver, translate from openlp.core.lib import Plugin, Receiver, translate
from openlp.plugins.audit.lib import AuditTab from openlp.plugins.audit.lib import AuditTab
@ -64,30 +65,27 @@ class AuditPlugin(Plugin):
The actual **Tools** menu item, so that your actions can The actual **Tools** menu item, so that your actions can
use it as their parent. use it as their parent.
""" """
self.ToolsAuditItem = QtGui.QAction(tools_menu)
AuditIcon = QtGui.QIcon() AuditIcon = QtGui.QIcon()
AuditIcon.addPixmap(QtGui.QPixmap(u':/tools/tools_alert.png'), AuditIcon.addPixmap(QtGui.QPixmap(u':/tools/tools_alert.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.ToolsAuditItem = QtGui.QAction(tools_menu)
self.ToolsAuditItem.setIcon(AuditIcon) self.ToolsAuditItem.setIcon(AuditIcon)
self.ToolsAuditItem.setObjectName(u'ToolsAuditItem')
self.ToolsAuditItem.setCheckable(True) self.ToolsAuditItem.setCheckable(True)
self.ToolsAuditItem.setChecked(True) self.ToolsAuditItem.setChecked(False)
tools_menu.addSeparator()
tools_menu.addAction(self.ToolsAuditItem)
self.ToolsAuditItem.setText(translate(u'AuditPlugin', u'A&udit')) self.ToolsAuditItem.setText(translate(u'AuditPlugin', u'A&udit'))
self.ToolsAuditItem.setStatusTip( self.ToolsAuditItem.setStatusTip(
translate(u'AuditPlugin', u'Start/Stop live song auditing')) translate(u'AuditPlugin', u'Start/Stop live song auditing'))
self.ToolsAuditItem.setShortcut(translate(u'AuditPlugin', u'F4')) self.ToolsAuditItem.setShortcut(translate(u'AuditPlugin', u'F4'))
# self.ToolsAuditItem.setObjectName(u'ToolsAuditItem')
# Translations... tools_menu.addSeparator()
# # Signals and slots tools_menu.addAction(self.ToolsAuditItem)
# QtCore.QObject.connect(self.MediaManagerDock, # Signals and slots
# QtCore.SIGNAL(u'visibilityChanged(bool)'), QtCore.QObject.connect(self.ToolsAuditItem,
# self.ViewMediaManagerItem.setChecked) QtCore.SIGNAL(u'visibilityChanged(bool)'),
# QtCore.QObject.connect(self.ViewMediaManagerItem, self.ToolsAuditItem.setChecked)
# QtCore.SIGNAL(u'triggered(bool)'), QtCore.QObject.connect(self.ToolsAuditItem,
# self.toggleMediaManager) QtCore.SIGNAL(u'triggered(bool)'),
self.toggleAuditState)
def get_settings_tab(self): def get_settings_tab(self):
self.AuditTab = AuditTab() self.AuditTab = AuditTab()
@ -97,15 +95,18 @@ class AuditPlugin(Plugin):
log.info(u'Plugin Initialising') log.info(u'Plugin Initialising')
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit) QtCore.SIGNAL(u'audit_live'), self.onReceiveAudit)
self.auditfile = open(u'openlp.aud', 'a') self.auditFile = open(u'openlp.aud', 'a')
self.auditActive = False self.auditActive = False
def toggleAuditState(self):
self.auditActive = not self.auditActive
def onReceiveAudit(self, auditData): def onReceiveAudit(self, auditData):
if self.auditActive: if self.auditActive:
self.auditFile.write(u'%s,%s\n' % (date.today(), auditData)) self.auditFile.write(u'%s,%s\n' % (date.today(), auditData))
self.auditfile.flush() self.auditFile.flush()
def finalise(self): def finalise(self):
log.debug(u'Finalise') log.debug(u'Finalise')
if self.auditfile is not None: if self.auditFile is not None:
self.auditfile.close() self.auditFile.close()