forked from openlp/openlp
Clean up Event Processing
bzr-revno: 512
This commit is contained in:
commit
7a317f82f4
@ -60,12 +60,9 @@ def contextMenuSeparator(base):
|
||||
from settingsmanager import SettingsManager
|
||||
from pluginconfig import PluginConfig
|
||||
from plugin import Plugin
|
||||
from eventmanager import EventManager
|
||||
from pluginmanager import PluginManager
|
||||
from settingstab import SettingsTab
|
||||
from mediamanageritem import MediaManagerItem
|
||||
from event import Event
|
||||
from event import EventType
|
||||
from xmlrootclass import XmlRootClass
|
||||
from serviceitem import ServiceItem
|
||||
from eventreceiver import Receiver
|
||||
|
@ -1,51 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri,
|
||||
Carsten Tingaard, Jonathan Corwin
|
||||
|
||||
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
|
||||
"""
|
||||
|
||||
class EventType(object):
|
||||
"""
|
||||
Types of events are stored in this class.
|
||||
"""
|
||||
# "Default" event - a non-event
|
||||
Default = 0
|
||||
TriggerAlert = 1
|
||||
# General application events
|
||||
Ready = 10
|
||||
# Service events
|
||||
LoadServiceItem = 20
|
||||
# Preview events
|
||||
PreviewShow = 30
|
||||
LiveShow = 31
|
||||
#Theme Related Events
|
||||
ThemeListChanged = 40
|
||||
#Plugin Related Events
|
||||
LoadSongList = 50
|
||||
|
||||
|
||||
class Event(object):
|
||||
"""
|
||||
Provides an Event class to encapsulate events within openlp.org.
|
||||
"""
|
||||
def __init__(self, sender, event_type=EventType.Default, payload=None):
|
||||
self.event_type = event_type
|
||||
self.payload = payload
|
||||
self.sender = sender
|
@ -1,72 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80
|
||||
"""
|
||||
OpenLP - Open Source Lyrics Projection
|
||||
|
||||
Copyright (c) 2008 Raoul Snyman
|
||||
|
||||
Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri,
|
||||
Carsten Tingaard, Jonathan Corwin
|
||||
|
||||
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 os
|
||||
import logging
|
||||
|
||||
class EventManager(object):
|
||||
"""
|
||||
A mechanism to send events to all registered endpoints. The
|
||||
endpoints are registered and listen with a handle_event method.
|
||||
The endpoint will decide whether to do somthing with the event or
|
||||
ignore it.
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'EventManager')
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Defines the class and a list of endpoints
|
||||
"""
|
||||
self.endpoints = []
|
||||
log.info(u'Initialising')
|
||||
self.processing = False
|
||||
self.events = []
|
||||
|
||||
def register(self, plugin):
|
||||
"""
|
||||
Called by plugings who wish to receive event notifications
|
||||
"""
|
||||
log.debug(u'Class %s registered with EventManager', plugin)
|
||||
self.endpoints.append(plugin)
|
||||
|
||||
def post_event(self, event):
|
||||
"""
|
||||
Called by any part of the system which wants send events to the plugins
|
||||
|
||||
``event``
|
||||
The event type to be triggered
|
||||
|
||||
"""
|
||||
log.debug(u'post event called for event %s (%s)', event.event_type, event.sender)
|
||||
self.events.append(event)
|
||||
if not self.processing:
|
||||
self.processing = True
|
||||
while len(self.events) > 0:
|
||||
pEvent = self.events[0]
|
||||
for point in self.endpoints:
|
||||
status = point.handle_event(pEvent)
|
||||
#if call returns true message is finished with
|
||||
if status is not None and status :
|
||||
break
|
||||
self.events.remove(pEvent)
|
||||
self.processing = False
|
@ -18,6 +18,7 @@ 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
|
||||
|
||||
@ -25,11 +26,39 @@ class EventReceiver(QtCore.QObject):
|
||||
"""
|
||||
Class to allow events to be passed from different parts of the system.
|
||||
This is a private class and should not be used directly but via the Receiver class
|
||||
|
||||
``stop_import``
|
||||
Stops the Bible Import
|
||||
``pre_load_bibles``
|
||||
Triggers the plugin to relaod the bible lists
|
||||
``process_events``
|
||||
Requests the Application to flush the events queue
|
||||
``{preview|live}_slide_first``
|
||||
display the first slide on the list
|
||||
``{preview|live}_slide_previous``
|
||||
display the previous slide on the list
|
||||
``{preview|live}_slide_next``
|
||||
display the next slide on the list
|
||||
``{preview|live}_slide_last``
|
||||
display the last slide on the list
|
||||
``{plugin}_add_service_item ``
|
||||
ask the plugin to push the selected items to the service item
|
||||
``update_themes ``
|
||||
send out message with new themes
|
||||
``update_global_theme ``
|
||||
Tell the components we have a new global theme
|
||||
``load_song_list``
|
||||
Tells the the song plugin to reload the song list
|
||||
|
||||
"""
|
||||
global log
|
||||
log = logging.getLogger(u'EventReceiver')
|
||||
|
||||
def __init__(self):
|
||||
QtCore.QObject.__init__(self)
|
||||
|
||||
def send_message(self, event, msg=None):
|
||||
log.debug(u'Event %s passed with payload %s' % (event, msg))
|
||||
self.emit(QtCore.SIGNAL(event), msg)
|
||||
|
||||
class Receiver():
|
||||
@ -39,11 +68,11 @@ class Receiver():
|
||||
As there is only one instance of it in the systems the QT signal/slot architecture
|
||||
can send messages across the system
|
||||
|
||||
Send message
|
||||
Receiver().send_message(u'messageid',data)
|
||||
``Send message``
|
||||
Receiver().send_message(u'<<Message ID>>', data)
|
||||
|
||||
Receive Message
|
||||
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'openlprepaint'),<<ACTION>>)
|
||||
``Receive Message``
|
||||
QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'<<Message ID>>'),<<ACTION>>)
|
||||
"""
|
||||
eventreceiver = EventReceiver()
|
||||
|
||||
|
@ -19,12 +19,13 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
"""
|
||||
|
||||
import logging
|
||||
from PyQt4 import QtCore
|
||||
|
||||
from openlp.core.lib import PluginConfig
|
||||
# why does this not work???
|
||||
# from openlp.core.lib import Event, EventType
|
||||
# so I have to do this???
|
||||
from event import Event, EventType
|
||||
from eventreceiver import Receiver
|
||||
|
||||
class Plugin(object):
|
||||
"""
|
||||
@ -122,11 +123,11 @@ class Plugin(object):
|
||||
self.log = logging.getLogger(self.name)
|
||||
self.preview_controller = plugin_helpers[u'preview']
|
||||
self.live_controller = plugin_helpers[u'live']
|
||||
self.event_manager = plugin_helpers[u'event']
|
||||
self.render_manager = plugin_helpers[u'render']
|
||||
self.service_manager = plugin_helpers[u'service']
|
||||
self.settings = plugin_helpers[u'settings']
|
||||
self.dnd_id=None
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'%s_add_service_item'% self.name), self.process_add_service_event)
|
||||
|
||||
def check_pre_conditions(self):
|
||||
"""
|
||||
@ -177,29 +178,13 @@ class Plugin(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
def handle_event(self, event):
|
||||
def process_add_service_event(self):
|
||||
"""
|
||||
Handle the event contained in the event object. If you want
|
||||
to use this default behaviour, you must set self.dnd_id equal
|
||||
to that sent by the dnd source - eg the MediaItem
|
||||
|
||||
``event``
|
||||
An object describing the event.
|
||||
Proxy method as method is not defined early enough
|
||||
in the processing
|
||||
"""
|
||||
# default behaviour - can be overridden if desired
|
||||
log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
|
||||
if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id:
|
||||
log.debug(u'Load Service Item received')
|
||||
self.media_item.onAddClick()
|
||||
return True
|
||||
if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id:
|
||||
log.debug(u'Load Preview Item received')
|
||||
self.media_item.onPreviewClick()
|
||||
return True
|
||||
if event.event_type == EventType.LiveShow and event.payload == self.dnd_id:
|
||||
log.debug(u'Load Live Show Item received')
|
||||
return True
|
||||
self.media_item.onLiveClick()
|
||||
log.debug(u'process_add_service_event event called for plugin %s' % self.name)
|
||||
self.media_item.onAddClick()
|
||||
|
||||
def about(self):
|
||||
"""
|
||||
@ -208,38 +193,6 @@ class Plugin(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
def save(self, data):
|
||||
"""
|
||||
Service item data is passed to this function, which should return a
|
||||
string which can be written to the service file.
|
||||
|
||||
``data``
|
||||
The data to be saved.
|
||||
"""
|
||||
pass
|
||||
|
||||
def load(self, string):
|
||||
"""
|
||||
A string from the service file is passed in. This function parses and
|
||||
sets up the internals of the plugin.
|
||||
|
||||
``string``
|
||||
The data to be loaded into the plugin.
|
||||
"""
|
||||
pass
|
||||
|
||||
def render(self, theme, screen=None):
|
||||
"""
|
||||
Render the screenth screenful of data using theme settings in theme.
|
||||
|
||||
``theme``
|
||||
The theme to use when rendering.
|
||||
|
||||
``screen``
|
||||
Defaults to *None*. The screen to render to.
|
||||
"""
|
||||
pass
|
||||
|
||||
def initialise(self):
|
||||
"""
|
||||
Called by the plugin Manager to initialise anything it needs.
|
||||
|
@ -21,7 +21,7 @@ import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from openlp.core.lib import Plugin, EventManager
|
||||
from openlp.core.lib import Plugin
|
||||
|
||||
class PluginManager(object):
|
||||
"""
|
||||
@ -50,7 +50,7 @@ class PluginManager(object):
|
||||
# this has to happen after the UI is sorted self.find_plugins(dir)
|
||||
log.info(u'Plugin manager done init')
|
||||
|
||||
def find_plugins(self, dir, plugin_helpers, eventmanager):
|
||||
def find_plugins(self, dir, plugin_helpers):
|
||||
"""
|
||||
Scan the directory dir for objects inheriting from ``openlp.plugin``.
|
||||
|
||||
@ -60,8 +60,6 @@ class PluginManager(object):
|
||||
``plugin_helpers``
|
||||
A list of helper objects to pass to the plugins.
|
||||
|
||||
``eventmanager``
|
||||
The event manager to pass to the plugins.
|
||||
"""
|
||||
self.plugin_helpers = plugin_helpers
|
||||
startdepth = len(os.path.abspath(dir).split(os.sep))
|
||||
@ -103,11 +101,9 @@ class PluginManager(object):
|
||||
pList = {u'plugin': plugin, u'status': u'Inactive'}
|
||||
if plugin.check_pre_conditions():
|
||||
log.debug(u'Plugin %s active', unicode(plugin.name))
|
||||
eventmanager.register(plugin)
|
||||
pList[u'status'] = u'Active'
|
||||
self.plugins.append(pList)
|
||||
|
||||
|
||||
def order_by_weight(self, x, y):
|
||||
"""
|
||||
Sort two plugins and order them by their weight.
|
||||
|
@ -32,11 +32,9 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
def __init__(self, thememanager, parent=None):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.thememanager = thememanager
|
||||
# Needed here as UI setup generates Events
|
||||
self.path = None
|
||||
self.theme = ThemeXML()
|
||||
self.setupUi(self)
|
||||
|
||||
#define signals
|
||||
#Buttons
|
||||
QtCore.QObject.connect(self.Color1PushButton ,
|
||||
|
@ -21,7 +21,7 @@ import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from time import sleep
|
||||
from openlp.core.lib import translate, EventManager, Event, EventType, Receiver
|
||||
from openlp.core.lib import translate, Receiver
|
||||
|
||||
class MainDisplay(QtGui.QWidget):
|
||||
"""
|
||||
@ -58,20 +58,10 @@ class MainDisplay(QtGui.QWidget):
|
||||
self.alertactive = False
|
||||
self.alertTab = None
|
||||
self.timer_id = 0
|
||||
# Register the main form as an event consumer.
|
||||
self.parent.EventManager.register(self)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'live_slide_blank'), self.blankDisplay)
|
||||
|
||||
def handle_event(self, event):
|
||||
"""
|
||||
Accept Events for the system and If It's for Alert
|
||||
action it and Return true to stop futher processing
|
||||
"""
|
||||
log.debug(u'MainDisplay received event %s with payload %s'%(event.event_type, event.payload))
|
||||
if event.event_type == EventType.TriggerAlert:
|
||||
self.displayAlert(event.payload)
|
||||
return True
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'alert_text'), self.displayAlert)
|
||||
|
||||
def setup(self, screenNumber):
|
||||
"""
|
||||
|
@ -26,8 +26,8 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
|
||||
ServiceManager, ThemeManager, MainDisplay, SlideController, \
|
||||
PluginForm
|
||||
from openlp.core.lib import translate, Plugin, MediaManagerItem, \
|
||||
SettingsTab, EventManager, RenderManager, PluginConfig, \
|
||||
SettingsManager, PluginManager, EventType
|
||||
SettingsTab, RenderManager, PluginConfig, \
|
||||
SettingsManager, PluginManager, Receiver
|
||||
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
@ -416,7 +416,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
self.screenList = screens
|
||||
self.oosNotSaved = False
|
||||
self.settingsmanager = SettingsManager(screens)
|
||||
self.EventManager = EventManager()
|
||||
self.mainDisplay = MainDisplay(self, screens)
|
||||
self.generalConfig = PluginConfig(u'General')
|
||||
self.alertForm = AlertForm(self)
|
||||
@ -458,6 +457,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked)
|
||||
QtCore.QObject.connect(self.OptionsSettingsItem,
|
||||
QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'update_global_theme'), self.defaultThemeChanged)
|
||||
#warning cyclic dependency
|
||||
#RenderManager needs to call ThemeManager and
|
||||
#ThemeManager needs to call RenderManager
|
||||
@ -467,12 +468,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
#make the controllers available to the plugins
|
||||
self.plugin_helpers[u'preview'] = self.PreviewController
|
||||
self.plugin_helpers[u'live'] = self.LiveController
|
||||
self.plugin_helpers[u'event'] = self.EventManager
|
||||
self.plugin_helpers[u'render'] = self.RenderManager
|
||||
self.plugin_helpers[u'service'] = self.ServiceManagerContents
|
||||
self.plugin_helpers[u'settings'] = self.settingsForm
|
||||
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers,
|
||||
self.EventManager)
|
||||
self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
|
||||
# hook methods have to happen after find_plugins. Find plugins needs the
|
||||
# controllers hence the hooks have moved from setupUI() to here
|
||||
|
||||
@ -490,8 +489,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
# Call the initialise method to setup plugins.
|
||||
log.info(u'initialise plugins')
|
||||
self.plugin_manager.initialise_plugins()
|
||||
# Register the main form as an event consumer.
|
||||
self.EventManager.register(self)
|
||||
# Once all components are initialised load the Themes
|
||||
log.info(u'Load Themes')
|
||||
self.ThemeManagerContents.loadThemes()
|
||||
@ -593,9 +590,5 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
title = u'%s - %s*' % (self.mainTitle, service_name)
|
||||
self.setWindowTitle(title)
|
||||
|
||||
def handle_event(self, event):
|
||||
if event.event_type == EventType.ThemeListChanged:
|
||||
self.ServiceManagerContents.updateThemeList(event.payload)
|
||||
self.settingsForm.ThemesTab.updateThemeList(event.payload)
|
||||
self.DefaultThemeLabel.setText(self.defaultThemeText + \
|
||||
self.ThemeManagerContents.getDefault())
|
||||
def defaultThemeChanged(self, theme):
|
||||
self.DefaultThemeLabel.setText(self.defaultThemeText + theme)
|
||||
|
@ -24,9 +24,9 @@ import zipfile
|
||||
import shutil
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, Event, \
|
||||
RenderManager, EventType, EventManager, translate, buildIcon, \
|
||||
contextMenuAction, contextMenuSeparator
|
||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
|
||||
RenderManager, translate, buildIcon, \
|
||||
contextMenuAction, contextMenuSeparator, Receiver
|
||||
from openlp.core.utils import ConfigHelper
|
||||
|
||||
class ServiceManagerList(QtGui.QTreeWidget):
|
||||
@ -66,6 +66,7 @@ class ServiceManagerList(QtGui.QTreeWidget):
|
||||
class Iter(QtGui.QTreeWidgetItemIterator):
|
||||
def __init__(self, *args):
|
||||
QtGui.QTreeWidgetItemIterator.__init__(self, *args)
|
||||
|
||||
def next(self):
|
||||
self.__iadd__(1)
|
||||
value = self.value()
|
||||
@ -158,6 +159,8 @@ class ServiceManager(QtGui.QWidget):
|
||||
QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed)
|
||||
QtCore.QObject.connect(self.ServiceManagerList,
|
||||
QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
|
||||
# Last little bits of setting up
|
||||
self.config = PluginConfig(u'ServiceManager')
|
||||
self.servicePath = self.config.get_data_path()
|
||||
@ -488,7 +491,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
link = event.mimeData()
|
||||
if link.hasText():
|
||||
plugin = event.mimeData().text()
|
||||
self.parent.EventManager.post_event(Event(u'ServiceManager', EventType.LoadServiceItem, plugin))
|
||||
Receiver().send_message(u'%s_add_service_item' % plugin)
|
||||
|
||||
def updateThemeList(self, theme_list):
|
||||
"""
|
||||
|
@ -28,9 +28,9 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.ui import AmendThemeForm, ServiceManager
|
||||
from openlp.core.theme import Theme
|
||||
from openlp.core.lib import PluginConfig, Event, EventType, \
|
||||
EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, \
|
||||
file_to_xml, buildIcon
|
||||
from openlp.core.lib import PluginConfig, \
|
||||
OpenLPToolbar, ThemeXML, Renderer, translate, \
|
||||
file_to_xml, buildIcon, Receiver
|
||||
from openlp.core.utils import ConfigHelper
|
||||
|
||||
class ThemeManager(QtGui.QWidget):
|
||||
@ -72,7 +72,9 @@ class ThemeManager(QtGui.QWidget):
|
||||
self.Layout.addWidget(self.ThemeListWidget)
|
||||
#Signals
|
||||
QtCore.QObject.connect(self.ThemeListWidget,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobal)
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'update_global_theme'), self.changeGlobalFromTab)
|
||||
#Variables
|
||||
self.themelist = []
|
||||
self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
|
||||
@ -86,7 +88,22 @@ class ThemeManager(QtGui.QWidget):
|
||||
def getDefault(self):
|
||||
return self.global_theme
|
||||
|
||||
def changeGlobal(self, index):
|
||||
def changeGlobalFromTab(self, themeName):
|
||||
log.debug(u'changeGlobalFromTab %s', themeName)
|
||||
for count in range (0, self.ThemeListWidget.count()):
|
||||
#reset the old name
|
||||
item = self.ThemeListWidget.item(count)
|
||||
oldName = item.text()
|
||||
newName = unicode(item.data(QtCore.Qt.UserRole).toString())
|
||||
if oldName != newName:
|
||||
self.ThemeListWidget.item(count).setText(newName)
|
||||
#Set the new name
|
||||
if themeName == newName:
|
||||
name = u'%s (%s)' % (newName, translate(u'ThemeManager', u'default'))
|
||||
self.ThemeListWidget.item(count).setText(name)
|
||||
|
||||
def changeGlobalFromScreen(self, index):
|
||||
log.debug(u'changeGlobalFromScreen %s', index)
|
||||
for count in range (0, self.ThemeListWidget.count()):
|
||||
item = self.ThemeListWidget.item(count)
|
||||
oldName = item.text()
|
||||
@ -99,6 +116,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
name = u'%s (%s)' % (self.global_theme, translate(u'ThemeManager', u'default'))
|
||||
self.ThemeListWidget.item(count).setText(name)
|
||||
self.config.set_config(u'theme global theme', self.global_theme)
|
||||
Receiver().send_message(u'update_global_theme', self.global_theme )
|
||||
self.pushThemes()
|
||||
|
||||
def onAddTheme(self):
|
||||
@ -184,7 +202,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
self.pushThemes()
|
||||
|
||||
def pushThemes(self):
|
||||
self.parent.EventManager.post_event(Event(u'ThemeManager', EventType.ThemeListChanged, self.getThemes()))
|
||||
Receiver().send_message(u'update_themes', self.getThemes() )
|
||||
|
||||
def getThemes(self):
|
||||
return self.themelist
|
||||
@ -194,7 +212,6 @@ class ThemeManager(QtGui.QWidget):
|
||||
xml_file = os.path.join(self.path, unicode(themename), unicode(themename) + u'.xml')
|
||||
try:
|
||||
xml = file_to_xml(xml_file)
|
||||
#print xml
|
||||
except:
|
||||
newtheme = ThemeXML()
|
||||
newtheme.new_document(u'New Theme')
|
||||
@ -205,9 +222,7 @@ class ThemeManager(QtGui.QWidget):
|
||||
unicode(0), unicode(0), unicode(0))
|
||||
xml = newtheme.extract_xml()
|
||||
theme = ThemeXML()
|
||||
#print theme
|
||||
theme.parse(xml)
|
||||
#print "A ", theme
|
||||
theme.extend_image_filename(self.path)
|
||||
return theme
|
||||
|
||||
|
@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SettingsTab, translate
|
||||
from openlp.core.lib import SettingsTab, translate, Receiver
|
||||
|
||||
class ThemesTab(SettingsTab):
|
||||
"""
|
||||
@ -88,16 +88,16 @@ class ThemesTab(SettingsTab):
|
||||
self.LevelLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
|
||||
self.GlobalLevelLabel)
|
||||
self.ThemesTabLayout.addWidget(self.LevelGroupBox)
|
||||
|
||||
QtCore.QObject.connect(self.SongLevelRadioButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onSongLevelButtonPressed)
|
||||
QtCore.QObject.connect(self.ServiceLevelRadioButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onServiceLevelButtonPressed)
|
||||
QtCore.QObject.connect(self.GlobalLevelRadioButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onGlobalLevelButtonPressed)
|
||||
|
||||
QtCore.QObject.connect(self.DefaultComboBox,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.GlobalGroupBox.setTitle(translate(u'ThemesTab', u'Global theme'))
|
||||
@ -122,6 +122,7 @@ class ThemesTab(SettingsTab):
|
||||
def save(self):
|
||||
self.config.set_config(u'theme global style', self.global_style )
|
||||
self.config.set_config(u'theme global theme',self.global_theme)
|
||||
Receiver().send_message(u'update_global_theme', self.global_theme )
|
||||
|
||||
def onSongLevelButtonPressed(self):
|
||||
self.global_style= u'Song'
|
||||
|
@ -22,7 +22,7 @@ import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4.QtCore import *
|
||||
|
||||
from openlp.core.lib import Plugin, Event, EventType, translate
|
||||
from openlp.core.lib import Plugin, translate
|
||||
|
||||
from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
|
||||
|
||||
@ -41,9 +41,6 @@ class BiblePlugin(Plugin):
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
#Register the bible Manager
|
||||
self.biblemanager = BibleManager(self.config)
|
||||
# passed with drag and drop messages
|
||||
self.dnd_id = u'Bibles'
|
||||
|
||||
|
||||
def get_settings_tab(self):
|
||||
self.bibles_tab = BiblesTab()
|
||||
@ -68,18 +65,6 @@ class BiblePlugin(Plugin):
|
||||
export_menu.addAction(self.ExportBibleItem)
|
||||
self.ExportBibleItem.setText(translate(u'BiblePlugin', u'&Bible'))
|
||||
|
||||
def initialise(self):
|
||||
pass
|
||||
|
||||
def onBibleNewClick(self):
|
||||
self.media_item.onBibleNewClick()
|
||||
|
||||
def handle_event(self, event):
|
||||
"""
|
||||
Handle the event contained in the event object.
|
||||
"""
|
||||
log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
|
||||
if event.event_type == EventType.ThemeListChanged:
|
||||
log.debug(u'New Theme request received')
|
||||
self.bibles_tab.updateThemeList(event.payload)
|
||||
return Plugin.handle_event(self, event)
|
||||
|
@ -152,9 +152,9 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
||||
def onCancelButtonClicked(self):
|
||||
# tell import to stop
|
||||
self.message = u'Bible import stopped'
|
||||
Receiver().send_message(u'openlpstopimport')
|
||||
Receiver().send_message(u'stop_import')
|
||||
# tell bibleplugin to reload the bibles
|
||||
Receiver().send_message(u'openlpreloadbibles')
|
||||
Receiver().send_message(u'pre_load_bibles')
|
||||
self.close()
|
||||
|
||||
def onImportButtonClicked(self):
|
||||
@ -172,7 +172,7 @@ class BibleImportForm(QtGui.QDialog, Ui_BibleImportDialog):
|
||||
self.MessageLabel.setText(message)
|
||||
self.ProgressBar.setValue(self.barmax)
|
||||
# tell bibleplugin to reload the bibles
|
||||
Receiver().send_message(u'openlpreloadbibles')
|
||||
Receiver().send_message(u'pre_load_bibles')
|
||||
reply = QtGui.QMessageBox.information(self,
|
||||
translate(u'BibleMediaItem', u'Information'),
|
||||
translate(u'BibleMediaItem', message))
|
||||
|
@ -21,7 +21,7 @@ import logging
|
||||
|
||||
from PyQt4 import Qt, QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import translate, str_to_bool
|
||||
from openlp.core.lib import translate, str_to_bool, Receiver
|
||||
from openlp.core.lib import SettingsTab
|
||||
|
||||
class BiblesTab(SettingsTab):
|
||||
@ -146,6 +146,8 @@ class BiblesTab(SettingsTab):
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onBibleThemeComboBoxChanged)
|
||||
QtCore.QObject.connect(self.LayoutStyleComboBox,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onLayoutStyleComboBoxChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.VerseDisplayGroupBox.setTitle(translate(u'SettingsForm', u'Verse Display'))
|
||||
|
@ -22,7 +22,7 @@ import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from forms import EditCustomForm
|
||||
from openlp.core.lib import Plugin, Event, EventType
|
||||
from openlp.core.lib import Plugin
|
||||
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem
|
||||
|
||||
|
||||
@ -42,20 +42,8 @@ class CustomPlugin(Plugin):
|
||||
self.icon = QtGui.QIcon()
|
||||
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_custom.png'),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
# passed with drag and drop messages
|
||||
self.dnd_id=u'Custom'
|
||||
|
||||
def get_media_manager_item(self):
|
||||
# Create the CustomManagerItem object
|
||||
self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
|
||||
return self.media_item
|
||||
|
||||
def handle_event(self, event):
|
||||
"""
|
||||
Handle the event contained in the event object.
|
||||
"""
|
||||
log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
|
||||
if event.event_type == EventType.ThemeListChanged:
|
||||
log.debug(u'New Theme request received')
|
||||
self.edit_custom_form.loadThemes(event.payload)
|
||||
return Plugin.handle_event(self, event)
|
||||
|
@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
from PyQt4 import Qt, QtCore, QtGui
|
||||
|
||||
from editcustomdialog import Ui_customEditDialog
|
||||
from openlp.core.lib import SongXMLBuilder, SongXMLParser
|
||||
from openlp.core.lib import SongXMLBuilder, SongXMLParser, Receiver
|
||||
from openlp.plugins.custom.lib.models import CustomSlide
|
||||
|
||||
class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
@ -50,6 +50,8 @@ class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
|
||||
QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), self.onVerseListViewSelected)
|
||||
QtCore.QObject.connect(self.VerseListView,
|
||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'update_themes'), self.loadThemes)
|
||||
# Create other objects and forms
|
||||
self.custommanager = custommanager
|
||||
self.initialise()
|
||||
|
@ -21,7 +21,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, Event, EventType
|
||||
from openlp.core.lib import Plugin
|
||||
from openlp.plugins.images.lib import ImageMediaItem, ImageTab
|
||||
|
||||
class ImagePlugin(Plugin):
|
||||
@ -37,8 +37,6 @@ class ImagePlugin(Plugin):
|
||||
self.icon = QtGui.QIcon()
|
||||
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_image.png'),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
# passed with drag and drop messages
|
||||
self.dnd_id = u'Image'
|
||||
|
||||
def get_settings_tab(self):
|
||||
self.ImageTab = ImageTab()
|
||||
|
@ -28,7 +28,7 @@ from openlp.plugins.images.lib.imagetoolbar import ImageToolbar
|
||||
# in order for DnD to the Service manager to work correctly.
|
||||
class ImageListView(BaseListWithDnD):
|
||||
def __init__(self, parent=None):
|
||||
self.PluginName = u'Image'
|
||||
self.PluginName = u'Images'
|
||||
BaseListWithDnD.__init__(self, parent)
|
||||
|
||||
class ImageMediaItem(MediaManagerItem):
|
||||
|
@ -41,7 +41,6 @@ class PresentationPlugin(Plugin):
|
||||
self.icon = QtGui.QIcon()
|
||||
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.dnd_id = u'Presentations'
|
||||
|
||||
def get_settings_tab(self):
|
||||
"""
|
||||
|
@ -22,7 +22,7 @@ import sys
|
||||
|
||||
from PyQt4 import QtNetwork, QtGui, QtCore
|
||||
|
||||
from openlp.core.lib import Plugin, Event, EventType, Receiver
|
||||
from openlp.core.lib import Plugin, Receiver
|
||||
from openlp.plugins.remotes.lib import RemoteTab
|
||||
|
||||
class RemotesPlugin(Plugin):
|
||||
@ -58,7 +58,7 @@ class RemotesPlugin(Plugin):
|
||||
event = unicode(datagram[:pos].lower())
|
||||
|
||||
if event == u'alert':
|
||||
self.event_manager.post_event(Event(u'RemotePlugin', EventType.TriggerAlert , unicode(datagram[pos + 1:])))
|
||||
Receiver().send_message(u'alert_text', unicode(datagram[pos + 1:]))
|
||||
if event == u'next_slide':
|
||||
Receiver().send_message(u'live_slide_next')
|
||||
|
||||
|
@ -22,8 +22,8 @@ import logging
|
||||
|
||||
from PyQt4 import Qt, QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, \
|
||||
EventType, EventManager, translate
|
||||
from openlp.core.lib import SongXMLBuilder, SongXMLParser, \
|
||||
translate, Receiver
|
||||
from openlp.plugins.songs.forms import EditVerseForm
|
||||
from openlp.plugins.songs.lib.models import Song
|
||||
from editsongdialog import Ui_EditSongDialog
|
||||
@ -36,7 +36,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
log = logging.getLogger(u'EditSongForm')
|
||||
log.info(u'Song Editor loaded')
|
||||
|
||||
def __init__(self, songmanager, eventmanager, parent=None):
|
||||
def __init__(self, songmanager, parent=None):
|
||||
"""
|
||||
Constructor
|
||||
"""
|
||||
@ -71,9 +71,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)
|
||||
QtCore.QObject.connect(self.MaintenanceButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'update_themes'), self.loadThemes)
|
||||
# Create other objects and forms
|
||||
self.songmanager = songmanager
|
||||
self.eventmanager = eventmanager
|
||||
self.parent = parent
|
||||
self.verse_form = EditVerseForm()
|
||||
self.initialise()
|
||||
@ -364,7 +365,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.processTitle()
|
||||
self.songmanager.save_song(self.song)
|
||||
if self.title_change:
|
||||
self.eventmanager.post_event(Event(u'EditSongForm', EventType.LoadSongList))
|
||||
Receiver().send_message(u'load_song_list')
|
||||
self.close()
|
||||
|
||||
def processLyrics(self):
|
||||
|
@ -22,12 +22,13 @@ import logging
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \
|
||||
SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD
|
||||
SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD, \
|
||||
Receiver
|
||||
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm
|
||||
|
||||
class SongListView(BaseListWithDnD):
|
||||
def __init__(self, parent=None):
|
||||
self.PluginName = u'Song'
|
||||
self.PluginName = u'Songs'
|
||||
BaseListWithDnD.__init__(self, parent)
|
||||
|
||||
class SongMediaItem(MediaManagerItem):
|
||||
@ -43,7 +44,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.PluginTextShort = u'Song'
|
||||
self.ConfigSection = u'song'
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
self.edit_song_form = EditSongForm(self.parent.songmanager, self.parent.event_manager, self)
|
||||
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
|
||||
self.song_maintenance_form = SongMaintenanceForm(self.parent.songmanager, self)
|
||||
|
||||
def setupUi(self):
|
||||
@ -127,6 +128,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)
|
||||
QtCore.QObject.connect(self.ListView,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'load_song_list'), self.onSearchTextButtonClick)
|
||||
|
||||
#define and add the context menu
|
||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||
|
@ -22,7 +22,7 @@ import logging
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import Plugin, Event, EventType, translate
|
||||
from openlp.core.lib import Plugin, translate
|
||||
from openlp.plugins.songs.lib import SongManager, SongsTab, SongMediaItem
|
||||
from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
|
||||
OpenSongImportForm, OpenLPExportForm
|
||||
@ -46,8 +46,6 @@ class SongsPlugin(Plugin):
|
||||
self.icon = QtGui.QIcon()
|
||||
self.icon.addPixmap(QtGui.QPixmap(u':/media/media_song.png'),
|
||||
QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
# passed with drag and drop messages
|
||||
self.dnd_id=u'Song'
|
||||
|
||||
def get_media_manager_item(self):
|
||||
# Create the MediaManagerItem object
|
||||
@ -128,16 +126,3 @@ class SongsPlugin(Plugin):
|
||||
|
||||
def onExportOpenSongItemClicked(self):
|
||||
self.opensong_export_form.show()
|
||||
|
||||
def handle_event(self, event):
|
||||
"""
|
||||
Handle the event contained in the event object.
|
||||
"""
|
||||
log.debug(u'Handle event called with event %s' % event.event_type)
|
||||
if event.event_type == EventType.ThemeListChanged:
|
||||
log.debug(u'New Theme request received')
|
||||
self.media_item.edit_song_form.loadThemes(event.payload)
|
||||
if event.event_type == EventType.LoadSongList :
|
||||
log.debug(u'Load Load Song List Item received')
|
||||
self.media_item.displayResultsSong(self.songmanager.get_songs())
|
||||
return Plugin.handle_event(self, event)
|
||||
|
Loading…
Reference in New Issue
Block a user