Merge lp:~trb143/openlp/trb143 into lp:openlp

Proposed by Tim Bentley
Status: Superseded
Proposed branch: lp:~trb143/openlp/trb143
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~trb143/openlp/trb143
Reviewer Review Type Date Requested Status
Raoul Snyman Needs Fixing
Michael Gorven (community) Approve
OpenLP Core Pending
Review via email: mp+4756@code.launchpad.net

This proposal has been superseded by a proposal from 2009-03-26.

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

This is my first attempt at merge request please be nice ;-)
The code added eventmanager and thememanager (based on service manager)
Tidies up the plugin interface to make it generic for passing objects in and fixes all plugins.
Refactor the AlertDialog and Tab so the Dialog can see the Tab. Update SettingsManager.
Create a Event calling chain based on the Alert Display button. (See the log file for output)
Clean up MainWindow and PluginManager
Other small formatting tidyups.

Revision history for this message
Michael Gorven (mgorven) wrote :

Just two minor suggestions. The get_payload() and set_payload() methods aren't really necessary. If you later want to control access to payload you can always use a property to do so. Secondly, I think there should be blank lines between the methods in the ThemeData class.

review: Approve
lp:~trb143/openlp/trb143 updated
429. By Tim Bentley

Continue fixing the EventManager usage
Use Mainwindow to trigger the loading of the themes by the ServiceManager

Revision history for this message
Tim Bentley (trb143) wrote :

Add more changes in revision 429 to deal with Theme Management and use of events,

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Just noticed a few things (yes, the code monster is here)...

- Various places:
  * Incorrect spacing:
     foo=bar
    Should be:
     foo = bar
  * All classes inherited from Qt classes must use Qt naming conventions.

- In openlp/core/lib/plugin.py
   if plugin_helpers != None:
  Better:
   if plugin_helpers is not None:

- In openlp/core/pluginmanager.py
  * You have:
     log.info(u'"Plugin manager loaded')
    It's got a " that shouldn't be there...
  * Method initialise_plugins needs it's documentation updated.

- In openlp/core/ui/alertform.py
  * This whole dialog needs to be redone in the same format as the other dialogs, with multiple inheritance.

review: Needs Fixing
lp:~trb143/openlp/trb143 updated
430. By Tim Bentley

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
Revert changes to Alert Form.

431. By Tim Bentley

Final changes following a revert and removal.
Finish plugin.py
Add getThemes hook to thememanager.py

432. By Tim Bentley

More corrections following revert

433. By Tim Bentley

