More presentation fixes

bzr-revno: 626
This commit is contained in:
j@corwin.co.uk 2009-10-25 14:39:45 +00:00 committed by Tim Bentley
commit 4871acd05c
4 changed files with 48 additions and 11 deletions

View File

@ -93,6 +93,10 @@ class EventReceiver(QtCore.QObject):
``preview_song`` ``preview_song``
Tells the song plugin the edit has finished and the song can be previewed Tells the song plugin the edit has finished and the song can be previewed
Only available if the edit was triggered by the Preview button. Only available if the edit was triggered by the Preview button.
``slidecontroller_change``
Informs the slidecontroller that a slide change has occurred
""" """
global log global log
log = logging.getLogger(u'EventReceiver') log = logging.getLogger(u'EventReceiver')

View File

@ -236,6 +236,8 @@ class SlideController(QtGui.QWidget):
QtCore.SIGNAL(u'slidecontroller_previous'), self.onSlideSelectedPrevious) QtCore.SIGNAL(u'slidecontroller_previous'), self.onSlideSelectedPrevious)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_last'), self.onSlideSelectedLast) QtCore.SIGNAL(u'slidecontroller_last'), self.onSlideSelectedLast)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_change'), self.onSlideChange)
def receiveSpinDelay(self, value): def receiveSpinDelay(self, value):
self.DelaySpinBox.setValue(int(value)) self.DelaySpinBox.setValue(int(value))
@ -412,13 +414,24 @@ class SlideController(QtGui.QWidget):
self.parent.mainDisplay.frameView(frame) self.parent.mainDisplay.frameView(frame)
self.row = row self.row = row
def grabMainDisplay(self): def onSlideChange(self, row):
winid = QtGui.QApplication.desktop().winId() """
rm = self.parent.RenderManager The slide has been changed. Update the slidecontroller accordingly
rect = rm.screen_list[rm.current_display][u'size'] """
winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), rect.y(), rect.width(), rect.height()) self.PreviewListWidget.selectRow(row)
self.SlidePreview.setPixmap(winimg) QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
def grabMainDisplay(self):
rm = self.parent.RenderManager
if not rm.screen_list[rm.current_display][u'primary']:
winid = QtGui.QApplication.desktop().winId()
rect = rm.screen_list[rm.current_display][u'size']
winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), rect.y(), rect.width(), rect.height())
self.SlidePreview.setPixmap(winimg)
else:
label = self.PreviewListWidget.cellWidget(self.PreviewListWidget.currentRow(), 0)
self.SlidePreview.setPixmap(label.pixmap())
def onSlideSelectedNext(self): def onSlideSelectedNext(self):
""" """
Go to the next slide. Go to the next slide.

View File

@ -68,6 +68,7 @@ class MessageListener(object):
self.controller.load_presentation(file) self.controller.load_presentation(file)
self.controller.start_presentation() self.controller.start_presentation()
self.controller.slidenumber = 0 self.controller.slidenumber = 0
self.controller.timer.start()
def activate(self): def activate(self):
if self.controller.is_active(): if self.controller.is_active():
@ -82,7 +83,7 @@ class MessageListener(object):
self.activate() self.activate()
if message is not None: if message is not None:
self.controller.goto_slide(message[0]+1) self.controller.goto_slide(message[0]+1)
self.controller.slidenumber = self.controller.get_slide_number() self.controller.poll_slidenumber()
def first(self, message): def first(self, message):
""" """
@ -90,7 +91,7 @@ class MessageListener(object):
""" """
self.activate() self.activate()
self.controller.start_presentation() self.controller.start_presentation()
self.controller.slidenumber = self.controller.get_slide_number() self.controller.poll_slidenumber()
def last(self, message): def last(self, message):
""" """
@ -98,7 +99,7 @@ class MessageListener(object):
""" """
self.activate() self.activate()
self.controller.goto_slide(self.controller.get_slide_count()) self.controller.goto_slide(self.controller.get_slide_count())
self.controller.slidenumber = self.controller.get_slide_number() self.controller.poll_slidenumber()
def next(self, message): def next(self, message):
""" """
@ -106,7 +107,7 @@ class MessageListener(object):
""" """
self.activate() self.activate()
self.controller.next_step() self.controller.next_step()
self.controller.slidenumber = self.controller.get_slide_number() self.controller.poll_slidenumber()
def previous(self, message): def previous(self, message):
""" """
@ -114,7 +115,7 @@ class MessageListener(object):
""" """
self.activate() self.activate()
self.controller.previous_step() self.controller.previous_step()
self.controller.slidenumber = self.controller.get_slide_number() self.controller.poll_slidenumber()
def shutdown(self, message): def shutdown(self, message):
""" """
@ -122,6 +123,7 @@ class MessageListener(object):
""" """
self.controller.close_presentation() self.controller.close_presentation()
self.controller.slidenumber = 0 self.controller.slidenumber = 0
self.controller.timer.shutdown()
def blank(self): def blank(self):
if not self.controller.is_loaded(): if not self.controller.is_loaded():

View File

@ -24,6 +24,8 @@ import shutil
from PyQt4 import QtCore from PyQt4 import QtCore
from openlp.core.lib import Receiver
class PresentationController(object): class PresentationController(object):
""" """
Base class for presentation controllers to inherit from Base class for presentation controllers to inherit from
@ -143,6 +145,9 @@ class PresentationController(object):
self.thumbnailprefix = u'slide' self.thumbnailprefix = u'slide'
if not os.path.isdir(self.thumbnailroot): if not os.path.isdir(self.thumbnailroot):
os.makedirs(self.thumbnailroot) os.makedirs(self.thumbnailroot)
self.timer = QtCore.QTimer()
self.timer.setInterval(500)
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.poll_slidenumber)
def check_available(self): def check_available(self):
""" """
@ -291,3 +296,16 @@ class PresentationController(object):
The slide an image is required for, starting at 1 The slide an image is required for, starting at 1
""" """
return None return None
def poll_slidenumber(self):
"""
Check the current slide number
"""
if not self.is_active():
return
current = self.get_slide_number()
if current == self.slidenumber:
return
self.slidenumber = current
Receiver().send_message(u'slidecontroller_change', self.slidenumber - 1)