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
This commit is contained in:
Tim Bentley 2009-03-22 07:13:34 +00:00
parent b8c0ee1d70
commit 6a0eaa2cfe
15 changed files with 197 additions and 119 deletions

View File

@ -3,7 +3,7 @@
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman 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 Carsten Tingaard, Jonathan Corwin
This program is free software; you can redistribute it and/or modify it under 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. Provides an Event class to encapsulate events within openlp.org.
""" """
def __init__(self, event_type=EventType.Default): def __init__(self, event_type=EventType.Default):
self.type = event_type 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

View File

@ -67,7 +67,7 @@ class Plugin(object):
and screen number. 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 This is the constructor for the plugin object. This provides an easy
way for descendent plugins to populate common data. This method *must* way for descendent plugins to populate common data. This method *must*
@ -88,8 +88,9 @@ class Plugin(object):
self.weight = 0 self.weight = 0
# Set up logging # Set up logging
self.log = logging.getLogger(self.name) self.log = logging.getLogger(self.name)
self.preview_controller=preview_controller if plugin_helpers != None:
self.live_controller=live_controller self.preview_controller=plugin_helpers[u'preview']
self.live_controller=plugin_helpers[u'preview']
def check_pre_conditions(self): def check_pre_conditions(self):
""" """

View File

@ -3,7 +3,7 @@
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman 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 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 the terms of the GNU General Public License as published by the Free Software
@ -22,7 +22,7 @@ import os
import sys import sys
import logging import logging
from openlp.core.lib import Plugin from openlp.core.lib import Plugin, EventManager
class PluginManager(object): class PluginManager(object):
""" """
@ -30,15 +30,15 @@ class PluginManager(object):
and executes all the hooks, as and when necessary. and executes all the hooks, as and when necessary.
""" """
global log global log
log=logging.getLogger("PluginMgr") log=logging.getLogger(u'PluginMgr')
log.info("Plugin manager loaded") log.info(u'"Plugin manager loaded')
def __init__(self, dir): def __init__(self, dir):
""" """
The constructor for the plugin manager. The constructor for the plugin manager.
Passes the controllers on to the plugins for them to interact with via their ServiceItems 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: if not dir in sys.path:
log.debug("Inserting %s into sys.path", dir) log.debug("Inserting %s into sys.path", dir)
sys.path.insert(0, 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) # this has to happen after the UI is sorted self.find_plugins(dir)
log.info("Plugin manager done init") 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 Scan the directory dir for objects inheriting from openlp.plugin
""" """
self.preview_controller=preview_controller self.plugin_helpers = plugin_helpers
self.live_controller=live_controller
startdepth=len(os.path.abspath(dir).split(os.sep)) startdepth=len(os.path.abspath(dir).split(os.sep))
log.debug("find plugins %s at depth %d" %( str(dir), startdepth)) log.debug("find plugins %s at depth %d" %( str(dir), startdepth))
@ -80,16 +79,15 @@ class PluginManager(object):
plugin_objects = [] plugin_objects = []
for p in self.plugin_classes: for p in self.plugin_classes:
try: try:
plugin = p(self.preview_controller, self.live_controller) plugin = p(self.plugin_helpers)
log.debug('loaded plugin' + str(p) + ' with controllers'+str(self.preview_controller)+str(self.live_controller)) log.debug(u'loaded plugin %s with helpers'%str(p))
except TypeError: except TypeError:
# TODO: need to get rid of this once all plugins are up to date log.error(u'loaded plugin %s has no helpers'%str(p))
plugin = p()
log.debug('loaded plugin' + str(p) + ' with no controllers')
log.debug("Plugin="+str(p)) log.debug("Plugin="+str(p))
if plugin.check_pre_conditions(): if plugin.check_pre_conditions():
log.debug("Appending "+str(p)) log.debug("Appending "+str(p))
plugin_objects.append(plugin) plugin_objects.append(plugin)
eventmanager.register(plugin)
self.plugins = sorted(plugin_objects, self.order_by_weight) self.plugins = sorted(plugin_objects, self.order_by_weight)
def order_by_weight(self, x, y): def order_by_weight(self, x, y):
@ -106,7 +104,7 @@ class PluginManager(object):
log.debug('Inserting media manager item from %s' % plugin.name) log.debug('Inserting media manager item from %s' % plugin.name)
mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title) mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title)
# TODO: These shouldn't be called here... # TODO: These shouldn't be called here...
plugin.initialise() #plugin.initialise()
def hook_settings_tabs(self, settingsform=None): def hook_settings_tabs(self, settingsform=None):
""" """
@ -137,5 +135,19 @@ class PluginManager(object):
for plugin in self.plugins: for plugin in self.plugins:
plugin.add_export_menu_item(export_menu) plugin.add_export_menu_item(export_menu)
def hook_handle_event(self, event): def hook_handle_event(self, eventmanager):
pass 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()

