← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/plugins into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/plugins into lp:openlp.

Requested reviews:
    openlp.org Core (openlp-core)

Plugin related changes 
Fix ImageToolbar so it can step through slides
Clean up Presentations to:
- Only appear if UNO is present
- Build an impress Toolbar and add infrastructure for that.
- Framework for a PowerPoint and Mac toolbar if needed.
- Handle Impress items on servicemanager.

Martin the impress toolbar may be of interest as you may want an audio and video one.

-- 
https://code.launchpad.net/~trb143/openlp/plugins/+merge/8635
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py	2009-07-10 13:16:15 +0000
+++ openlp/core/lib/serviceitem.py	2009-07-12 11:12:51 +0000
@@ -57,7 +57,6 @@
         self.theme = None
         self.service_item_path = None
         self.service_item_type = None
-        #log.debug(u'Service item created for %s ', self.shortname)
         self.service_frames = []
 
     def addIcon(self, icon):
@@ -75,6 +74,16 @@
     def render(self):
         """
         The render method is what renders the frames for the screen.
+        There are three types of render
+        ``text``
+            Where the renderManager is used to build the display frames
+
+        ``image``
+            Where a list of frames are provided
+
+        ``toolbar``
+            Where a file is passed to a toolbar for processing
+
         """
         log.debug(u'Render called')
         if self.theme == None:
@@ -89,7 +98,7 @@
                 for format in formated:
                     frame = self.RenderManager.generate_slide(format, self.raw_footer)
                     self.frames.append({u'title': slide[u'title'], u'image': frame})
-        elif self.service_item_type == u'command':
+        elif self.service_item_type == u'toolbar':
             self.frames = self.service_frames
             self.service_frames = []
         elif self.service_item_type == u'image':
@@ -133,18 +142,19 @@
         frame_title = frame_title.split(u'\n')[0]
         self.service_frames.append({u'title': frame_title, u'raw_slide': raw_slide})
 
-    def add_from_command(self, frame_title, command):
+    def add_using_toolbar(self, path, name):
         """
         Add a slide from a command.
 
-        ``frame_title``
-            The title of the slide in the service item.
-
-        ``command``
-            The command of/for the slide.
+        ``path``
+            Where to find the file
+
+        ``name``
+            Individual file name
+
         """
-        self.service_item_type = u'command'
-        self.service_frames.append({u'title': frame_title, u'command': command})
+        self.service_item_type = u'toolbar'
+        self.service_frames.append({u'title': name, u'filename': path})
 
     def get_oos_repr(self):
         """

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2009-07-11 05:18:34 +0000
+++ openlp/core/ui/slidecontroller.py	2009-07-12 11:12:51 +0000
@@ -19,6 +19,7 @@
 """
 import logging
 import os
+import sys
 
 from PyQt4 import QtCore, QtGui
 from openlp.core.lib import OpenLPToolbar, translate, buildIcon
@@ -135,8 +136,10 @@
         ``handle``
             Identifier for the toolbar being stored this should equal the
             plugins name.
+
         ``controller``
             The toolbar class which should extend MasterToolbar
+
         """
         #store the handle name in lower case so no probems later
         self.toolbarList[handle.lower()] = controller
@@ -147,8 +150,10 @@
         ``handle``
             Identifier for the preview being stored this should equal the
             plugins name.
+
         ``controller``
             The preview class which should extend MasterToolbar
+
         """
         #store the handle name in lower case so no probems later
         self.previewList[handle.lower()] = controller
@@ -159,6 +164,7 @@
         Add extra information back into toolbar class
         ``handle``
             Identifier for the toolbar being requested
+
         """
         try:
             toolbar =  self.toolbarList[handle.lower()]
@@ -175,6 +181,7 @@
         Add extra information back into toolbar class
         ``handle``
             Identifier for the toolbar being requested
+
         """
         try:
             preview =  self.previewList[handle.lower()]
@@ -241,7 +248,6 @@
         self.SlidePreview.setScaledContents(True)
         self.SlidePreview.setObjectName(u'SlidePreview')
 
