← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~j-corwin/openlp/present into lp:openlp

 

Jonathan Corwin has proposed merging lp:~j-corwin/openlp/present into lp:openlp.

    Requested reviews:
    OpenLP Core (openlp-core)


Add support for first/last/blank buttons for presentations. Plus fix a few issues.

Note, this has a hardcoded 96 DPI (the most common) for positioning the powerpoint. If anyone has any ideas on how to get the actual screen DPI, please let me know.
-- 
https://code.launchpad.net/~j-corwin/openlp/present/+merge/12829
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2009-10-01 23:43:16 +0000
+++ openlp/core/ui/slidecontroller.py	2009-10-03 19:30:22 +0000
@@ -269,7 +269,7 @@
         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 @@
         """
         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 @@
         """
         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 @@
         """
         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):
         """

=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py	2009-09-30 19:37:45 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py	2009-10-03 19:30:22 +0000
@@ -118,6 +118,7 @@
             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 @@
             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):
        """

=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py	2009-09-28 20:45:04 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py	2009-10-03 19:30:22 +0000
@@ -36,19 +36,25 @@
     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 @@
         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):
         """

=== modified file 'openlp/plugins/presentations/lib/powerpointcontroller.py'
--- openlp/plugins/presentations/lib/powerpointcontroller.py	2009-09-30 19:26:51 +0000
+++ openlp/plugins/presentations/lib/powerpointcontroller.py	2009-10-03 19:30:22 +0000
@@ -153,12 +153,15 @@
             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):
             """

=== modified file 'openlp/plugins/presentations/lib/presentationcontroller.py'
--- openlp/plugins/presentations/lib/presentationcontroller.py	2009-09-30 19:26:51 +0000
+++ openlp/plugins/presentations/lib/presentationcontroller.py	2009-10-03 19:30:22 +0000
@@ -29,6 +29,15 @@
     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``


Follow ups