From 6a0eaa2cfe96af3552203bcc90b7e25d045ffdf6 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 22 Mar 2009 07:13:34 +0000 Subject: [PATCH] Clean up Plugin Interface to be more Generic Clean up Mainwindow for adding plugins Add ThemeManager to Main window and pass to plugins Add event Manager code to plugins and define some listners Update AlertDialog to send message and allow text to be entered --- openlp/core/lib/event.py | 13 +- openlp/core/lib/plugin.py | 7 +- openlp/core/pluginmanager.py | 44 +++--- openlp/core/render.py | 15 +- openlp/core/theme/theme.py | 6 +- openlp/core/ui/alertform.py | 39 ++++-- openlp/core/ui/mainwindow.py | 132 +++++++++++------- openlp/core/ui/servicemanager.py | 12 +- openlp/core/ui/settingsform.py | 3 - openlp/plugins/bibles/bibleplugin.py | 4 +- openlp/plugins/custom/customplugin.py | 21 ++- openlp/plugins/images/imageplugin.py | 8 +- .../presentations/presentationplugin.py | 4 +- openlp/plugins/songs/songsplugin.py | 4 +- openlp/plugins/videos/videoplugin.py | 4 +- 15 files changed, 197 insertions(+), 119 deletions(-) diff --git a/openlp/core/lib/event.py b/openlp/core/lib/event.py index efc67bd41..38579d21c 100644 --- a/openlp/core/lib/event.py +++ b/openlp/core/lib/event.py @@ -3,7 +3,7 @@ """ OpenLP - Open Source Lyrics Projection Copyright (c) 2008 Raoul Snyman -Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Scott Guerreri, +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 @@ -46,6 +46,15 @@ class Event(object): """ Provides an Event class to encapsulate events within openlp.org. """ - def __init__(self, event_type=EventType.Default): self.type = event_type + self.payload = None + + def get_payload(self): + return self.payload + + def set_payload(self, payload): + self.payload = payload + + def get_type(self): + return self.type diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 16194e65d..1cdf87eac 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -67,7 +67,7 @@ class Plugin(object): and screen number. """ - def __init__(self, name=None, version=None, preview_controller=None, live_controller=None): + def __init__(self, name=None, version=None, plugin_helpers=None): """ This is the constructor for the plugin object. This provides an easy way for descendent plugins to populate common data. This method *must* @@ -88,8 +88,9 @@ class Plugin(object): self.weight = 0 # Set up logging self.log = logging.getLogger(self.name) - self.preview_controller=preview_controller - self.live_controller=live_controller + if plugin_helpers != None: + self.preview_controller=plugin_helpers[u'preview'] + self.live_controller=plugin_helpers[u'preview'] def check_pre_conditions(self): """ diff --git a/openlp/core/pluginmanager.py b/openlp/core/pluginmanager.py index fa3c33442..d805efa20 100644 --- a/openlp/core/pluginmanager.py +++ b/openlp/core/pluginmanager.py @@ -3,7 +3,7 @@ """ OpenLP - Open Source Lyrics Projection Copyright (c) 2008 Raoul Snyman -Portions copyright (c) 2008 Martin Thompson, Tim Bentley, +Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley, 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 @@ -22,7 +22,7 @@ import os import sys import logging -from openlp.core.lib import Plugin +from openlp.core.lib import Plugin, EventManager class PluginManager(object): """ @@ -30,15 +30,15 @@ class PluginManager(object): and executes all the hooks, as and when necessary. """ global log - log=logging.getLogger("PluginMgr") - log.info("Plugin manager loaded") + log=logging.getLogger(u'PluginMgr') + log.info(u'"Plugin manager loaded') def __init__(self, dir): """ The constructor for the plugin manager. Passes the controllers on to the plugins for them to interact with via their ServiceItems """ - log.info("Plugin manager initing") + log.info(u'Plugin manager initing') if not dir in sys.path: log.debug("Inserting %s into sys.path", dir) sys.path.insert(0, dir) @@ -48,12 +48,11 @@ class PluginManager(object): # this has to happen after the UI is sorted self.find_plugins(dir) log.info("Plugin manager done init") - def find_plugins(self, dir, preview_controller, live_controller): # xxx shouldn't dir come from self.basepath + def find_plugins(self, dir, plugin_helpers, eventmanager): # TODO shouldn't dir come from self.basepath """ Scan the directory dir for objects inheriting from openlp.plugin """ - self.preview_controller=preview_controller - self.live_controller=live_controller + self.plugin_helpers = plugin_helpers startdepth=len(os.path.abspath(dir).split(os.sep)) log.debug("find plugins %s at depth %d" %( str(dir), startdepth)) @@ -80,16 +79,15 @@ class PluginManager(object): plugin_objects = [] for p in self.plugin_classes: try: - plugin = p(self.preview_controller, self.live_controller) - log.debug('loaded plugin' + str(p) + ' with controllers'+str(self.preview_controller)+str(self.live_controller)) + plugin = p(self.plugin_helpers) + log.debug(u'loaded plugin %s with helpers'%str(p)) except TypeError: - # TODO: need to get rid of this once all plugins are up to date - plugin = p() - log.debug('loaded plugin' + str(p) + ' with no controllers') + log.error(u'loaded plugin %s has no helpers'%str(p)) log.debug("Plugin="+str(p)) if plugin.check_pre_conditions(): log.debug("Appending "+str(p)) plugin_objects.append(plugin) + eventmanager.register(plugin) self.plugins = sorted(plugin_objects, self.order_by_weight) def order_by_weight(self, x, y): @@ -106,7 +104,7 @@ class PluginManager(object): log.debug('Inserting media manager item from %s' % plugin.name) mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title) # TODO: These shouldn't be called here... - plugin.initialise() + #plugin.initialise() def hook_settings_tabs(self, settingsform=None): """ @@ -137,5 +135,19 @@ class PluginManager(object): for plugin in self.plugins: plugin.add_export_menu_item(export_menu) - def hook_handle_event(self, event): - pass + def hook_handle_event(self, eventmanager): + for plugin in self.plugins: + handle_event = plugin.handle_event(None) + print plugin, handle_event +# if settings_tab is not None: +# log.debug('Inserting settings tab item from %s' % plugin.name) +# settingsform.addTab(settings_tab) +# else: +# log.debug('No settings in %s' % plugin.name) + def initialise_plugins(self): + """ + Loop through all the plugins and give them an opportunity to add an item + to the export menu. + """ + for plugin in self.plugins: + plugin.initialise() diff --git a/openlp/core/render.py b/openlp/core/render.py index 41a1643ab..471ad0093 100644 --- a/openlp/core/render.py +++ b/openlp/core/render.py @@ -44,8 +44,10 @@ class Renderer: self._theme=None self._bg_image_filename=None self._paint=None + def set_debug(self, debug): self._debug=debug + def set_theme(self, theme): self._theme=theme if theme.BackgroundType == 2: @@ -56,6 +58,7 @@ class Renderer: self._bg_image_filename=filename if self._paint is not None: self.scale_bg_image() + def scale_bg_image(self): assert self._paint i=QtGui.QImage(self._bg_image_filename) @@ -81,6 +84,7 @@ class Renderer: self._paint=p if self._bg_image_filename is not None: self.scale_bg_image() + def set_words_openlp(self, words): # print "set words openlp", words verses=[] @@ -95,6 +99,7 @@ class Renderer: verses_text.append('\n'.join(v).lstrip()) # remove first \n return verses_text + def render_screen(self, screennum): print "render screen\n", screennum, self.words[screennum] import time @@ -106,6 +111,7 @@ class Renderer: def set_text_rectangle(self, rect): """ Sets the rectangle within which text should be rendered""" self._rect=rect + def _render_background(self): # xxx may have to prerender to a memdc when set theme is called for use on slow machines # takes 26ms on mijiti's machine! @@ -149,6 +155,7 @@ class Renderer: p.drawPixmap(self.background_offsetx,self.background_offsety, self.img) p.end() print "render background done" + def split_set_of_lines(self, lines): """Given a list of lines, decide how to split them best if they don't all fit on the screen @@ -212,7 +219,6 @@ class Renderer: return retval - def _render_lines(self, lines): """render a set of lines according to the theme, return bounding box""" print "_render_lines", lines @@ -234,6 +240,7 @@ class Renderer: print "render lines DONE" return bbox + def _render_lines_unaligned(self, lines, tlcorner=(0,0)): """Given a list of lines to render, render each one in turn @@ -265,7 +272,6 @@ class Renderer: return retval - def _render_single_line(self, line, tlcorner=(0,0)): """render a single line of words onto the DC, top left corner @@ -402,8 +408,3 @@ class Renderer: p.drawText(x,y+metrics.height()-metrics.descent()-1, line) p.end() return (w, h) - - - - - diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 81f94a9ce..c36434273 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -15,7 +15,8 @@ blankstylexml=\ ''' BlankStyle - 0 + 1 + 0 $000000 @@ -37,6 +38,9 @@ class Theme: attributes: name : theme name + BackgroundMode : 1 - Transparent + 1 - Opaque + BackgroundType : 0 - solid color 1 - gradient color 2 - image diff --git a/openlp/core/ui/alertform.py b/openlp/core/ui/alertform.py index 0446c60a8..c695fdcdf 100644 --- a/openlp/core/ui/alertform.py +++ b/openlp/core/ui/alertform.py @@ -17,22 +17,32 @@ 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 from PyQt4.QtGui import QDialog from openlp.core import translate from openlp.core.resources import * +from openlp.core.ui import AlertsTab +from openlp.core.lib import EventManager, Event class AlertForm(QDialog): - - def __init__(self, parent=None): + global log + log=logging.getLogger(u'AlertForm') + + def __init__(self, eventmanager, parent=None): QDialog.__init__(self, parent) + self.alertsTab = AlertsTab() + self.eventmanager = eventmanager self.setupUi(self) + log.info(u'Defined') + + def get_settings_tab(self): + return self.alertsTab def setupUi(self, AlertForm): AlertForm.setObjectName("AlertForm") - AlertForm.resize(370, 105) + AlertForm.resize(370, 110) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off) AlertForm.setWindowIcon(icon) @@ -56,7 +66,7 @@ class AlertForm(QDialog): self.AlertEntryLabel.setSizePolicy(sizePolicy) self.AlertEntryLabel.setObjectName("AlertEntryLabel") self.AlertEntryEditItem = QtGui.QLineEdit(self.AlertEntryWidget) - self.AlertEntryEditItem.setGeometry(QtCore.QRect(0, 20, 353, 21)) + self.AlertEntryEditItem.setGeometry(QtCore.QRect(0, 20, 353, 26)) self.AlertEntryEditItem.setObjectName("AlertEntryEditItem") self.AlertFormLayout.addWidget(self.AlertEntryWidget) self.ButtonBoxWidget = QtGui.QWidget(AlertForm) @@ -83,20 +93,29 @@ class AlertForm(QDialog): self.retranslateUi(AlertForm) QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("clicked()"), AlertForm.close) + QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL("clicked()"), self.onDisplayClicked) QtCore.QMetaObject.connectSlotsByName(AlertForm) def retranslateUi(self, AlertForm): - AlertForm.setWindowTitle(translate("AlertForm", "Alert Message")) - self.AlertEntryLabel.setText(translate("AlertForm", "Alert Text:")) - self.DisplayButton.setText(translate("AlertForm", "Display")) - self.CancelButton.setText(translate("AlertForm", "Cancel")) + AlertForm.setWindowTitle(translate("AlertForm", u'Alert Message')) + self.AlertEntryLabel.setText(translate("AlertForm", u'Alert Text:')) + self.DisplayButton.setText(translate("AlertForm", u'Display')) + self.CancelButton.setText(translate("AlertForm", u'Cancel')) # def show(self): # self.AlertForm.show() - + + def handle_event(self, event): + """ + Handle the event contained in the event object. + """ + log.debug(u'Handle event called with event %s' %event.get_type()) def load_settings(self): pass def save_settings(self): pass + + def onDisplayClicked(self): + self.eventmanager.post_event(Event()) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6d39f1254..47cb26fe6 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -3,7 +3,7 @@ """ OpenLP - Open Source Lyrics Projection Copyright (c) 2008 Raoul Snyman -Portions copyright (c) 2008 Martin Thompson, Tim Bentley, +Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley, 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 @@ -18,54 +18,74 @@ 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 from time import sleep + from PyQt4 import * from PyQt4 import QtCore, QtGui from openlp.core.resources import * from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ - SlideController, ServiceManager -from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab + SlideController, ServiceManager, ThemeManager +from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab, EventManager from openlp.core import PluginManager -import logging + class MainWindow(object): global log - log=logging.getLogger("MainWindow") - log.info("MainWindow loaded") + log=logging.getLogger(u'MainWindow') + log.info(u'MainWindow loaded') def __init__(self): self.main_window = QtGui.QMainWindow() - self.alert_form = AlertForm() + self.EventManager = EventManager() + self.alert_form = AlertForm(self.EventManager) self.about_form = AboutForm() self.settings_form = SettingsForm() + self.settings_form.addTab(self.alert_form.get_settings_tab()) + pluginpath = os.path.split(os.path.abspath(__file__))[0] pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins')) self.plugin_manager = PluginManager(pluginpath) + self.plugin_helpers = {} + self.setupUi() - log.info('') - self.plugin_manager.find_plugins(pluginpath, self.PreviewController, self.LiveController) + log.info(u'Load 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'theme'] = self.ThemeManagerContents # Theme manger + + self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers, self.EventManager) # hook methods have to happen after find_plugins. Find plugins needs the controllers # hence the hooks have moved from setupUI() to here # Find and insert media manager items - log.info("hook media") + log.info(u'hook media') self.plugin_manager.hook_media_manager(self.MediaToolBox) # Find and insert settings tabs - log.info("hook settings") + log.info(u'hook settings') self.plugin_manager.hook_settings_tabs(self.settings_form) # Call the hook method to pull in import menus. - log.info("hook menus") + log.info(u'hook menus') self.plugin_manager.hook_import_menu(self.FileImportMenu) # Call the hook method to pull in export menus. - self.plugin_manager.hook_import_menu(self.FileExportMenu) + self.plugin_manager.hook_export_menu(self.FileExportMenu) + # Call the initialise method to setup plugins. + log.info(u'initialise plugins') + self.plugin_manager.initialise_plugins() + + # Register the different UI components with Event Manager + self.EventManager.register(self.ServiceManagerContents) + self.EventManager.register(self.ThemeManagerContents) + self.EventManager.register(self.alert_form) + def setupUi(self): self.main_window.setObjectName("main_window") self.main_window.resize(1087, 847) @@ -151,7 +171,7 @@ class MainWindow(object): self.MediaManagerLayout.addWidget(self.MediaToolBox) self.MediaManagerDock.setWidget(self.MediaManagerContents) self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock) - + #Sevice Manager Defined self.ServiceManagerDock = QtGui.QDockWidget(self.main_window) ServiceManagerIcon = QtGui.QIcon() ServiceManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_servicemanager.png"), @@ -162,6 +182,7 @@ class MainWindow(object): self.ServiceManagerContents = ServiceManager(self) self.ServiceManagerDock.setWidget(self.ServiceManagerContents) self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock) + #Theme Manager Defined self.ThemeManagerDock = QtGui.QDockWidget(self.main_window) ThemeManagerIcon = QtGui.QIcon() ThemeManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_thememanager.png"), @@ -169,41 +190,46 @@ class MainWindow(object): self.ThemeManagerDock.setWindowIcon(ThemeManagerIcon) self.ThemeManagerDock.setFloating(False) self.ThemeManagerDock.setObjectName("ThemeManagerDock") - self.ThemeManagerContents = QtGui.QWidget() - self.ThemeManagerContents.setObjectName("ThemeManagerContents") - self.ThemeManagerLayout = QtGui.QVBoxLayout(self.ThemeManagerContents) - self.ThemeManagerLayout.setSpacing(0) - self.ThemeManagerLayout.setMargin(0) - self.ThemeManagerLayout.setObjectName("ThemeManagerLayout") - self.ThemeManagerToolbar = QtGui.QToolBar(self.ThemeManagerContents) - self.ThemeManagerToolbar.setObjectName("ThemeManagerToolbar") - NewThemeIcon = QtGui.QIcon() - NewThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_new.png"), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.ThemeNewItem = self.ThemeManagerToolbar.addAction(NewThemeIcon, 'New theme') - EditThemeIcon = QtGui.QIcon() - EditThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_edit.png"), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.ThemeEditItem = self.ThemeManagerToolbar.addAction(EditThemeIcon, 'Edit theme') - DeleteThemeIcon = QtGui.QIcon() - DeleteThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_delete.png"), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.ThemeDeleteButton = self.ThemeManagerToolbar.addAction(DeleteThemeIcon, 'Delete theme') - self.ThemeManagerToolbar.addSeparator() - ImportThemeIcon = QtGui.QIcon() - ImportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_import.png"), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.ThemeImportButton = self.ThemeManagerToolbar.addAction(ImportThemeIcon, 'Import theme') - ExportThemeIcon = QtGui.QIcon() - ExportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_export.png"), - QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.ThemeExportButton = self.ThemeManagerToolbar.addAction(ExportThemeIcon, 'Export theme') - self.ThemeManagerLayout.addWidget(self.ThemeManagerToolbar) - self.ThemeManagerListView = QtGui.QListView(self.ThemeManagerContents) - self.ThemeManagerListView.setObjectName("ThemeManagerListView") - self.ThemeManagerLayout.addWidget(self.ThemeManagerListView) + + self.ThemeManagerContents = ThemeManager(self) + +# self.ThemeManagerContents = QtGui.QWidget() +# self.ThemeManagerContents.setObjectName("ThemeManagerContents") +# self.ThemeManagerLayout = QtGui.QVBoxLayout(self.ThemeManagerContents) +# self.ThemeManagerLayout.setSpacing(0) +# self.ThemeManagerLayout.setMargin(0) +# self.ThemeManagerLayout.setObjectName("ThemeManagerLayout") +# self.ThemeManagerToolbar = QtGui.QToolBar(self.ThemeManagerContents) +# self.ThemeManagerToolbar.setObjectName("ThemeManagerToolbar") +# NewThemeIcon = QtGui.QIcon() +# NewThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_new.png"), +# QtGui.QIcon.Normal, QtGui.QIcon.Off) +# self.ThemeNewItem = self.ThemeManagerToolbar.addAction(NewThemeIcon, 'New theme') +# EditThemeIcon = QtGui.QIcon() +# EditThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_edit.png"), +# QtGui.QIcon.Normal, QtGui.QIcon.Off) +# self.ThemeEditItem = self.ThemeManagerToolbar.addAction(EditThemeIcon, 'Edit theme') +# DeleteThemeIcon = QtGui.QIcon() +# DeleteThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_delete.png"), +# QtGui.QIcon.Normal, QtGui.QIcon.Off) +# self.ThemeDeleteButton = self.ThemeManagerToolbar.addAction(DeleteThemeIcon, 'Delete theme') +# self.ThemeManagerToolbar.addSeparator() +# ImportThemeIcon = QtGui.QIcon() +# ImportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_import.png"), +# QtGui.QIcon.Normal, QtGui.QIcon.Off) +# self.ThemeImportButton = self.ThemeManagerToolbar.addAction(ImportThemeIcon, 'Import theme') +# ExportThemeIcon = QtGui.QIcon() +# ExportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_export.png"), +# QtGui.QIcon.Normal, QtGui.QIcon.Off) +# self.ThemeExportButton = self.ThemeManagerToolbar.addAction(ExportThemeIcon, 'Export theme') +# self.ThemeManagerLayout.addWidget(self.ThemeManagerToolbar) +# self.ThemeManagerListView = QtGui.QListView(self.ThemeManagerContents) +# self.ThemeManagerListView.setObjectName("ThemeManagerListView") +# self.ThemeManagerLayout.addWidget(self.ThemeManagerListView) + self.ThemeManagerDock.setWidget(self.ThemeManagerContents) self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ThemeManagerDock) + self.FileNewItem = QtGui.QAction(self.main_window) self.FileNewItem.setIcon(self.ServiceManagerContents.Toolbar.getIconFromTitle("New Service")) self.FileNewItem.setObjectName("FileNewItem") @@ -359,11 +385,11 @@ class MainWindow(object): # self.ServiceManagerContents.ThemeComboBox.setItemText(1, QtGui.QApplication.translate("main_window", "Snowy Mountains", None, QtGui.QApplication.UnicodeUTF8)) # self.ServiceManagerContents.ThemeComboBox.setItemText(2, QtGui.QApplication.translate("main_window", "Wilderness", None, QtGui.QApplication.UnicodeUTF8)) self.ThemeManagerDock.setWindowTitle(QtGui.QApplication.translate("main_window", "Theme Manager", None, QtGui.QApplication.UnicodeUTF8)) - self.ThemeNewItem.setText(QtGui.QApplication.translate("main_window", "New Theme", None, QtGui.QApplication.UnicodeUTF8)) - self.ThemeEditItem.setText(QtGui.QApplication.translate("main_window", "Edit Theme", None, QtGui.QApplication.UnicodeUTF8)) - self.ThemeDeleteButton.setText(QtGui.QApplication.translate("main_window", "Delete Theme", None, QtGui.QApplication.UnicodeUTF8)) - self.ThemeImportButton.setText(QtGui.QApplication.translate("main_window", "Import Theme", None, QtGui.QApplication.UnicodeUTF8)) - self.ThemeExportButton.setText(QtGui.QApplication.translate("main_window", "Export Theme", None, QtGui.QApplication.UnicodeUTF8)) +# self.ThemeNewItem.setText(QtGui.QApplication.translate("main_window", "New Theme", None, QtGui.QApplication.UnicodeUTF8)) +# self.ThemeEditItem.setText(QtGui.QApplication.translate("main_window", "Edit Theme", None, QtGui.QApplication.UnicodeUTF8)) +# self.ThemeDeleteButton.setText(QtGui.QApplication.translate("main_window", "Delete Theme", None, QtGui.QApplication.UnicodeUTF8)) +# self.ThemeImportButton.setText(QtGui.QApplication.translate("main_window", "Import Theme", None, QtGui.QApplication.UnicodeUTF8)) +# self.ThemeExportButton.setText(QtGui.QApplication.translate("main_window", "Export Theme", None, QtGui.QApplication.UnicodeUTF8)) self.FileNewItem.setText(QtGui.QApplication.translate("main_window", "&New", None, QtGui.QApplication.UnicodeUTF8)) self.FileNewItem.setToolTip(QtGui.QApplication.translate("main_window", "New Service", None, QtGui.QApplication.UnicodeUTF8)) self.FileNewItem.setStatusTip(QtGui.QApplication.translate("main_window", "Create a new Service", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index ed0ce8fc4..aacf445ab 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -40,7 +40,7 @@ class ServiceData(QAbstractItemModel): Root contains a list of ServiceItems """ global log - log=logging.getLogger("ServiceData") + log=logging.getLogger(u'ServiceData') def __init__(self): QAbstractItemModel.__init__(self) self.items=[] @@ -108,6 +108,8 @@ class ServiceManager(QWidget): one lump. Also handles the UI tasks of moving things up and down etc. """ + global log + log=logging.getLogger(u'ServiceManager') def __init__(self, parent): QWidget.__init__(self) @@ -163,6 +165,7 @@ class ServiceManager(QWidget): self.service_data.addRow(item) else: self.service_data.insertRow(row+1, item) + def removeServiceItem(self): """Remove currently selected item""" pass @@ -186,3 +189,10 @@ class ServiceManager(QWidget): oosfile.write(self.oos_as_text) oosfile.write("# END OOS\n") oosfile.close() + + def handle_event(self, event): + """ + Handle the event contained in the event object. + """ + log.debug(u'Handle event called with event %s' %event.get_type()) + diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 22a0e230a..5b8a17552 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -40,9 +40,6 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): # Themes tab self.ThemesTab = ThemesTab() self.addTab(self.ThemesTab) - # Alerts tab - self.AlertsTab = AlertsTab() - self.addTab(self.AlertsTab) def addTab(self, tab): log.info(u'Inserting %s' % tab.title()) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 4684bae34..d3ca64f81 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -35,9 +35,9 @@ class BiblePlugin(Plugin): log=logging.getLogger(u'BiblePlugin') log.info(u'Bible Plugin loaded') - def __init__(self): + def __init__(self, plugin_helpers): # Call the parent constructor - Plugin.__init__(self, u'Bibles', u'1.9.0') + Plugin.__init__(self, u'Bibles', u'1.9.0', plugin_helpers) self.weight = -9 # Create the plugin icon self.icon = QtGui.QIcon() diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 3afa3e114..bf23e7722 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -22,7 +22,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.resources import * -from openlp.core.lib import Plugin +from openlp.core.lib import Plugin, Event from forms import EditCustomForm from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem, CustomServiceItem @@ -32,9 +32,9 @@ class CustomPlugin(Plugin): log=logging.getLogger(u'CustomPlugin') log.info(u'Custom Plugin loaded') - def __init__(self, preview_controller, live_controller): + def __init__(self, plugin_helpers): # Call the parent constructor - Plugin.__init__(self, u'Custom', u'1.9.0', preview_controller, live_controller) + Plugin.__init__(self, u'Custom', u'1.9.0', plugin_helpers) self.weight = -5 self.custommanager = CustomManager(self.config) self.edit_custom_form = EditCustomForm(self.custommanager) @@ -43,17 +43,16 @@ class CustomPlugin(Plugin): self.icon.addPixmap(QtGui.QPixmap(':/media/media_custom.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.preview_service_item = CustomServiceItem(preview_controller) - self.live_service_item = CustomServiceItem(live_controller) + self.preview_service_item = CustomServiceItem(self.preview_controller) + self.live_service_item = CustomServiceItem(self.live_controller) 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 get_settings_tab(self): - pass - - def initialise(self): - pass - + def handle_event(self, event): + """ + Handle the event contained in the event object. + """ + log.debug(u'Handle event called with event %s' %event.get_type()) diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index a6947c89b..f6b8ce2e1 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -31,17 +31,17 @@ class ImagePlugin(Plugin): log=logging.getLogger(u'ImagePlugin') log.info(u'Image Plugin loaded') - def __init__(self, preview_controller, live_controller): + def __init__(self, plugin_helpers): # Call the parent constructor - Plugin.__init__(self, u'Images', u'1.9.0', preview_controller, live_controller) + Plugin.__init__(self, u'Images', u'1.9.0', plugin_helpers) self.weight = -7 # Create the plugin icon self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(':/media/media_image.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.preview_service_item = ImageServiceItem(preview_controller) - self.live_service_item = ImageServiceItem(live_controller) + self.preview_service_item = ImageServiceItem(self.preview_controller) + self.live_service_item = ImageServiceItem(self.live_controller) def get_media_manager_item(self): # Create the MediaManagerItem object diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index b4cf4bfa4..4587039cf 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -28,9 +28,9 @@ from openlp.plugins.presentations.lib import PresentationMediaItem class PresentationPlugin(Plugin): - def __init__(self): + def __init__(self, plugin_helpers): # Call the parent constructor - Plugin.__init__(self, u'Presentations', u'1.9.0') + Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers) self.weight = -8 # Create the plugin icon self.icon = QtGui.QIcon() diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index fd874c1d9..715ec2c03 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -33,9 +33,9 @@ class SongsPlugin(Plugin): log=logging.getLogger(u'SongsPlugin') log.info(u'Song Plugin loaded') - def __init__(self): + def __init__(self, plugin_helpers): # Call the parent constructor - Plugin.__init__(self, u'Songs', u'1.9.0') + Plugin.__init__(self, u'Songs', u'1.9.0', plugin_helpers) self.weight = -10 self.songmanager = SongManager(self.config) self.openlp_import_form = OpenLPImportForm() diff --git a/openlp/plugins/videos/videoplugin.py b/openlp/plugins/videos/videoplugin.py index 036d8d34c..2d64a9879 100644 --- a/openlp/plugins/videos/videoplugin.py +++ b/openlp/plugins/videos/videoplugin.py @@ -26,9 +26,9 @@ from openlp.plugins.videos.lib import VideoTab, VideoMediaItem class VideoPlugin(Plugin): - def __init__(self): + def __init__(self, plugin_helpers): # Call the parent constructor - Plugin.__init__(self, u'Videos', u'1.9.0') + Plugin.__init__(self, u'Videos', u'1.9.0', plugin_helpers) self.weight = -6 # Create the plugin icon self.icon = QtGui.QIcon()