Fixed duplicate Image plugin loading
Fixed error in Custom Plugin stopping it load

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2009-03-19 17:36:06 +0000
+++ openlp/core/lib/__init__.py 2009-03-22 07:11:05 +0000
@@ -22,6 +22,7 @@
22from settingstab import SettingsTab22from settingstab import SettingsTab
23from mediamanageritem import MediaManagerItem23from mediamanageritem import MediaManagerItem
24from event import Event24from event import Event
25from eventmanager import EventManager
25from xmlrootclass import XmlRootClass26from xmlrootclass import XmlRootClass
26from serviceitem import ServiceItem27from serviceitem import ServiceItem
27from eventreceiver import Receiver28from eventreceiver import Receiver
@@ -32,4 +33,4 @@
3233
33__all__ = ['PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event',34__all__ = ['PluginConfig', 'Plugin', 'SettingsTab', 'MediaManagerItem', 'Event',
34 'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder', 35 'XmlRootClass', 'ServiceItem', 'Receiver', 'OpenLPToolbar', 'SongXMLBuilder',
35 'SongXMLParser']36 'SongXMLParser', 'EventManager']
3637
=== modified file 'openlp/core/lib/event.py'
--- openlp/core/lib/event.py 2008-12-01 09:33:16 +0000
+++ openlp/core/lib/event.py 2009-03-22 07:13:34 +0000
@@ -3,7 +3,7 @@
3"""3"""
4OpenLP - Open Source Lyrics Projection4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2008 Raoul Snyman5Copyright (c) 2008 Raoul Snyman
6Portions copyright (c) 2008 Martin Thompson, Tim Bentley, Scott Guerreri,6Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri,
7 Carsten Tingaard, Jonathan Corwin7 Carsten Tingaard, Jonathan Corwin
88
9This program is free software; you can redistribute it and/or modify it under9This program is free software; you can redistribute it and/or modify it under
@@ -46,6 +46,15 @@
46 """46 """
47 Provides an Event class to encapsulate events within openlp.org.47 Provides an Event class to encapsulate events within openlp.org.
48 """48 """
49
50 def __init__(self, event_type=EventType.Default):49 def __init__(self, event_type=EventType.Default):
51 self.type = event_type50 self.type = event_type
51 self.payload = None
52
53 def get_payload(self):
54 return self.payload
55
56 def set_payload(self, payload):
57 self.payload = payload
58
59 def get_type(self):
60 return self.type
5261
=== added file 'openlp/core/lib/eventmanager.py'
--- openlp/core/lib/eventmanager.py 1970-01-01 00:00:00 +0000
+++ openlp/core/lib/eventmanager.py 2009-03-22 07:11:05 +0000
@@ -0,0 +1,46 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80
3"""
4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2008 Raoul Snyman
6Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri,
7 Carsten Tingaard, Jonathan Corwin
8
9This program is free software; you can redistribute it and/or modify it under
10the terms of the GNU General Public License as published by the Free Software
11Foundation; version 2 of the License.
12
13This program is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15PARTICULAR PURPOSE. See the GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place, Suite 330, Boston, MA 02111-1307 USA
20"""
21import os
22import logging
23
24class EventManager(object):
25 """
26 A mechanism to send events to all registered endpoints
27 the endpoints are registered and listen with a handle_event method
28 the endpoint will decide whether to do somthing with the event or ignore it
29
30 """
31 global log
32 log=logging.getLogger(u'EventManager')
33
34 def __init__(self):
35 self.endpoints=[]
36 log.info(u'Starting')
37
38 def register(self, plugin):
39 log.debug(u'plugin %s registered with EventManager'%plugin)
40 self.endpoints.append(plugin)
41
42 def post_event(self, event):
43 log.debug(u'post event called for event %s'%event.get_type)
44 for point in self.endpoints:
45 point.handle_event(event)
46
047
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2009-03-01 09:13:27 +0000
+++ openlp/core/lib/plugin.py 2009-03-22 07:13:34 +0000
@@ -67,7 +67,7 @@
67 and screen number.67 and screen number.
68 """68 """
6969
70 def __init__(self, name=None, version=None, preview_controller=None, live_controller=None):70 def __init__(self, name=None, version=None, plugin_helpers=None):
71 """71 """
72 This is the constructor for the plugin object. This provides an easy72 This is the constructor for the plugin object. This provides an easy
73 way for descendent plugins to populate common data. This method *must*73 way for descendent plugins to populate common data. This method *must*
@@ -88,8 +88,9 @@
88 self.weight = 088 self.weight = 0
89 # Set up logging89 # Set up logging
90 self.log = logging.getLogger(self.name)90 self.log = logging.getLogger(self.name)
91 self.preview_controller=preview_controller91 if plugin_helpers != None:
92 self.live_controller=live_controller92 self.preview_controller=plugin_helpers[u'preview']
93 self.live_controller=plugin_helpers[u'preview']
93 94
94 def check_pre_conditions(self):95 def check_pre_conditions(self):
95 """96 """
9697
=== modified file 'openlp/core/pluginmanager.py'
--- openlp/core/pluginmanager.py 2009-03-12 20:19:24 +0000
+++ openlp/core/pluginmanager.py 2009-03-22 07:13:34 +0000
@@ -3,7 +3,7 @@
3"""3"""
4OpenLP - Open Source Lyrics Projection4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2008 Raoul Snyman5Copyright (c) 2008 Raoul Snyman
6Portions copyright (c) 2008 Martin Thompson, Tim Bentley,6Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley,
77
8This program is free software; you can redistribute it and/or modify it under8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free Software9the terms of the GNU General Public License as published by the Free Software
@@ -22,7 +22,7 @@
22import sys22import sys
23import logging23import logging
2424
25from openlp.core.lib import Plugin25from openlp.core.lib import Plugin, EventManager
2626
27class PluginManager(object):27class PluginManager(object):
28 """28 """
@@ -30,15 +30,15 @@
30 and executes all the hooks, as and when necessary.30 and executes all the hooks, as and when necessary.
31 """31 """
32 global log32 global log
33 log=logging.getLogger("PluginMgr")33 log=logging.getLogger(u'PluginMgr')
34 log.info("Plugin manager loaded")34 log.info(u'"Plugin manager loaded')
3535
36 def __init__(self, dir):36 def __init__(self, dir):
37 """37 """
38 The constructor for the plugin manager.38 The constructor for the plugin manager.
39 Passes the controllers on to the plugins for them to interact with via their ServiceItems39 Passes the controllers on to the plugins for them to interact with via their ServiceItems
40 """40 """
41 log.info("Plugin manager initing")41 log.info(u'Plugin manager initing')
42 if not dir in sys.path:42 if not dir in sys.path:
43 log.debug("Inserting %s into sys.path", dir)43 log.debug("Inserting %s into sys.path", dir)
44 sys.path.insert(0, dir)44 sys.path.insert(0, dir)
@@ -48,12 +48,11 @@
48 # this has to happen after the UI is sorted self.find_plugins(dir)48 # this has to happen after the UI is sorted self.find_plugins(dir)
49 log.info("Plugin manager done init")49 log.info("Plugin manager done init")
5050
51 def find_plugins(self, dir, preview_controller, live_controller): # xxx shouldn't dir come from self.basepath51 def find_plugins(self, dir, plugin_helpers, eventmanager): # TODO shouldn't dir come from self.basepath
52 """52 """
53 Scan the directory dir for objects inheriting from openlp.plugin53 Scan the directory dir for objects inheriting from openlp.plugin
54 """54 """
55 self.preview_controller=preview_controller55 self.plugin_helpers = plugin_helpers
56 self.live_controller=live_controller
57 startdepth=len(os.path.abspath(dir).split(os.sep))56 startdepth=len(os.path.abspath(dir).split(os.sep))
58 log.debug("find plugins %s at depth %d" %( str(dir), startdepth))57 log.debug("find plugins %s at depth %d" %( str(dir), startdepth))
5958
@@ -80,16 +79,15 @@
80 plugin_objects = []79 plugin_objects = []
81 for p in self.plugin_classes:80 for p in self.plugin_classes:
82 try:81 try:
83 plugin = p(self.preview_controller, self.live_controller)82 plugin = p(self.plugin_helpers)
84 log.debug('loaded plugin' + str(p) + ' with controllers'+str(self.preview_controller)+str(self.live_controller))83 log.debug(u'loaded plugin %s with helpers'%str(p))
85 except TypeError:84 except TypeError:
86 # TODO: need to get rid of this once all plugins are up to date85 log.error(u'loaded plugin %s has no helpers'%str(p))
87 plugin = p()
88 log.debug('loaded plugin' + str(p) + ' with no controllers')
89 log.debug("Plugin="+str(p))86 log.debug("Plugin="+str(p))
90 if plugin.check_pre_conditions():87 if plugin.check_pre_conditions():
91 log.debug("Appending "+str(p))88 log.debug("Appending "+str(p))
92 plugin_objects.append(plugin)89 plugin_objects.append(plugin)
90 eventmanager.register(plugin)
93 self.plugins = sorted(plugin_objects, self.order_by_weight)91 self.plugins = sorted(plugin_objects, self.order_by_weight)
9492
95 def order_by_weight(self, x, y):93 def order_by_weight(self, x, y):
@@ -106,7 +104,7 @@
106 log.debug('Inserting media manager item from %s' % plugin.name)104 log.debug('Inserting media manager item from %s' % plugin.name)
107 mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title)105 mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title)
108 # TODO: These shouldn't be called here...106 # TODO: These shouldn't be called here...
109 plugin.initialise()107 #plugin.initialise()
110108
111 def hook_settings_tabs(self, settingsform=None):109 def hook_settings_tabs(self, settingsform=None):
112 """110 """
@@ -137,5 +135,19 @@
137 for plugin in self.plugins:135 for plugin in self.plugins:
138 plugin.add_export_menu_item(export_menu)136 plugin.add_export_menu_item(export_menu)
139137
140 def hook_handle_event(self, event):138 def hook_handle_event(self, eventmanager):
141 pass139 for plugin in self.plugins:
140 handle_event = plugin.handle_event(None)
141 print plugin, handle_event
142# if settings_tab is not None:
143# log.debug('Inserting settings tab item from %s' % plugin.name)
144# settingsform.addTab(settings_tab)
145# else:
146# log.debug('No settings in %s' % plugin.name)
147 def initialise_plugins(self):
148 """
149 Loop through all the plugins and give them an opportunity to add an item
150 to the export menu.
151 """
152 for plugin in self.plugins:
153 plugin.initialise()
142154
=== modified file 'openlp/core/render.py'
--- openlp/core/render.py 2009-03-12 20:19:24 +0000
+++ openlp/core/render.py 2009-03-22 07:13:34 +0000
@@ -44,8 +44,10 @@
44 self._theme=None44 self._theme=None
45 self._bg_image_filename=None45 self._bg_image_filename=None
46 self._paint=None46 self._paint=None
47
47 def set_debug(self, debug):48 def set_debug(self, debug):
48 self._debug=debug49 self._debug=debug
50
49 def set_theme(self, theme):51 def set_theme(self, theme):
50 self._theme=theme52 self._theme=theme
51 if theme.BackgroundType == 2:53 if theme.BackgroundType == 2:
@@ -56,6 +58,7 @@
56 self._bg_image_filename=filename58 self._bg_image_filename=filename
57 if self._paint is not None:59 if self._paint is not None:
58 self.scale_bg_image()60 self.scale_bg_image()
61
59 def scale_bg_image(self):62 def scale_bg_image(self):
60 assert self._paint63 assert self._paint
61 i=QtGui.QImage(self._bg_image_filename)64 i=QtGui.QImage(self._bg_image_filename)
@@ -81,6 +84,7 @@
81 self._paint=p84 self._paint=p
82 if self._bg_image_filename is not None:85 if self._bg_image_filename is not None:
83 self.scale_bg_image()86 self.scale_bg_image()
87
84 def set_words_openlp(self, words):88 def set_words_openlp(self, words):
85# print "set words openlp", words89# print "set words openlp", words
86 verses=[]90 verses=[]
@@ -95,6 +99,7 @@
95 verses_text.append('\n'.join(v).lstrip()) # remove first \n99 verses_text.append('\n'.join(v).lstrip()) # remove first \n
96100
97 return verses_text101 return verses_text
102
98 def render_screen(self, screennum):103 def render_screen(self, screennum):
99 print "render screen\n", screennum, self.words[screennum]104 print "render screen\n", screennum, self.words[screennum]
100 import time105 import time
@@ -106,6 +111,7 @@
106 def set_text_rectangle(self, rect):111 def set_text_rectangle(self, rect):
107 """ Sets the rectangle within which text should be rendered"""112 """ Sets the rectangle within which text should be rendered"""
108 self._rect=rect113 self._rect=rect
114
109 def _render_background(self):115 def _render_background(self):
110 # xxx may have to prerender to a memdc when set theme is called for use on slow machines116 # xxx may have to prerender to a memdc when set theme is called for use on slow machines
111 # takes 26ms on mijiti's machine!117 # takes 26ms on mijiti's machine!
@@ -149,6 +155,7 @@
149 p.drawPixmap(self.background_offsetx,self.background_offsety, self.img)155 p.drawPixmap(self.background_offsetx,self.background_offsety, self.img)
150 p.end()156 p.end()
151 print "render background done"157 print "render background done"
158
152 def split_set_of_lines(self, lines):159 def split_set_of_lines(self, lines):
153160
154 """Given a list of lines, decide how to split them best if they don't all fit on the screen161 """Given a list of lines, decide how to split them best if they don't all fit on the screen
@@ -212,7 +219,6 @@
212219
213 return retval220 return retval
214221
215
216 def _render_lines(self, lines):222 def _render_lines(self, lines):
217 """render a set of lines according to the theme, return bounding box"""223 """render a set of lines according to the theme, return bounding box"""
218 print "_render_lines", lines224 print "_render_lines", lines
@@ -234,6 +240,7 @@
234 print "render lines DONE"240 print "render lines DONE"
235241
236 return bbox242 return bbox
243
237 def _render_lines_unaligned(self, lines, tlcorner=(0,0)):244 def _render_lines_unaligned(self, lines, tlcorner=(0,0)):
238245
239 """Given a list of lines to render, render each one in turn246 """Given a list of lines to render, render each one in turn
@@ -265,7 +272,6 @@
265272
266 return retval273 return retval
267274
268
269 def _render_single_line(self, line, tlcorner=(0,0)):275 def _render_single_line(self, line, tlcorner=(0,0)):
270276
271 """render a single line of words onto the DC, top left corner277 """render a single line of words onto the DC, top left corner
@@ -402,8 +408,3 @@
402 p.drawText(x,y+metrics.height()-metrics.descent()-1, line)408 p.drawText(x,y+metrics.height()-metrics.descent()-1, line)
403 p.end()409 p.end()
404 return (w, h)410 return (w, h)
405
406
407
408
409
410411
=== modified file 'openlp/core/theme/theme.py'
--- openlp/core/theme/theme.py 2009-03-12 20:19:24 +0000
+++ openlp/core/theme/theme.py 2009-03-22 07:13:34 +0000
@@ -15,7 +15,8 @@
15'''<?xml version="1.0" encoding="iso-8859-1"?>15'''<?xml version="1.0" encoding="iso-8859-1"?>
16<Theme>16<Theme>
17 <Name>BlankStyle</Name>17 <Name>BlankStyle</Name>
18 <BackgroundType>0</BackgroundType>18 <BackgroundMode>1</BackgroundMode>
19 <BackgroundType>0</BackgroundType>
19 <BackgroundParameter1>$000000</BackgroundParameter1>20 <BackgroundParameter1>$000000</BackgroundParameter1>
20 <BackgroundParameter2/>21 <BackgroundParameter2/>
21 <BackgroundParameter3/>22 <BackgroundParameter3/>
@@ -37,6 +38,9 @@
37 attributes:38 attributes:
38 name : theme name39 name : theme name
39 40
41 BackgroundMode : 1 - Transparent
42 1 - Opaque
43
40 BackgroundType : 0 - solid color44 BackgroundType : 0 - solid color
41 1 - gradient color45 1 - gradient color
42 2 - image46 2 - image
4347
=== modified file 'openlp/core/ui/__init__.py'
--- openlp/core/ui/__init__.py 2009-03-01 09:13:27 +0000
+++ openlp/core/ui/__init__.py 2009-03-22 07:11:05 +0000
@@ -27,7 +27,8 @@
27from alertform import AlertForm27from alertform import AlertForm
28from settingsform import SettingsForm28from settingsform import SettingsForm
29from servicemanager import ServiceManager29from servicemanager import ServiceManager
30from thememanager import ThemeManager
30from mainwindow import MainWindow31from mainwindow import MainWindow
3132
32__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm',33__all__ = ['SplashScreen', 'AboutForm', 'SettingsForm',
33 'MainWindow', 'SlideController', 'ServiceManager']34 'MainWindow', 'SlideController', 'ServiceManager', 'ThemeManager']
3435
=== modified file 'openlp/core/ui/alertform.py'
--- openlp/core/ui/alertform.py 2009-03-01 09:13:27 +0000
+++ openlp/core/ui/alertform.py 2009-03-22 07:13:34 +0000
@@ -17,22 +17,32 @@
17this program; if not, write to the Free Software Foundation, Inc., 59 Temple17this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18Place, Suite 330, Boston, MA 02111-1307 USA18Place, Suite 330, Boston, MA 02111-1307 USA
19"""19"""
2020import logging
21from PyQt4 import QtCore, QtGui21from PyQt4 import QtCore, QtGui
22from PyQt4.QtGui import QDialog22from PyQt4.QtGui import QDialog
2323
24from openlp.core import translate24from openlp.core import translate
25from openlp.core.resources import *25from openlp.core.resources import *
26from openlp.core.ui import AlertsTab
27from openlp.core.lib import EventManager, Event
2628
27class AlertForm(QDialog):29class AlertForm(QDialog):
2830 global log
29 def __init__(self, parent=None):31 log=logging.getLogger(u'AlertForm')
32
33 def __init__(self, eventmanager, parent=None):
30 QDialog.__init__(self, parent)34 QDialog.__init__(self, parent)
35 self.alertsTab = AlertsTab()
36 self.eventmanager = eventmanager
31 self.setupUi(self)37 self.setupUi(self)
38 log.info(u'Defined')
39
40 def get_settings_tab(self):
41 return self.alertsTab
3242
33 def setupUi(self, AlertForm):43 def setupUi(self, AlertForm):
34 AlertForm.setObjectName("AlertForm")44 AlertForm.setObjectName("AlertForm")
35 AlertForm.resize(370, 105)45 AlertForm.resize(370, 110)
36 icon = QtGui.QIcon()46 icon = QtGui.QIcon()
37 icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off)47 icon.addPixmap(QtGui.QPixmap(":/icon/openlp.org-icon-32.bmp"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
38 AlertForm.setWindowIcon(icon)48 AlertForm.setWindowIcon(icon)
@@ -56,7 +66,7 @@
56 self.AlertEntryLabel.setSizePolicy(sizePolicy)66 self.AlertEntryLabel.setSizePolicy(sizePolicy)
57 self.AlertEntryLabel.setObjectName("AlertEntryLabel")67 self.AlertEntryLabel.setObjectName("AlertEntryLabel")
58 self.AlertEntryEditItem = QtGui.QLineEdit(self.AlertEntryWidget)68 self.AlertEntryEditItem = QtGui.QLineEdit(self.AlertEntryWidget)
59 self.AlertEntryEditItem.setGeometry(QtCore.QRect(0, 20, 353, 21))69 self.AlertEntryEditItem.setGeometry(QtCore.QRect(0, 20, 353, 26))
60 self.AlertEntryEditItem.setObjectName("AlertEntryEditItem")70 self.AlertEntryEditItem.setObjectName("AlertEntryEditItem")
61 self.AlertFormLayout.addWidget(self.AlertEntryWidget)71 self.AlertFormLayout.addWidget(self.AlertEntryWidget)
62 self.ButtonBoxWidget = QtGui.QWidget(AlertForm)72 self.ButtonBoxWidget = QtGui.QWidget(AlertForm)
@@ -83,20 +93,29 @@
83 self.retranslateUi(AlertForm)93 self.retranslateUi(AlertForm)
84 94
85 QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("clicked()"), AlertForm.close)95 QtCore.QObject.connect(self.CancelButton, QtCore.SIGNAL("clicked()"), AlertForm.close)
96 QtCore.QObject.connect(self.DisplayButton, QtCore.SIGNAL("clicked()"), self.onDisplayClicked)
86 QtCore.QMetaObject.connectSlotsByName(AlertForm)97 QtCore.QMetaObject.connectSlotsByName(AlertForm)
8798
88 def retranslateUi(self, AlertForm):99 def retranslateUi(self, AlertForm):
89 AlertForm.setWindowTitle(translate("AlertForm", "Alert Message"))100 AlertForm.setWindowTitle(translate("AlertForm", u'Alert Message'))
90 self.AlertEntryLabel.setText(translate("AlertForm", "Alert Text:"))101 self.AlertEntryLabel.setText(translate("AlertForm", u'Alert Text:'))
91 self.DisplayButton.setText(translate("AlertForm", "Display"))102 self.DisplayButton.setText(translate("AlertForm", u'Display'))
92 self.CancelButton.setText(translate("AlertForm", "Cancel"))103 self.CancelButton.setText(translate("AlertForm", u'Cancel'))
93104
94# def show(self):105# def show(self):
95# self.AlertForm.show()106# self.AlertForm.show()
96 107
108 def handle_event(self, event):
109 """
110 Handle the event contained in the event object.
111 """
112 log.debug(u'Handle event called with event %s' %event.get_type())
97 113
98 def load_settings(self):114 def load_settings(self):
99 pass115 pass
100 116
101 def save_settings(self):117 def save_settings(self):
102 pass118 pass
119
120 def onDisplayClicked(self):
121 self.eventmanager.post_event(Event())
103122
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2009-03-05 10:52:55 +0000
+++ openlp/core/ui/mainwindow.py 2009-03-22 07:13:34 +0000
@@ -3,7 +3,7 @@
3"""3"""
4OpenLP - Open Source Lyrics Projection4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2008 Raoul Snyman5Copyright (c) 2008 Raoul Snyman
6Portions copyright (c) 2008 Martin Thompson, Tim Bentley,6Portions copyright (c) 2008 - 2009 Martin Thompson, Tim Bentley,
77
8This program is free software; you can redistribute it and/or modify it under8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free Software9the terms of the GNU General Public License as published by the Free Software
@@ -18,54 +18,74 @@
18Place, Suite 330, Boston, MA 02111-1307 USA18Place, Suite 330, Boston, MA 02111-1307 USA
19"""19"""
20import os20import os
2121import logging
22from time import sleep22from time import sleep
23
23from PyQt4 import *24from PyQt4 import *
24from PyQt4 import QtCore, QtGui25from PyQt4 import QtCore, QtGui
2526
26from openlp.core.resources import *27from openlp.core.resources import *
2728
28from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \29from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \
29 SlideController, ServiceManager30 SlideController, ServiceManager, ThemeManager
30from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab31from openlp.core.lib import Plugin, MediaManagerItem, SettingsTab, EventManager
3132
32from openlp.core import PluginManager33from openlp.core import PluginManager
33import logging34
34class MainWindow(object):35class MainWindow(object):
35 global log36 global log
36 log=logging.getLogger("MainWindow")37 log=logging.getLogger(u'MainWindow')
37 log.info("MainWindow loaded")38 log.info(u'MainWindow loaded')
3839
39 def __init__(self):40 def __init__(self):
40 self.main_window = QtGui.QMainWindow()41 self.main_window = QtGui.QMainWindow()
41 self.alert_form = AlertForm()42 self.EventManager = EventManager()
43 self.alert_form = AlertForm(self.EventManager)
42 self.about_form = AboutForm()44 self.about_form = AboutForm()
43 self.settings_form = SettingsForm()45 self.settings_form = SettingsForm()
46 self.settings_form.addTab(self.alert_form.get_settings_tab())
47
44 pluginpath = os.path.split(os.path.abspath(__file__))[0]48 pluginpath = os.path.split(os.path.abspath(__file__))[0]
45 pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins'))49 pluginpath = os.path.abspath(os.path.join(pluginpath, '..', '..','plugins'))
46 self.plugin_manager = PluginManager(pluginpath)50 self.plugin_manager = PluginManager(pluginpath)
51 self.plugin_helpers = {}
52
47 self.setupUi()53 self.setupUi()
4854
49 log.info('')55 log.info(u'Load Plugins')
50 self.plugin_manager.find_plugins(pluginpath, self.PreviewController, self.LiveController)56 self.plugin_helpers[u'preview'] = self.PreviewController
57 self.plugin_helpers[u'live'] = self.LiveController
58 self.plugin_helpers[u'event'] = self.EventManager
59 self.plugin_helpers[u'theme'] = self.ThemeManagerContents # Theme manger
60
61 self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers, self.EventManager)
51 # hook methods have to happen after find_plugins. Find plugins needs the controllers62 # hook methods have to happen after find_plugins. Find plugins needs the controllers
52 # hence the hooks have moved from setupUI() to here63 # hence the hooks have moved from setupUI() to here
5364
54 # Find and insert media manager items65 # Find and insert media manager items
55 log.info("hook media")66 log.info(u'hook media')
56 self.plugin_manager.hook_media_manager(self.MediaToolBox)67 self.plugin_manager.hook_media_manager(self.MediaToolBox)
5768
58 # Find and insert settings tabs69 # Find and insert settings tabs
59 log.info("hook settings")70 log.info(u'hook settings')
60 self.plugin_manager.hook_settings_tabs(self.settings_form)71 self.plugin_manager.hook_settings_tabs(self.settings_form)
6172
62 # Call the hook method to pull in import menus.73 # Call the hook method to pull in import menus.
63 log.info("hook menus")74 log.info(u'hook menus')
64 self.plugin_manager.hook_import_menu(self.FileImportMenu)75 self.plugin_manager.hook_import_menu(self.FileImportMenu)
6576
66 # Call the hook method to pull in export menus.77 # Call the hook method to pull in export menus.
67 self.plugin_manager.hook_import_menu(self.FileExportMenu)78 self.plugin_manager.hook_export_menu(self.FileExportMenu)
6879
80 # Call the initialise method to setup plugins.
81 log.info(u'initialise plugins')
82 self.plugin_manager.initialise_plugins()
83
84 # Register the different UI components with Event Manager
85 self.EventManager.register(self.ServiceManagerContents)
86 self.EventManager.register(self.ThemeManagerContents)
87 self.EventManager.register(self.alert_form)
88
69 def setupUi(self):89 def setupUi(self):
70 self.main_window.setObjectName("main_window")90 self.main_window.setObjectName("main_window")
71 self.main_window.resize(1087, 847)91 self.main_window.resize(1087, 847)
@@ -151,7 +171,7 @@
151 self.MediaManagerLayout.addWidget(self.MediaToolBox)171 self.MediaManagerLayout.addWidget(self.MediaToolBox)
152 self.MediaManagerDock.setWidget(self.MediaManagerContents)172 self.MediaManagerDock.setWidget(self.MediaManagerContents)
153 self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock)173 self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.MediaManagerDock)
154174 #Sevice Manager Defined
155 self.ServiceManagerDock = QtGui.QDockWidget(self.main_window)175 self.ServiceManagerDock = QtGui.QDockWidget(self.main_window)
156 ServiceManagerIcon = QtGui.QIcon()176 ServiceManagerIcon = QtGui.QIcon()
157 ServiceManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_servicemanager.png"),177 ServiceManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_servicemanager.png"),
@@ -162,6 +182,7 @@
162 self.ServiceManagerContents = ServiceManager(self)182 self.ServiceManagerContents = ServiceManager(self)
163 self.ServiceManagerDock.setWidget(self.ServiceManagerContents)183 self.ServiceManagerDock.setWidget(self.ServiceManagerContents)
164 self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock)184 self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ServiceManagerDock)
185 #Theme Manager Defined
165 self.ThemeManagerDock = QtGui.QDockWidget(self.main_window)186 self.ThemeManagerDock = QtGui.QDockWidget(self.main_window)
166 ThemeManagerIcon = QtGui.QIcon()187 ThemeManagerIcon = QtGui.QIcon()
167 ThemeManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_thememanager.png"),188 ThemeManagerIcon.addPixmap(QtGui.QPixmap(":/system/system_thememanager.png"),
@@ -169,41 +190,46 @@
169 self.ThemeManagerDock.setWindowIcon(ThemeManagerIcon)190 self.ThemeManagerDock.setWindowIcon(ThemeManagerIcon)
170 self.ThemeManagerDock.setFloating(False)191 self.ThemeManagerDock.setFloating(False)
171 self.ThemeManagerDock.setObjectName("ThemeManagerDock")192 self.ThemeManagerDock.setObjectName("ThemeManagerDock")
172 self.ThemeManagerContents = QtGui.QWidget()193
173 self.ThemeManagerContents.setObjectName("ThemeManagerContents")194 self.ThemeManagerContents = ThemeManager(self)
174 self.ThemeManagerLayout = QtGui.QVBoxLayout(self.ThemeManagerContents)195
175 self.ThemeManagerLayout.setSpacing(0)196# self.ThemeManagerContents = QtGui.QWidget()
176 self.ThemeManagerLayout.setMargin(0)197# self.ThemeManagerContents.setObjectName("ThemeManagerContents")
177 self.ThemeManagerLayout.setObjectName("ThemeManagerLayout")198# self.ThemeManagerLayout = QtGui.QVBoxLayout(self.ThemeManagerContents)
178 self.ThemeManagerToolbar = QtGui.QToolBar(self.ThemeManagerContents)199# self.ThemeManagerLayout.setSpacing(0)
179 self.ThemeManagerToolbar.setObjectName("ThemeManagerToolbar")200# self.ThemeManagerLayout.setMargin(0)
180 NewThemeIcon = QtGui.QIcon()201# self.ThemeManagerLayout.setObjectName("ThemeManagerLayout")
181 NewThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_new.png"),202# self.ThemeManagerToolbar = QtGui.QToolBar(self.ThemeManagerContents)
182 QtGui.QIcon.Normal, QtGui.QIcon.Off)203# self.ThemeManagerToolbar.setObjectName("ThemeManagerToolbar")
183 self.ThemeNewItem = self.ThemeManagerToolbar.addAction(NewThemeIcon, 'New theme')204# NewThemeIcon = QtGui.QIcon()
184 EditThemeIcon = QtGui.QIcon()205# NewThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_new.png"),
185 EditThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_edit.png"),206# QtGui.QIcon.Normal, QtGui.QIcon.Off)
186 QtGui.QIcon.Normal, QtGui.QIcon.Off)207# self.ThemeNewItem = self.ThemeManagerToolbar.addAction(NewThemeIcon, 'New theme')
187 self.ThemeEditItem = self.ThemeManagerToolbar.addAction(EditThemeIcon, 'Edit theme')208# EditThemeIcon = QtGui.QIcon()
188 DeleteThemeIcon = QtGui.QIcon()209# EditThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_edit.png"),
189 DeleteThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_delete.png"),210# QtGui.QIcon.Normal, QtGui.QIcon.Off)
190 QtGui.QIcon.Normal, QtGui.QIcon.Off)211# self.ThemeEditItem = self.ThemeManagerToolbar.addAction(EditThemeIcon, 'Edit theme')
191 self.ThemeDeleteButton = self.ThemeManagerToolbar.addAction(DeleteThemeIcon, 'Delete theme')212# DeleteThemeIcon = QtGui.QIcon()
192 self.ThemeManagerToolbar.addSeparator()213# DeleteThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_delete.png"),
193 ImportThemeIcon = QtGui.QIcon()214# QtGui.QIcon.Normal, QtGui.QIcon.Off)
194 ImportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_import.png"),215# self.ThemeDeleteButton = self.ThemeManagerToolbar.addAction(DeleteThemeIcon, 'Delete theme')
195 QtGui.QIcon.Normal, QtGui.QIcon.Off)216# self.ThemeManagerToolbar.addSeparator()
196 self.ThemeImportButton = self.ThemeManagerToolbar.addAction(ImportThemeIcon, 'Import theme')217# ImportThemeIcon = QtGui.QIcon()
197 ExportThemeIcon = QtGui.QIcon()218# ImportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_import.png"),
198 ExportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_export.png"),219# QtGui.QIcon.Normal, QtGui.QIcon.Off)
199 QtGui.QIcon.Normal, QtGui.QIcon.Off)220# self.ThemeImportButton = self.ThemeManagerToolbar.addAction(ImportThemeIcon, 'Import theme')
200 self.ThemeExportButton = self.ThemeManagerToolbar.addAction(ExportThemeIcon, 'Export theme')221# ExportThemeIcon = QtGui.QIcon()
201 self.ThemeManagerLayout.addWidget(self.ThemeManagerToolbar)222# ExportThemeIcon.addPixmap(QtGui.QPixmap(":/themes/theme_export.png"),
202 self.ThemeManagerListView = QtGui.QListView(self.ThemeManagerContents)223# QtGui.QIcon.Normal, QtGui.QIcon.Off)
203 self.ThemeManagerListView.setObjectName("ThemeManagerListView")224# self.ThemeExportButton = self.ThemeManagerToolbar.addAction(ExportThemeIcon, 'Export theme')
204 self.ThemeManagerLayout.addWidget(self.ThemeManagerListView)225# self.ThemeManagerLayout.addWidget(self.ThemeManagerToolbar)
226# self.ThemeManagerListView = QtGui.QListView(self.ThemeManagerContents)
227# self.ThemeManagerListView.setObjectName("ThemeManagerListView")
228# self.ThemeManagerLayout.addWidget(self.ThemeManagerListView)
229
205 self.ThemeManagerDock.setWidget(self.ThemeManagerContents)230 self.ThemeManagerDock.setWidget(self.ThemeManagerContents)
206 self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ThemeManagerDock)231 self.main_window.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.ThemeManagerDock)
232
207 self.FileNewItem = QtGui.QAction(self.main_window)233 self.FileNewItem = QtGui.QAction(self.main_window)
208 self.FileNewItem.setIcon(self.ServiceManagerContents.Toolbar.getIconFromTitle("New Service"))234 self.FileNewItem.setIcon(self.ServiceManagerContents.Toolbar.getIconFromTitle("New Service"))
209 self.FileNewItem.setObjectName("FileNewItem")235 self.FileNewItem.setObjectName("FileNewItem")
@@ -359,11 +385,11 @@
359# self.ServiceManagerContents.ThemeComboBox.setItemText(1, QtGui.QApplication.translate("main_window", "Snowy Mountains", None, QtGui.QApplication.UnicodeUTF8))385# self.ServiceManagerContents.ThemeComboBox.setItemText(1, QtGui.QApplication.translate("main_window", "Snowy Mountains", None, QtGui.QApplication.UnicodeUTF8))
360# self.ServiceManagerContents.ThemeComboBox.setItemText(2, QtGui.QApplication.translate("main_window", "Wilderness", None, QtGui.QApplication.UnicodeUTF8))386# self.ServiceManagerContents.ThemeComboBox.setItemText(2, QtGui.QApplication.translate("main_window", "Wilderness", None, QtGui.QApplication.UnicodeUTF8))
361 self.ThemeManagerDock.setWindowTitle(QtGui.QApplication.translate("main_window", "Theme Manager", None, QtGui.QApplication.UnicodeUTF8))387 self.ThemeManagerDock.setWindowTitle(QtGui.QApplication.translate("main_window", "Theme Manager", None, QtGui.QApplication.UnicodeUTF8))
362 self.ThemeNewItem.setText(QtGui.QApplication.translate("main_window", "New Theme", None, QtGui.QApplication.UnicodeUTF8))388# self.ThemeNewItem.setText(QtGui.QApplication.translate("main_window", "New Theme", None, QtGui.QApplication.UnicodeUTF8))
363 self.ThemeEditItem.setText(QtGui.QApplication.translate("main_window", "Edit Theme", None, QtGui.QApplication.UnicodeUTF8))389# self.ThemeEditItem.setText(QtGui.QApplication.translate("main_window", "Edit Theme", None, QtGui.QApplication.UnicodeUTF8))
364 self.ThemeDeleteButton.setText(QtGui.QApplication.translate("main_window", "Delete Theme", None, QtGui.QApplication.UnicodeUTF8))390# self.ThemeDeleteButton.setText(QtGui.QApplication.translate("main_window", "Delete Theme", None, QtGui.QApplication.UnicodeUTF8))
365 self.ThemeImportButton.setText(QtGui.QApplication.translate("main_window", "Import Theme", None, QtGui.QApplication.UnicodeUTF8))391# self.ThemeImportButton.setText(QtGui.QApplication.translate("main_window", "Import Theme", None, QtGui.QApplication.UnicodeUTF8))
366 self.ThemeExportButton.setText(QtGui.QApplication.translate("main_window", "Export Theme", None, QtGui.QApplication.UnicodeUTF8))392# self.ThemeExportButton.setText(QtGui.QApplication.translate("main_window", "Export Theme", None, QtGui.QApplication.UnicodeUTF8))
367 self.FileNewItem.setText(QtGui.QApplication.translate("main_window", "&New", None, QtGui.QApplication.UnicodeUTF8))393 self.FileNewItem.setText(QtGui.QApplication.translate("main_window", "&New", None, QtGui.QApplication.UnicodeUTF8))
368 self.FileNewItem.setToolTip(QtGui.QApplication.translate("main_window", "New Service", None, QtGui.QApplication.UnicodeUTF8))394 self.FileNewItem.setToolTip(QtGui.QApplication.translate("main_window", "New Service", None, QtGui.QApplication.UnicodeUTF8))
369 self.FileNewItem.setStatusTip(QtGui.QApplication.translate("main_window", "Create a new Service", None, QtGui.QApplication.UnicodeUTF8))395 self.FileNewItem.setStatusTip(QtGui.QApplication.translate("main_window", "Create a new Service", None, QtGui.QApplication.UnicodeUTF8))
370396
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2009-03-04 21:56:27 +0000
+++ openlp/core/ui/servicemanager.py 2009-03-22 07:13:34 +0000
@@ -40,7 +40,7 @@
40 Root contains a list of ServiceItems40 Root contains a list of ServiceItems
41 """41 """
42 global log42 global log
43 log=logging.getLogger("ServiceData")43 log=logging.getLogger(u'ServiceData')
44 def __init__(self):44 def __init__(self):
45 QAbstractItemModel.__init__(self)45 QAbstractItemModel.__init__(self)
46 self.items=[]46 self.items=[]
@@ -108,6 +108,8 @@
108 one lump.108 one lump.
109 Also handles the UI tasks of moving things up and down etc.109 Also handles the UI tasks of moving things up and down etc.
110 """110 """
111 global log
112 log=logging.getLogger(u'ServiceManager')
111113
112 def __init__(self, parent):114 def __init__(self, parent):
113 QWidget.__init__(self)115 QWidget.__init__(self)
@@ -163,6 +165,7 @@
163 self.service_data.addRow(item)165 self.service_data.addRow(item)
164 else:166 else:
165 self.service_data.insertRow(row+1, item)167 self.service_data.insertRow(row+1, item)
168
166 def removeServiceItem(self):169 def removeServiceItem(self):
167 """Remove currently selected item"""170 """Remove currently selected item"""
168 pass171 pass
@@ -186,3 +189,10 @@
186 oosfile.write(self.oos_as_text)189 oosfile.write(self.oos_as_text)
187 oosfile.write("# END OOS\n")190 oosfile.write("# END OOS\n")
188 oosfile.close()191 oosfile.close()
192
193 def handle_event(self, event):
194 """
195 Handle the event contained in the event object.
196 """
197 log.debug(u'Handle event called with event %s' %event.get_type())
198
189199
=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py 2009-03-05 20:31:17 +0000
+++ openlp/core/ui/settingsform.py 2009-03-22 07:13:34 +0000
@@ -40,9 +40,6 @@
40 # Themes tab40 # Themes tab
41 self.ThemesTab = ThemesTab()41 self.ThemesTab = ThemesTab()
42 self.addTab(self.ThemesTab)42 self.addTab(self.ThemesTab)
43 # Alerts tab
44 self.AlertsTab = AlertsTab()
45 self.addTab(self.AlertsTab)
4643
47 def addTab(self, tab):44 def addTab(self, tab):
48 log.info(u'Inserting %s' % tab.title())45 log.info(u'Inserting %s' % tab.title())
4946
=== added file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py 1970-01-01 00:00:00 +0000
+++ openlp/core/ui/thememanager.py 2009-03-22 07:11:05 +0000
@@ -0,0 +1,193 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3"""
4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2009 Raoul Snyman
6Portions copyright (c) 2009 Martin Thompson, Tim Bentley,
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free Software
10Foundation; version 2 of the License.
11
12This program is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License along with
17this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18Place, Suite 330, Boston, MA 02111-1307 USA
19"""
20import os
21
22from time import sleep
23from copy import deepcopy
24from PyQt4 import *
25from PyQt4 import QtCore, QtGui
26from PyQt4.QtCore import *
27from PyQt4.QtGui import *
28# from openlp.core.resources import *
29# from openlp.core.ui import AboutForm, AlertForm, SettingsForm, SlideController
30from openlp.core.lib import OpenLPToolbar
31#from openlp.core.lib import ThemeItem
32
33# from openlp.core import PluginManager
34import logging
35
36class ThemeData(QAbstractItemModel):
37 """
38 Tree of items for an order of Theme.
39 Includes methods for reading and writing the contents to an OOS file
40 Root contains a list of ThemeItems
41 """
42 global log
43 log=logging.getLogger(u'ThemeData')
44 def __init__(self):
45 QAbstractItemModel.__init__(self)
46 self.items=[]
47 log.info("Starting")
48 def columnCount(self, parent):
49 return 1; # always only a single column (for now)
50 def rowCount(self, parent):
51 return len(self.items)
52 def insertRow(self, row, Theme_item):
53# self.beginInsertRows(QModelIndex(),row,row)
54 log.info("insert row %d:%s"%(row,Theme_item))
55 self.items.insert(row, Theme_item)
56 log.info("Items: %s" % self.items)
57# self.endInsertRows()
58 def removeRow(self, row):
59 self.beginRemoveRows(QModelIndex(), row,row)
60 self.items.pop(row)
61 self.endRemoveRows()
62 def addRow(self, item):
63 self.insertRow(len(self.items), item)
64
65 def index(self, row, col, parent = QModelIndex()):
66 return self.createIndex(row,col)
67
68 def parent(self, index=QModelIndex()):
69 return QModelIndex() # no children as yet
70 def data(self, index, role):
71 """
72 Called by the Theme manager to draw us in the Theme window
73 """
74 row=index.row()
75 if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
76 return QVariant()
77 item=self.items[row]
78 if role==Qt.DisplayRole:
79 retval= item.pluginname + ":" + item.shortname
80 elif role == Qt.DecorationRole:
81 retval = item.iconic_representation
82 elif role == Qt.ToolTipRole:
83 retval= None
84 else:
85 retval= None
86 if retval == None:
87 retval=QVariant()
88# log.info("Returning"+ str(retval))
89 if type(retval) is not type(QVariant):
90 return QVariant(retval)
91 else:
92 return retval
93
94 def __iter__(self):
95 for i in self.items:
96 yield i
97
98 def item(self, row):
99 log.info("Get Item:%d -> %s" %(row, str(self.items)))
100 return self.items[row]
101
102
103class ThemeManager(QWidget):
104
105 """Manages the orders of Theme. Currently this involves taking
106 text strings from plugins and adding them to an OOS file. In
107 future, it will also handle zipping up all the resources used into
108 one lump.
109 Also handles the UI tasks of moving things up and down etc.
110 """
111 global log
112 log=logging.getLogger(u'ThemeManager')
113
114 def __init__(self, parent):
115 QWidget.__init__(self)
116 self.parent=parent
117 self.Layout = QtGui.QVBoxLayout(self)
118 self.Layout.setSpacing(0)
119 self.Layout.setMargin(0)
120 self.Toolbar = OpenLPToolbar(self)
121 self.Toolbar.addToolbarButton("New Theme", ":/themes/theme_new.png")
122 self.Toolbar.addToolbarButton("Edit Theme", ":/themes/theme_edit.png")
123 self.Toolbar.addToolbarButton("Delete Theme", ":/themes/theme_delete.png")
124 self.Toolbar.addSeparator()
125 self.Toolbar.addToolbarButton("Import Theme", ":/themes/theme_import.png")
126 self.Toolbar.addToolbarButton("Export Theme", ":/themes/theme_export.png")
127 self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
128 self.Toolbar.addAction(self.ThemeWidget)
129
130 self.Layout.addWidget(self.Toolbar)
131
132 self.TreeView = QtGui.QTreeView(self)
133 self.Theme_data=ThemeData()
134 self.TreeView.setModel(self.Theme_data)
135 self.Layout.addWidget(self.TreeView)
136
137# def addThemeItem(self, item):
138# """Adds Theme item"""
139# log.info("addThemeItem")
140# indexes=self.TreeView.selectedIndexes()
141# assert len(indexes) <= 1 # can only have one selected index in this view
142# if indexes == []:
143# log.info("No row")
144# row = None
145# selected_item = None
146# else:
147# row=indexes[0].row()
148# # if currently selected is of correct type, add it to it
149# log.info("row:%d"%row)
150# selected_item=self.Theme_data.item(row)
151# if type(selected_item) == type(item):
152# log.info("Add to existing item")
153# selected_item.add(item)
154# else:
155# log.info("Create new item")
156# if row is None:
157# self.Theme_data.addRow(item)
158# else:
159# self.Theme_data.insertRow(row+1, item)
160#
161# def removeThemeItem(self):
162# """Remove currently selected item"""
163# pass
164#
165# def oos_as_text(self):
166# text=[]
167# log.info( "oos as text")
168# log.info("Data:"+str(self.Theme_data))
169# for i in self.Theme_data:
170# text.append("# " + str(i))
171# text.append(i.get_oos_text())
172# return '\n'.join(text)
173#
174# def write_oos(self, filename):
175# """
176# Write a full OOS file out - iterate over plugins and call their respective methods
177# This format is totally arbitrary testing purposes - something sensible needs to go in here!
178# """
179# oosfile=open(filename, "w")
180# oosfile.write("# BEGIN OOS\n")
181# oosfile.write(self.oos_as_text)
182# oosfile.write("# END OOS\n")
183# oosfile.close()
184
185 def handle_event(self, event):
186 """
187 Handle the event contained in the event object.
188 """
189 log.debug(u'Handle event called with event %s' %event.get_type())
190
191 def get_themes(self):
192 return [u'Theme A', u'Theme B']
193
0194
=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py 2009-03-18 17:19:30 +0000
+++ openlp/plugins/bibles/bibleplugin.py 2009-03-22 07:13:34 +0000
@@ -35,9 +35,9 @@
35 log=logging.getLogger(u'BiblePlugin')35 log=logging.getLogger(u'BiblePlugin')
36 log.info(u'Bible Plugin loaded')36 log.info(u'Bible Plugin loaded')
3737
38 def __init__(self):38 def __init__(self, plugin_helpers):
39 # Call the parent constructor39 # Call the parent constructor
40 Plugin.__init__(self, u'Bibles', u'1.9.0')40 Plugin.__init__(self, u'Bibles', u'1.9.0', plugin_helpers)
41 self.weight = -941 self.weight = -9
42 # Create the plugin icon42 # Create the plugin icon
43 self.icon = QtGui.QIcon()43 self.icon = QtGui.QIcon()
4444
=== modified file 'openlp/plugins/custom/customplugin.py'
--- openlp/plugins/custom/customplugin.py 2009-03-17 05:05:04 +0000
+++ openlp/plugins/custom/customplugin.py 2009-03-22 07:13:34 +0000
@@ -22,7 +22,7 @@
22from PyQt4 import QtCore, QtGui22from PyQt4 import QtCore, QtGui
2323
24from openlp.core.resources import *24from openlp.core.resources import *
25from openlp.core.lib import Plugin25from openlp.core.lib import Plugin, Event
26from forms import EditCustomForm26from forms import EditCustomForm
27from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem, CustomServiceItem27from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem, CustomServiceItem
2828
@@ -32,9 +32,9 @@
32 log=logging.getLogger(u'CustomPlugin')32 log=logging.getLogger(u'CustomPlugin')
33 log.info(u'Custom Plugin loaded')33 log.info(u'Custom Plugin loaded')
3434
35 def __init__(self, preview_controller, live_controller):35 def __init__(self, plugin_helpers):
36 # Call the parent constructor36 # Call the parent constructor
37 Plugin.__init__(self, u'Custom', u'1.9.0', preview_controller, live_controller)37 Plugin.__init__(self, u'Custom', u'1.9.0', plugin_helpers)
38 self.weight = -538 self.weight = -5
39 self.custommanager = CustomManager(self.config)39 self.custommanager = CustomManager(self.config)
40 self.edit_custom_form = EditCustomForm(self.custommanager)40 self.edit_custom_form = EditCustomForm(self.custommanager)
@@ -43,17 +43,16 @@
43 self.icon.addPixmap(QtGui.QPixmap(':/media/media_custom.png'),43 self.icon.addPixmap(QtGui.QPixmap(':/media/media_custom.png'),
44 QtGui.QIcon.Normal, QtGui.QIcon.Off)44 QtGui.QIcon.Normal, QtGui.QIcon.Off)
45 45
46 self.preview_service_item = CustomServiceItem(preview_controller)46 self.preview_service_item = CustomServiceItem(self.preview_controller)
47 self.live_service_item = CustomServiceItem(live_controller) 47 self.live_service_item = CustomServiceItem(self.live_controller)
4848
49 def get_media_manager_item(self):49 def get_media_manager_item(self):
50 # Create the CustomManagerItem object50 # Create the CustomManagerItem object
51 self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')51 self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
52 return self.media_item52 return self.media_item
53 53
54 def get_settings_tab(self):54 def handle_event(self, event):
55 pass55 """
5656 Handle the event contained in the event object.
57 def initialise(self):57 """
58 pass58 log.debug(u'Handle event called with event %s' %event.get_type())
59
6059
=== modified file 'openlp/plugins/images/imageplugin.py'
--- openlp/plugins/images/imageplugin.py 2009-03-18 17:19:30 +0000
+++ openlp/plugins/images/imageplugin.py 2009-03-22 07:13:34 +0000
@@ -31,17 +31,17 @@
31 log=logging.getLogger(u'ImagePlugin')31 log=logging.getLogger(u'ImagePlugin')
32 log.info(u'Image Plugin loaded')32 log.info(u'Image Plugin loaded')
3333
34 def __init__(self, preview_controller, live_controller):34 def __init__(self, plugin_helpers):
35 # Call the parent constructor35 # Call the parent constructor
36 Plugin.__init__(self, u'Images', u'1.9.0', preview_controller, live_controller)36 Plugin.__init__(self, u'Images', u'1.9.0', plugin_helpers)
37 self.weight = -737 self.weight = -7
38 # Create the plugin icon38 # Create the plugin icon
39 self.icon = QtGui.QIcon()39 self.icon = QtGui.QIcon()
40 self.icon.addPixmap(QtGui.QPixmap(':/media/media_image.png'),40 self.icon.addPixmap(QtGui.QPixmap(':/media/media_image.png'),
41 QtGui.QIcon.Normal, QtGui.QIcon.Off)41 QtGui.QIcon.Normal, QtGui.QIcon.Off)
4242
43 self.preview_service_item = ImageServiceItem(preview_controller)43 self.preview_service_item = ImageServiceItem(self.preview_controller)
44 self.live_service_item = ImageServiceItem(live_controller)44 self.live_service_item = ImageServiceItem(self.live_controller)
4545
46 def get_media_manager_item(self):46 def get_media_manager_item(self):
47 # Create the MediaManagerItem object47 # Create the MediaManagerItem object
4848
=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py 2009-03-19 17:31:33 +0000
+++ openlp/plugins/presentations/presentationplugin.py 2009-03-22 07:13:34 +0000
@@ -28,9 +28,9 @@
2828
29class PresentationPlugin(Plugin):29class PresentationPlugin(Plugin):
3030
31 def __init__(self):31 def __init__(self, plugin_helpers):
32 # Call the parent constructor32 # Call the parent constructor
33 Plugin.__init__(self, u'Presentations', u'1.9.0')33 Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers)
34 self.weight = -834 self.weight = -8
35 # Create the plugin icon35 # Create the plugin icon
36 self.icon = QtGui.QIcon()36 self.icon = QtGui.QIcon()
3737
=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py 2009-03-18 17:19:30 +0000
+++ openlp/plugins/songs/songsplugin.py 2009-03-22 07:13:34 +0000
@@ -33,9 +33,9 @@
33 log=logging.getLogger(u'SongsPlugin')33 log=logging.getLogger(u'SongsPlugin')
34 log.info(u'Song Plugin loaded')34 log.info(u'Song Plugin loaded')
3535
36 def __init__(self):36 def __init__(self, plugin_helpers):
37 # Call the parent constructor37 # Call the parent constructor
38 Plugin.__init__(self, u'Songs', u'1.9.0')38 Plugin.__init__(self, u'Songs', u'1.9.0', plugin_helpers)
39 self.weight = -1039 self.weight = -10
40 self.songmanager = SongManager(self.config)40 self.songmanager = SongManager(self.config)
41 self.openlp_import_form = OpenLPImportForm()41 self.openlp_import_form = OpenLPImportForm()
4242
=== modified file 'openlp/plugins/videos/videoplugin.py'
--- openlp/plugins/videos/videoplugin.py 2009-03-19 17:31:33 +0000
+++ openlp/plugins/videos/videoplugin.py 2009-03-22 07:13:34 +0000
@@ -26,9 +26,9 @@
2626
27class VideoPlugin(Plugin):27class VideoPlugin(Plugin):
2828
29 def __init__(self):29 def __init__(self, plugin_helpers):
30 # Call the parent constructor30 # Call the parent constructor
31 Plugin.__init__(self, u'Videos', u'1.9.0')31 Plugin.__init__(self, u'Videos', u'1.9.0', plugin_helpers)
32 self.weight = -632 self.weight = -6
33 # Create the plugin icon33 # Create the plugin icon
34 self.icon = QtGui.QIcon()34 self.icon = QtGui.QIcon()