From 92b1b82a58bd9c6903d95d5edc74599297c6ad43 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 25 Jun 2009 20:42:22 +0100 Subject: [PATCH 1/6] Clean up cnvdb Start on Presentation Plugin code for Impress --- cnvdb.py | 34 +++++++-- openlp/plugins/presentations/lib/__init__.py | 3 +- .../plugins/presentations/lib/impresscom.py | 75 +++++++++++++++++-- .../presentations/presentationplugin.py | 14 +++- 4 files changed, 109 insertions(+), 17 deletions(-) diff --git a/cnvdb.py b/cnvdb.py index 4bf4af2f8..73c105b5b 100644 --- a/cnvdb.py +++ b/cnvdb.py @@ -1,4 +1,25 @@ +#!/usr/bin/env python +# -*- 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-2009 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 codecs +import sys class Convert(): @@ -8,16 +29,17 @@ class Convert(): def process(self, inname, outname): infile = codecs.open(inname, 'r', encoding='iso-8859-1') writefile = codecs.open(outname, 'w', encoding='utf-8') - count = 0 for line in infile: writefile.write(line) - if count < 150: - print line - count += 1 infile.close() writefile.close() - if __name__ == '__main__': + if len(sys.argv) < 2: + print 'No action specified.' + sys.exit() + print u'Uncode conversion ' + print u'Input file = ', sys.argv[1:] + print u'Output file = ', sys.argv[2:] mig = Convert() - mig.process(u'/home/timali/.local/share/openlp/songs/songs.dmp',u'/home/timali/.local/share/openlp/songs/songs.dmp2') + mig.process(sys.argv[1:],sys.argv[2:]) diff --git a/openlp/plugins/presentations/lib/__init__.py b/openlp/plugins/presentations/lib/__init__.py index c84152dd5..767d922a0 100644 --- a/openlp/plugins/presentations/lib/__init__.py +++ b/openlp/plugins/presentations/lib/__init__.py @@ -21,5 +21,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA from filelistdata import FileListData from mediaitem import PresentationMediaItem from presentationtab import PresentationTab +from impresscom import Openoffice -__all__ = ['PresentationMediaItem', 'FileListData', 'PresentationTab'] +__all__ = ['PresentationMediaItem', 'FileListData', 'PresentationTab', 'OpenOffice'] diff --git a/openlp/plugins/presentations/lib/impresscom.py b/openlp/plugins/presentations/lib/impresscom.py index d522ae1d0..b5fb63579 100644 --- a/openlp/plugins/presentations/lib/impresscom.py +++ b/openlp/plugins/presentations/lib/impresscom.py @@ -1,5 +1,22 @@ -#from win32com.client import Dispatch +# -*- 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-2009 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 +""" # OOo API documentation: # http://api.openoffice.org/docs/common/ref/com/sun/star/presentation/XSlideShowController.html # http://docs.go-oo.org/sd/html/classsd_1_1SlideShow.html @@ -7,15 +24,55 @@ # http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations # http://mail.python.org/pipermail/python-win32/2008-January/006676.html -class ImpressCOMApp(object): +import os , subprocess +import time +import uno + +class Openoffice(object): def __init__(self): + self.startOpenoffice() + + def createResolver(self): + self.localContext = uno.getComponentContext() + self.resolver = self.localContext.ServiceManager.createInstanceWithContext(u'com.sun.star.bridge.UnoUrlResolver', self.localContext) + try: + self.ctx = self.resolver.resolve(u'uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext') + except: + return False + return True + + def buildEnvironment(self): + self.smgr = self.ctx.ServiceManager + self.desktop = self.smgr.createInstanceWithContext( "com.sun.star.frame.Desktop", self.ctx ) + self.model = self.desktop.getCurrentComponent() + text = self.model.Text + cursor = text.createTextCursor() + text.insertString(cursor, "Hello world", 0) + self.ctx.ServiceManager self.createApp() + if self._sm == None: + # start OO here + # Create output log file + time.sleep(10) + self.createApp() + + def startOpenoffice(self): + cmd = u'openoffice.org -nologo -norestore -minimized ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"' + retval = subprocess.Popen(cmd, shell=True) + self.oopid = retval.pid + + def checkOoPid(self): + procfile = open("/proc/%d/stat" %(self.oopid)) + if procfile.readline().split()[1] == u'(soffice)': + return False + return True def createApp(self): try: - self._sm = Dispatch(u'com.sun.star.ServiceManager') self._app = self._sm.createInstance( "com.sun.star.frame.Desktop" ) + print "started" except: + print "oops" self._sm = None self._app = None return @@ -35,6 +92,7 @@ class ImpressCOMApp(object): self._sm = None class ImpressCOMPres(object): + def __init__(self, oooApp, filename): self.oooApp = oooApp self.filename = filename @@ -111,8 +169,9 @@ class ImpressCOMSlide(object): return self.preview if __name__ == '__main__': - ooo = ImpressCOMApp() - show = ImpressCOMPres(ooo, u'c:/test1.ppt') - show.go() - show.resume() - show.nextStep() + ooo = Openoffice() + ooo.createResolver() + #show = ImpressCOMPres(ooo, u'/home/timali/test1.odp') + #show.go() + #show.resume() + #show.nextStep() diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 53cd0a463..1bc95ef26 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -19,16 +19,21 @@ Place, Suite 330, Boston, MA 02111-1307 USA """ import os +import logging from PyQt4 import QtCore, QtGui from openlp.core.lib import Plugin, MediaManagerItem -from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab +from openlp.plugins.presentations.lib import PresentationMediaItem, PresentationTab, Openoffice class PresentationPlugin(Plugin): + global log + log = logging.getLogger(u'PresentationPlugin') + def __init__(self, plugin_helpers): # Call the parent constructor + log.debug('Initialised') Plugin.__init__(self, u'Presentations', u'1.9.0', plugin_helpers) self.weight = -8 # Create the plugin icon @@ -43,4 +48,9 @@ class PresentationPlugin(Plugin): def get_media_manager_item(self): # Create the MediaManagerItem object self.media_item = PresentationMediaItem(self, self.icon, u'Presentations') - return self.media_item \ No newline at end of file + return self.media_item + + def check_pre_conditions(self): + log.debug('check_pre_conditions') + self.openoffice = Openoffice() + return self.openoffice.checkOoPid() From 66c665d352a0b2d4929918d7d3e99c36c260c889 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Thu, 25 Jun 2009 21:06:02 +0100 Subject: [PATCH 2/6] More Fixes --- openlp/plugins/presentations/lib/impresscom.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/presentations/lib/impresscom.py b/openlp/plugins/presentations/lib/impresscom.py index b5fb63579..cee6c2ae8 100644 --- a/openlp/plugins/presentations/lib/impresscom.py +++ b/openlp/plugins/presentations/lib/impresscom.py @@ -57,15 +57,17 @@ class Openoffice(object): self.createApp() def startOpenoffice(self): - cmd = u'openoffice.org -nologo -norestore -minimized ' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"' + cmd = u'openoffice.org -nologo, -norestore, -minimized, -impress,' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"' retval = subprocess.Popen(cmd, shell=True) self.oopid = retval.pid def checkOoPid(self): procfile = open("/proc/%d/stat" %(self.oopid)) - if procfile.readline().split()[1] == u'(soffice)': - return False - return True + file = procfile.readline().split()[1] + print file + if file == u'(soffice)' or file == u'(openoffice.org)': + return True + return False def createApp(self): try: From 2879a524167380edc36e295c0359df2603d6fe7b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 26 Jun 2009 17:39:16 +0100 Subject: [PATCH 3/6] Start of plugable SlideControllers --- openlp/core/lib/mediamanageritem.py | 8 +- openlp/core/ui/__init__.py | 2 +- openlp/core/ui/mainwindow.py | 10 +- openlp/core/ui/servicemanager.py | 4 + openlp/plugins/images/lib/mediaitem.py | 5 +- .../plugins/presentations/lib/impresscom.py | 18 +- openlp/plugins/presentations/lib/mediaitem.py | 183 +++++++++--------- 7 files changed, 127 insertions(+), 103 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index d63b7f0f6..af1335220 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -48,6 +48,7 @@ class MediaManagerItem(QtGui.QWidget): if title is not None: self.title = title self.Toolbar = None + #self.ConfigSection = None self.PageLayout = QtGui.QVBoxLayout(self) self.PageLayout.setSpacing(0) self.PageLayout.setMargin(0) @@ -126,12 +127,12 @@ class MediaManagerItem(QtGui.QWidget): # "text with an icon" then all this will help # even for plugins of another sort, the setup of the right-click menu, common toolbar # will help to keep things consistent and ease the creation of new plugins - + # also a set of completely consistent action anesm then exist # (onPreviewClick() is always called that, rather than having the # name of the plugin added in as well... I regard that as a # feature, I guess others might differ!) - + def setupUi(self): # Add a toolbar self.addToolbar() @@ -219,7 +220,8 @@ class MediaManagerItem(QtGui.QWidget): self.parent.config.set_list(self.ConfigSection, self.ListData.getFileList()) def generateSlideData(self): - assert (0, 'This fn needs to be defined by the plugin'); + #assert (0, 'This fn needs to be defined by the plugin'); + pass def onPreviewClick(self): log.debug(self.PluginTextShort+u'Preview Requested') diff --git a/openlp/core/ui/__init__.py b/openlp/core/ui/__init__.py index cbc6cde0d..d6ee48872 100644 --- a/openlp/core/ui/__init__.py +++ b/openlp/core/ui/__init__.py @@ -17,7 +17,7 @@ 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 """ - +from slidecontrollermanager import SlideControllerManager from maindisplay import MainDisplay from amendthemeform import AmendThemeForm from slidecontroller import SlideController diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6da2e9875..c5d26bc46 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -23,7 +23,7 @@ import logging from PyQt4 import QtCore, QtGui from openlp.core.ui import AboutForm, SettingsForm, AlertForm, ServiceManager, \ - ThemeManager, MainDisplay, SlideController + ThemeManager, MainDisplay, SlideController, SlideControllerManager from openlp.core.lib import translate, Plugin, MediaManagerItem, SettingsTab, \ EventManager, RenderManager, PluginConfig from openlp.core import PluginManager @@ -50,6 +50,7 @@ class MainWindow(object): self.alertForm = AlertForm(self) self.aboutForm = AboutForm() self.settingsForm = SettingsForm(self.screenList, self) + self.slideControllerManager = SlideControllerManager() # Set up the path with plugins pluginpath = os.path.split(os.path.abspath(__file__))[0] pluginpath = os.path.abspath( @@ -167,8 +168,11 @@ class MainWindow(object): self.ControlSplitter.setObjectName(u'ControlSplitter') self.MainContentLayout.addWidget(self.ControlSplitter) # Create slide controllers - self.PreviewController = SlideController(self.ControlSplitter, self) - self.LiveController = SlideController(self.ControlSplitter, self, True) + PreviewController = SlideController(self.ControlSplitter, self) + LiveController = SlideController(self.ControlSplitter, self, True) + self.slideControllerManager.add_controllers(u'base', PreviewController, LiveController) + self.PreviewController = self.slideControllerManager.getPreviewController(u'base') + self.LiveController = self.slideControllerManager.getLiveController(u'base') # Create menu self.MenuBar = QtGui.QMenuBar(self.mainWindow) self.MenuBar.setGeometry(QtCore.QRect(0, 0, 1087, 27)) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 90323e25f..b39c45b46 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -280,6 +280,9 @@ class ServiceManager(QtGui.QWidget): self.service_theme = self.ThemeComboBox.currentText() self.parent.RenderManager.set_service_theme(self.service_theme) self.config.set_config(u'theme service theme', self.service_theme) + self.regenerateServiceItems() + + def regenerateServiceItems(self): if len(self.serviceItems) > 0: tempServiceItems = self.serviceItems self.onNewService() @@ -368,3 +371,4 @@ class ServiceManager(QtGui.QWidget): self.service_theme = u'' self.ThemeComboBox.setCurrentIndex(id) self.parent.RenderManager.set_service_theme(self.service_theme) + self.regenerateServiceItems() diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index a8898526b..687e0c53d 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -32,7 +32,7 @@ class ImageListView(BaseListWithDnD): def __init__(self, parent=None): self.PluginName = u'Image' BaseListWithDnD.__init__(self, parent) - + class ImageMediaItem(MediaManagerItem): """ This is the custom media manager item for images. @@ -49,10 +49,9 @@ class ImageMediaItem(MediaManagerItem): self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)' # this next is a class, not an instance of a class - it will # be instanced by the base MediaManagerItem - self.ListViewWithDnD_class = ImageListView + self.ListViewWithDnD_class = ImageListView MediaManagerItem.__init__(self, parent, icon, title) - def generateSlideData(self, service_item): indexes = self.ListView.selectedIndexes() service_item.title = u'Image(s)' diff --git a/openlp/plugins/presentations/lib/impresscom.py b/openlp/plugins/presentations/lib/impresscom.py index cee6c2ae8..3838e0b44 100644 --- a/openlp/plugins/presentations/lib/impresscom.py +++ b/openlp/plugins/presentations/lib/impresscom.py @@ -62,12 +62,20 @@ class Openoffice(object): self.oopid = retval.pid def checkOoPid(self): - procfile = open("/proc/%d/stat" %(self.oopid)) - file = procfile.readline().split()[1] - print file - if file == u'(soffice)' or file == u'(openoffice.org)': + if os.name == u'nt': + import win32api + handle = win32api.OpenProcess(PROCESS_TERMINATE, False, self.oopid) + #todo need some code here return True - return False + elif os.name == u'mac': + pass + else: + procfile = open("/proc/%d/stat" %(self.oopid)) + file = procfile.readline().split()[1] + print file + if file == u'(soffice)' or file == u'(openoffice.org)': + return True + return False def createApp(self): try: diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index 589196738..ab341c430 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -21,8 +21,15 @@ import logging import os from PyQt4 import QtCore, QtGui -from openlp.core.lib import MediaManagerItem, translate 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' + BaseListWithDnD.__init__(self, parent) class PresentationMediaItem(MediaManagerItem): """ @@ -33,88 +40,96 @@ class PresentationMediaItem(MediaManagerItem): log.info(u'Presentations Media Item loaded') def __init__(self, parent, icon, title): + self.TranslationContext = u'PresentationPlugin' + self.PluginTextShort = u'Presentation' + self.ConfigSection = u'presentation' + self.OnNewPrompt = u'Select Image(s)' + self.OnNewFileMasks = u'Images (*.ppt *.pps *.odp)' + # this next is a class, not an instance of a class - it will + # be instanced by the base MediaManagerItem + self.ListViewWithDnD_class = PresentationListView MediaManagerItem.__init__(self, parent, icon, title) - def setupUi(self): - # Add a toolbar - self.addToolbar() - # Create buttons for the toolbar - ## New Presentation Button ## - self.addToolbarButton( - translate(u'PresentationsMediaItem',u'New presentations'), - translate(u'PresentationsMediaItem',u'Load presentations into openlp.org'), - ':/presentations/presentation_load.png', self.onPresentationNewClick, 'PresentationNewItem') - ## Delete Presentation Button ## - self.addToolbarButton( - translate(u'PresentationsMediaItem',u'Delete Presentation'), - translate(u'PresentationsMediaItem',u'Delete the selected presentation'), - ':/presentations/presentation_delete.png', self.onPresentationDeleteClick, 'PresentationDeleteItem') - ## Separator Line ## - self.addToolbarSeparator() - ## Preview Presentation Button ## - self.addToolbarButton( - translate(u'PresentationsMediaItem',u'Preview Presentation'), - translate(u'PresentationsMediaItem',u'Preview the selected Presentation'), - ':/system/system_preview.png', self.onPresentationPreviewClick, 'PresentationPreviewItem') - ## Live Presentation Button ## - self.addToolbarButton( - translate(u'PresentationsMediaItem',u'Go Live'), - translate(u'PresentationsMediaItem',u'Send the selected presentation live'), - ':/system/system_live.png', self.onPresentationLiveClick, 'PresentationLiveItem') - ## Add Presentation Button ## - self.addToolbarButton( - translate(u'PresentationsMediaItem',u'Add Presentation To Service'), - translate(u'PresentationsMediaItem',u'Add the selected Presentations(s) to the service'), - ':/system/system_add.png',self.onPresentationAddClick, 'PresentationsAddItem') - ## Add the Presentationlist widget ## - - self.PresentationWidget = QtGui.QWidget(self) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.PresentationWidget.sizePolicy().hasHeightForWidth()) - self.PresentationWidget.setSizePolicy(sizePolicy) - self.PresentationWidget.setObjectName(u'PresentationWidget') - self.DisplayLayout = QtGui.QGridLayout(self.PresentationWidget) - self.DisplayLayout.setObjectName(u'DisplayLayout') - self.DisplayTypeComboBox = QtGui.QComboBox(self.PresentationWidget) - self.DisplayTypeComboBox.setObjectName(u'DisplayTypeComboBox') - self.DisplayLayout.addWidget(self.DisplayTypeComboBox, 0, 1, 1, 2) - self.DisplayTypeLabel = QtGui.QLabel(self.PresentationWidget) - self.DisplayTypeLabel.setObjectName(u'SearchTypeLabel') - self.DisplayLayout.addWidget(self.DisplayTypeLabel, 0, 0, 1, 1) - - self.DisplayTypeLabel.setText(translate(u'PresentationMediaItem', u'Present using:')) - - # Add the song widget to the page layout - self.PageLayout.addWidget(self.PresentationWidget) - - self.PresentationsListView = QtGui.QListView() - self.PresentationsListView.setAlternatingRowColors(True) - self.PresentationsListData = FileListData() - self.PresentationsListView.setModel(self.PresentationsListData) - - self.PageLayout.addWidget(self.PresentationsListView) - - #define and add the context menu - self.PresentationsListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - - self.PresentationsListView.addAction(self.contextMenuAction( - self.PresentationsListView, ':/system/system_preview.png', - translate(u'PresentationsMediaItem',u'&Preview presentations'), self.onPresentationPreviewClick)) - self.PresentationsListView.addAction(self.contextMenuAction( - self.PresentationsListView, ':/system/system_live.png', - translate(u'PresentationsMediaItem',u'&Show Live'), self.onPresentationLiveClick)) - self.PresentationsListView.addAction(self.contextMenuAction( - self.PresentationsListView, ':/system/system_add.png', - translate(u'PresentationsMediaItem',u'&Add to Service'), self.onPresentationAddClick)) +# def setupUi(self): +# # Add a toolbar +# self.addToolbar() +# # Create buttons for the toolbar +# ## New Presentation Button ## +# self.addToolbarButton( +# translate(u'PresentationsMediaItem',u'New presentations'), +# translate(u'PresentationsMediaItem',u'Load presentations into openlp.org'), +# ':/presentations/presentation_load.png', self.onPresentationNewClick, 'PresentationNewItem') +# ## Delete Presentation Button ## +# self.addToolbarButton( +# translate(u'PresentationsMediaItem',u'Delete Presentation'), +# translate(u'PresentationsMediaItem',u'Delete the selected presentation'), +# ':/presentations/presentation_delete.png', self.onPresentationDeleteClick, 'PresentationDeleteItem') +# ## Separator Line ## +# self.addToolbarSeparator() +# ## Preview Presentation Button ## +# self.addToolbarButton( +# translate(u'PresentationsMediaItem',u'Preview Presentation'), +# translate(u'PresentationsMediaItem',u'Preview the selected Presentation'), +# ':/system/system_preview.png', self.onPresentationPreviewClick, 'PresentationPreviewItem') +# ## Live Presentation Button ## +# self.addToolbarButton( +# translate(u'PresentationsMediaItem',u'Go Live'), +# translate(u'PresentationsMediaItem',u'Send the selected presentation live'), +# ':/system/system_live.png', self.onPresentationLiveClick, 'PresentationLiveItem') +# ## Add Presentation Button ## +# self.addToolbarButton( +# translate(u'PresentationsMediaItem',u'Add Presentation To Service'), +# translate(u'PresentationsMediaItem',u'Add the selected Presentations(s) to the service'), +# ':/system/system_add.png',self.onPresentationAddClick, 'PresentationsAddItem') +# ## Add the Presentationlist widget ## +# +# self.PresentationWidget = QtGui.QWidget(self) +# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) +# sizePolicy.setHorizontalStretch(0) +# sizePolicy.setVerticalStretch(0) +# sizePolicy.setHeightForWidth(self.PresentationWidget.sizePolicy().hasHeightForWidth()) +# self.PresentationWidget.setSizePolicy(sizePolicy) +# self.PresentationWidget.setObjectName(u'PresentationWidget') +# self.DisplayLayout = QtGui.QGridLayout(self.PresentationWidget) +# self.DisplayLayout.setObjectName(u'DisplayLayout') +# self.DisplayTypeComboBox = QtGui.QComboBox(self.PresentationWidget) +# self.DisplayTypeComboBox.setObjectName(u'DisplayTypeComboBox') +# self.DisplayLayout.addWidget(self.DisplayTypeComboBox, 0, 1, 1, 2) +# self.DisplayTypeLabel = QtGui.QLabel(self.PresentationWidget) +# self.DisplayTypeLabel.setObjectName(u'SearchTypeLabel') +# self.DisplayLayout.addWidget(self.DisplayTypeLabel, 0, 0, 1, 1) +# +# self.DisplayTypeLabel.setText(translate(u'PresentationMediaItem', u'Present using:')) +# +# # Add the song widget to the page layout +# self.PageLayout.addWidget(self.PresentationWidget) +# +# self.PresentationsListView = QtGui.QListView() +# self.PresentationsListView.setAlternatingRowColors(True) +# self.PresentationsListData = FileListData() +# self.PresentationsListView.setModel(self.PresentationsListData) +# +# self.PageLayout.addWidget(self.PresentationsListView) +# +# #define and add the context menu +# self.PresentationsListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) +# +# self.PresentationsListView.addAction(self.contextMenuAction( +# self.PresentationsListView, ':/system/system_preview.png', +# translate(u'PresentationsMediaItem',u'&Preview presentations'), self.onPresentationPreviewClick)) +# self.PresentationsListView.addAction(self.contextMenuAction( +# self.PresentationsListView, ':/system/system_live.png', +# translate(u'PresentationsMediaItem',u'&Show Live'), self.onPresentationLiveClick)) +# self.PresentationsListView.addAction(self.contextMenuAction( +# self.PresentationsListView, ':/system/system_add.png', +# translate(u'PresentationsMediaItem',u'&Add to Service'), self.onPresentationAddClick)) 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.DisplayTypeComboBox.addItem(u'Impress') +# self.DisplayTypeComboBox.addItem(u'Powerpoint') +# self.DisplayTypeComboBox.addItem(u'Keynote') def onPresentationNewClick(self): files = QtGui.QFileDialog.getOpenFileNames(None, @@ -131,8 +146,9 @@ class PresentationMediaItem(MediaManagerItem): return filelist def loadPresentationList(self, list): - for files in list: - self.PresentationsListData.addRow(files) + pass +# for files in list: +# self.PresentationsListData.addRow(files) def onPresentationDeleteClick(self): indexes = self.PresentationsListView.selectedIndexes() @@ -140,12 +156,3 @@ class PresentationMediaItem(MediaManagerItem): current_row = int(index.row()) self.PresentationsListData.removeRow(current_row) self.parent.config.set_list(u'Presentations', self.PresentationsListData.getFileList()) - - def onPresentationPreviewClick(self): - pass - - def onPresentationLiveClick(self): - pass - - def onPresentationAddClick(self): - pass \ No newline at end of file From b76790bc2fe7ea565b345326ede44303b0a9effb Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 26 Jun 2009 18:51:43 +0100 Subject: [PATCH 4/6] Fixes and cleanups following MediaManager Merge --- openlp/plugins/bibles/bibleplugin.py | 13 ++----- openlp/plugins/bibles/lib/mediaitem.py | 53 ++++++++++++++------------ openlp/plugins/custom/customplugin.py | 12 ++---- openlp/plugins/images/imageplugin.py | 3 +- openlp/plugins/media/mediaplugin.py | 2 + openlp/plugins/songs/songsplugin.py | 12 ++---- 6 files changed, 43 insertions(+), 52 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 517ce1cf8..0a1347fae 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -41,6 +41,9 @@ class BiblePlugin(Plugin): QtGui.QIcon.Normal, QtGui.QIcon.Off) #Register the bible Manager self.biblemanager = BibleManager(self.config) + # passed with drag and drop messages + self.dnd_id = u'Bibles' + def get_settings_tab(self): self.bibles_tab = BiblesTab() @@ -79,12 +82,4 @@ class BiblePlugin(Plugin): if event.event_type == EventType.ThemeListChanged: log.debug(u'New Theme request received') self.bibles_tab.updateThemeList(self.theme_manager.getThemes()) - if event.event_type == EventType.LoadServiceItem and event.payload == 'Bibles': - log.debug(u'Load Service Item received') - self.media_item.onBibleAddClick() - if event.event_type == EventType.PreviewShow and event.payload == 'Bibles': - log.debug(u'Load Preview Item received') - self.media_item.onBiblePreviewClick() - if event.event_type == EventType.LiveShow and event.payload == 'Bibles': - log.debug(u'Load Live Show Item received') - self.media_item.onBibleLiveClick() + Plugin.handle_event(self, event) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index b1f868a5c..ffce9712b 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -54,6 +54,11 @@ class BibleMediaItem(MediaManagerItem): log.info(u'Bible Media Item loaded') def __init__(self, parent, icon, title): + self.TranslationContext = u'BiblePlugin' + self.PluginTextShort = u'Bible' + self.ConfigSection = u'bibles' +# self.OnNewPrompt = u'Select Image(s)' +# self.OnNewFileMasks = u'Images (*.jpg *jpeg *.gif *.png *.bmp)' MediaManagerItem.__init__(self, parent, icon, title) self.search_results = {} # place to store the search results QtCore.QObject.connect(Receiver().get_receiver(), @@ -74,18 +79,18 @@ class BibleMediaItem(MediaManagerItem): self.addToolbarButton( translate(u'BibleMediaItem',u'Preview Bible'), translate(u'BibleMediaItem',u'Preview the selected Bible Verse'), - u':/system/system_preview.png', self.onBiblePreviewClick, u'BiblePreviewItem') + u':/system/system_preview.png', self.onPreviewClick, u'BiblePreviewItem') ## Live Bible Button ## self.addToolbarButton( translate(u'BibleMediaItem',u'Go Live'), translate(u'BibleMediaItem',u'Send the selected Bible Verse(s) live'), - u':/system/system_live.png', self.onBibleLiveClick, u'BibleLiveItem') + u':/system/system_live.png', self.onLiveClick, u'BibleLiveItem') ## Add Bible Button ## self.addToolbarButton( translate(u'BibleMediaItem',u'Add Bible Verse(s) To Service'), translate(u'BibleMediaItem',u'Add the selected Bible(s) to the service'), u':/system/system_add.png', - self.onBibleAddClick, u'BibleAddItem') + self.onAddClick, u'BibleAddItem') # Create the tab widget self.SearchTabWidget = QtGui.QTabWidget(self) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) @@ -209,18 +214,18 @@ class BibleMediaItem(MediaManagerItem): QtCore.QObject.connect(self.QuickSearchButton, QtCore.SIGNAL(u'pressed()'), self.onQuickSearchButton) QtCore.QObject.connect(self.BibleListWidget, - QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onBiblePreviewClick) + QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick) # Context Menus self.BibleListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.BibleListWidget.addAction(self.contextMenuAction( self.BibleListWidget, u':/system/system_preview.png', - translate(u'BibleMediaItem',u'&Preview Verse'), self.onBiblePreviewClick)) + translate(u'BibleMediaItem',u'&Preview Verse'), self.onPreviewClick)) self.BibleListWidget.addAction(self.contextMenuAction( self.BibleListWidget, u':/system/system_live.png', - translate(u'BibleMediaItem',u'&Show Live'), self.onBibleLiveClick)) + translate(u'BibleMediaItem',u'&Show Live'), self.onLiveClick)) self.BibleListWidget.addAction(self.contextMenuAction( self.BibleListWidget, u':/system/system_add.png', - translate(u'BibleMediaItem',u'&Add to Service'), self.onBibleAddClick)) + translate(u'BibleMediaItem',u'&Add to Service'), self.onAddClick)) def retranslateUi(self): log.debug(u'retranslateUi') @@ -330,23 +335,23 @@ class BibleMediaItem(MediaManagerItem): if self.search_results is not None: self.displayResults(bible) - def onBibleLiveClick(self): - service_item = ServiceItem(self.parent) - service_item.addIcon( u':/media/media_verse.png') - self.generateSlideData(service_item) - self.parent.live_controller.addServiceItem(service_item) - - def onBibleAddClick(self): - service_item = ServiceItem(self.parent) - service_item.addIcon(u':/media/media_verse.png') - self.generateSlideData(service_item) - self.parent.service_manager.addServiceItem(service_item) - - def onBiblePreviewClick(self): - service_item = ServiceItem(self.parent) - service_item.addIcon(u':/media/media_verse.png') - self.generateSlideData(service_item) - self.parent.preview_controller.addServiceItem(service_item) +# def onLiveClick(self): +# service_item = ServiceItem(self.parent) +# service_item.addIcon( u':/media/media_verse.png') +# self.generateSlideData(service_item) +# self.parent.live_controller.addServiceItem(service_item) +# +# def onAddClick(self): +# service_item = ServiceItem(self.parent) +# service_item.addIcon(u':/media/media_verse.png') +# self.generateSlideData(service_item) +# self.parent.service_manager.addServiceItem(service_item) +# +# def onPreviewClick(self): +# service_item = ServiceItem(self.parent) +# service_item.addIcon(u':/media/media_verse.png') +# self.generateSlideData(service_item) +# self.parent.preview_controller.addServiceItem(service_item) def generateSlideData(self, service_item): log.debug(u'generating slide data') diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 2f2d77a80..2efa30f1e 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -42,6 +42,8 @@ class CustomPlugin(Plugin): self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(u':/media/media_custom.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + # passed with drag and drop messages + self.dnd_id=u'Custom' def get_media_manager_item(self): # Create the CustomManagerItem object @@ -56,12 +58,4 @@ class CustomPlugin(Plugin): if event.event_type == EventType.ThemeListChanged: log.debug(u'New Theme request received') self.edit_custom_form.loadThemes(self.theme_manager.getThemes()) - if event.event_type == EventType.LoadServiceItem and event.payload == 'Custom': - log.debug(u'Load Service Item received') - self.media_item.onCustomAddClick() - if event.event_type == EventType.PreviewShow and event.payload == 'Custom': - log.debug(u'Load Preview Item received ') - self.media_item.onCustomPreviewClick() - if event.event_type == EventType.LiveShow and event.payload == 'Custom': - log.debug(u'Load Live Show Item received') - self.media_item.onCustomLiveClick() + Plugin.handle_event(self, event) diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index a9371524a..29330fbb4 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -37,7 +37,8 @@ class ImagePlugin(Plugin): self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(u':/media/media_image.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) - self.dnd_id = u'Image' # passed with drag and drop messages + # passed with drag and drop messages + self.dnd_id = u'Image' def get_media_manager_item(self): # Create the MediaManagerItem object diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 7c79c4bd7..e90257104 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -33,6 +33,8 @@ class MediaPlugin(Plugin): self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(u':/media/media_video.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + # passed with drag and drop messages + self.dnd_id=u'Media' def get_settings_tab(self): self.MediaTab = MediaTab() diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index f18f85e0d..5767f8dbe 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -45,6 +45,8 @@ class SongsPlugin(Plugin): self.icon = QtGui.QIcon() self.icon.addPixmap(QtGui.QPixmap(u':/media/media_song.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) + # passed with drag and drop messages + self.dnd_id=u'Songs' def get_media_manager_item(self): # Create the MediaManagerItem object @@ -125,15 +127,7 @@ class SongsPlugin(Plugin): if event.event_type == EventType.ThemeListChanged: log.debug(u'New Theme request received') self.media_item.edit_song_form.loadThemes(self.theme_manager.getThemes()) - if event.event_type == EventType.LoadServiceItem and event.payload == 'Song': - log.debug(u'Load Service Item received') - self.media_item.onSongAddClick() - if event.event_type == EventType.PreviewShow and event.payload == 'Song': - log.debug(u'Load Preview Item received ') - self.media_item.onSongPreviewClick() - if event.event_type == EventType.LiveShow and event.payload == 'Song': - log.debug(u'Load Live Show Item received') - self.media_item.onSongLiveClick() if event.event_type == EventType.LoadSongList : log.debug(u'Load Load Song List Item received') self.media_item.displayResultsSong(self.songmanager.get_songs()) + Plugin.handle_event(self, event) From c981cb21d274193399c0e669c61e7b99bc55a374 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 26 Jun 2009 19:54:05 +0100 Subject: [PATCH 5/6] More fixes and cleanups --- openlp/plugins/custom/lib/mediaitem.py | 3 +++ openlp/plugins/songs/lib/mediaitem.py | 3 +++ openlp/plugins/songs/songsplugin.py | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index e02050059..7120e4dcb 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -53,6 +53,9 @@ class CustomMediaItem(MediaManagerItem): log.info(u'Custom Media Item loaded') def __init__(self, parent, icon, title): + self.TranslationContext = u'CustomPlugin' + self.PluginTextShort = u'Custom' + self.ConfigSection = u'custom' MediaManagerItem.__init__(self, parent, icon, title) self.parent = parent diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 5d9455481..87c050fed 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -54,6 +54,9 @@ class SongMediaItem(MediaManagerItem): log.info(u'Song Media Item loaded') def __init__(self, parent, icon, title): + self.TranslationContext = u'SongPlugin' + self.PluginTextShort = u'Song' + self.ConfigSection = u'song' MediaManagerItem.__init__(self, parent, icon, title) self.edit_song_form = EditSongForm(self.parent.songmanager, self.parent.event_manager) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 5767f8dbe..c48bb6413 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -46,7 +46,7 @@ class SongsPlugin(Plugin): self.icon.addPixmap(QtGui.QPixmap(u':/media/media_song.png'), QtGui.QIcon.Normal, QtGui.QIcon.Off) # passed with drag and drop messages - self.dnd_id=u'Songs' + self.dnd_id=u'Song' def get_media_manager_item(self): # Create the MediaManagerItem object From b36b78afdceffd91d96e52e8aebae39faef3285b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 26 Jun 2009 20:06:28 +0100 Subject: [PATCH 6/6] Try to fix openoffice startup --- openlp/plugins/presentations/lib/impresscom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/presentations/lib/impresscom.py b/openlp/plugins/presentations/lib/impresscom.py index 3838e0b44..59c7366f8 100644 --- a/openlp/plugins/presentations/lib/impresscom.py +++ b/openlp/plugins/presentations/lib/impresscom.py @@ -57,7 +57,7 @@ class Openoffice(object): self.createApp() def startOpenoffice(self): - cmd = u'openoffice.org -nologo, -norestore, -minimized, -impress,' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"' + cmd = u'openoffice.org -nologo -norestore -minimized -impress' + u'"' + u'-accept=socket,host=localhost,port=2002;urp;'+ u'"' retval = subprocess.Popen(cmd, shell=True) self.oopid = retval.pid