Support blank/first/last buttons in presentations

This commit is contained in:
Jonathan Corwin 2009-10-03 20:18:59 +01:00
parent 665b65e424
commit 1cf3c9a223
5 changed files with 129 additions and 37 deletions

View File

@ -269,7 +269,7 @@ class SlideController(QtGui.QWidget):
if item.service_item_type == ServiceType.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'], slideno])
else:
self.displayServiceManagerItems(item, slideno)
@ -321,14 +321,23 @@ class SlideController(QtGui.QWidget):
"""
Go to the first slide.
"""
self.PreviewListWidget.selectRow(0)
self.onSlideSelected()
if self.commandItem.service_item_type == ServiceType.Command:
Receiver().send_message(u'%s_first'% self.commandItem.name.lower())
else:
self.PreviewListWidget.selectRow(0)
self.onSlideSelected()
def onBlankScreen(self):
def onBlankScreen(self, blanked):
"""
Blank the screen.
"""
self.parent.mainDisplay.blankDisplay()
if self.commandItem.service_item_type == ServiceType.Command:
if blanked:
Receiver().send_message(u'%s_blank'% self.commandItem.name.lower())
else:
Receiver().send_message(u'%s_unblank'% self.commandItem.name.lower())
else:
self.parent.mainDisplay.blankDisplay()
def onSlideSelected(self):
"""
@ -337,15 +346,18 @@ class SlideController(QtGui.QWidget):
"""
row = self.PreviewListWidget.currentRow()
if row > -1 and row < self.PreviewListWidget.rowCount():
#label = self.PreviewListWidget.cellWidget(row, 0)
frame = self.serviceitem.frames[row][u'image']
before = time.time()
if frame is None:
frame = self.serviceitem.render_individual(row)
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
log.info(u'Slide Rendering took %4s' % (time.time() - before))
if self.isLive:
self.parent.mainDisplay.frameView(frame)
if self.commandItem.service_item_type == ServiceType.Command:
Receiver().send_message(u'%s_slide'% self.commandItem.name.lower(), [row])
else:
#label = self.PreviewListWidget.cellWidget(row, 0)
frame = self.serviceitem.frames[row][u'image']
before = time.time()
if frame is None:
frame = self.serviceitem.render_individual(row)
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
log.info(u'Slide Rendering took %4s' % (time.time() - before))
if self.isLive:
self.parent.mainDisplay.frameView(frame)
def onSlideSelectedNext(self):
"""
@ -378,8 +390,11 @@ class SlideController(QtGui.QWidget):
"""
Go to the last slide.
"""
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1)
self.onSlideSelected()
if self.commandItem.service_item_type == ServiceType.Command:
Receiver().send_message(u'%s_last'% self.commandItem.name.lower())
else:
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1)
self.onSlideSelected()
def onStartLoop(self):
"""

View File

