forked from openlp/openlp
Add audit File and state handling
This commit is contained in:
parent
32fb30b7c8
commit
88c66b368c
@ -80,6 +80,9 @@ class EventReceiver(QtCore.QObject):
|
|||||||
|
|
||||||
``audit_live``
|
``audit_live``
|
||||||
Sends live song audit requests to the audit component
|
Sends live song audit requests to the audit component
|
||||||
|
|
||||||
|
``audit_changed``
|
||||||
|
Audit information may have changed
|
||||||
"""
|
"""
|
||||||
global log
|
global log
|
||||||
log = logging.getLogger(u'EventReceiver')
|
log = logging.getLogger(u'EventReceiver')
|
||||||
|
@ -27,7 +27,7 @@ import logging
|
|||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, Receiver, translate
|
from openlp.core.lib import Plugin, Receiver, translate, str_to_bool
|
||||||
from openlp.plugins.audit.lib import AuditTab
|
from openlp.plugins.audit.lib import AuditTab
|
||||||
|
|
||||||
class AuditPlugin(Plugin):
|
class AuditPlugin(Plugin):
|
||||||
@ -95,17 +95,48 @@ 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')
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
self.auditActive = False
|
QtCore.SIGNAL(u'audit_changed'), self.onUpdateAudit)
|
||||||
|
self.auditFileName = self.config.get_config(u'audit file', u'')
|
||||||
|
self.auditActive = str_to_bool(self.config.get_config(u'audit active', False))
|
||||||
|
if self.auditFileName == u'':
|
||||||
|
self.auditActive = False
|
||||||
|
self.ToolsAuditItem.setEnabled(False)
|
||||||
|
self.auditFile = None
|
||||||
|
else:
|
||||||
|
self.auditFile = open(self.auditFileName, u'a')
|
||||||
|
self.ToolsAuditItem.setChecked(self.auditActive)
|
||||||
|
|
||||||
def toggleAuditState(self):
|
def toggleAuditState(self):
|
||||||
self.auditActive = not self.auditActive
|
self.auditActive = not self.auditActive
|
||||||
|
self.config.set_config(u'audit active', self.auditActive)
|
||||||
|
|
||||||
def onReceiveAudit(self, auditData):
|
def onReceiveAudit(self, auditData):
|
||||||
|
"""
|
||||||
|
Audit a live song from SlideController
|
||||||
|
"""
|
||||||
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 onUpdateAudit(self):
|
||||||
|
"""
|
||||||
|
Someone may have changed to audit details
|
||||||
|
Sort out the file and the auditing state
|
||||||
|
"""
|
||||||
|
self.auditFileNameNew = self.config.get_config(u'audit file', u'')
|
||||||
|
self.auditActive = str_to_bool(self.config.get_config(u'audit active', False))
|
||||||
|
if self.auditFileNameNew == u'':
|
||||||
|
self.auditActive = False
|
||||||
|
self.ToolsAuditItem.setChecked(self.auditActive)
|
||||||
|
self.ToolsAuditItem.setEnabled(False)
|
||||||
|
return
|
||||||
|
self.ToolsAuditItem.setEnabled(True)
|
||||||
|
if self.auditFileNameNew != self.auditFileName:
|
||||||
|
if self.auditFile is not None:
|
||||||
|
self.auditFile.close()
|
||||||
|
self.auditFile = open(self.auditFileNameNew, u'a')
|
||||||
|
|
||||||
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:
|
||||||
|
@ -35,25 +35,30 @@ class AuditTab(SettingsTab):
|
|||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
self.setObjectName(u'AuditTab')
|
self.setObjectName(u'AuditTab')
|
||||||
self.AuditLayout = QtGui.QFormLayout(self)
|
|
||||||
self.AuditLayout.setObjectName(u'AuditLayout')
|
|
||||||
self.AuditModeGroupBox = QtGui.QGroupBox(self)
|
self.AuditModeGroupBox = QtGui.QGroupBox(self)
|
||||||
self.AuditModeGroupBox.setObjectName(u'AuditModeGroupBox')
|
self.AuditModeGroupBox.setObjectName(u'AuditModeGroupBox')
|
||||||
self.AuditModeLayout = QtGui.QVBoxLayout(self.AuditModeGroupBox)
|
self.verticalLayout = QtGui.QVBoxLayout(self.AuditModeGroupBox)
|
||||||
self.AuditModeLayout.setSpacing(8)
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
self.AuditModeLayout.setMargin(8)
|
self.horizontalLayout = QtGui.QHBoxLayout()
|
||||||
self.AuditModeLayout.setObjectName(u'AuditModeLayout')
|
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||||
self.AuditPortSpinBox = QtGui.QSpinBox(self.AuditModeGroupBox)
|
self.AuditFileName = QtGui.QLineEdit(self)
|
||||||
self.AuditPortSpinBox.setObjectName(u'AuditPortSpinBox')
|
self.AuditFileName.setObjectName("AuditFileName")
|
||||||
self.AuditPortSpinBox.setMaximum(32767)
|
self.horizontalLayout.addWidget(self.AuditFileName)
|
||||||
self.AuditModeLayout.addWidget(self.AuditPortSpinBox)
|
icon1 = QtGui.QIcon()
|
||||||
self.AuditActive = QtGui.QCheckBox(self.AuditModeGroupBox)
|
icon1.addPixmap(QtGui.QPixmap(u':/imports/import_load.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||||
self.AuditActive.setObjectName(u'AuditPortSpinBox')
|
self.AuditFileButton = QtGui.QPushButton(self)
|
||||||
self.AuditModeLayout.addWidget(self.AuditActive)
|
self.AuditFileButton.setObjectName("AuditFileButton")
|
||||||
self.WarningLabel = QtGui.QLabel(self.AuditModeGroupBox)
|
self.AuditFileButton.setIcon(icon1)
|
||||||
self.WarningLabel.setObjectName(u'WarningLabel')
|
self.horizontalLayout.addWidget(self.AuditFileButton)
|
||||||
self.AuditModeLayout.addWidget(self.WarningLabel)
|
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||||
self.AuditLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.AuditModeGroupBox)
|
self.AuditActive = QtGui.QCheckBox(self)
|
||||||
|
self.AuditActive.setObjectName("AuditActive")
|
||||||
|
self.verticalLayout.addWidget(self.AuditActive)
|
||||||
|
self.WarningLabel = QtGui.QLabel(self)
|
||||||
|
self.WarningLabel.setObjectName("WarningLabel")
|
||||||
|
self.verticalLayout.addWidget(self.WarningLabel)
|
||||||
|
QtCore.QObject.connect(self.AuditFileButton,
|
||||||
|
QtCore.SIGNAL(u'pressed()'), self.onAuditFileButtonClicked)
|
||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
self.AuditModeGroupBox.setTitle(translate(u'AuditTab', u'Audit File'))
|
self.AuditModeGroupBox.setTitle(translate(u'AuditTab', u'Audit File'))
|
||||||
@ -61,10 +66,16 @@ class AuditTab(SettingsTab):
|
|||||||
self.WarningLabel.setText(translate(u'AuditTab', u'A restart is needed for this change to become effective'))
|
self.WarningLabel.setText(translate(u'AuditTab', u'A restart is needed for this change to become effective'))
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
self.AuditPortSpinBox.setValue(int(self.config.get_config(u'Audit port', 4316)))
|
self.AuditFileName.setText(self.config.get_config(u'Audit file', u''))
|
||||||
self.AuditActive.setChecked(int(self.config.get_config(u'startup', 0)))
|
self.AuditActive.setChecked(int(self.config.get_config(u'startup', 0)))
|
||||||
|
|
||||||
def save(self):
|
def onAuditFileButtonClicked(self):
|
||||||
self.config.set_config(u'Audit port', unicode(self.AuditPortSpinBox.value()))
|
filename = QtGui.QFileDialog.getOpenFileName(self, u'Audit File',self.AuditFileName.text())
|
||||||
self.config.set_config(u'startup', unicode(self.AuditActive.checkState()))
|
if filename != u'':
|
||||||
|
filename = unicode(filename)
|
||||||
|
self.AuditFileName.setText(filename)
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
self.config.set_config(u'Audit file', unicode(self.AuditFileName.text()))
|
||||||
|
self.config.set_config(u'startup', unicode(self.AuditActive.checkState()))
|
||||||
|
Receiver().send_message(u'audit_changed')
|
||||||
|
Loading…
Reference in New Issue
Block a user