forked from openlp/openlp
Audit UI 3
This commit is contained in:
parent
1cc973b334
commit
02f839f5cc
@ -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')
|
||||
|
@ -42,6 +42,18 @@ class AuditPlugin(Plugin):
|
||||
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 get_settings_tab(self):
|
||||
self.AuditTab = AuditTab()
|
||||
@ -54,3 +66,10 @@ class AuditPlugin(Plugin):
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'Plugin Initialising')
|
||||
self.auditfile = open(u'openlp.aud', 'a')
|
||||
self.media_item.auditFile = self.auditfile
|
||||
|
||||
def finalise(self):
|
||||
log.debug(u'Finalise')
|
||||
if self.auditfile is not None:
|
||||
self.auditfile.close()
|
||||
|
@ -39,39 +39,32 @@ class AuditTab(SettingsTab):
|
||||
self.AuditLayout.setObjectName(u'AuditLayout')
|
||||
self.AuditModeGroupBox = QtGui.QGroupBox(self)
|
||||
self.AuditModeGroupBox.setObjectName(u'AuditModeGroupBox')
|
||||
self.TimeoutLayout = QtGui.QHBoxLayout(self.AuditModeGroupBox)
|
||||
self.TimeoutLayout.setSpacing(8)
|
||||
self.TimeoutLayout.setMargin(0)
|
||||
self.TimeoutLayout.setObjectName(u'TimeoutLayout')
|
||||
self.TimeoutLabel = QtGui.QLabel(self.AuditModeGroupBox)
|
||||
self.TimeoutLabel.setObjectName(u'TimeoutLabel')
|
||||
self.TimeoutLayout.addWidget(self.TimeoutLabel)
|
||||
self.TimeoutSpinBox = QtGui.QSpinBox(self.AuditModeGroupBox)
|
||||
self.TimeoutSpinBox.setMaximum(180)
|
||||
self.TimeoutSpinBox.setObjectName(u'TimeoutSpinBox')
|
||||
self.TimeoutLayout.addWidget(self.TimeoutSpinBox)
|
||||
self.TimeoutSpacer = QtGui.QSpacerItem(147, 20,
|
||||
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.TimeoutLayout.addItem(self.TimeoutSpacer)
|
||||
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)
|
||||
# Signals and slots
|
||||
QtCore.QObject.connect(self.TimeoutSpinBox,
|
||||
QtCore.SIGNAL(u'valueChanged(int)'), self.onTimeoutSpinBoxChanged)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.TimeoutLabel.setText(translate(u'AuditTab', u'Slide Loop Delay:'))
|
||||
self.TimeoutSpinBox.setSuffix(translate(u'AuditTab', u's'))
|
||||
|
||||
def onTimeoutSpinBoxChanged(self):
|
||||
self.loop_delay = self.TimeoutSpinBox.value()
|
||||
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.loop_delay = int(self.config.get_config(u'loop delay', 5))
|
||||
self.TimeoutSpinBox.setValue(self.loop_delay)
|
||||
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'loop delay', self.loop_delay)
|
||||
Receiver().send_message(u'update_spin_delay', self.loop_delay )
|
||||
self.config.set_config(u'Audit port', unicode(self.AuditPortSpinBox.value()))
|
||||
self.config.set_config(u'startup', unicode(self.AuditActive.checkState()))
|
||||
|
||||
def postSetUp(self):
|
||||
Receiver().send_message(u'update_spin_delay', self.loop_delay )
|
||||
|
@ -24,9 +24,10 @@
|
||||
|
||||
import logging
|
||||
import os
|
||||
from datetime import date
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import MediaManagerItem, translate, buildIcon
|
||||
from openlp.core.lib import MediaManagerItem, translate, buildIcon, Receiver
|
||||
|
||||
class AuditMediaItem(MediaManagerItem):
|
||||
"""
|
||||
@ -45,9 +46,13 @@ class AuditMediaItem(MediaManagerItem):
|
||||
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):
|
||||
pass
|
||||
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')
|
||||
@ -77,7 +82,13 @@ class AuditMediaItem(MediaManagerItem):
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user