@ -118,6 +118,7 @@ class ImpressController(PresentationController):
self.document = desktop.loadComponentFromURL(
url, "_blank", 0, properties)
self.presentation = self.document.getPresentation()
self.presentation.Display = self.plugin.render_manager.current_display + 1
self.presentation.start()
self.controller = \
desktop.getCurrentComponent().Presentation.getController()
@ -178,32 +179,38 @@ class ImpressController(PresentationController):
self.document = None
def is_loaded(self):
return self.presentation is not None and self.document is not None
return self.presentation is not None \
and self.document is not None \
and self.controller is not None
def is_active(self):
if not self.is_loaded():
return False
return self.presentation.isRunning() and self.presentation.isActive()
return self.controller.isRunning() and self.controller.isActive()
def unblank_screen(self):
return self.presentation.resume()
return self.controller.resume()
def blank_screen(self):
self.presentation.blankScreen(0)
self.controller.blankScreen(0)
def stop_presentation(self):
self.presentation.deactivate()
self.controller.deactivate()
# self.presdoc.end()
def start_presentation(self):
self.presentation.activate()
self.controller.activate()
self.goto_slide(1)
# self.presdoc.start()
def get_slide_number(self):
return self.presentation.getCurrentSlideIndex
return self.controller.getCurrentSlideIndex()
def get_slide_count(self):
return self.controller.getSlideCount()
def goto_slide(self, slideno):
self.presentation.gotoSlideIndex(slideno)
self.controller.gotoSlideIndex(slideno-1)
def next_step(self):
"""

View File

@ -36,19 +36,25 @@ class MessageListener(object):
def __init__(self, controllers):
self.controllers = controllers
self.handler = None
# messages are sent from core.ui.slidecontroller
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_start'), self.startup)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_stop'), self.shutDown)
QtCore.SIGNAL(u'presentations_stop'), self.shutdown)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_first'), self.next)
QtCore.SIGNAL(u'presentations_first'), self.first)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_previous'), self.previous)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_next'), self.next)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_last'), self.next)
QtCore.SIGNAL(u'presentations_last'), self.last)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_slide'), self.slide)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_blank'), self.blank)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'presentations_unblank'), self.unblank)
def startup(self, message):
"""
@ -56,25 +62,77 @@ class MessageListener(object):
Save the handler as any new presentations start here
"""
self.handler, file = self.decodeMessage(message)
self.controllers[self.handler].load_presentation(file)
self.controller = self.controllers[self.handler]
if self.controller.is_loaded():
self.shutdown()
self.controller.load_presentation(file)
def slide(self, message):
#if not self.controller.is_loaded():
# return
#if not self.controller.is_active():
# self.controller.start_presentation()
self.controller.goto_slide(message[0])
def first(self, message):
"""
Based on the handler passed at startup triggers the first slide
"""
#if not self.controller.is_loaded():
# return
self.controller.start_presentation()
def last(self, message):
"""
Based on the handler passed at startup triggers the first slide
"""
#if not self.controller.is_loaded():
# return
#if not self.controller.is_active():
# self.controller.start_presentation()
self.controller.goto_slide(self.controller.get_slide_count())
def next(self, message):
"""
Based on the handler passed at startup triggers the next slide event
"""
self.controllers[self.handler].next_step()
#if not self.controller.is_loaded():
# return
#if not self.controller.is_active():
# self.controller.start_presentation()
# self.controller.goto_slide(self.controller.current_slide)
self.controller.next_step()
def previous(self, message):
"""
Based on the handler passed at startup triggers the previous slide event
"""
self.controllers[self.handler].previous_step()
#if not self.controller.is_loaded():
# return
#if not self.controller.is_active():
# self.controller.start_presentation()
# self.controller.goto_slide(self.controller.current_slide)
self.controller.previous_step()
def shutDown(self, message):
def shutdown(self, message):
"""
Based on the handler passed at startup triggers slide show to shut down
"""
self.controllers[self.handler].close_presentation()
self.controller.close_presentation()
def blank(self):
#if not self.controller.is_loaded():
# return
#if not self.controller.is_active():
# self.controller.start_presentation()
self.controller.blank_screen()
def unblank(self):
#if not self.controller.is_loaded():
# return
#if not self.controller.is_active():
# self.controller.start_presentation()
self.controller.unblank_screen()
def decodeMessage(self, message):
"""

View File

@ -153,12 +153,15 @@ class PowerpointController(PresentationController):
Starts a presentation from the beginning
"""
self.presentation.SlideShowSettings.Run()
self.presentation.SlideShowWindow.View.GotoSlide(1)
rendermanager = self.plugin.render_manager
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
self.presentation.SlideShowWindow.Top = rect.y()
self.presentation.SlideShowWindow.Height = rect.height()
self.presentation.SlideShowWindow.Left = rect.x()
self.presentation.SlideShowWindow.Width = rect.width()
dpi = 96 # This assumption is good some of the time, but not
# all, but I don't know how to get the screen DPI yet
self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi
self.presentation.SlideShowWindow.Height = rect.height() * 72 / dpi
self.presentation.SlideShowWindow.Left = rect.x() * 72 / dpi
self.presentation.SlideShowWindow.Width = rect.width() * 72 / dpi
def get_slide_number(self):
"""

View File

@ -29,6 +29,15 @@ class PresentationController(object):
It creates the runtime environment, loads and closes the presentation as
well as triggering the correct activities based on the users input
To create a new controller, take a copy of this file and name it
so it ends in controller.py, i.e. foobarcontroller.py
Make sure it inhetits PresentationController
Then fill in the blanks. If possible try and make sure it loads
on all platforms, using for example os.name checks, although
__init__ and check_available should always work.
See impresscontroller, powerpointcontroller or pptviewcontroller
for examples.
**Basic Attributes**
``name``