-
 class MasterToolbar(QtCore.QObject):
     """
     Class from which all toolbars should extend

=== modified file 'openlp/plugins/images/lib/imageslidecontroller.py'
--- openlp/plugins/images/lib/imageslidecontroller.py	2009-07-06 16:34:13 +0000
+++ openlp/plugins/images/lib/imageslidecontroller.py	2009-07-12 11:12:51 +0000
@@ -93,7 +93,7 @@
         Go to the last slide.
         """
         if self.PreviewListWidget.rowCount() > 1:
-            self.timer_id =  self.startTimer(int(self.TimeoutSpinBox.value()) * 1000)
+            self.timer_id =  self.startTimer(int(self.DelaySpinBox.value()) * 1000)
 
     def onStopLoop(self):
         """
@@ -104,3 +104,12 @@
     def timerEvent(self, event):
         if event.timerId() == self.timer_id:
             self.onSlideSelectedNext()
+
+    def addServiceItem(self, item, slideno):
+        self.serviceitem = item
+        MasterToolbar.addServiceItem(self, item, slideno)
+
+    def addServiceManagerItem(self, item, slideno):
+        self.serviceitem = item
+        MasterToolbar.addServiceManagerItem(self, item, slideno)
+

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2009-07-04 05:52:30 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2009-07-12 11:12:51 +0000
@@ -77,7 +77,10 @@
         for file in list:
             (path, filename) = os.path.split(unicode(file))
             item_name = QtGui.QListWidgetItem(filename)
-            item_name.setIcon(buildIcon(file))
+            image = QtGui.QImage(88, 50, QtGui.QImage.Format_ARGB32_Premultiplied)
+            image.load(file)
+            c = QtGui.QIcon(QtGui.QPixmap.fromImage(image))
+            item_name.setIcon(c)
             item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
             self.ListView.addItem(item_name)
 

=== modified file 'openlp/plugins/presentations/lib/__init__.py'
--- openlp/plugins/presentations/lib/__init__.py	2009-06-25 19:42:22 +0000
+++ openlp/plugins/presentations/lib/__init__.py	2009-07-11 19:54:55 +0000
@@ -17,10 +17,8 @@
 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 Place, Suite 330, Boston, MA 02111-1307 USA
 """
-
-from filelistdata import FileListData
 from mediaitem import PresentationMediaItem
 from presentationtab import PresentationTab
-from impresscom import Openoffice
+from impressslidecontroller import impressToolbar
 
-__all__ = ['PresentationMediaItem', 'FileListData', 'PresentationTab', 'OpenOffice']
+__all__ = ['PresentationMediaItem', 'PresentationTab', 'impressToolbar']

=== removed file 'openlp/plugins/presentations/lib/filelistdata.py'
--- openlp/plugins/presentations/lib/filelistdata.py	2009-06-16 18:21:24 +0000
+++ openlp/plugins/presentations/lib/filelistdata.py	1970-01-01 00:00:00 +0000
@@ -1,82 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
-"""
-OpenLP - Open Source Lyrics Projection
-Copyright (c) 2008 Raoul Snyman
-Portions copyright (c) 2008 Martin Thompson, Tim Bentley,
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free Software
-Foundation; version 2 of the License.
-
-This program is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License along with
-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-Place, Suite 330, Boston, MA 02111-1307 USA
-"""
-import os
-import logging
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-
-class FileListData(QAbstractListModel):
-    """
-    An abstract list of strings and the preview icon to go with them
-    """
-    global log
-    log=logging.getLogger(u'FileListData')
-    log.info(u'started')
-
-    def __init__(self):
-        QAbstractListModel.__init__(self)
-        self.items=[] # will be a list of (full filename shortname) tuples
-
-    def rowCount(self, parent):
-        return len(self.items)
-
-    def insertRow(self, row, filename):
-        self.beginInsertRows(QModelIndex(),row,row)
-        log.info(u'insert row %d:%s'%(row,filename))
-        # get short filename to display next to image
-        (prefix, shortfilename) = os.path.split(unicode(filename))
-        log.info(u'shortfilename=%s'%(shortfilename))
-        # create a preview image
-        self.items.insert(row, (filename, shortfilename))
-        self.endInsertRows()
-
-    def removeRow(self, row):
-        self.beginRemoveRows(QModelIndex(), row,row)
-        self.items.pop(row)
-        self.endRemoveRows()
-
-    def addRow(self, filename):
-        self.insertRow(len(self.items), filename)
-
-    def data(self, index, role):
-        row=index.row()
-        if row > len(self.items): # if the last row is selected and deleted, we then get called with an empty row!
-            return QVariant()
-        if role==Qt.DisplayRole:
-            retval= self.items[row][1]
-#        elif role == Qt.DecorationRole:
-#            retval= self.items[row][1]
-        elif role == Qt.ToolTipRole:
-            retval= self.items[row][0]
-        else:
-            retval= QVariant()
-#         log.info(u'Returning"+ unicode(retval))
-        if type(retval) is not type(QVariant):
-            return QVariant(retval)
-        else:
-            return retval
-
-    def getFileList(self):
-        filelist = [item[0] for item in self.items];
-        return filelist
-
-    def getFilename(self, index):
-        row = index.row()
-        return self.items[row][0]

