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

Proposed by Tim Bentley
Status: Merged
Merged at revision: not available
Proposed branch: lp:~trb143/openlp/bugfixes
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~trb143/openlp/bugfixes
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+9946@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

Fix up issues from last merge
Clean up the Renderer some more fixing bugs and removing unneeded code
Clean up Alerts
All Remote Plugin and client (Needs more work but it's a start)

Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve
lp:~trb143/openlp/bugfixes updated
506. By Tim Bentley

Remote pluging
EventManager Fixes
Cleanups
Renderer Performance improvements

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp.pyw'
--- openlp.pyw 2009-08-09 17:58:37 +0000
+++ openlp.pyw 2009-08-10 19:11:54 +0000
@@ -79,4 +79,6 @@
79 Instantiate and run the application.79 Instantiate and run the application.
80 """80 """
81 app = OpenLP(sys.argv)81 app = OpenLP(sys.argv)
82 #import cProfile
83 #cProfile.run("app.run()", "profile.out")
82 app.run()84 app.run()
8385
=== modified file 'openlp/core/lib/event.py'
--- openlp/core/lib/event.py 2009-08-09 17:58:37 +0000
+++ openlp/core/lib/event.py 2009-08-10 19:11:54 +0000
@@ -27,6 +27,7 @@
27 """27 """
28 # "Default" event - a non-event28 # "Default" event - a non-event
29 Default = 029 Default = 0
30 TriggerAlert = 1
30 # General application events31 # General application events
31 Ready = 1032 Ready = 10
32 # Service events33 # Service events
3334
=== modified file 'openlp/core/lib/eventmanager.py'
--- openlp/core/lib/eventmanager.py 2009-08-09 17:58:37 +0000
+++ openlp/core/lib/eventmanager.py 2009-08-10 20:10:20 +0000
@@ -39,12 +39,14 @@
39 """39 """
40 self.endpoints = []40 self.endpoints = []
41 log.info(u'Initialising')41 log.info(u'Initialising')
42 self.processing = False
43 self.events = []
4244
43 def register(self, plugin):45 def register(self, plugin):
44 """46 """
45 Called by plugings who wish to receive event notifications47 Called by plugings who wish to receive event notifications
46 """48 """
47 log.debug(u'plugin %s registered with EventManager', plugin)49 log.debug(u'Class %s registered with EventManager', plugin)
48 self.endpoints.append(plugin)50 self.endpoints.append(plugin)
4951
50 def post_event(self, event):52 def post_event(self, event):
@@ -56,5 +58,12 @@
5658
57 """59 """
58 log.debug(u'post event called for event %s', event.event_type)60 log.debug(u'post event called for event %s', event.event_type)
59 for point in self.endpoints:61 self.events.append(event)
60 point.handle_event(event)62 if not self.processing:
63 self.processing = True
64 while len(self.events) > 0:
65 pEvent = self.events[0]
66 for point in self.endpoints:
67 point.handle_event(pEvent)
68 self.events.remove(pEvent)
69 self.processing = False
6170
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2009-07-18 05:43:50 +0000
+++ openlp/core/lib/plugin.py 2009-08-10 20:10:20 +0000
@@ -243,7 +243,7 @@
243 """243 """
244 pass244 pass
245245
246 def shutdown(self):246 def finalise(self):
247 """247 """
248 Called by the plugin Manager to cleanup things248 Called by the plugin Manager to cleanup things
249 """249 """
250250
=== modified file 'openlp/core/lib/pluginmanager.py'
--- openlp/core/lib/pluginmanager.py 2009-07-18 05:43:50 +0000
+++ openlp/core/lib/pluginmanager.py 2009-08-10 20:10:20 +0000
@@ -174,10 +174,10 @@
174 for plugin in self.plugins:174 for plugin in self.plugins:
175 plugin.initialise()175 plugin.initialise()
176176
177 def cleanup_plugins(self):177 def finalise_plugins(self):
178 """178 """
179 Loop through all the plugins and give them an opportunity to179 Loop through all the plugins and give them an opportunity to
180 clean themselves up180 clean themselves up
181 """181 """
182 for plugin in self.plugins:182 for plugin in self.plugins:
183 plugin.cleanup()183 plugin.finalise()
184184
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py 2009-08-07 17:19:32 +0000
+++ openlp/core/lib/renderer.py 2009-08-09 18:38:44 +0000
@@ -144,6 +144,7 @@
144 The footer of the slide.144 The footer of the slide.
145 """145 """
146 log.debug(u'format_slide - Start')146 log.debug(u'format_slide - Start')
147# print words
147 verses = []148 verses = []
148 words = words.replace(u'\r\n', u'\n')149 words = words.replace(u'\r\n', u'\n')
149 verses_text = words.split(u'\n\n')150 verses_text = words.split(u'\n\n')
@@ -152,8 +153,8 @@
152 lines = verse.split(u'\n')153 lines = verse.split(u'\n')
153 for line in lines:154 for line in lines:
154 text.append(line)155 text.append(line)
155 #print text
156 split_text = self.pre_render_text(text)156 split_text = self.pre_render_text(text)
157# print split_text
157 log.debug(u'format_slide - End')158 log.debug(u'format_slide - End')
158 return split_text159 return split_text
159160
@@ -162,11 +163,10 @@
162 #take the width work out approx how many characters and add 50%163 #take the width work out approx how many characters and add 50%
163 line_width = self._rect.width() - self._right_margin164 line_width = self._rect.width() - self._right_margin
164 #number of lines on a page - adjust for rounding up.165 #number of lines on a page - adjust for rounding up.
165 #print self._rect.height() , metrics.height(), int(self._rect.height() / metrics.height())166# print "Metrics ", line_width
166 page_length = int(self._rect.height() / metrics.height() - 2 ) - 1167 page_length = int(self._rect.height() / metrics.height() - 2 ) - 1
167 ave_line_width = line_width / metrics.averageCharWidth()168 ave_line_width = line_width / metrics.averageCharWidth()
168# print "A", ave_line_width169 ave_line_width = int(ave_line_width + (ave_line_width * 1))
169 ave_line_width = int(ave_line_width + (ave_line_width * 0.5))
170# print "B", ave_line_width170# print "B", ave_line_width
171 split_pages = []171 split_pages = []
172 page = []172 page = []
@@ -174,39 +174,36 @@
174 count = 0174 count = 0
175 for line in text:175 for line in text:
176# print "C", line , len(line)176# print "C", line , len(line)
177 if len(line) > ave_line_width:177 while len(line) > 0:
178 while len(line) > 0:178# print "C1", line , len(line)
179 if len(line) > ave_line_width:
179 pos = line.find(u' ', ave_line_width)180 pos = line.find(u' ', ave_line_width)
180# print "D2", len(line), ave_line_width, pos, line[:pos]
181 split_text = line[:pos]181 split_text = line[:pos]
182# print "E", metrics.width(split_text, -1), line_width182 else:
183 while metrics.width(split_text, -1) > line_width:183 pos = len(line)
184 #Find the next space to the left184 split_text = line
185 pos = line[:pos].rfind(u' ')185# print "E", metrics.width(split_text, -1), line_width
186# print "F", ave_line_width, pos, line[:pos]186 while metrics.width(split_text, -1) > line_width:
187 #no more spaces found187 #Find the next space to the left
188 if pos == 0:188 pos = line[:pos].rfind(u' ')
189 split_text = line189# print "F", pos, line[:pos]
190 while metrics.width(split_text, -1) > line_width:190 #no more spaces found
191 split_text = split_text[:-1]191 if pos == 0:
192 pos = len(split_text)192 split_text = line
193 else:193 while metrics.width(split_text, -1) > line_width:
194 split_text = line[:pos]194 split_text = split_text[:-1]
195 pos = len(split_text)
196 else:
197 split_text = line[:pos]
195# print "F1", split_text, line, pos198# print "F1", split_text, line, pos
196 split_lines.append(split_text)199 split_lines.append(split_text)
197 line = line[pos:]200 line = line[pos:]
198 #Text fits in a line now201 #Text fits in a line now
199 if len(line) <= ave_line_width:202# if len(line) <= line_width:
200 split_lines.append(line)203# split_lines.append(line)
201 line = u''204# line = u''
202# count += 1205# print "G", split_lines
203# if count == 15:206# print "H", line
204# a = c
205# print "G", split_lines
206# print "H", line
207 else:
208 split_lines.append(line)
209 line = u''
210 #print "I", split_lines, page_length207 #print "I", split_lines, page_length
211 for line in split_lines:208 for line in split_lines:
212 page.append(line)209 page.append(line)
@@ -397,26 +394,32 @@
397 # We draw the text to see how big it is and then iterate to make it fit394 # We draw the text to see how big it is and then iterate to make it fit
398 # when we line wrap we do in in the "lyrics" style, so the second line is395 # when we line wrap we do in in the "lyrics" style, so the second line is
399 # right aligned with a "hanging indent"396 # right aligned with a "hanging indent"
400 words = line.split(u' ')397 #print "----------------------------"
401 thisline = u' '.join(words)398 #print line
402 lastword = len(words)399# words = line.split(u' ')
403 lines = []400# thisline = u' '.join(words)
401# lastword = len(words)
402# lines = []
404 maxx = self._rect.width();403 maxx = self._rect.width();
405 maxy = self._rect.height();404 maxy = self._rect.height();
406 while (len(words) > 0):405# while (len(words) > 0):
407 w , h = self._get_extent_and_render(thisline, footer)406# w , h = self._get_extent_and_render(thisline, footer)
408 rhs = w + x407# print "m", w, h, x, maxx
409 if rhs < maxx - self._right_margin:408# rhs = w + x
410 lines.append(thisline)409# if rhs < maxx - self._right_margin:
411 words = words[lastword:]410# lines.append(thisline)
412 thisline = ' '.join(words)411# words = words[lastword:]
413 lastword = len(words)412# thisline = ' '.join(words)
414 else:413# lastword = len(words)
415 lastword -= 1414# else:
416 thisline = ' '.join(words[:lastword])415# lastword -= 1
416# thisline = ' '.join(words[:lastword])
417 lines = []
418 lines.append(line)
417 startx = x419 startx = x
418 starty = y420 starty = y
419 rightextent = None421 rightextent = None
422 #print "inputs", startx, starty, maxx, maxy
420 # dont allow alignment messing with footers423 # dont allow alignment messing with footers
421 if footer:424 if footer:
422 align = 0425 align = 0
@@ -424,6 +427,7 @@
424 else:427 else:
425 align = int(self._theme .display_horizontalAlign)428 align = int(self._theme .display_horizontalAlign)
426 shadow_offset = self._shadow_offset429 shadow_offset = self._shadow_offset
430 #print lines
427 for linenum in range(len(lines)):431 for linenum in range(len(lines)):
428 line = lines[linenum]432 line = lines[linenum]
429 #find out how wide line is433 #find out how wide line is
@@ -534,8 +538,6 @@
534 # setup defaults538 # setup defaults
535 painter = QtGui.QPainter()539 painter = QtGui.QPainter()
536 painter.begin(self._frame)540 painter.begin(self._frame)
537 # 'twould be more efficient to set this once when theme changes
538 # or p changes
539 if footer :541 if footer :
540 font = self.footerFont542 font = self.footerFont
541 else:543 else:
542544
=== modified file 'openlp/core/ui/alertform.py'
--- openlp/core/ui/alertform.py 2009-06-16 18:21:24 +0000
+++ openlp/core/ui/alertform.py 2009-08-10 20:10:20 +0000
@@ -93,11 +93,5 @@
93 self.DisplayButton.setText(translate(u'AlertForm', u'Display'))93 self.DisplayButton.setText(translate(u'AlertForm', u'Display'))
94 self.CancelButton.setText(translate(u'AlertForm', u'Cancel'))94 self.CancelButton.setText(translate(u'AlertForm', u'Cancel'))
9595
96 def load_settings(self):
97 pass
98
99 def save_settings(self):
100 pass
101
102 def onDisplayClicked(self):96 def onDisplayClicked(self):
103 self.parent.mainDisplay.alert(self.parent.settingsForm.AlertsTab, self.AlertEntryEditItem.text())97 self.parent.mainDisplay.displayAlert(self.AlertEntryEditItem.text())
10498
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py 2009-08-09 12:05:54 +0000
+++ openlp/core/ui/maindisplay.py 2009-08-10 20:10:20 +0000
@@ -17,16 +17,19 @@
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
2222
23from time import sleep23from time import sleep
24from openlp.core.lib import translate24from openlp.core.lib import translate, EventManager, Event, EventType
2525
26class MainDisplay(QtGui.QWidget):26class MainDisplay(QtGui.QWidget):
27 """27 """
28 This is the form that is used to display things on the projector.28 This is the form that is used to display things on the projector.
29 """29 """
30 global log
31 log=logging.getLogger(u'MainDisplay')
32 log.info(u'MainDisplay Loaded')
3033
31 def __init__(self, parent, screens):34 def __init__(self, parent, screens):
32 """35 """
@@ -38,7 +41,9 @@
38 ``screens``41 ``screens``
39 The list of screens.42 The list of screens.
40 """43 """
41 QtGui.QWidget.__init__(self, parent)44 log.debug(u'Initilisation started')
45 QtGui.QWidget.__init__(self, None)
46 self.parent = parent
42 self.setWindowTitle(u'OpenLP Display')47 self.setWindowTitle(u'OpenLP Display')
43 self.screens = screens48 self.screens = screens
44 self.layout = QtGui.QVBoxLayout(self)49 self.layout = QtGui.QVBoxLayout(self)
@@ -51,9 +56,15 @@
51 self.displayBlank = False56 self.displayBlank = False
52 self.blankFrame = None57 self.blankFrame = None
53 self.alertactive = False58 self.alertactive = False
54 self.alerttext = u''
55 self.alertTab = None59 self.alertTab = None
56 self.timer_id = 060 self.timer_id = 0
61 # Register the main form as an event consumer.
62 self.parent.EventManager.register(self)
63
64 def handle_event(self, event):
65 log.debug(u'MainDisplay received event %s with payload %s'%(event.event_type, event.payload))
66 if event.event_type == EventType.TriggerAlert:
67 self.displayAlert(event.payload)
5768
58 def setup(self, screenNumber):69 def setup(self, screenNumber):
59 """70 """
@@ -116,42 +127,35 @@
116 self.displayBlank = False127 self.displayBlank = False
117 self.frameView(self.frame)128 self.frameView(self.frame)
118129
119 def alert(self, alertTab, text):130 def displayAlert(self, text=u''):
120 """131 """
121 Called from the Alert Tab to display an alert132 Called from the Alert Tab to display an alert
122 ``alertTab``
123 details from AlertTab
124133
125 ``text``134 ``text``
126 display text135 display text
127 """136 """
128 self.alerttext = text137 alertTab = self.parent.settingsForm.AlertsTab
129 self.alertTab = alertTab
130 if len(text) > 0:
131 self.displayAlert()
132
133 def displayAlert(self):
134 alertframe = QtGui.QPixmap.fromImage(self.frame)138 alertframe = QtGui.QPixmap.fromImage(self.frame)
135 painter = QtGui.QPainter(alertframe)139 painter = QtGui.QPainter(alertframe)
136 top = alertframe.rect().height() * 0.9140 top = alertframe.rect().height() * 0.9
137 painter.fillRect(141 painter.fillRect(
138 QtCore.QRect(0, top, alertframe.rect().width(), alertframe.rect().height() - top),142 QtCore.QRect(0, top, alertframe.rect().width(), alertframe.rect().height() - top),
139 QtGui.QColor(self.alertTab.bg_color))143 QtGui.QColor(alertTab.bg_color))
140 font = QtGui.QFont()144 font = QtGui.QFont()
141 font.setFamily(self.alertTab.font_face)145 font.setFamily(alertTab.font_face)
142 font.setBold(True)146 font.setBold(True)
143 font.setPointSize(40)147 font.setPointSize(40)
144 painter.setFont(font)148 painter.setFont(font)
145 painter.setPen(QtGui.QColor(self.alertTab.font_color))149 painter.setPen(QtGui.QColor(alertTab.font_color))
146 x, y = (0, top)150 x, y = (0, top)
147 metrics = QtGui.QFontMetrics(font)151 metrics = QtGui.QFontMetrics(font)
148 painter.drawText(152 painter.drawText(
149 x, y + metrics.height() - metrics.descent() - 1, self.alerttext)153 x, y + metrics.height() - metrics.descent() - 1, text)
150 painter.end()154 painter.end()
151 self.display.setPixmap(alertframe)155 self.display.setPixmap(alertframe)
152 # check to see if we have a timer running156 # check to see if we have a timer running
153 if self.timer_id == 0:157 if self.timer_id == 0:
154 self.timer_id = self.startTimer(int(self.alertTab.timeout) * 1000)158 self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
155159
156 def timerEvent(self, event):160 def timerEvent(self, event):
157 if event.timerId() == self.timer_id:161 if event.timerId() == self.timer_id:
158162
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2009-08-09 17:58:37 +0000
+++ openlp/core/ui/mainwindow.py 2009-08-10 20:10:20 +0000
@@ -404,8 +404,8 @@
404 self.screenList = screens404 self.screenList = screens
405 self.oosNotSaved = False405 self.oosNotSaved = False
406 self.settingsmanager = SettingsManager(screens)406 self.settingsmanager = SettingsManager(screens)
407 self.mainDisplay = MainDisplay(None, screens)
408 self.EventManager = EventManager()407 self.EventManager = EventManager()
408 self.mainDisplay = MainDisplay(self, screens)
409 self.generalConfig = PluginConfig(u'General')409 self.generalConfig = PluginConfig(u'General')
410 self.alertForm = AlertForm(self)410 self.alertForm = AlertForm(self)
411 self.aboutForm = AboutForm()411 self.aboutForm = AboutForm()
@@ -476,11 +476,11 @@
476 # Call the initialise method to setup plugins.476 # Call the initialise method to setup plugins.
477 log.info(u'initialise plugins')477 log.info(u'initialise plugins')
478 self.plugin_manager.initialise_plugins()478 self.plugin_manager.initialise_plugins()
479 # Register the main form as an event consumer.
480 self.EventManager.register(self)
479 # Once all components are initialised load the Themes481 # Once all components are initialised load the Themes
480 log.info(u'Load Themes')482 log.info(u'Load Themes')
481 self.ThemeManagerContents.loadThemes()483 self.ThemeManagerContents.loadThemes()
482 # Register the main form as an event consumer.
483 self.EventManager.register(self)
484484
485 def getMonitorNumber(self):485 def getMonitorNumber(self):
486 """486 """
@@ -552,7 +552,7 @@
552 def cleanUp(self):552 def cleanUp(self):
553 # Call the cleanup method to shutdown plugins.553 # Call the cleanup method to shutdown plugins.
554 log.info(u'cleanup plugins')554 log.info(u'cleanup plugins')
555 self.plugin_manager.initialise_plugins()555 self.plugin_manager.finalise_plugins()
556556
557 def OosChanged(self, reset=False, oosName=None):557 def OosChanged(self, reset=False, oosName=None):
558 """558 """
559559
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2009-08-09 12:05:54 +0000
+++ openlp/core/ui/slidecontroller.py 2009-08-10 20:10:20 +0000
@@ -65,7 +65,7 @@
65 """65 """
66 self.toolbarList = {}66 self.toolbarList = {}
67 self.previewList = {}67 self.previewList = {}
68 QtGui.QWidget.__init__(self, parent.mainWindow)68 QtGui.QWidget.__init__(self, parent)
69 self.isLive = isLive69 self.isLive = isLive
70 self.parent = parent70 self.parent = parent
71 self.Panel = QtGui.QWidget(parent.ControlSplitter)71 self.Panel = QtGui.QWidget(parent.ControlSplitter)
7272
=== added directory 'openlp/plugins/remotes'
=== added file 'openlp/plugins/remotes/__init__.py'
=== added directory 'openlp/plugins/remotes/lib'
=== added file 'openlp/plugins/remotes/lib/__init__.py'
--- openlp/plugins/remotes/lib/__init__.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/remotes/lib/__init__.py 2009-08-10 18:20:46 +0000
@@ -0,0 +1,21 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3"""
4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2008 Raoul Snyman
6Portions copyright (c) 2008-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"""
20
21from mediaitem import RemoteMediaItem
022
=== added file 'openlp/plugins/remotes/lib/mediaitem.py'
--- openlp/plugins/remotes/lib/mediaitem.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/remotes/lib/mediaitem.py 2009-08-10 18:20:46 +0000
@@ -0,0 +1,215 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3"""
4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2008 Raoul Snyman
6Portions copyright (c) 2008-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 logging
21
22from PyQt4 import QtCore, QtGui
23
24from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, BaseListWithDnD
25
26class RemoteListView(BaseListWithDnD):
27 def __init__(self, parent=None):
28 self.PluginName = u'Remote'
29 BaseListWithDnD.__init__(self, parent)
30
31class RemoteMediaItem(MediaManagerItem):
32 """
33 This is the custom media manager item for Custom Slides.
34 """
35 global log
36 log=logging.getLogger(u'RemoteMediaItem')
37 log.info(u'Remote Media Item loaded')
38
39 def __init__(self, parent, icon, title):
40 MediaManagerItem.__init__(self, parent, icon, title)
41 self.parent = parent
42 self.TranslationContext = u'RemotesPlugin'
43 self.PluginTextShort = u'Remotes'
44 self.ConfigSection = u'Remotes'
45 self.ListViewWithDnD_class = RemoteListView
46 MediaManagerItem.__init__(self, parent, icon, title)
47
48 def initialise(self):
49 pass
50
51 def setupUi(self):
52 # Add a toolbar
53 self.addToolbar()
54# # Create buttons for the toolbar
55# ## New Custom Button ##
56# self.addToolbarButton(
57# translate(u'CustomMediaItem',u'New Custom Item'),
58# translate(u'CustomMediaItem',u'Add a new Custom Item'),
59# u':/custom/custom_new.png', self.onCustomNewClick, u'CustomNewItem')
60# ## Edit Custom Button ##
61# self.addToolbarButton(
62# translate(u'CustomMediaItem',u'Edit Custom Item'),
63# translate(u'CustomMediaItem',u'Edit the selected Custom Item'),
64# u':/custom/custom_edit.png', self.onCustomEditClick, u'CustomEditItem')
65# ## Delete Custom Button ##
66# self.addToolbarButton(
67# translate(u'CustomMediaItem',u'Delete Custom Item'),
68# translate(u'CustomMediaItem',u'Delete the selected Custom Item'),
69# u':/custom/custom_delete.png', self.onCustomDeleteClick, u'CustomDeleteItem')
70# ## Separator Line ##
71# self.addToolbarSeparator()
72# ## Preview Custom Button ##
73# self.addToolbarButton(
74# translate(u'CustomMediaItem',u'Preview Custom Item'),
75# translate(u'CustomMediaItem',u'Preview the selected Custom Item'),
76# u':/system/system_preview.png', self.onCustomPreviewClick, u'CustomPreviewItem')
77# ## Live Custom Button ##
78# self.addToolbarButton(
79# translate(u'CustomMediaItem',u'Go Live'),
80# translate(u'CustomMediaItem', u'Send the selected Custom live'),
81# u':/system/system_live.png', self.onCustomLiveClick, u'CustomLiveItem')
82# ## Add Custom Button ##
83# self.addToolbarButton(
84# translate(u'CustomMediaItem',u'Add Custom To Service'),
85# translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'),
86# u':/system/system_add.png', self.onCustomAddClick, u'CustomAddItem')
87# # Add the Customlist widget
88# self.CustomWidget = QtGui.QWidget(self)
89# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
90# sizePolicy.setHorizontalStretch(0)
91# sizePolicy.setVerticalStretch(0)
92# sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth())
93# self.CustomWidget.setSizePolicy(sizePolicy)
94# self.CustomWidget.setObjectName(u'CustomWidget')
95# # Add the Custom widget to the page layout
96# self.PageLayout.addWidget(self.CustomWidget)
97# self.CustomListView = CustomList()
98# self.CustomListView.setAlternatingRowColors(True)
99# self.CustomListData = TextListData()
100# self.CustomListView.setModel(self.CustomListData)
101# self.CustomListView.setDragEnabled(True)
102# self.PageLayout.addWidget(self.CustomListView)
103# # Signals
104# QtCore.QObject.connect(self.CustomListView,
105# QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onCustomPreviewClick)
106# #define and add the context menu
107# self.CustomListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
108# self.CustomListView.addAction(self.contextMenuAction(self.CustomListView,
109# ':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'),
110# self.onCustomEditClick))
111# self.CustomListView.addAction(self.contextMenuSeparator(self.CustomListView))
112# self.CustomListView.addAction(self.contextMenuAction(
113# self.CustomListView, ':/system/system_preview.png',
114# translate(u'CustomMediaItem',u'&Preview Custom'), self.onCustomPreviewClick))
115# self.CustomListView.addAction(self.contextMenuAction(
116# self.CustomListView, ':/system/system_live.png',
117# translate(u'CustomMediaItem',u'&Show Live'), self.onCustomLiveClick))
118# self.CustomListView.addAction(self.contextMenuAction(
119# self.CustomListView, ':/system/system_add.png',
120# translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick))
121
122# def retranslateUi(self):
123# self.ClearTextButton.setText(translate(u'CustomMediaItem', u'Clear'))
124# self.SearchTextButton.setText(translate(u'CustomMediaItem', u'Search'))
125
126# def initialise(self):
127# self.loadCustomList(self.parent.custommanager.get_all_slides())
128#
129# def loadCustomList(self, list):
130# self.CustomListData.resetStore()
131# for CustomSlide in list:
132# self.CustomListData.addRow(CustomSlide.id,CustomSlide.title)
133#
134# def onClearTextButtonClick(self):
135# """
136# Clear the search text.
137# """
138# self.SearchTextEdit.clear()
139#
140# def onSearchTextEditChanged(self, text):
141# # only search if > 3 characters
142# if len(text) > 3:
143# self.onSearchTextButtonClick()
144#
145# def onSearchTextButtonClick(self):
146# search_keywords = str(self.SearchTextEdit.displayText())
147# search_results = []
148# search_type = self.SearchTypeComboBox.currentText()
149# search_results = self.Custommanager.search_Custom_lyrics(search_keywords)
150# self._display_results(search_results)
151#
152# def onCustomNewClick(self):
153# self.parent.edit_custom_form.loadCustom(0)
154# self.parent.edit_custom_form.exec_()
155# self.initialise()
156#
157# def onCustomEditClick(self):
158# indexes = self.CustomListView.selectedIndexes()
159# for index in indexes:
160# self.parent.edit_custom_form.loadCustom(self.CustomListData.getId(index))
161# self.parent.edit_custom_form.exec_()
162# self.initialise()
163#
164# def onCustomDeleteClick(self):
165# indexes = self.CustomListView.selectedIndexes()
166# for index in indexes:
167# id = self.CustomListData.getId(index)
168# self.parent.custommanager.delete_custom(id)
169# self.CustomListData.deleteRow(index)
170#
171# def onCustomPreviewClick(self):
172# log.debug(u'Custom Preview Requested')
173# service_item = ServiceItem(self.parent)
174# service_item.addIcon(u':/media/media_song.png')
175# self.generateSlideData(service_item)
176# self.parent.preview_controller.addServiceItem(service_item)
177#
178# def onCustomLiveClick(self):
179# log.debug(u'Custom Live Requested')
180# service_item = ServiceItem(self.parent)
181# service_item.addIcon(u':/media/media_song.png')
182# self.generateSlideData(service_item)
183# self.parent.live_controller.addServiceItem(service_item)
184#
185# def onCustomAddClick(self):
186# log.debug(u'Custom Add Requested')
187# service_item = ServiceItem(self.parent)
188# service_item.addIcon(u':/media/media_song.png')
189# self.generateSlideData(service_item)
190# self.parent.service_manager.addServiceItem(service_item)
191#
192# def generateSlideData(self, service_item):
193# raw_slides =[]
194# raw_footer = []
195# slide = None
196# theme = None
197# indexes = self.CustomListView.selectedIndexes()
198# for index in indexes:
199# id = self.CustomListData.getId(index)
200# customSlide = self.parent.custommanager.get_custom(id)
201# title = customSlide.title
202# credit = customSlide.credits
203# theme = customSlide.theme_name
204# if len(theme) is not 0 :
205# service_item.theme = theme
206# songXML=SongXMLParser(customSlide.text)
207# verseList = songXML.get_verses()
208# for verse in verseList:
209# raw_slides.append(verse[1])
210# raw_footer.append(title + u' '+ credit)
211# if theme is not None:
212# service_item.title = title
213# for slide in raw_slides:
214# service_item.add_from_text(slide[:30], slide)
215# service_item.raw_footer = raw_footer
0216
=== added file 'openlp/plugins/remotes/remoteclient-cli.py'
--- openlp/plugins/remotes/remoteclient-cli.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/remotes/remoteclient-cli.py 2009-08-10 18:20:46 +0000
@@ -0,0 +1,54 @@
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
4"""
5OpenLP - Open Source Lyrics Projection
6Copyright (c) 2008 Raoul Snyman
7Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley,
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 sys
22import logging
23from PyQt4 import QtNetwork, QtGui, QtCore
24
25logging.basicConfig(level=logging.DEBUG,
26 format=u'%(asctime)s:%(msecs)3d %(name)-15s %(levelname)-8s %(message)s',
27 datefmt=u'%m-%d %H:%M:%S', filename=u'openlp-cli.log', filemode=u'w')
28
29class OpenLPRemoteCli():
30 global log
31 log = logging.getLogger(u'OpenLP Remote Application')
32 log.info(u'Application Loaded')
33
34 def __init__(self, argv):
35 log.debug(u'Initialising')
36 try:
37 self.tcpsocket = QtNetwork.QUdpSocket()
38 self.sendData()
39 except:
40 log.error(u'Errow thrown %s', sys.exc_info()[1])
41 print u'Errow thrown ', sys.exc_info()[1]
42
43 def sendData(self):
44 text = "Alert:Wave to Zak, Superfly"
45 print self.tcpsocket
46 print self.tcpsocket.writeDatagram(text, QtNetwork.QHostAddress(QtNetwork.QHostAddress.Broadcast), 4316)
47
48 def run(self):
49 pass
50
51if __name__ == u'__main__':
52 app = OpenLPRemoteCli(sys.argv)
53 app.run()
54
055
=== added file 'openlp/plugins/remotes/remoteplugin.py'
--- openlp/plugins/remotes/remoteplugin.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/remotes/remoteplugin.py 2009-08-10 20:10:20 +0000
@@ -0,0 +1,56 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
3"""
4OpenLP - Open Source Lyrics Projection
5Copyright (c) 2008 Raoul Snyman
6Portions copyright (c) 2008-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 logging
21import sys
22
23from PyQt4 import QtNetwork, QtGui, QtCore
24
25from openlp.core.lib import Plugin, Event, EventType
26
27class RemotesPlugin(Plugin):
28
29 global log
30 log = logging.getLogger(u'RemotesPlugin')
31 log.info(u'Remote Plugin loaded')
32
33 def __init__(self, plugin_helpers):
34 # Call the parent constructor
35 Plugin.__init__(self, u'Remotes', u'1.9.0', plugin_helpers)
36 self.weight = -1
37 self.server = QtNetwork.QUdpSocket()
38 self.server.bind(4316)
39 QtCore.QObject.connect(self.server,
40 QtCore.SIGNAL(u'readyRead()'), self.readData)
41
42 def readData(self):
43 while self.server.hasPendingDatagrams():
44 datagram, host, port = self.server.readDatagram(self.server.pendingDatagramSize())
45 self.handle_datagram(datagram)
46
47 def handle_datagram(self, datagram):
48 pos = datagram.find(u':')
49 event = unicode(datagram[:pos])
50 payyload = unicode(datagram[pos + 1:])
51 if event == u'Alert':
52 self.event_manager.post_event(Event(EventType.TriggerAlert, payyload))
53
54
55
56