forked from openlp/openlp
Support blank/first/last buttons in presentations
This commit is contained in:
parent
665b65e424
commit
1cf3c9a223
@ -269,7 +269,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
if item.service_item_type == ServiceType.Command:
|
if item.service_item_type == ServiceType.Command:
|
||||||
Receiver().send_message(u'%s_start' % item.name.lower(), \
|
Receiver().send_message(u'%s_start' % item.name.lower(), \
|
||||||
[item.shortname, item.service_item_path,
|
[item.shortname, item.service_item_path,
|
||||||
item.service_frames[0][u'title']])
|
item.service_frames[0][u'title'], slideno])
|
||||||
else:
|
else:
|
||||||
self.displayServiceManagerItems(item, slideno)
|
self.displayServiceManagerItems(item, slideno)
|
||||||
|
|
||||||
@ -321,14 +321,23 @@ class SlideController(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Go to the first slide.
|
Go to the first slide.
|
||||||
"""
|
"""
|
||||||
self.PreviewListWidget.selectRow(0)
|
if self.commandItem.service_item_type == ServiceType.Command:
|
||||||
self.onSlideSelected()
|
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.
|
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):
|
def onSlideSelected(self):
|
||||||
"""
|
"""
|
||||||
@ -337,15 +346,18 @@ class SlideController(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
row = self.PreviewListWidget.currentRow()
|
row = self.PreviewListWidget.currentRow()
|
||||||
if row > -1 and row < self.PreviewListWidget.rowCount():
|
if row > -1 and row < self.PreviewListWidget.rowCount():
|
||||||
#label = self.PreviewListWidget.cellWidget(row, 0)
|
if self.commandItem.service_item_type == ServiceType.Command:
|
||||||
frame = self.serviceitem.frames[row][u'image']
|
Receiver().send_message(u'%s_slide'% self.commandItem.name.lower(), [row])
|
||||||
before = time.time()
|
else:
|
||||||
if frame is None:
|
#label = self.PreviewListWidget.cellWidget(row, 0)
|
||||||
frame = self.serviceitem.render_individual(row)
|
frame = self.serviceitem.frames[row][u'image']
|
||||||
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
|
before = time.time()
|
||||||
log.info(u'Slide Rendering took %4s' % (time.time() - before))
|
if frame is None:
|
||||||
if self.isLive:
|
frame = self.serviceitem.render_individual(row)
|
||||||
self.parent.mainDisplay.frameView(frame)
|
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):
|
def onSlideSelectedNext(self):
|
||||||
"""
|
"""
|
||||||
@ -378,8 +390,11 @@ class SlideController(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
Go to the last slide.
|
Go to the last slide.
|
||||||
"""
|
"""
|
||||||
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1)
|
if self.commandItem.service_item_type == ServiceType.Command:
|
||||||
self.onSlideSelected()
|
Receiver().send_message(u'%s_last'% self.commandItem.name.lower())
|
||||||
|
else:
|
||||||
|
self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1)
|
||||||
|
self.onSlideSelected()
|
||||||
|
|
||||||
def onStartLoop(self):
|
def onStartLoop(self):
|
||||||
"""
|
"""
|
||||||
|
@ -118,6 +118,7 @@ class ImpressController(PresentationController):
|
|||||||
self.document = desktop.loadComponentFromURL(
|
self.document = desktop.loadComponentFromURL(
|
||||||
url, "_blank", 0, properties)
|
url, "_blank", 0, properties)
|
||||||
self.presentation = self.document.getPresentation()
|
self.presentation = self.document.getPresentation()
|
||||||
|
self.presentation.Display = self.plugin.render_manager.current_display + 1
|
||||||
self.presentation.start()
|
self.presentation.start()
|
||||||
self.controller = \
|
self.controller = \
|
||||||
desktop.getCurrentComponent().Presentation.getController()
|
desktop.getCurrentComponent().Presentation.getController()
|
||||||
@ -178,32 +179,38 @@ class ImpressController(PresentationController):
|
|||||||
self.document = None
|
self.document = None
|
||||||
|
|
||||||
def is_loaded(self):
|
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):
|
def is_active(self):
|
||||||
if not self.is_loaded():
|
if not self.is_loaded():
|
||||||
return False
|
return False
|
||||||
return self.presentation.isRunning() and self.presentation.isActive()
|
return self.controller.isRunning() and self.controller.isActive()
|
||||||
|
|
||||||
def unblank_screen(self):
|
def unblank_screen(self):
|
||||||
return self.presentation.resume()
|
return self.controller.resume()
|
||||||
|
|
||||||
def blank_screen(self):
|
def blank_screen(self):
|
||||||
self.presentation.blankScreen(0)
|
self.controller.blankScreen(0)
|
||||||
|
|
||||||
def stop_presentation(self):
|
def stop_presentation(self):
|
||||||
self.presentation.deactivate()
|
self.controller.deactivate()
|
||||||
# self.presdoc.end()
|
# self.presdoc.end()
|
||||||
|
|
||||||
def start_presentation(self):
|
def start_presentation(self):
|
||||||
self.presentation.activate()
|
self.controller.activate()
|
||||||
|
self.goto_slide(1)
|
||||||
# self.presdoc.start()
|
# self.presdoc.start()
|
||||||
|
|
||||||
def get_slide_number(self):
|
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):
|
def goto_slide(self, slideno):
|
||||||
self.presentation.gotoSlideIndex(slideno)
|
self.controller.gotoSlideIndex(slideno-1)
|
||||||
|
|
||||||
def next_step(self):
|
def next_step(self):
|
||||||
"""
|
"""
|
||||||
|
@ -36,19 +36,25 @@ class MessageListener(object):
|
|||||||
def __init__(self, controllers):
|
def __init__(self, controllers):
|
||||||
self.controllers = controllers
|
self.controllers = controllers
|
||||||
self.handler = None
|
self.handler = None
|
||||||
|
# messages are sent from core.ui.slidecontroller
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'presentations_start'), self.startup)
|
QtCore.SIGNAL(u'presentations_start'), self.startup)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
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.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.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'presentations_previous'), self.previous)
|
QtCore.SIGNAL(u'presentations_previous'), self.previous)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'presentations_next'), self.next)
|
QtCore.SIGNAL(u'presentations_next'), self.next)
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
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):
|
def startup(self, message):
|
||||||
"""
|
"""
|
||||||
@ -56,25 +62,77 @@ class MessageListener(object):
|
|||||||
Save the handler as any new presentations start here
|
Save the handler as any new presentations start here
|
||||||
"""
|
"""
|
||||||
self.handler, file = self.decodeMessage(message)
|
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):
|
def next(self, message):
|
||||||
"""
|
"""
|
||||||
Based on the handler passed at startup triggers the next slide event
|
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):
|
def previous(self, message):
|
||||||
"""
|
"""
|
||||||
Based on the handler passed at startup triggers the previous slide event
|
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
|
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):
|
def decodeMessage(self, message):
|
||||||
"""
|
"""
|
||||||
|
@ -153,12 +153,15 @@ class PowerpointController(PresentationController):
|
|||||||
Starts a presentation from the beginning
|
Starts a presentation from the beginning
|
||||||
"""
|
"""
|
||||||
self.presentation.SlideShowSettings.Run()
|
self.presentation.SlideShowSettings.Run()
|
||||||
|
self.presentation.SlideShowWindow.View.GotoSlide(1)
|
||||||
rendermanager = self.plugin.render_manager
|
rendermanager = self.plugin.render_manager
|
||||||
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
|
rect = rendermanager.screen_list[rendermanager.current_display][u'size']
|
||||||
self.presentation.SlideShowWindow.Top = rect.y()
|
dpi = 96 # This assumption is good some of the time, but not
|
||||||
self.presentation.SlideShowWindow.Height = rect.height()
|
# all, but I don't know how to get the screen DPI yet
|
||||||
self.presentation.SlideShowWindow.Left = rect.x()
|
self.presentation.SlideShowWindow.Top = rect.y() * 72 / dpi
|
||||||
self.presentation.SlideShowWindow.Width = rect.width()
|
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):
|
def get_slide_number(self):
|
||||||
"""
|
"""
|
||||||
|
@ -29,6 +29,15 @@ class PresentationController(object):
|
|||||||
It creates the runtime environment, loads and closes the presentation as
|
It creates the runtime environment, loads and closes the presentation as
|
||||||
well as triggering the correct activities based on the users input
|
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**
|
**Basic Attributes**
|
||||||
|
|
||||||
``name``
|
``name``
|
||||||
|
Loading…
Reference in New Issue
Block a user