=== renamed file 'openlp/plugins/presentations/lib/impresscom.py' => 'openlp/plugins/presentations/lib/impressslidecontroller.py'
--- openlp/plugins/presentations/lib/impresscom.py	2009-07-02 19:04:50 +0000
+++ openlp/plugins/presentations/lib/impressslidecontroller.py	2009-07-12 11:12:51 +0000
@@ -28,9 +28,14 @@
 import time
 import uno
 
-class Openoffice(object):
+from PyQt4 import QtCore, QtGui
+from openlp.core.lib import OpenLPToolbar, translate
+from openlp.core.ui.slidecontroller import MasterToolbar
+
+class impressToolbar(MasterToolbar):
     def __init__(self):
         self.startOpenoffice()
+        self.isLive = True
 
     def createResolver(self):
         self.localContext = uno.getComponentContext()
@@ -100,6 +105,143 @@
         self._app.Terminate()
         self._app = None
         self._sm = None
+    def defineToolbar(self):
+        # Controller toolbar
+        self.Toolbar = OpenLPToolbar(self)
+        sizeToolbarPolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
+            QtGui.QSizePolicy.Fixed)
+        sizeToolbarPolicy.setHorizontalStretch(0)
+        sizeToolbarPolicy.setVerticalStretch(0)
+        sizeToolbarPolicy.setHeightForWidth(
+            self.Toolbar.sizePolicy().hasHeightForWidth())
+        self.Toolbar.setSizePolicy(sizeToolbarPolicy)
+
+        if self.isLive:
+            self.Toolbar.addToolbarButton(u'First Slide',
+                u':/slides/slide_first.png',
+                translate(u'SlideController', u'Move to first'),
+                self.onSlideSelectedFirst)
+        self.Toolbar.addToolbarButton(u'Previous Slide',
+            u':/slides/slide_previous.png',
+            translate(u'SlideController', u'Move to previous'),
+            self.onSlideSelectedPrevious)
+        self.Toolbar.addToolbarButton(u'Next Slide',
+            u':/slides/slide_next.png',
+            translate(u'SlideController', u'Move to next'),
+            self.onSlideSelectedNext)
+        if self.isLive:
+            self.Toolbar.addToolbarButton(u'Last Slide',
+                u':/slides/slide_last.png',
+                translate(u'SlideController', u'Move to last'),
+                self.onSlideSelectedLast)
+            self.Toolbar.addSeparator()
+            self.Toolbar.addToolbarButton(u'Close Screen',
+                u':/slides/slide_close.png',
+                translate(u'SlideController', u'Close Screen'),
+                self.onBlankScreen)
+
+    def serviceLoaded(self):
+        """
+        method to allow toolbars to know when the service item
+        is fully in place
+        """
+        pass
+
+    def onSlideSelectedFirst(self):
+        """
+        Go to the first slide.
+        """
+        self.PreviewListWidget.selectRow(0)
+        self.onSlideSelected()
+
+    def onSlideSelectedNext(self):
+        """
+        Go to the next slide.
+        """
+        row = self.PreviewListWidget.currentRow() + 1
+        if row == self.PreviewListWidget.rowCount():
+            row = 0
+        self.PreviewListWidget.selectRow(row)
+        self.onSlideSelected()
+
+    def onSlideSelectedPrevious(self):
+        """
+        Go to the previous slide.
+        """
+        row = self.PreviewListWidget.currentRow() - 1
+        if row == -1:
+            row = self.PreviewListWidget.rowCount() - 1
+        self.PreviewListWidget.selectRow(row)
+        self.onSlideSelected()
+
+    def onSlideSelectedLast(self):
+        """
+        Go to the last slide.
+        """
+        self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount() - 1)
+        self.onSlideSelected()
+
+    def onBlankScreen(self):
+        """
+        Blank the screen.
+        """
+        self.mainDisplay.blankDisplay()
+
+    def onSlideSelected(self):
+        """
+        Generate the preview when you click on a slide.
+        if this is the Live Controller also display on the screen
+        """
+        row = self.PreviewListWidget.currentRow()
+        if row > -1 and row < self.PreviewListWidget.rowCount():
+            label = self.PreviewListWidget.cellWidget(row, 0)
+            smallframe = label.pixmap()
+            frame = self.serviceitem.frames[row][u'image']
+            self.SlidePreview.setPixmap(smallframe)
+            if self.isLive:
+                self.mainDisplay.frameView(frame)
+
+    def addServiceItem(self, serviceitem, slideno = 1):
+        """
+        Loads a ServiceItem into the system from plugins
+        Display the first slide
+        """
+        log.debug(u'add Service Item')
+#        serviceitem.render()
+#        self.addServiceManagerItem(serviceitem, 0)
+
+    def addServiceManagerItem(self, serviceitem, slideno):
+        """
+        Loads a ServiceItem into the system from ServiceManager
+        Display the slide number passed
+        """
+        log.debug(u'add Service Manager Item')
+#        self.PreviewListWidget.clear()
+#        self.PreviewListWidget.setRowCount(0)
+#        self.serviceitem = serviceitem
+#        framenumber = 0
+#        for frame in self.serviceitem.frames:
+#            self.PreviewListWidget.setRowCount(self.PreviewListWidget.rowCount() + 1)
+#            pixmap = QtGui.QPixmap.fromImage(frame[u'image'])
+#            item = QtGui.QTableWidgetItem()
+#            label = QtGui.QLabel()
+#            label.setMargin(15)
+#            label.setScaledContents(True)
+#            width = 300
+#            height = width * pixmap.height() / pixmap.width()
+#            label.setPixmap(pixmap)
+#            self.PreviewListWidget.setCellWidget(framenumber, 0,label)
+#            self.PreviewListWidget.setItem( framenumber, 0, item)
+#            self.PreviewListWidget.setRowHeight(framenumber, height)
+#            self.PreviewListWidget.setColumnWidth(0, width)
+#            framenumber += 1
+#        if slideno > self.PreviewListWidget.rowCount():
+#            self.PreviewListWidget.selectRow(self.PreviewListWidget.rowCount())
+#        else:
+#            self.PreviewListWidget.selectRow(slideno)
+#        self.onSlideSelected()
+#        self.serviceLoaded()
+
 
 class ImpressCOMPres(object):
 

