From 586425b0d9a54688bbf82efa174e340749cb14bc Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Fri, 14 Aug 2009 18:41:29 +0100 Subject: [PATCH] Clean up Remotes Add Tab to remotes to set Openlp.org port number --- openlp/plugins/presentations/lib/__init__.py | 4 +- .../lib/impressslidecontroller.py | 329 ------------------ openlp/plugins/remotes/lib/__init__.py | 2 +- openlp/plugins/remotes/lib/mediaitem.py | 215 ------------ openlp/plugins/remotes/remoteplugin.py | 9 +- 5 files changed, 11 insertions(+), 548 deletions(-) delete mode 100644 openlp/plugins/presentations/lib/impressslidecontroller.py delete mode 100644 openlp/plugins/remotes/lib/mediaitem.py diff --git a/openlp/plugins/presentations/lib/__init__.py b/openlp/plugins/presentations/lib/__init__.py index 627f40e36..4eb846020 100644 --- a/openlp/plugins/presentations/lib/__init__.py +++ b/openlp/plugins/presentations/lib/__init__.py @@ -19,6 +19,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA """ from mediaitem import PresentationMediaItem from presentationtab import PresentationTab -from impressslidecontroller import impressToolbar +from impresscontroller import impressController -__all__ = ['PresentationMediaItem', 'PresentationTab', 'impressToolbar'] +__all__ = ['PresentationMediaItem', 'PresentationTab', 'impressController'] diff --git a/openlp/plugins/presentations/lib/impressslidecontroller.py b/openlp/plugins/presentations/lib/impressslidecontroller.py deleted file mode 100644 index b8ba26e86..000000000 --- a/openlp/plugins/presentations/lib/impressslidecontroller.py +++ /dev/null @@ -1,329 +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-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 -# http://www.oooforum.org/forum/viewtopic.phtml?t=5252 -# http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Working_with_Presentations -# http://mail.python.org/pipermail/python-win32/2008-January/006676.html - -import os , subprocess -import time -import uno - -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() - 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 -invisible -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): - if os.name == u'nt': - import win32api - handle = win32api.OpenProcess(PROCESS_TERMINATE, False, self.oopid) - #todo need some code here - return True - 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: - self._app = self._sm.createInstance( "com.sun.star.frame.Desktop" ) - print "started" - except: - print "oops" - self._sm = None - self._app = None - return - - def getApp(self): - if self._app == None: - self.createApp() - if self._app == None: - return None - return self._app - - app = property(getApp) - - def quit(self): - 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): - - def __init__(self, oooApp, filename): - self.oooApp = oooApp - self.filename = filename - self.open() - - def getPres(self): - if self._pres == None: - self.open() - return self._pres - - pres = property(getPres) - - def open(self): - self.comp = self.oooApp.app.loadComponentFromURL(u'file:///' + self.filename, '_blank', 0, []) - self.presdoc = self.comp.getPresentation() - self.presdoc.start() - self._pres = self.presdoc.getController() - - def close(self): - self.pres.deactivate() - self.presdoc.end() - self.comp.dispose() - self._pres = None - self.presdoc = None - self.comp = None - - def isActive(self): - return self.pres.isRunning() and self.pres.isActive() - - def resume(self): - return self.pres.resume() - - def pause(self): - return self.pres.pause() - - def blankScreen(self): - self.pres.blankScreen(0) - - def stop(self): - self.pres.deactivate() - # self.presdoc.end() - - def go(self): - self.pres.activate() - # self.presdoc.start() - - def getSlideNumber(self): - return self.pres.getCurrentSlideIndex - - def setSlideNumber(self, slideno): - self.pres.gotoSlideIndex(slideno) - - slideNumber = property(getSlideNumber, setSlideNumber) - - def nextStep(self): - self.pres.gotoNextEffect() - - def prevStep(self): - self.pres.gotoPreviousSlide() - - def moveWindow(self, top, height, left, width): - # position the window somehow - pass - -class ImpressCOMSlide(object): - def __init__(self, pres, index): - self.pres = pres - self.slide = pres.getSlideByIndex(index) - - def preview(self): - if self.preview == None: - # get a slide somehow - pass - return self.preview - -if __name__ == '__main__': - ooo = Openoffice() - ooo.createResolver() - #show = ImpressCOMPres(ooo, u'/home/timali/test1.odp') - #show.go() - #show.resume() - #show.nextStep() diff --git a/openlp/plugins/remotes/lib/__init__.py b/openlp/plugins/remotes/lib/__init__.py index 5581e75fe..a35185ad9 100644 --- a/openlp/plugins/remotes/lib/__init__.py +++ b/openlp/plugins/remotes/lib/__init__.py @@ -18,4 +18,4 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -from mediaitem import RemoteMediaItem +from remotetab import RemoteTab diff --git a/openlp/plugins/remotes/lib/mediaitem.py b/openlp/plugins/remotes/lib/mediaitem.py deleted file mode 100644 index f66dd6189..000000000 --- a/openlp/plugins/remotes/lib/mediaitem.py +++ /dev/null @@ -1,215 +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-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 logging - -from PyQt4 import QtCore, QtGui - -from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, BaseListWithDnD - -class RemoteListView(BaseListWithDnD): - def __init__(self, parent=None): - self.PluginName = u'Remote' - BaseListWithDnD.__init__(self, parent) - -class RemoteMediaItem(MediaManagerItem): - """ - This is the custom media manager item for Custom Slides. - """ - global log - log=logging.getLogger(u'RemoteMediaItem') - log.info(u'Remote Media Item loaded') - - def __init__(self, parent, icon, title): - MediaManagerItem.__init__(self, parent, icon, title) - self.parent = parent - self.TranslationContext = u'RemotesPlugin' - self.PluginTextShort = u'Remotes' - self.ConfigSection = u'Remotes' - self.ListViewWithDnD_class = RemoteListView - MediaManagerItem.__init__(self, parent, icon, title) - - def initialise(self): - pass - - def setupUi(self): - # Add a toolbar - self.addToolbar() -# # Create buttons for the toolbar -# ## New Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'New Custom Item'), -# translate(u'CustomMediaItem',u'Add a new Custom Item'), -# u':/custom/custom_new.png', self.onCustomNewClick, u'CustomNewItem') -# ## Edit Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Edit Custom Item'), -# translate(u'CustomMediaItem',u'Edit the selected Custom Item'), -# u':/custom/custom_edit.png', self.onCustomEditClick, u'CustomEditItem') -# ## Delete Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Delete Custom Item'), -# translate(u'CustomMediaItem',u'Delete the selected Custom Item'), -# u':/custom/custom_delete.png', self.onCustomDeleteClick, u'CustomDeleteItem') -# ## Separator Line ## -# self.addToolbarSeparator() -# ## Preview Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Preview Custom Item'), -# translate(u'CustomMediaItem',u'Preview the selected Custom Item'), -# u':/system/system_preview.png', self.onCustomPreviewClick, u'CustomPreviewItem') -# ## Live Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Go Live'), -# translate(u'CustomMediaItem', u'Send the selected Custom live'), -# u':/system/system_live.png', self.onCustomLiveClick, u'CustomLiveItem') -# ## Add Custom Button ## -# self.addToolbarButton( -# translate(u'CustomMediaItem',u'Add Custom To Service'), -# translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'), -# u':/system/system_add.png', self.onCustomAddClick, u'CustomAddItem') -# # Add the Customlist widget -# self.CustomWidget = QtGui.QWidget(self) -# sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) -# sizePolicy.setHorizontalStretch(0) -# sizePolicy.setVerticalStretch(0) -# sizePolicy.setHeightForWidth(self.CustomWidget.sizePolicy().hasHeightForWidth()) -# self.CustomWidget.setSizePolicy(sizePolicy) -# self.CustomWidget.setObjectName(u'CustomWidget') -# # Add the Custom widget to the page layout -# self.PageLayout.addWidget(self.CustomWidget) -# self.CustomListView = CustomList() -# self.CustomListView.setAlternatingRowColors(True) -# self.CustomListData = TextListData() -# self.CustomListView.setModel(self.CustomListData) -# self.CustomListView.setDragEnabled(True) -# self.PageLayout.addWidget(self.CustomListView) -# # Signals -# QtCore.QObject.connect(self.CustomListView, -# QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onCustomPreviewClick) -# #define and add the context menu -# self.CustomListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) -# self.CustomListView.addAction(self.contextMenuAction(self.CustomListView, -# ':/custom/custom_edit.png', translate(u'CustomMediaItem', u'&Edit Custom'), -# self.onCustomEditClick)) -# self.CustomListView.addAction(self.contextMenuSeparator(self.CustomListView)) -# self.CustomListView.addAction(self.contextMenuAction( -# self.CustomListView, ':/system/system_preview.png', -# translate(u'CustomMediaItem',u'&Preview Custom'), self.onCustomPreviewClick)) -# self.CustomListView.addAction(self.contextMenuAction( -# self.CustomListView, ':/system/system_live.png', -# translate(u'CustomMediaItem',u'&Show Live'), self.onCustomLiveClick)) -# self.CustomListView.addAction(self.contextMenuAction( -# self.CustomListView, ':/system/system_add.png', -# translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick)) - -# def retranslateUi(self): -# self.ClearTextButton.setText(translate(u'CustomMediaItem', u'Clear')) -# self.SearchTextButton.setText(translate(u'CustomMediaItem', u'Search')) - -# def initialise(self): -# self.loadCustomList(self.parent.custommanager.get_all_slides()) -# -# def loadCustomList(self, list): -# self.CustomListData.resetStore() -# for CustomSlide in list: -# self.CustomListData.addRow(CustomSlide.id,CustomSlide.title) -# -# def onClearTextButtonClick(self): -# """ -# Clear the search text. -# """ -# self.SearchTextEdit.clear() -# -# def onSearchTextEditChanged(self, text): -# # only search if > 3 characters -# if len(text) > 3: -# self.onSearchTextButtonClick() -# -# def onSearchTextButtonClick(self): -# search_keywords = str(self.SearchTextEdit.displayText()) -# search_results = [] -# search_type = self.SearchTypeComboBox.currentText() -# search_results = self.Custommanager.search_Custom_lyrics(search_keywords) -# self._display_results(search_results) -# -# def onCustomNewClick(self): -# self.parent.edit_custom_form.loadCustom(0) -# self.parent.edit_custom_form.exec_() -# self.initialise() -# -# def onCustomEditClick(self): -# indexes = self.CustomListView.selectedIndexes() -# for index in indexes: -# self.parent.edit_custom_form.loadCustom(self.CustomListData.getId(index)) -# self.parent.edit_custom_form.exec_() -# self.initialise() -# -# def onCustomDeleteClick(self): -# indexes = self.CustomListView.selectedIndexes() -# for index in indexes: -# id = self.CustomListData.getId(index) -# self.parent.custommanager.delete_custom(id) -# self.CustomListData.deleteRow(index) -# -# def onCustomPreviewClick(self): -# log.debug(u'Custom Preview Requested') -# service_item = ServiceItem(self.parent) -# service_item.addIcon(u':/media/media_song.png') -# self.generateSlideData(service_item) -# self.parent.preview_controller.addServiceItem(service_item) -# -# def onCustomLiveClick(self): -# log.debug(u'Custom Live Requested') -# service_item = ServiceItem(self.parent) -# service_item.addIcon(u':/media/media_song.png') -# self.generateSlideData(service_item) -# self.parent.live_controller.addServiceItem(service_item) -# -# def onCustomAddClick(self): -# log.debug(u'Custom Add Requested') -# service_item = ServiceItem(self.parent) -# service_item.addIcon(u':/media/media_song.png') -# self.generateSlideData(service_item) -# self.parent.service_manager.addServiceItem(service_item) -# -# def generateSlideData(self, service_item): -# raw_slides =[] -# raw_footer = [] -# slide = None -# theme = None -# indexes = self.CustomListView.selectedIndexes() -# for index in indexes: -# id = self.CustomListData.getId(index) -# customSlide = self.parent.custommanager.get_custom(id) -# title = customSlide.title -# credit = customSlide.credits -# theme = customSlide.theme_name -# if len(theme) is not 0 : -# service_item.theme = theme -# songXML=SongXMLParser(customSlide.text) -# verseList = songXML.get_verses() -# for verse in verseList: -# raw_slides.append(verse[1]) -# raw_footer.append(title + u' '+ credit) -# if theme is not None: -# service_item.title = title -# for slide in raw_slides: -# service_item.add_from_text(slide[:30], slide) -# service_item.raw_footer = raw_footer diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 1c37c3c2c..98be53b01 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -23,6 +23,7 @@ import sys from PyQt4 import QtNetwork, QtGui, QtCore from openlp.core.lib import Plugin, Event, EventType +from openlp.plugins.remotes.lib import RemoteTab class RemotesPlugin(Plugin): @@ -35,10 +36,16 @@ class RemotesPlugin(Plugin): Plugin.__init__(self, u'Remotes', u'1.9.0', plugin_helpers) self.weight = -1 self.server = QtNetwork.QUdpSocket() - self.server.bind(4316) + self.server.bind(int(self.config.get_config(u'remote port', 4316))) QtCore.QObject.connect(self.server, QtCore.SIGNAL(u'readyRead()'), self.readData) + def get_settings_tab(self): + """ + Create the settings Tab + """ + return RemoteTab() + def readData(self): log.info(u'Remoted data has arrived') while self.server.hasPendingDatagrams():