View File

@ -44,8 +44,10 @@ class Renderer:
self._theme=None self._theme=None
self._bg_image_filename=None self._bg_image_filename=None
self._paint=None self._paint=None
def set_debug(self, debug): def set_debug(self, debug):
self._debug=debug self._debug=debug
def set_theme(self, theme): def set_theme(self, theme):
self._theme=theme self._theme=theme
if theme.BackgroundType == 2: if theme.BackgroundType == 2:
@ -56,6 +58,7 @@ class Renderer:
self._bg_image_filename=filename self._bg_image_filename=filename
if self._paint is not None: if self._paint is not None:
self.scale_bg_image() self.scale_bg_image()
def scale_bg_image(self): def scale_bg_image(self):
assert self._paint assert self._paint
i=QtGui.QImage(self._bg_image_filename) i=QtGui.QImage(self._bg_image_filename)
@ -81,6 +84,7 @@ class Renderer:
self._paint=p self._paint=p
if self._bg_image_filename is not None: if self._bg_image_filename is not None:
self.scale_bg_image() self.scale_bg_image()
def set_words_openlp(self, words): def set_words_openlp(self, words):
# print "set words openlp", words # print "set words openlp", words
verses=[] verses=[]
@ -95,6 +99,7 @@ class Renderer:
verses_text.append('\n'.join(v).lstrip()) # remove first \n verses_text.append('\n'.join(v).lstrip()) # remove first \n
return verses_text return verses_text
def render_screen(self, screennum): def render_screen(self, screennum):
print "render screen\n", screennum, self.words[screennum] print "render screen\n", screennum, self.words[screennum]
import time import time
@ -106,6 +111,7 @@ class Renderer:
def set_text_rectangle(self, rect): def set_text_rectangle(self, rect):
""" Sets the rectangle within which text should be rendered""" """ Sets the rectangle within which text should be rendered"""
self._rect=rect self._rect=rect
def _render_background(self): def _render_background(self):
# xxx may have to prerender to a memdc when set theme is called for use on slow machines # xxx may have to prerender to a memdc when set theme is called for use on slow machines
# takes 26ms on mijiti's machine! # takes 26ms on mijiti's machine!
@ -149,6 +155,7 @@ class Renderer:
p.drawPixmap(self.background_offsetx,self.background_offsety, self.img) p.drawPixmap(self.background_offsetx,self.background_offsety, self.img)
p.end() p.end()
print "render background done" print "render background done"
def split_set_of_lines(self, lines): 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 """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 return retval
def _render_lines(self, lines): def _render_lines(self, lines):
"""render a set of lines according to the theme, return bounding box""" """render a set of lines according to the theme, return bounding box"""
print "_render_lines", lines print "_render_lines", lines
@ -234,6 +240,7 @@ class Renderer:
print "render lines DONE" print "render lines DONE"
return bbox return bbox
def _render_lines_unaligned(self, lines, tlcorner=(0,0)): def _render_lines_unaligned(self, lines, tlcorner=(0,0)):
"""Given a list of lines to render, render each one in turn """Given a list of lines to render, render each one in turn
@ -265,7 +272,6 @@ class Renderer:
return retval return retval
def _render_single_line(self, line, tlcorner=(0,0)): def _render_single_line(self, line, tlcorner=(0,0)):
"""render a single line of words onto the DC, top left corner """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.drawText(x,y+metrics.height()-metrics.descent()-1, line)
p.end() p.end()
return (w, h) return (w, h)

View File

@ -15,7 +15,8 @@ blankstylexml=\
'''<?xml version="1.0" encoding="iso-8859-1"?> '''<?xml version="1.0" encoding="iso-8859-1"?>
<Theme> <Theme>
<Name>BlankStyle</Name> <Name>BlankStyle</Name>
<BackgroundType>0</BackgroundType> <BackgroundMode>1</BackgroundMode>
<BackgroundType>0</BackgroundType>
<BackgroundParameter1>$000000</BackgroundParameter1> <BackgroundParameter1>$000000</BackgroundParameter1>
<BackgroundParameter2/> <BackgroundParameter2/>
<BackgroundParameter3/> <BackgroundParameter3/>
@ -37,6 +38,9 @@ class Theme:
attributes: attributes:
name : theme name name : theme name
BackgroundMode : 1 - Transparent
1 - Opaque
BackgroundType : 0 - solid color BackgroundType : 0 - solid color
1 - gradient color 1 - gradient color
2 - image 2 - image

View File

@ -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 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from PyQt4.QtGui import QDialog from PyQt4.QtGui import QDialog
from openlp.core import translate from openlp.core import translate
from openlp.core.resources import * from openlp.core.resources import *
from openlp.core.ui import AlertsTab
from openlp.core.lib import EventManager, Event
class AlertForm(QDialog): class AlertForm(QDialog):
global log
def __init__(self, parent=None): log=logging.getLogger(u'AlertForm')
def __init__(self, eventmanager, parent=None):
QDialog.__init__(self, parent) QDialog.__init__(self, parent)
self.alertsTab = AlertsTab()
self.eventmanager = eventmanager
self.setupUi(self) self.setupUi(self)
log.info(u'Defined')
def get_settings_tab(self):
return self.alertsTab
def setupUi(self, AlertForm): def setupUi(self, AlertForm):
AlertForm.setObjectName("AlertForm") AlertForm.setObjectName("AlertForm")
AlertForm.resize(370, 105) AlertForm.resize(370, 110)
icon = QtGui.QIcon() icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
AlertForm.setWindowIcon(icon) AlertForm.setWindowIcon(icon)
@ -56,7 +66,7 @@ class AlertForm(QDialog):
self.AlertEntryLabel.setSizePolicy(sizePolicy) self.AlertEntryLabel.setSizePolicy(sizePolicy)
self.AlertEntryLabel.setObjectName("AlertEntryLabel") self.AlertEntryLabel.setObjectName("AlertEntryLabel")
self.AlertEntryEditItem = QtGui.QLineEdit(self.AlertEntryWidget) 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.AlertEntryEditItem.setObjectName("AlertEntryEditItem")
self.AlertFormLayout.addWidget(self.AlertEntryWidget) self.AlertFormLayout.addWidget(self.AlertEntryWidget)
self.ButtonBoxWidget = QtGui.QWidget(AlertForm) self.ButtonBoxWidget = QtGui.QWidget(AlertForm)
@ -83,20 +93,29 @@ class AlertForm(QDialog):
self.retranslateUi(AlertForm) self.retranslateUi(AlertForm)
QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("clicked()"), AlertForm.close) QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("clicked()"), AlertForm.close)
QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL("clicked()"), self.onDisplayClicked)
QtCore.QMetaObject.connectSlotsByName(AlertForm) QtCore.QMetaObject.connectSlotsByName(AlertForm)
def retranslateUi(self, AlertForm): def retranslateUi(self, AlertForm):
AlertForm.setWindowTitle(translate("AlertForm", "Alert Message")) AlertForm.setWindowTitle(translate("AlertForm", u'Alert Message'))
self.AlertEntryLabel.setText(translate("AlertForm", "Alert Text:")) self.AlertEntryLabel.setText(translate("AlertForm", u'Alert Text:'))
self.DisplayButton.setText(translate("AlertForm", "Display")) self.DisplayButton.setText(translate("AlertForm", u'Display'))
self.CancelButton.setText(translate("AlertForm", "Cancel")) self.CancelButton.setText(translate("AlertForm", u'Cancel'))
# def show(self): # def show(self):
# self.AlertForm.show() # 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): def load_settings(self):
pass pass
def save_settings(self): def save_settings(self):
pass pass
def onDisplayClicked(self):
self.eventmanager.post_event(Event())

View File

@ -3,7 +3,7 @@
""" """
OpenLP - Open Source Lyrics Projection OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman 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 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 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 Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import os import os
import logging
from time import sleep from time import sleep
from PyQt4 import * from PyQt4 import *
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.resources import * from openlp.core.resources import *
from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
SlideController, ServiceManager SlideController, ServiceManager, ThemeManager
from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab, EventManager
from openlp.core import PluginManager from openlp.core import PluginManager
import logging
class MainWindow(object): class MainWindow(object):
global log global log
log=logging.getLogger("MainWindow") log=logging.getLogger(u'MainWindow')
log.info("MainWindow loaded") log.info(u'MainWindow loaded')
def __init__(self): def __init__(self):
self.main_window = QtGui.QMainWindow() self.main_window = QtGui.QMainWindow()
self.alert_form = AlertForm() self.EventManager = EventManager()
self.alert_form = AlertForm(self.EventManager)
self.about_form = AboutForm() self.about_form = AboutForm()
self.settings_form = SettingsForm() 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.split(os.path.abspath(__file__))[0]
pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins')) pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins'))
self.plugin_manager = PluginManager(pluginpath) self.plugin_manager = PluginManager(pluginpath)
self.plugin_helpers = {}
self.setupUi() self.setupUi()
log.info('') log.info(u'Load Plugins')
self.plugin_manager.find_plugins(pluginpath, self.PreviewController, self.LiveController) 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 # hook methods have to happen after find_plugins. Find plugins needs the controllers
# hence the hooks have moved from setupUI() to here # hence the hooks have moved from setupUI() to here
# Find and insert media manager items # Find and insert media manager items
log.info("hook media") log.info(u'hook media')
self.plugin_manager.hook_media_manager(self.MediaToolBox) self.plugin_manager.hook_media_manager(self.MediaToolBox)
# Find and insert settings tabs # Find and insert settings tabs
log.info("hook settings") log.info(u'hook settings')
self.plugin_manager.hook_settings_tabs(self.settings_form) self.plugin_manager.hook_settings_tabs(self.settings_form)
# Call the hook method to pull in import menus. # 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) 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_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): def setupUi(self):
self.main_window.setObjectName("main_window") self.main_window.setObjectName("main_window")
self.main_window.resize(1087, 847) self.main_window.resize(1087, 847)
@ -151,7 +171,7 @@ class MainWindow(object):
self.MediaManagerLayout.addWidget(self.MediaToolBox) self.MediaManagerLayout.addWidget(self.MediaToolBox)
self.MediaManagerDock.setWidget(self.MediaManagerContents) self.MediaManagerDock.setWidget(self.MediaManagerContents)
self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock) self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock)
#Sevice Manager Defined
self.ServiceManagerDock = QtGui.QDockWidget(self.main_window) self.ServiceManagerDock = QtGui.QDockWidget(self.main_window)
ServiceManagerIcon = QtGui.QIcon() ServiceManagerIcon = QtGui.QIcon()
ServiceManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_servicemanager.png"), ServiceManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_servicemanager.png"),
@ -162,6 +182,7 @@ class MainWindow(object):
self.ServiceManagerContents = ServiceManager(self) self.ServiceManagerContents = ServiceManager(self)
self.ServiceManagerDock.setWidget(self.ServiceManagerContents) self.ServiceManagerDock.setWidget(self.ServiceManagerContents)
self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock) self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock)
#Theme Manager Defined
self.ThemeManagerDock = QtGui.QDockWidget(self.main_window) self.ThemeManagerDock = QtGui.QDockWidget(self.main_window)
ThemeManagerIcon = QtGui.QIcon() ThemeManagerIcon = QtGui.QIcon()
ThemeManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_thememanager.png"), ThemeManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_thememanager.png"),
@ -169,41 +190,46 @@ class MainWindow(object):
self.ThemeManagerDock.setWindowIcon(ThemeManagerIcon) self.ThemeManagerDock.setWindowIcon(ThemeManagerIcon)
self.ThemeManagerDock.setFloating(False) self.ThemeManagerDock.setFloating(False)
self.ThemeManagerDock.setObjectName("ThemeManagerDock") self.ThemeManagerDock.setObjectName("ThemeManagerDock")
self.ThemeManagerContents = QtGui.QWidget()
self.ThemeManagerContents.setObjectName("ThemeManagerContents") self.ThemeManagerContents = ThemeManager(self)
self.ThemeManagerLayout = QtGui.QVBoxLayout(self.ThemeManagerContents)
self.ThemeManagerLayout.setSpacing(0) # self.ThemeManagerContents = QtGui.QWidget()
self.ThemeManagerLayout.setMargin(0) # self.ThemeManagerContents.setObjectName("ThemeManagerContents")
self.ThemeManagerLayout.setObjectName("ThemeManagerLayout") # self.ThemeManagerLayout = QtGui.QVBoxLayout(self.ThemeManagerContents)
self.ThemeManagerToolbar = QtGui.QToolBar(self.ThemeManagerContents) # self.ThemeManagerLayout.setSpacing(0)
self.ThemeManagerToolbar.setObjectName("ThemeManagerToolbar") # self.ThemeManagerLayout.setMargin(0)
NewThemeIcon = QtGui.QIcon() # self.ThemeManagerLayout.setObjectName("ThemeManagerLayout")
NewThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_new.png"), # self.ThemeManagerToolbar = QtGui.QToolBar(self.ThemeManagerContents)
QtGui.QIcon.Normal, QtGui.QIcon.Off) # self.ThemeManagerToolbar.setObjectName("ThemeManagerToolbar")
self.ThemeNewItem = self.ThemeManagerToolbar.addAction(NewThemeIcon, 'New theme') # NewThemeIcon = QtGui.QIcon()
EditThemeIcon = QtGui.QIcon() # NewThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_new.png"),
EditThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_edit.png"), # QtGui.QIcon.Normal, QtGui.QIcon.Off)
QtGui.QIcon.Normal, QtGui.QIcon.Off) # self.ThemeNewItem = self.ThemeManagerToolbar.addAction(NewThemeIcon, 'New theme')
self.ThemeEditItem = self.ThemeManagerToolbar.addAction(EditThemeIcon, 'Edit theme') # EditThemeIcon = QtGui.QIcon()
DeleteThemeIcon = QtGui.QIcon() # EditThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_edit.png"),
DeleteThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_delete.png"), # QtGui.QIcon.Normal, QtGui.QIcon.Off)
QtGui.QIcon.Normal, QtGui.QIcon.Off) # self.ThemeEditItem = self.ThemeManagerToolbar.addAction(EditThemeIcon, 'Edit theme')
self.ThemeDeleteButton = self.ThemeManagerToolbar.addAction(DeleteThemeIcon, 'Delete theme') # DeleteThemeIcon = QtGui.QIcon()
self.ThemeManagerToolbar.addSeparator() # DeleteThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_delete.png"),
ImportThemeIcon = QtGui.QIcon() # QtGui.QIcon.Normal, QtGui.QIcon.Off)
ImportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_import.png"), # self.ThemeDeleteButton = self.ThemeManagerToolbar.addAction(DeleteThemeIcon, 'Delete theme')
QtGui.QIcon.Normal, QtGui.QIcon.Off) # self.ThemeManagerToolbar.addSeparator()
self.ThemeImportButton = self.ThemeManagerToolbar.addAction(ImportThemeIcon, 'Import theme') # ImportThemeIcon = QtGui.QIcon()
ExportThemeIcon = QtGui.QIcon() # ImportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_import.png"),
ExportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_export.png"), # QtGui.QIcon.Normal, QtGui.QIcon.Off)
QtGui.QIcon.Normal, QtGui.QIcon.Off) # self.ThemeImportButton = self.ThemeManagerToolbar.addAction(ImportThemeIcon, 'Import theme')
self.ThemeExportButton = self.ThemeManagerToolbar.addAction(ExportThemeIcon, 'Export theme') # ExportThemeIcon = QtGui.QIcon()
self.ThemeManagerLayout.addWidget(self.ThemeManagerToolbar) # ExportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_export.png"),
self.ThemeManagerListView = QtGui.QListView(self.ThemeManagerContents) # QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.ThemeManagerListView.setObjectName("ThemeManagerListView") # self.ThemeExportButton = self.ThemeManagerToolbar.addAction(ExportThemeIcon, 'Export theme')
self.ThemeManagerLayout.addWidget(self.ThemeManagerListView) # 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.ThemeManagerDock.setWidget(self.ThemeManagerContents)
self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ThemeManagerDock) self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ThemeManagerDock)
self.FileNewItem = QtGui.QAction(self.main_window) self.FileNewItem = QtGui.QAction(self.main_window)
self.FileNewItem.setIcon(self.ServiceManagerContents.Toolbar.getIconFromTitle("New Service")) self.FileNewItem.setIcon(self.ServiceManagerContents.Toolbar.getIconFromTitle("New Service"))
self.FileNewItem.setObjectName("FileNewItem") 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(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.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.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.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.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.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.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.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.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.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)) self.FileNewItem.setStatusTip(QtGui.QApplication.translate("main_window", "Create a new Service", None, QtGui.QApplication.UnicodeUTF8))

View File

@ -40,7 +40,7 @@ class ServiceData(QAbstractItemModel):
Root contains a list of ServiceItems Root contains a list of ServiceItems
""" """
global log global log
log=logging.getLogger("ServiceData") log=logging.getLogger(u'ServiceData')
def __init__(self): def __init__(self):
QAbstractItemModel.__init__(self) QAbstractItemModel.__init__(self)
self.items=[] self.items=[]
@ -108,6 +108,8 @@ class ServiceManager(QWidget):
one lump. one lump.
Also handles the UI tasks of moving things up and down etc. Also handles the UI tasks of moving things up and down etc.
""" """
global log
log=logging.getLogger(u'ServiceManager')
def __init__(self, parent): def __init__(self, parent):
QWidget.__init__(self) QWidget.__init__(self)
@ -163,6 +165,7 @@ class ServiceManager(QWidget):
self.service_data.addRow(item) self.service_data.addRow(item)
else: else:
self.service_data.insertRow(row+1, item) self.service_data.insertRow(row+1, item)
def removeServiceItem(self): def removeServiceItem(self):
"""Remove currently selected item""" """Remove currently selected item"""
pass pass
@ -186,3 +189,10 @@ class ServiceManager(QWidget):
oosfile.write(self.oos_as_text) oosfile.write(self.oos_as_text)
oosfile.write("# END OOS\n") oosfile.write("# END OOS\n")
oosfile.close() 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())

View File

@ -40,9 +40,6 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog):
# Themes tab # Themes tab
self.ThemesTab = ThemesTab() self.ThemesTab = ThemesTab()
self.addTab(self.ThemesTab) self.addTab(self.ThemesTab)
# Alerts tab
self.AlertsTab = AlertsTab()
self.addTab(self.AlertsTab)
def addTab(self, tab): def addTab(self, tab):
log.info(u'Inserting %s' % tab.title()) log.info(u'Inserting %s' % tab.title())

View File

@ -35,9 +35,9 @@ class BiblePlugin(Plugin):
log=logging.getLogger(u'BiblePlugin') log=logging.getLogger(u'BiblePlugin')
log.info(u'Bible Plugin loaded') log.info(u'Bible Plugin loaded')
def __init__(self): def __init__(self, plugin_helpers):
# Call the parent constructor # 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 self.weight = -9
# Create the plugin icon # Create the plugin icon
self.icon = QtGui.QIcon() self.icon = QtGui.QIcon()

View File

@ -22,7 +22,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.resources import * from openlp.core.resources import *
from openlp.core.lib import Plugin from openlp.core.lib import Plugin, Event
from forms import EditCustomForm from forms import EditCustomForm
from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem, CustomServiceItem from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem, CustomServiceItem
@ -32,9 +32,9 @@ class CustomPlugin(Plugin):
log=logging.getLogger(u'CustomPlugin') log=logging.getLogger(u'CustomPlugin')
log.info(u'Custom Plugin loaded') log.info(u'Custom Plugin loaded')
def __init__(self, preview_controller, live_controller): def __init__(self, plugin_helpers):
# Call the parent constructor # 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.weight = -5
self.custommanager = CustomManager(self.config) self.custommanager = CustomManager(self.config)
self.edit_custom_form = EditCustomForm(self.custommanager) self.edit_custom_form = EditCustomForm(self.custommanager)
@ -43,17 +43,16 @@ class CustomPlugin(Plugin):
self.icon.addPixmap(QtGui.QPixmap(':/media/media_custom.png'), self.icon.addPixmap(QtGui.QPixmap(':/media/media_custom.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.preview_service_item = CustomServiceItem(preview_controller) self.preview_service_item = CustomServiceItem(self.preview_controller)
self.live_service_item = CustomServiceItem(live_controller) self.live_service_item = CustomServiceItem(self.live_controller)
def get_media_manager_item(self): def get_media_manager_item(self):
# Create the CustomManagerItem object # Create the CustomManagerItem object
self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides') self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
return self.media_item return self.media_item
def get_settings_tab(self): def handle_event(self, event):
pass """
Handle the event contained in the event object.
def initialise(self): """
pass log.debug(u'Handle event called with event %s' %event.get_type())

View File

@ -31,17 +31,17 @@ class ImagePlugin(Plugin):
log=logging.getLogger(u'ImagePlugin') log=logging.getLogger(u'ImagePlugin')
log.info(u'Image Plugin loaded') log.info(u'Image Plugin loaded')
def __init__(self, preview_controller, live_controller): def __init__(self, plugin_helpers):
# Call the parent constructor # 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 self.weight = -7
# Create the plugin icon # Create the plugin icon
self.icon = QtGui.QIcon() self.icon = QtGui.QIcon()
self.icon.addPixmap(QtGui.QPixmap(':/media/media_image.png'), self.icon.addPixmap(QtGui.QPixmap(':/media/media_image.png'),
QtGui.QIcon.Normal, QtGui.QIcon.Off) QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.preview_service_item = ImageServiceItem(preview_controller) self.preview_service_item = ImageServiceItem(self.preview_controller)
self.live_service_item = ImageServiceItem(live_controller) self.live_service_item = ImageServiceItem(self.live_controller)
def get_media_manager_item(self): def get_media_manager_item(self):
# Create the MediaManagerItem object # Create the MediaManagerItem object

View File

@ -28,9 +28,9 @@ from openlp.plugins.presentations.lib import PresentationMediaItem
class PresentationPlugin(Plugin): class PresentationPlugin(Plugin):
def __init__(self): def __init__(self, plugin_helpers):
# Call the parent constructor # 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 self.weight = -8
# Create the plugin icon # Create the plugin icon
self.icon = QtGui.QIcon() self.icon = QtGui.QIcon()

View File

@ -33,9 +33,9 @@ class SongsPlugin(Plugin):
log=logging.getLogger(u'SongsPlugin') log=logging.getLogger(u'SongsPlugin')
log.info(u'Song Plugin loaded') log.info(u'Song Plugin loaded')
def __init__(self): def __init__(self, plugin_helpers):
# Call the parent constructor # 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.weight = -10
self.songmanager = SongManager(self.config) self.songmanager = SongManager(self.config)
self.openlp_import_form = OpenLPImportForm() self.openlp_import_form = OpenLPImportForm()

View File

@ -26,9 +26,9 @@ from openlp.plugins.videos.lib import VideoTab, VideoMediaItem
class VideoPlugin(Plugin): class VideoPlugin(Plugin):
def __init__(self): def __init__(self, plugin_helpers):
# Call the parent constructor # 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 self.weight = -6
# Create the plugin icon # Create the plugin icon
self.icon = QtGui.QIcon() self.icon = QtGui.QIcon()