This commit is contained in:
Tim Bentley 2009-11-08 07:22:12 +00:00
commit f0e0cfa4c1
6 changed files with 80 additions and 45 deletions

View File

@ -47,16 +47,16 @@ class DisplayWidget(QtGui.QWidget):
if type(event) == QtGui.QKeyEvent:
#here accept the event and do something
if event.key() == QtCore.Qt.Key_Up:
Receiver().send_message(u'slidecontroller_previous')
Receiver().send_message(u'live_slidecontroller_previous')
event.accept()
elif event.key() == QtCore.Qt.Key_Down:
Receiver().send_message(u'slidecontroller_next')
Receiver().send_message(u'live_slidecontroller_next')
event.accept()
elif event.key() == QtCore.Qt.Key_PageUp:
Receiver().send_message(u'slidecontroller_first')
Receiver().send_message(u'live_slidecontroller_first')
event.accept()
elif event.key() == QtCore.Qt.Key_PageDown:
Receiver().send_message(u'slidecontroller_last')
Receiver().send_message(u'live_slidecontroller_last')
event.accept()
elif event.key() == QtCore.Qt.Key_Escape:
self.resetDisplay()
@ -116,9 +116,9 @@ class MainDisplay(DisplayWidget):
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'alert_text'), self.displayAlert)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_start'), self.hideDisplay)
QtCore.SIGNAL(u'live_slide_hide'), self.hideDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_stop'), self.showDisplay)
QtCore.SIGNAL(u'live_slide_show'), self.showDisplay)
QtCore.QObject.connect(self.mediaObject,
QtCore.SIGNAL(u'finished()'), self.onMediaFinish)
QtCore.QObject.connect(Receiver.get_receiver(),

View File

@ -253,16 +253,20 @@ class SlideController(QtGui.QWidget):
self.Toolbar.makeWidgetsInvisible(self.media_list)
else:
self.Toolbar.makeWidgetsInvisible(self.song_list)
if isLive:
prefix = u'live_slidecontroller'
else:
prefix = u'preview_slidecontroller'
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_first'), self.onSlideSelectedFirst)
QtCore.SIGNAL(u'%s_first' % prefix), self.onSlideSelectedFirst)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_next'), self.onSlideSelectedNext)
QtCore.SIGNAL(u'%s_next' % prefix), self.onSlideSelectedNext)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_previous'), self.onSlideSelectedPrevious)
QtCore.SIGNAL(u'%s_previous' % prefix), self.onSlideSelectedPrevious)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_last'), self.onSlideSelectedLast)
QtCore.SIGNAL(u'%s_last' % prefix), self.onSlideSelectedLast)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'slidecontroller_change'), self.onSlideChange)
QtCore.SIGNAL(u'%s_change' % prefix), self.onSlideChange)
def onSongBarHandler(self):
request = self.sender().text()
@ -350,7 +354,7 @@ class SlideController(QtGui.QWidget):
if item.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_start' % item.name.lower(), \
[item.shortname, item.service_item_path,
item.service_frames[0][u'title']])
item.service_frames[0][u'title'], self.isLive])
slideno = 0
if self.songEdit:
slideno = self.row
@ -380,7 +384,7 @@ class SlideController(QtGui.QWidget):
if item.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_start' % item.name.lower(), \
[item.shortname, item.service_item_path,
item.service_frames[0][u'title'], slideno])
item.service_frames[0][u'title'], slideno, self.isLive])
self.displayServiceManagerItems(item, slideno)
def displayServiceManagerItems(self, serviceitem, slideno):
@ -438,7 +442,7 @@ class SlideController(QtGui.QWidget):
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_first'% self.commandItem.name.lower())
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
self.updatePreview()
else:
self.PreviewListWidget.selectRow(0)
self.onSlideSelected()
@ -467,7 +471,7 @@ class SlideController(QtGui.QWidget):
if self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_slide'% self.commandItem.name.lower(), [row])
if self.isLive:
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
self.updatePreview()
else:
frame = self.serviceitem.frames[row][u'image']
before = time.time()
@ -484,18 +488,24 @@ class SlideController(QtGui.QWidget):
The slide has been changed. Update the slidecontroller accordingly
"""
self.PreviewListWidget.selectRow(row)
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
self.updatePreview()
def grabMainDisplay(self):
def updatePreview(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)
# Grab now, but try again in a couple of seconds if slide change is slow
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
QtCore.QTimer.singleShot(2.5, self.grabMainDisplay)
else:
label = self.PreviewListWidget.cellWidget(self.PreviewListWidget.currentRow(), 0)
self.SlidePreview.setPixmap(label.pixmap())
def grabMainDisplay(self):
rm = self.parent.RenderManager
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)
def onSlideSelectedNext(self):
"""
@ -504,7 +514,7 @@ class SlideController(QtGui.QWidget):
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_next'% self.commandItem.name.lower())
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
self.updatePreview()
else:
row = self.PreviewListWidget.currentRow() + 1
if row == self.PreviewListWidget.rowCount():
@ -520,7 +530,7 @@ class SlideController(QtGui.QWidget):
self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(
u'%s_previous'% self.commandItem.name.lower())
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
self.updatePreview()
else:
row = self.PreviewListWidget.currentRow() - 1
if row == -1:
@ -535,7 +545,7 @@ class SlideController(QtGui.QWidget):
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
Receiver().send_message(u'%s_last'% self.commandItem.name.lower())
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
self.updatePreview()
else:
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1)
self.onSlideSelected()

