forked from openlp/openlp
requested cleanups 1
This commit is contained in:
parent
0c6a1d5762
commit
8b65992307
@ -166,6 +166,15 @@ class Plugin(object):
|
|||||||
"""
|
"""
|
||||||
pass
|
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):
|
def get_settings_tab(self):
|
||||||
"""
|
"""
|
||||||
Create a tab for the settings window.
|
Create a tab for the settings window.
|
||||||
|
@ -178,6 +178,18 @@ class PluginManager(object):
|
|||||||
if plugin[u'status'] == u'Active':
|
if plugin[u'status'] == u'Active':
|
||||||
plugin[u'plugin'].add_export_menu_item(export_menu)
|
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):
|
def initialise_plugins(self):
|
||||||
"""
|
"""
|
||||||
Loop through all the plugins and give them an opportunity to
|
Loop through all the plugins and give them an opportunity to
|
||||||
|
@ -545,6 +545,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.plugin_manager.hook_import_menu(self.FileImportMenu)
|
self.plugin_manager.hook_import_menu(self.FileImportMenu)
|
||||||
# Call the hook method to pull in export menus.
|
# Call the hook method to pull in export menus.
|
||||||
self.plugin_manager.hook_export_menu(self.FileExportMenu)
|
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.
|
# Call the initialise method to setup plugins.
|
||||||
log.info(u'initialise plugins')
|
log.info(u'initialise plugins')
|
||||||
self.plugin_manager.initialise_plugins()
|
self.plugin_manager.initialise_plugins()
|
||||||
|
@ -26,8 +26,8 @@ import logging
|
|||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from openlp.core.lib import Plugin
|
from openlp.core.lib import Plugin, Receiver, translate
|
||||||
from openlp.plugins.audit.lib import AuditMediaItem, AuditTab
|
from openlp.plugins.audit.lib import AuditTab
|
||||||
|
|
||||||
class AuditPlugin(Plugin):
|
class AuditPlugin(Plugin):
|
||||||
global log
|
global log
|
||||||
@ -55,19 +55,55 @@ class AuditPlugin(Plugin):
|
|||||||
else:
|
else:
|
||||||
return False
|
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):
|
def get_settings_tab(self):
|
||||||
self.AuditTab = AuditTab()
|
self.AuditTab = AuditTab()
|
||||||
return self.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):
|
def initialise(self):
|
||||||
log.info(u'Plugin Initialising')
|
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.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):
|
def finalise(self):
|
||||||
log.debug(u'Finalise')
|
log.debug(u'Finalise')
|
||||||
|
@ -22,5 +22,4 @@
|
|||||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
from mediaitem import AuditMediaItem
|
|
||||||
from audittab import AuditTab
|
from audittab import AuditTab
|
||||||
|
@ -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))
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB |
Loading…
Reference in New Issue
Block a user