=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py	2009-07-09 16:51:25 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py	2009-07-12 11:12:51 +0000
@@ -21,25 +21,26 @@
 import os
 
 from PyQt4 import QtCore, QtGui
-from openlp.plugins.presentations.lib import FileListData
 from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD
 
 # We have to explicitly create separate classes for each plugin
 # in order for DnD to the Service manager to work correctly.
 class PresentationListView(BaseListWithDnD):
     def __init__(self, parent=None):
-        self.PluginName = u'Presentation'
+        self.PluginName = u'Presentations'
         BaseListWithDnD.__init__(self, parent)
 
 class PresentationMediaItem(MediaManagerItem):
     """
-    This is the custom media manager item for Custom Slides.
+    This is the Presentation media manager item for Presentation Items.
+    It can present files using Openoffice
     """
     global log
     log=logging.getLogger(u'PresentationsMediaItem')
     log.info(u'Presentations Media Item loaded')
 
-    def __init__(self, parent, icon, title):
+    def __init__(self, parent, icon, title, controllers):
+        self.controllers = controllers
         self.TranslationContext = u'PresentationPlugin'
         self.PluginTextShort = u'Presentation'
         self.ConfigSection = u'presentation'
@@ -76,10 +77,13 @@
 
     def initialise(self):
         list = self.parent.config.load_list(u'presentations')
