2010-09-10 19:21:14 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2010-12-26 11:04:47 +00:00
|
|
|
# Copyright (c) 2008-2011 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
2011-03-24 19:04:02 +00:00
|
|
|
# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, #
|
|
|
|
# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, #
|
|
|
|
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
|
2010-09-10 19:21:14 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# 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
|
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
|
|
|
|
2010-09-16 21:10:36 +00:00
|
|
|
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
2010-09-10 19:21:14 +00:00
|
|
|
from openlp.core.lib.db import Manager
|
2011-04-03 11:36:43 +00:00
|
|
|
from openlp.core.lib.ui import icon_action, UiStrings
|
2011-03-31 08:43:19 +00:00
|
|
|
from openlp.core.utils.actions import ActionList
|
2010-09-10 19:21:14 +00:00
|
|
|
from openlp.plugins.alerts.lib import AlertsManager, AlertsTab
|
|
|
|
from openlp.plugins.alerts.lib.db import init_schema
|
|
|
|
from openlp.plugins.alerts.forms import AlertForm
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
class AlertsPlugin(Plugin):
|
|
|
|
log.info(u'Alerts Plugin loaded')
|
|
|
|
|
|
|
|
def __init__(self, plugin_helpers):
|
2011-03-10 19:17:05 +00:00
|
|
|
Plugin.__init__(self, u'Alerts', plugin_helpers,
|
2011-02-11 04:04:05 +00:00
|
|
|
settingsTabClass=AlertsTab)
|
2010-09-10 19:21:14 +00:00
|
|
|
self.weight = -3
|
|
|
|
self.icon = build_icon(u':/plugins/plugin_alerts.png')
|
|
|
|
self.alertsmanager = AlertsManager(self)
|
|
|
|
self.manager = Manager(u'alerts', init_schema)
|
2011-01-22 12:21:43 +00:00
|
|
|
self.alertForm = AlertForm(self)
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
def addToolsMenuItem(self, tools_menu):
|
|
|
|
"""
|
|
|
|
Give the alerts 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.
|
|
|
|
"""
|
|
|
|
log.info(u'add tools menu')
|
2011-03-29 13:56:49 +00:00
|
|
|
self.toolsAlertItem = icon_action(tools_menu, u'toolsAlertItem',
|
|
|
|
u':/plugins/plugin_alerts.png')
|
2010-09-10 19:21:14 +00:00
|
|
|
self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
|
|
|
|
self.toolsAlertItem.setStatusTip(
|
|
|
|
translate('AlertsPlugin', 'Show an alert message.'))
|
|
|
|
self.toolsAlertItem.setShortcut(u'F7')
|
2011-01-09 00:27:46 +00:00
|
|
|
self.serviceManager.mainwindow.ToolsMenu.addAction(self.toolsAlertItem)
|
2010-09-10 19:21:14 +00:00
|
|
|
QtCore.QObject.connect(self.toolsAlertItem,
|
|
|
|
QtCore.SIGNAL(u'triggered()'), self.onAlertsTrigger)
|
|
|
|
self.toolsAlertItem.setVisible(False)
|
|
|
|
|
|
|
|
def initialise(self):
|
|
|
|
log.info(u'Alerts Initialising')
|
|
|
|
Plugin.initialise(self)
|
|
|
|
self.toolsAlertItem.setVisible(True)
|
2011-04-03 11:36:43 +00:00
|
|
|
ActionList.add_action(self.toolsAlertItem, UiStrings.Tools)
|
2011-02-11 04:04:05 +00:00
|
|
|
self.liveController.alertTab = self.settings_tab
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
def finalise(self):
|
2010-11-03 17:19:44 +00:00
|
|
|
"""
|
|
|
|
Tidy up on exit
|
|
|
|
"""
|
2010-09-10 19:21:14 +00:00
|
|
|
log.info(u'Alerts Finalising')
|
2010-11-03 17:19:44 +00:00
|
|
|
self.manager.finalise()
|
2010-09-10 19:21:14 +00:00
|
|
|
Plugin.finalise(self)
|
|
|
|
self.toolsAlertItem.setVisible(False)
|
2011-03-31 08:43:19 +00:00
|
|
|
ActionList.remove_action(self.toolsAlertItem, u'Tools')
|
2010-09-10 19:21:14 +00:00
|
|
|
|
|
|
|
def toggleAlertsState(self):
|
|
|
|
self.alertsActive = not self.alertsActive
|
|
|
|
QtCore.QSettings().setValue(self.settingsSection + u'/active',
|
|
|
|
QtCore.QVariant(self.alertsActive))
|
|
|
|
|
|
|
|
def onAlertsTrigger(self):
|
|
|
|
self.alertForm.loadList()
|
|
|
|
self.alertForm.exec_()
|
|
|
|
|
|
|
|
def about(self):
|
|
|
|
about_text = translate('AlertsPlugin', '<strong>Alerts Plugin</strong>'
|
|
|
|
'<br />The alert plugin controls the displaying of nursery alerts '
|
|
|
|
'on the display screen')
|
|
|
|
return about_text
|
2010-09-14 17:46:21 +00:00
|
|
|
|
2010-09-27 18:15:55 +00:00
|
|
|
def setPluginTextStrings(self):
|
2010-09-10 19:21:14 +00:00
|
|
|
"""
|
|
|
|
Called to define all translatable texts of the plugin
|
|
|
|
"""
|
2010-09-15 17:55:27 +00:00
|
|
|
## Name PluginList ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.Name] = {
|
2010-12-31 02:17:41 +00:00
|
|
|
u'singular': translate('AlertsPlugin', 'Alert', 'name singular'),
|
|
|
|
u'plural': translate('AlertsPlugin', 'Alerts', 'name plural')
|
2010-09-14 17:46:21 +00:00
|
|
|
}
|
2010-09-15 17:55:27 +00:00
|
|
|
## Name for MediaDockManager, SettingsManager ##
|
2010-10-05 16:09:48 +00:00
|
|
|
self.textStrings[StringContent.VisibleName] = {
|
2010-12-31 02:17:41 +00:00
|
|
|
u'title': translate('AlertsPlugin', 'Alerts', 'container title')
|
|
|
|
}
|