From 14837d6efa3841df4128b3cf606a99471bf18a3c Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 12 Dec 2009 09:24:12 +0000 Subject: [PATCH 1/8] Fix up preview in 1024x764 so looks sensible --- openlp/core/ui/slidecontroller.py | 2 +- openlp/plugins/bibles/lib/bibleOSISimpl.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 21c0e4d2a..3fa0bf557 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -246,7 +246,7 @@ class SlideController(QtGui.QWidget): self.SlidePreview.sizePolicy().hasHeightForWidth()) self.SlidePreview.setSizePolicy(sizePolicy) self.SlidePreview.setFixedSize( - QtCore.QSize(self.settingsmanager.slidecontroller_image, 225)) + QtCore.QSize(self.settingsmanager.slidecontroller_image,self.settingsmanager.slidecontroller_image / 1.3 )) self.SlidePreview.setFrameShape(QtGui.QFrame.Box) self.SlidePreview.setFrameShadow(QtGui.QFrame.Plain) self.SlidePreview.setLineWidth(1) diff --git a/openlp/plugins/bibles/lib/bibleOSISimpl.py b/openlp/plugins/bibles/lib/bibleOSISimpl.py index 089649b89..276846c16 100644 --- a/openlp/plugins/bibles/lib/bibleOSISimpl.py +++ b/openlp/plugins/bibles/lib/bibleOSISimpl.py @@ -28,6 +28,7 @@ import os.path import logging import chardet import codecs +import time from PyQt4 import QtCore @@ -174,12 +175,17 @@ class BibleOSISImpl(): testament) dialogobject.incrementProgressBar( self.booksOfBible[p[0]]) + Receiver.send_message(u'process_events') + #minor delay to get the events processed + time.sleep(0.1) count = 0 self.bibledb.add_verse(book.id, p[1], p[2], text) count += 1 #Every 3 verses repaint the screen - if count % 3 == 0: + if count % 30 == 0: Receiver.send_message(u'process_events') + #minor delay to get the events processed + time.sleep(0.1) count = 0 except: log.exception(u'Loading bible from OSIS file failed') From f7f0f1814277a03b782f66b03095c1b30110ff8d Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 13 Dec 2009 08:28:51 +0000 Subject: [PATCH 2/8] Fix bug with Verse Tags being lost when expanding or contracting the verse edit list --- openlp/plugins/songs/forms/editsongform.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index dc5b522b4..3d04c7cb1 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -336,14 +336,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): data = u'%s:%s' %(verse, subVerse) item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data)) item.setText(afterText) - #number of lines has change + #number of lines has change so repaint the list moving the data if len(tempText.split(u'\n')) != len(afterText.split(u'\n')): tempList = {} + tempId = {} for row in range(0, self.VerseListWidget.count()): tempList[row] = self.VerseListWidget.item(row).text() + tempId[row] = self.VerseListWidget.item(row).\ + data(QtCore.Qt.UserRole) self.VerseListWidget.clear() for row in range (0, len(tempList)): - self.VerseListWidget.addItem(tempList[row]) + item = QtGui.QListWidgetItem(tempList[row]) + item.setData(QtCore.Qt.UserRole, tempId[row]) + self.VerseListWidget.addItem(item) self.VerseListWidget.repaint() self.VerseEditButton.setEnabled(False) self.VerseDeleteButton.setEnabled(False) From d676430ffadbec1cc86ff3e67d4784e7387c01a1 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 13 Dec 2009 08:57:58 +0000 Subject: [PATCH 3/8] Add option to Custom to suppress the footer. Not always needed for Copyright. Default Required --- openlp/plugins/custom/customplugin.py | 5 +- openlp/plugins/custom/lib/__init__.py | 1 + openlp/plugins/custom/lib/customtab.py | 74 ++++++++++++++++++++++++++ openlp/plugins/custom/lib/mediaitem.py | 8 ++- 4 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 openlp/plugins/custom/lib/customtab.py diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index a1828efa3..8cb90deaf 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -27,7 +27,7 @@ import logging from forms import EditCustomForm from openlp.core.lib import Plugin, build_icon -from openlp.plugins.custom.lib import CustomManager, CustomMediaItem +from openlp.plugins.custom.lib import CustomManager, CustomMediaItem, CustomTab class CustomPlugin(Plugin): @@ -51,6 +51,9 @@ class CustomPlugin(Plugin): self.edit_custom_form = EditCustomForm(self.custommanager) self.icon = build_icon(u':/media/media_custom.png') + def get_settings_tab(self): + return CustomTab(self.name) + def get_media_manager_item(self): # Create the CustomManagerItem object return CustomMediaItem(self, self.icon, self.name) diff --git a/openlp/plugins/custom/lib/__init__.py b/openlp/plugins/custom/lib/__init__.py index f780fc6b8..8141d7f58 100644 --- a/openlp/plugins/custom/lib/__init__.py +++ b/openlp/plugins/custom/lib/__init__.py @@ -25,3 +25,4 @@ from manager import CustomManager from mediaitem import CustomMediaItem +from customtab import CustomTab diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py new file mode 100644 index 000000000..c4e0c6ee9 --- /dev/null +++ b/openlp/plugins/custom/lib/customtab.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2009 Raoul Snyman # +# Portions copyright (c) 2008-2009 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Maikel Stuivenberg, Martin Thompson, Jon Tibble, # +# Carsten Tinggaard # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import SettingsTab, str_to_bool + +class CustomTab(SettingsTab): + """ + CustomTab is the Custom settings tab in the settings dialog. + """ + def __init__(self, title, section=None): + SettingsTab.__init__(self, title, section) + + def setupUi(self): + self.setObjectName(u'CustomTab') + self.tabTitleVisible = self.trUtf8('Custom') + self.CustomLayout = QtGui.QFormLayout(self) + self.CustomLayout.setObjectName(u'CustomLayout') + self.CustomModeGroupBox = QtGui.QGroupBox(self) + self.CustomModeGroupBox.setObjectName(u'CustomModeGroupBox') + self.CustomModeLayout = QtGui.QVBoxLayout(self.CustomModeGroupBox) + self.CustomModeLayout.setSpacing(8) + self.CustomModeLayout.setMargin(8) + self.CustomModeLayout.setObjectName(u'CustomModeLayout') + self.DisplayFooterCheckBox = QtGui.QCheckBox(self.CustomModeGroupBox) + self.DisplayFooterCheckBox.setObjectName(u'DisplayFooterCheckBox') + self.CustomModeLayout.addWidget(self.DisplayFooterCheckBox) + self.CustomLayout.setWidget( + 0, QtGui.QFormLayout.LabelRole, self.CustomModeGroupBox) + QtCore.QObject.connect(self.DisplayFooterCheckBox, + QtCore.SIGNAL(u'stateChanged(int)'), + self.onDisplayFooterCheckBoxChanged) + + def retranslateUi(self): + self.CustomModeGroupBox.setTitle(self.trUtf8('Custom Display')) + self.DisplayFooterCheckBox.setText( + self.trUtf8('Suppress display of footer:')) + + def onDisplayFooterCheckBoxChanged(self, check_state): + self.displayFooter = False + # we have a set value convert to True/False + if check_state == QtCore.Qt.Checked: + self.displayFooter = True + + def load(self): + self.displayFooter = str_to_bool( + self.config.get_config(u'display footer', True)) + self.DisplayFooterCheckBox.setChecked(self.displayFooter) + + def save(self): + self.config.set_config(u'display footer', unicode(self.displayFooter)) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 995278f98..989e9ecf4 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -27,7 +27,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD, Receiver +from openlp.core.lib import MediaManagerItem, SongXMLParser, BaseListWithDnD,\ +Receiver, str_to_bool class CustomListView(BaseListWithDnD): def __init__(self, parent=None): @@ -155,9 +156,12 @@ class CustomMediaItem(MediaManagerItem): verseList = songXML.get_verses() for verse in verseList: raw_slides.append(verse[1]) - raw_footer.append(title + u' '+ credit) service_item.title = title for slide in raw_slides: service_item.add_from_text(slide[:30], slide) + if str_to_bool(self.parent.config.get_config(u'display footer', True)): + raw_footer.append(title + u' '+ credit) + else: + raw_footer.append(u'') service_item.raw_footer = raw_footer return True From fe959f451f546d98f28443bb25b4cfa2886b19e4 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 13 Dec 2009 14:20:24 +0000 Subject: [PATCH 4/8] Fix up Alert generation (needs to be tested on duel screen) --- openlp/core/ui/alertform.py | 2 +- openlp/core/ui/maindisplay.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/alertform.py b/openlp/core/ui/alertform.py index fd4380700..96dc88dc5 100644 --- a/openlp/core/ui/alertform.py +++ b/openlp/core/ui/alertform.py @@ -99,4 +99,4 @@ class AlertForm(QtGui.QDialog): self.CancelButton.setText(self.trUtf8('Cancel')) def onDisplayClicked(self): - self.parent.mainDisplay.displayAlert(self.AlertEntryEditItem.text()) + self.parent.mainDisplay.displayAlert(unicode(self.AlertEntryEditItem.text())) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 7a621a8ae..f63dd373d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -214,6 +214,7 @@ class MainDisplay(DisplayWidget): self.setVisible(True) self.showFullScreen() self.frame = frame + print type(self.frame) def blankDisplay(self, blanked=True): if blanked: @@ -234,8 +235,12 @@ class MainDisplay(DisplayWidget): ``text`` display text """ + log.debug(u'display alert called %s' % text) alertTab = self.parent.settingsForm.AlertsTab - alertframe = QtGui.QPixmap.fromImage(self.frame) + if isinstance(self.frame, QtGui.QImage): + alertframe = QtGui.QPixmap.fromImage(self.frame) + else: + alertframe = QtGui.QPixmap.fromImage(self.frame[u'main']) painter = QtGui.QPainter(alertframe) top = alertframe.rect().height() * 0.9 painter.fillRect( @@ -261,7 +266,10 @@ class MainDisplay(DisplayWidget): def timerEvent(self, event): if event.timerId() == self.timer_id: - self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame)) + if isinstance(self.frame, QtGui.QImage): + self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame)) + else: + self.display.setPixmap(QtGui.QPixmap.fromImage(self.frame[u'main'])) self.killTimer(self.timer_id) self.timer_id = 0 From be3fecac2095eb5ae54289bc9d3813dae8a6a6b7 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 13 Dec 2009 22:08:10 +0000 Subject: [PATCH 5/8] Sort out Presentation plugin Handler * Allow 2 presentations to work at same time * Sort out live / preview issues to stop cross messaging --- openlp/core/lib/mediamanageritem.py | 6 +- openlp/core/lib/serviceitem.py | 2 + openlp/core/ui/maindisplay.py | 1 - openlp/core/ui/slidecontroller.py | 53 ++-- .../presentations/lib/messagelistener.py | 253 ++++++++++++------ 5 files changed, 210 insertions(+), 105 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 5ec87b1bc..3652bae20 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -357,7 +357,7 @@ class MediaManagerItem(QtGui.QWidget): self.trUtf8('No items selected...'), self.trUtf8('You must select one or more items')) else: - log.debug(self.PluginNameShort + u' Preview Requested') + log.debug(self.PluginNameShort + u' Preview requested') service_item = self.buildServiceItem() if service_item: service_item.fromPlugin = True @@ -369,7 +369,7 @@ class MediaManagerItem(QtGui.QWidget): self.trUtf8('No items selected...'), self.trUtf8('You must select one or more items')) else: - log.debug(self.PluginNameShort + u' Live Requested') + log.debug(self.PluginNameShort + u' Live requested') service_item = self.buildServiceItem() if service_item: service_item.fromPlugin = True @@ -381,7 +381,7 @@ class MediaManagerItem(QtGui.QWidget): self.trUtf8('No items selected...'), self.trUtf8('You must select one or more items')) else: - log.debug(self.PluginNameShort + u' Add Requested') + log.debug(self.PluginNameShort + u' Add requested') service_item = self.buildServiceItem() if service_item: service_item.fromPlugin = False diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index f8fe7d539..d1afa556b 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -112,6 +112,8 @@ class ServiceItem(object): for slide in self._raw_frames: slide[u'image'] = \ self.RenderManager.resize_image(slide[u'image']) + elif self.service_item_type == ServiceItemType.Command: + pass else: log.error(u'Invalid value renderer :%s' % self.service_item_type) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index f63dd373d..edbf41de8 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -214,7 +214,6 @@ class MainDisplay(DisplayWidget): self.setVisible(True) self.showFullScreen() self.frame = frame - print type(self.frame) def blankDisplay(self, blanked=True): if blanked: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 3fa0bf557..4b599a3e0 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -390,14 +390,12 @@ class SlideController(QtGui.QWidget): #If old item was a command tell it to stop if self.serviceItem and self.serviceItem.is_command(): self.onMediaStop() - if item.is_command(): - if self.isLive: - Receiver.send_message(u'%s_start' % item.name.lower(), \ - [item.title, item.service_item_path, - item.get_frame_title(), slideno, self.isLive]) - else: - if item.is_media(): - self.onMediaStart(item) + if item.is_media(): + self.onMediaStart(item) + elif item.is_command(): + Receiver.send_message(u'%s_start' % item.name.lower(), \ + [item.title, item.service_item_path, + item.get_frame_title(), slideno, self.isLive]) self.displayServiceManagerItems(item, slideno) def displayServiceManagerItems(self, serviceItem, slideno): @@ -475,7 +473,8 @@ class SlideController(QtGui.QWidget): if not self.serviceItem: return if self.serviceItem.is_command(): - Receiver.send_message(u'%s_first'% self.serviceItem.name.lower()) + Receiver.send_message(u'%s_first'% \ + self.serviceItem.name.lower(), self.isLive) self.updatePreview() else: self.PreviewListWidget.selectRow(0) @@ -504,17 +503,20 @@ class SlideController(QtGui.QWidget): row = self.PreviewListWidget.currentRow() self.selectedRow = 0 if row > -1 and row < self.PreviewListWidget.rowCount(): - if self.serviceItem.is_command(): - Receiver.send_message(u'%s_slide'% self.serviceItem.name.lower(), [row]) - if self.isLive: - self.updatePreview() + if self.serviceItem.is_command() and self.isLive: + Receiver.send_message(u'%s_slide'% \ + self.serviceItem.name.lower(), u'%s:%s' % (row, self.isLive)) + self.updatePreview() else: before = time.time() frame = self.serviceItem.get_rendered_frame(row) if isinstance(frame, QtGui.QImage): self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame)) else: - self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame[u'main'])) + if isinstance(frame[u'main'], basestring): + self.SlidePreview.setPixmap(QtGui.QPixmap(frame[u'main'])) + else: + self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame[u'main'])) log.log(15, u'Slide Rendering took %4s' % (time.time() - before)) if self.isLive: self.parent.mainDisplay.frameView(frame, True) @@ -553,7 +555,8 @@ class SlideController(QtGui.QWidget): if not self.serviceItem: return if self.serviceItem.is_command(): - Receiver.send_message(u'%s_next'% self.serviceItem.name.lower()) + Receiver.send_message(u'%s_next' % \ + self.serviceItem.name.lower(), self.isLive) self.updatePreview() else: row = self.PreviewListWidget.currentRow() + 1 @@ -570,7 +573,7 @@ class SlideController(QtGui.QWidget): return if self.serviceItem.is_command(): Receiver.send_message( - u'%s_previous'% self.serviceItem.name.lower()) + u'%s_previous'% self.serviceItem.name.lower(), self.isLive) self.updatePreview() else: row = self.PreviewListWidget.currentRow() - 1 @@ -586,7 +589,8 @@ class SlideController(QtGui.QWidget): if not self.serviceItem: return if self.serviceItem.is_command(): - Receiver.send_message(u'%s_last'% self.serviceItem.name.lower()) + Receiver.send_message(u'%s_last' % \ + self.serviceItem.name.lower(), self.isLive) self.updatePreview() else: self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1) @@ -628,11 +632,16 @@ class SlideController(QtGui.QWidget): self.serviceItem, row) def onMediaStart(self, item): - self.mediaObject.stop() - self.mediaObject.clearQueue() - file = os.path.join(item.service_item_path, item.get_frame_title()) - self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) - self.onMediaPlay() + if self.isLive: + Receiver.send_message(u'%s_start' % item.name.lower(), \ + [item.title, item.service_item_path, + item.get_frame_title(), slideno, self.isLive]) + else: + self.mediaObject.stop() + self.mediaObject.clearQueue() + file = os.path.join(item.service_item_path, item.get_frame_title()) + self.mediaObject.setCurrentSource(Phonon.MediaSource(file)) + self.onMediaPlay() def onMediaPause(self): if self.isLive: diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 833cac360..9e9a0047c 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -30,6 +30,124 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver +class Controller(object): + """ + This is the Presentation listener who acts on events from the slide + controller and passes the messages on the the correct presentation handlers + """ + global log + log = logging.getLogger(u'Controller') + log.info(u'Controller loaded') + + def __init__(self, live): + self.isLive = live + log.info(u'%s controller loaded' % live) + + def addHandler(self, controller, file): + log.debug(u'Live = %s, addHandler %s' % (self.isLive, file)) + self.controller = controller + if self.controller.is_loaded(): + self.shutdown(None) + self.controller.load_presentation(file) + if self.isLive: + self.controller.start_presentation() + Receiver.send_message(u'live_slide_hide') + self.controller.slidenumber = 0 + + def activate(self): + log.debug(u'Live = %s, activate' % self.isLive) + if self.controller.is_active(): + return + if not self.controller.is_loaded(): + self.controller.load_presentation(self.controller.filepath) + if self.isLive: + self.controller.start_presentation() + if self.controller.slidenumber > 1: + self.controller.goto_slide(self.controller.slidenumber) + + def slide(self, message): + log.debug(u'Live = %s, slide' % self.isLive) + print "slide ", message + if not self.isLive: + return + self.activate() + if message: + self.controller.goto_slide(message[0] + 1) + self.controller.poll_slidenumber(self.isLive) + + def first(self, message): + """ + Based on the handler passed at startup triggers the first slide + """ + log.debug(u'Live = %s, first' % self.isLive) + print "first ", message + if not self.isLive: + return + self.activate() + self.controller.start_presentation() + self.controller.poll_slidenumber(self.isLive) + + def last(self, message): + """ + Based on the handler passed at startup triggers the first slide + """ + log.debug(u'Live = %s, last' % self.isLive) + print "last ", message + if not self.isLive: + return + self.activate() + self.controller.goto_slide(self.controller.get_slide_count()) + self.controller.poll_slidenumber(self.isLive) + + def next(self, message): + """ + Based on the handler passed at startup triggers the next slide event + """ + log.debug(u'Live = %s, next' % self.isLive) + print "next ", message + if not self.isLive: + return + self.activate() + self.controller.next_step() + self.controller.poll_slidenumber(self.isLive) + + def previous(self, message): + """ + Based on the handler passed at startup triggers the previous slide event + """ + log.debug(u'Live = %s, previous' % self.isLive) + if not self.isLive: + return + print "previous ", message + self.activate() + self.controller.previous_step() + self.controller.poll_slidenumber(self.isLive) + + def shutdown(self, message): + """ + Based on the handler passed at startup triggers slide show to shut down + """ + log.debug(u'Live = %s, shutdown' % self.isLive) + self.controller.close_presentation() + self.controller.slidenumber = 0 + #self.timer.stop() + + def blank(self): + if not self.isLive: + return + if not self.controller.is_loaded(): + return + if not self.controller.is_active(): + return + self.controller.blank_screen() + + def unblank(self): + if not self.is_live: + return + self.activate() + self.controller.unblank_screen() + + class MessageListener(object): """ This is the Presentation listener who acts on events from the slide @@ -41,8 +159,9 @@ class MessageListener(object): def __init__(self, controllers): self.controllers = controllers - self.handler = None - self.is_live = None + self.previewHandler = Controller(False) + self.liveHandler = Controller(True) + self.isLive = None # messages are sent from core.ui.slidecontroller QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'presentations_start'), self.startup) @@ -71,108 +190,84 @@ class MessageListener(object): Start of new presentation Save the handler as any new presentations start here """ - self.handler, file, self.is_live = self.decodeMessage(message) - self.controller = self.controllers[self.handler] - if self.controller.is_loaded(): - self.shutdown(None) - self.controller.load_presentation(file) - if self.is_live: - self.controller.start_presentation() - Receiver.send_message(u'live_slide_hide') - self.controller.slidenumber = 0 - self.timer.start() - - def activate(self): - if self.controller.is_active(): - return - if not self.controller.is_loaded(): - self.controller.load_presentation(self.controller.filepath) - self.controller.start_presentation() - if self.controller.slidenumber > 1: - self.controller.goto_slide(self.controller.slidenumber) + log.debug(u'Startup called with message %s' % message) + self.handler, file, isLive = self.decodeMessage(message) + if isLive: + self.liveHandler.addHandler(self.controllers[self.handler], file) + else: + self.previewHandler.addHandler(self.controllers[self.handler], file) def slide(self, message): - if not self.is_live: - return - self.activate() - if message: - self.controller.goto_slide(message[0]+1) - self.controller.poll_slidenumber(self.is_live) + slide, live = self.splitMessage(message) + if live: + self.liveHandler.activate() + else: + self.previewHandler.activate() def first(self, message): - """ - Based on the handler passed at startup triggers the first slide - """ - if not self.is_live: - return - self.activate() - self.controller.start_presentation() - self.controller.poll_slidenumber(self.is_live) + if self.isLive: + self.liveHandler.first(message) + else: + self.previewHandler.first(message) def last(self, message): - """ - Based on the handler passed at startup triggers the first slide - """ - if not self.is_live: - return - self.activate() - self.controller.goto_slide(self.controller.get_slide_count()) - self.controller.poll_slidenumber(self.is_live) + if self.isLive: + self.liveHandler.last(message) + else: + self.previewHandler.last(message) def next(self, message): - """ - Based on the handler passed at startup triggers the next slide event - """ - if not self.is_live: - return - self.activate() - self.controller.next_step() - self.controller.poll_slidenumber(self.is_live) + if self.isLive: + self.liveHandler.next(message) + else: + self.previewHandler.next(message) def previous(self, message): - """ - Based on the handler passed at startup triggers the previous slide event - """ - if not self.is_live: - return - self.activate() - self.controller.previous_step() - self.controller.poll_slidenumber(self.is_live) + if self.isLive: + self.liveHandler.previous(message) + else: + self.previewHandler.previous(message) def shutdown(self, message): - """ - Based on the handler passed at startup triggers slide show to shut down - """ - if self.is_live: + if self.isLive: + self.liveHandler.shutdown(message) Receiver.send_message(u'live_slide_show') - self.controller.close_presentation() - self.controller.slidenumber = 0 - self.timer.stop() + else: + self.previewHandler.shutdown(message) def blank(self): - if not self.is_live: - return - if not self.controller.is_loaded(): - return - if not self.controller.is_active(): - return - self.controller.blank_screen() + if self.isLive: + self.liveHandler.blank() + else: + self.previewHandler.blank() def unblank(self): - if not self.is_live: - return - self.activate() - self.controller.unblank_screen() + if self.isLive: + self.liveHandler.unblank() + else: + self.previewHandler.unblank() + + def splitMessage(self, message): + """ + Splits the selection messages + into it's component parts + + ``message`` + Message containing Presentaion handler name and file to be presented. + """ + bits = message.split(u':') + return bits[0], bits[1] def decodeMessage(self, message): """ - Splits the message from the SlideController into it's component parts + Splits the initial message from the SlideController + into it's component parts ``message`` Message containing Presentaion handler name and file to be presented. """ file = os.path.join(message[1], message[2]) - return message[0], file, message[3] + return message[0], file, message[4] def timeout(self): self.controller.poll_slidenumber(self.is_live) From 1271eac76ec55033c45a5ca4082002daf4c7e1b8 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 14 Dec 2009 16:55:58 +0000 Subject: [PATCH 6/8] Correct comment --- openlp/core/lib/renderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 3d6198419..78e37a76a 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -578,7 +578,7 @@ class Renderer(object): painter.drawText(x, y + metrics.ascent(), line) painter.end() if self._theme.display_slideTransition: - # Print 2nd image with 50% weight + # Print 2nd image with 70% weight painter = QtGui.QPainter() painter.begin(self._frameOp) painter.setRenderHint(QtGui.QPainter.Antialiasing); From 2f09c70274662dc93c99e183db31405a855e785e Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 14 Dec 2009 17:05:53 +0000 Subject: [PATCH 7/8] Presentation cleanup - finished for now --- .../presentations/lib/messagelistener.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/presentations/lib/messagelistener.py b/openlp/plugins/presentations/lib/messagelistener.py index 9e9a0047c..31e1a86c2 100644 --- a/openlp/plugins/presentations/lib/messagelistener.py +++ b/openlp/plugins/presentations/lib/messagelistener.py @@ -65,15 +65,13 @@ class Controller(object): if self.controller.slidenumber > 1: self.controller.goto_slide(self.controller.slidenumber) - def slide(self, message): - log.debug(u'Live = %s, slide' % self.isLive) - print "slide ", message - if not self.isLive: - return + def slide(self, slide, live): + log.debug(u'Live = %s, slide' % live) +# if not isLive: +# return self.activate() - if message: - self.controller.goto_slide(message[0] + 1) - self.controller.poll_slidenumber(self.isLive) + self.controller.goto_slide(int(slide) + 1) + self.controller.poll_slidenumber(live) def first(self, message): """ @@ -200,9 +198,9 @@ class MessageListener(object): def slide(self, message): slide, live = self.splitMessage(message) if live: - self.liveHandler.activate() + self.liveHandler.slide(slide, live) else: - self.previewHandler.activate() + self.previewHandler.slide(slide, live) def first(self, message): if self.isLive: From 1b1b811cb7d91bb8a62d35483b41879713ddb103 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 14 Dec 2009 18:10:00 +0000 Subject: [PATCH 8/8] Custom display footer if Credit required --- openlp/plugins/custom/lib/customtab.py | 2 +- openlp/plugins/custom/lib/mediaitem.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py index c4e0c6ee9..642381f2f 100644 --- a/openlp/plugins/custom/lib/customtab.py +++ b/openlp/plugins/custom/lib/customtab.py @@ -57,7 +57,7 @@ class CustomTab(SettingsTab): def retranslateUi(self): self.CustomModeGroupBox.setTitle(self.trUtf8('Custom Display')) self.DisplayFooterCheckBox.setText( - self.trUtf8('Suppress display of footer:')) + self.trUtf8('Display Footer:')) def onDisplayFooterCheckBoxChanged(self, check_state): self.displayFooter = False diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 989e9ecf4..556c89918 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -159,7 +159,8 @@ class CustomMediaItem(MediaManagerItem): service_item.title = title for slide in raw_slides: service_item.add_from_text(slide[:30], slide) - if str_to_bool(self.parent.config.get_config(u'display footer', True)): + if str_to_bool(self.parent.config.get_config(u'display footer', True)) or \ + len(credit) > 0: raw_footer.append(title + u' '+ credit) else: raw_footer.append(u'')