-        self.loadPresentationList(list)
-        self.DisplayTypeComboBox.addItem(u'Impress')
-#        self.DisplayTypeComboBox.addItem(u'Powerpoint')
-#        self.DisplayTypeComboBox.addItem(u'Keynote')
+        self.loadList(list)
+        for item in self.controllers:
+            #load the drop down selection
+            self.DisplayTypeComboBox.addItem(item)
+            #load the preview toolbars
+            self.parent.preview_controller.registerToolbar(item,  self.controllers[item])
+            self.parent.live_controller.registerToolbar(item,  self.controllers[item])
 
     def loadList(self, list):
         for file in list:
@@ -88,14 +92,21 @@
             item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
             self.ListView.addItem(item_name)
 
-    def loadPresentationList(self, list):
-        pass
-#        for files in list:
-#            self.PresentationsListData.addRow(files)
+    def onDeleteClick(self):
+        item = self.ListView.currentItem()
+        if item is not None:
+            item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+            row = self.ListView.row(item)
+            self.ListView.takeItem(row)
+            self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList())
 
-    def onPresentationDeleteClick(self):
-        indexes = self.PresentationsListView.selectedIndexes()
-        for index in indexes:
-            current_row = int(index.row())
-            self.PresentationsListData.removeRow(current_row)
-        self.parent.config.set_list(u'Presentations', self.PresentationsListData.getFileList())
+    def generateSlideData(self, service_item):
+        items = self.ListView.selectedIndexes()
+        service_item.title = self.DisplayTypeComboBox.currentText()
+        service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
+        for item in items:
+            bitem =  self.ListView.item(item.row())
+            filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
+            frame = QtGui.QImage(unicode(filename))
+            (path, name) = os.path.split(filename)
+            service_item.add_using_toolbar(path, name)

=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py	2009-07-09 16:51:25 +0000
+++ openlp/plugins/presentations/presentationplugin.py	2009-07-12 11:12:51 +0000
@@ -24,7 +24,7 @@
 from PyQt4 import QtCore, QtGui
 
 from openlp.core.lib import Plugin,  MediaManagerItem
-from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab,  Openoffice
+from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab,  impressToolbar
 
 class PresentationPlugin(Plugin):
 
@@ -34,25 +34,49 @@
     def __init__(self, plugin_helpers):
         # Call the parent constructor
         log.debug('Initialised')
+        self.controllers = {}
         Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers)
         self.weight = -8
         # Create the plugin icon
         self.icon = QtGui.QIcon()
         self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),
             QtGui.QIcon.Normal, QtGui.QIcon.Off)
+        self.dnd_id = u'Presentations'
 
     def get_settings_tab(self):
+        """
+        Create the settings Tab
+        """
         self.presentation_tab = PresentationTab()
         return self.presentation_tab
 
     def get_media_manager_item(self):
-        # Create the MediaManagerItem object
-        self.media_item = PresentationMediaItem(self, self.icon, u'Presentations')
+        """
+        Create the Media Manager List
+        """
+        self.media_item = PresentationMediaItem(self, self.icon, u'Presentations', self.controllers)
         return self.media_item
 
+    def registerControllers(self, handle, controller):
+        self.controllers[handle] = controller
+
     def check_pre_conditions(self):
+        """
+        Check to see if we have any presentation software available
+        If Not do not install the plugin.
+        """
         log.debug('check_pre_conditions')
-        return True
-#        self.openoffice = Openoffice()
+        impress = True
+        try:
+            #Check to see if we have uno installed
+            import uno
+            openoffice = impressToolbar()
+            self.registerControllers(u'Impress', openoffice)
+        except:
+            pass
+        #If we have no controllers disable plugin
+        if len(self.controllers) > 0:
+            return True
+        else:
+            return False
 #        return self.openoffice.checkOoPid()
-


Follow ups