forked from openlp/openlp
Audit can now be disabled dynamically
This commit is contained in:
parent
37a9b5fb4e
commit
9ec94494e8
@ -134,14 +134,15 @@ class PluginManager(object):
|
||||
The Media Manager itself.
|
||||
"""
|
||||
for plugin in self.plugins:
|
||||
media_manager_item = plugin.get_media_manager_item()
|
||||
if media_manager_item is not None:
|
||||
log.debug(u'Inserting media manager item from %s' % \
|
||||
plugin.name)
|
||||
mediatoolbox.addItem(media_manager_item, plugin.icon,
|
||||
media_manager_item.title)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
media_manager_item.hide()
|
||||
if plugin.status is not PluginStatus.Disabled:
|
||||
media_manager_item = plugin.get_media_manager_item()
|
||||
if media_manager_item is not None:
|
||||
log.debug(u'Inserting media manager item from %s' % \
|
||||
plugin.name)
|
||||
mediatoolbox.addItem(media_manager_item, plugin.icon,
|
||||
media_manager_item.title)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
media_manager_item.hide()
|
||||
|
||||
def hook_settings_tabs(self, settingsform=None):
|
||||
"""
|
||||
@ -153,12 +154,13 @@ class PluginManager(object):
|
||||
Defaults to *None*. The settings form to add tabs to.
|
||||
"""
|
||||
for plugin in self.plugins:
|
||||
settings_tab = plugin.get_settings_tab()
|
||||
if settings_tab is not None:
|
||||
log.debug(u'Inserting settings tab item from %s' % plugin.name)
|
||||
settingsform.addTab(settings_tab)
|
||||
else:
|
||||
log.debug(u'No settings in %s' % plugin.name)
|
||||
if plugin.status is not PluginStatus.Disabled:
|
||||
settings_tab = plugin.get_settings_tab()
|
||||
if settings_tab is not None:
|
||||
log.debug(u'Inserting settings tab item from %s' % plugin.name)
|
||||
settingsform.addTab(settings_tab)
|
||||
else:
|
||||
log.debug(u'No settings in %s' % plugin.name)
|
||||
|
||||
def hook_import_menu(self, import_menu):
|
||||
"""
|
||||
@ -169,9 +171,10 @@ class PluginManager(object):
|
||||
The Import menu.
|
||||
"""
|
||||
for plugin in self.plugins:
|
||||
plugin.add_import_menu_item(import_menu)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
import_menu.hide()
|
||||
if plugin.status is not PluginStatus.Disabled:
|
||||
plugin.add_import_menu_item(import_menu)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
import_menu.hide()
|
||||
|
||||
def hook_export_menu(self, export_menu):
|
||||
"""
|
||||
@ -182,9 +185,10 @@ class PluginManager(object):
|
||||
The Export menu.
|
||||
"""
|
||||
for plugin in self.plugins:
|
||||
plugin.add_export_menu_item(export_menu)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
export_menu.hide()
|
||||
if plugin.status is not PluginStatus.Disabled:
|
||||
plugin.add_export_menu_item(export_menu)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
export_menu.hide()
|
||||
|
||||
def hook_tools_menu(self, tools_menu):
|
||||
"""
|
||||
@ -195,9 +199,10 @@ class PluginManager(object):
|
||||
The Tools menu.
|
||||
"""
|
||||
for plugin in self.plugins:
|
||||
plugin.add_tools_menu_item(tools_menu)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
tools_menu.hide()
|
||||
if plugin.status is not PluginStatus.Disabled:
|
||||
plugin.add_tools_menu_item(tools_menu)
|
||||
if plugin.status == PluginStatus.Inactive:
|
||||
tools_menu.hide()
|
||||
|
||||
def initialise_plugins(self):
|
||||
"""
|
||||
|
@ -28,7 +28,7 @@ import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, Receiver, translate, str_to_bool, buildIcon
|
||||
from openlp.plugins.audit.lib import AuditTab, AuditManager
|
||||
from openlp.plugins.audit.lib import AuditManager
|
||||
from openlp.plugins.audit.forms import AuditDetailForm, AuditDeleteForm
|
||||
from openlp.plugins.audit.lib.models import AuditItem
|
||||
|
||||
@ -44,6 +44,7 @@ class AuditPlugin(Plugin):
|
||||
# Create the plugin icon
|
||||
self.icon = buildIcon(u':/media/media_image.png')
|
||||
self.auditmanager = None
|
||||
self.auditActive = False
|
||||
|
||||
def can_be_disabled(self):
|
||||
return True
|
||||
@ -57,6 +58,7 @@ class AuditPlugin(Plugin):
|
||||
The actual **Tools** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
self.toolsMenu = tools_menu
|
||||
self.AuditMenu = QtGui.QMenu(tools_menu)
|
||||
self.AuditMenu.setObjectName(u'AuditMenu')
|
||||
self.AuditMenu.setTitle(
|
||||
@ -94,7 +96,7 @@ class AuditPlugin(Plugin):
|
||||
self.AuditStatus.setShortcut(translate(u'AuditPlugin', u'F4'))
|
||||
self.AuditStatus.setObjectName(u'AuditStatus')
|
||||
#Add Menus together
|
||||
tools_menu.addAction(self.AuditMenu.menuAction())
|
||||
self.toolsMenu.addAction(self.AuditMenu.menuAction())
|
||||
self.AuditMenu.addAction(self.AuditStatus)
|
||||
self.AuditMenu.addSeparator()
|
||||
self.AuditMenu.addAction(self.AuditDeleteAll)
|
||||
@ -114,10 +116,7 @@ class AuditPlugin(Plugin):
|
||||
QtCore.SIGNAL(u'triggered()'), self.onAuditDelete)
|
||||
QtCore.QObject.connect(self.AuditReport,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onAuditReport)
|
||||
|
||||
# def get_settings_tab(self):
|
||||
# self.AuditTab = AuditTab()
|
||||
# return self.AuditTab
|
||||
self.AuditMenu.menuAction().setVisible(False)
|
||||
|
||||
def initialise(self):
|
||||
log.info(u'Plugin Initialising')
|
||||
@ -132,11 +131,13 @@ class AuditPlugin(Plugin):
|
||||
self.auditmanager = AuditManager(self.config)
|
||||
self.auditdeleteform = AuditDeleteForm(self.auditmanager)
|
||||
self.auditdetailform = AuditDetailForm(self.auditmanager)
|
||||
self.AuditMenu.setVisible(True)
|
||||
self.AuditMenu.menuAction().setVisible(True)
|
||||
|
||||
def finalise(self):
|
||||
log.info(u'Plugin Finalise')
|
||||
self.AuditMenu.setVisible(True)
|
||||
self.AuditMenu.menuAction().setVisible(False)
|
||||
#stop any events being processed
|
||||
self.auditActive = False
|
||||
|
||||
def toggleAuditState(self):
|
||||
self.auditActive = not self.auditActive
|
||||
|
@ -22,5 +22,4 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
from audittab import AuditTab
|
||||
from manager import AuditManager
|
||||
|
@ -1,61 +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 #
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, translate, Receiver
|
||||
|
||||
class AuditTab(SettingsTab):
|
||||
"""
|
||||
AuditTab is the Audit settings tab in the settings dialog.
|
||||
"""
|
||||
def __init__(self):
|
||||
SettingsTab.__init__(self, translate(u'AuditTab', u'Audit'), u'Audit')
|
||||
|
||||
def setupUi(self):
|
||||
self.setObjectName(u'AuditTab')
|
||||
self.AuditModeGroupBox = QtGui.QGroupBox(self)
|
||||
self.AuditModeGroupBox.setObjectName(u'AuditModeGroupBox')
|
||||
self.verticalLayout = QtGui.QVBoxLayout(self.AuditModeGroupBox)
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
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)
|
||||
|
||||
def retranslateUi(self):
|
||||
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.AuditActive.setChecked(int(self.config.get_config(u'startup', 0)))
|
||||
|
||||
def save(self):
|
||||
self.config.set_config(
|
||||
u'startup', unicode(self.AuditActive.checkState()))
|
||||
Receiver().send_message(u'audit_changed')
|
Loading…
Reference in New Issue
Block a user