View File

@ -272,7 +272,7 @@ class ImpressController(PresentationController):
self.goto_slide(1)
def get_slide_number(self):
return self.controller.getCurrentSlideIndex()
return self.controller.getCurrentSlideIndex() + 1
def get_slide_count(self):
return self.document.getDrawPages().getCount()

View File

@ -41,6 +41,7 @@ class MessageListener(object):
def __init__(self, controllers):
self.controllers = controllers
self.handler = None
self.is_live = None
# messages are sent from core.ui.slidecontroller
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_start'), self.startup)
@ -60,20 +61,25 @@ class MessageListener(object):
QtCore.SIGNAL(u'presentations_blank'), self.blank)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_unblank'), self.unblank)
self.timer = QtCore.QTimer()
self.timer.setInterval(500)
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.timeout)
def startup(self, message):
"""
Start of new presentation
Save the handler as any new presentations start here
"""
self.handler, file = self.decodeMessage(message)
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)
self.controller.start_presentation()
if self.is_live:
self.controller.start_presentation()
Receiver().send_message(u'live_slide_hide')
self.controller.slidenumber = 0
self.controller.timer.start()
self.timer.start()
def activate(self):
if self.controller.is_active():
@ -85,52 +91,66 @@ class MessageListener(object):
self.controller.goto_slide(self.controller.slidenumber)
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.controller.poll_slidenumber(self.is_live)
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.controller.poll_slidenumber(self.is_live)
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.controller.poll_slidenumber(self.is_live)
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.controller.poll_slidenumber(self.is_live)
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.controller.poll_slidenumber(self.is_live)
def shutdown(self, message):
"""
Based on the handler passed at startup triggers slide show to shut down
"""
if self.is_live:
Receiver().send_message(u'live_slide_show')
self.controller.close_presentation()
self.controller.slidenumber = 0
self.controller.timer.shutdown()
self.timer.stop()
def blank(self):
if not self.is_live:
return
if not self.controller.is_loaded():
return
if not self.controller.is_active():
@ -138,6 +158,8 @@ class MessageListener(object):
self.controller.blank_screen()
def unblank(self):
if not self.is_live:
return
self.activate()
self.controller.unblank_screen()
@ -149,4 +171,7 @@ class MessageListener(object):
Message containing Presentaion handler name and file to be presented.
"""
file = os.path.join(message[1], message[2])
return message[0], file
return message[0], file, message[3]
def timeout(self):
self.controller.poll_slidenumber(self.is_live)

View File

@ -149,9 +149,6 @@ class PresentationController(object):
self.thumbnailprefix = u'slide'
if not os.path.isdir(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):
"""
@ -188,6 +185,7 @@ class PresentationController(object):
``presentation``
The file name of the presentations to the run.
"""
pass
@ -207,9 +205,7 @@ class PresentationController(object):
recent than the powerpoint
"""
lastimage = self.get_slide_preview_file(self.get_slide_count())
if lastimage is None:
return False
if not os.path.isfile(lastimage):
if not (lastimage and os.path.isfile(lastimage)):
return False
imgdate = os.stat(lastimage).st_mtime
pptdate = os.stat(self.filepath).st_mtime
@ -301,7 +297,7 @@ class PresentationController(object):
"""
return None
def poll_slidenumber(self):
def poll_slidenumber(self, is_live):
"""
Check the current slide number
"""
@ -311,5 +307,9 @@ class PresentationController(object):
if current == self.slidenumber:
return
self.slidenumber = current
Receiver().send_message(u'slidecontroller_change', self.slidenumber - 1)
if is_live:
prefix = u'live'
else:
prefix = u'preview'
Receiver().send_message(u'%s_slidecontroller_change' % prefix,
self.slidenumber - 1)

View File

@ -1 +1 @@
1.9.0-659
1.9.0-662