diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 063f117b4..84f318896 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -82,3 +82,10 @@ class MediaManagerItem(QtGui.QWidget): A very simple method to add a separator to the toolbar. """ self.Toolbar.addSeparator() + + def getInputFile(self, dialogname, dialoglocation, dialogfilter): + return QtGui.QFileDialog.getOpenFileName(self, dialogname,dialoglocation, dialogfilter) + + def getInputFiles(self, dialogname, dialoglocation, dialogfilter): + return QtGui.QFileDialog.getOpenFileNames(self, dialogname,dialoglocation, dialogfilter) + diff --git a/openlp/core/lib/pluginutils.py b/openlp/core/lib/pluginutils.py index 882420da7..5ff5b3416 100644 --- a/openlp/core/lib/pluginutils.py +++ b/openlp/core/lib/pluginutils.py @@ -17,18 +17,15 @@ 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 types from PyQt4 import QtCore, QtGui class PluginUtils(object): - def __init__(self): - """ - IClass for plugin helpers so the Plugin class is just a simple interface - """ - pass - - def add_separator(self, base): + """ + Extension class for plugin helpers so the Plugin class is just a simple interface + """ + def add_to_context_separator(self, base): action = QtGui.QAction("", base) action.setSeparator(True) return action @@ -52,3 +49,40 @@ class PluginUtils(object): action .setIcon(ButtonIcon) QtCore.QObject.connect(action, QtCore.SIGNAL("triggered()"), slot) return action + + def _load_display_list(self): + """ + Load a display list from the config files + """ + listcount = self.config.get_config("List Count") + list = [] + if listcount != None: + for i in range(0 , int(listcount)): + x = self.config.get_config("List Item "+str(i)) + list.append(x) + return list + + def _save_display_list(self, displaylist): + """ + Save display list from the config files + """ + c = displaylist.rowCount() + self.config.set_config("List Count", str(c)) + for i in range (0, int(c)): + self.config.set_config("List Item "+str(i), str(displaylist.item(i, 0).text())) + + def _get_last_dir(self): + """ + Read the last directory used for plugin + """ + lastdir = self.config.get_config("Last Dir") + if lastdir==None: + lastdir = "" + return lastdir + + def _save_last_directory(self, list): + """ + Save the last directory used for plugin + """ + path , nm = os.path.split(str(list)) + self.config.set_config("Last Dir", path) diff --git a/openlp/plugins/bibles/lib/bibleCSVimpl.py b/openlp/plugins/bibles/lib/bibleCSVimpl.py index 8e3d03046..2c6aab305 100644 --- a/openlp/plugins/bibles/lib/bibleCSVimpl.py +++ b/openlp/plugins/bibles/lib/bibleCSVimpl.py @@ -19,17 +19,12 @@ import os, os.path import sys import urllib2 -mypath=os.path.split(os.path.abspath(__file__))[0] -sys.path.insert(0,(os.path.join(mypath, '..', '..', '..'))) +#mypath=os.path.split(os.path.abspath(__file__))[0] +#sys.path.insert(0,(os.path.join(mypath, '..', '..', '..'))) from openlp.plugins.bibles.lib.bibleDBimpl import BibleDBImpl from openlp.plugins.bibles.lib.biblecommon import BibleCommon import logging -logging.basicConfig(level=logging.DEBUG, - format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', - datefmt='%m-%d %H:%M', - filename='plugins.log', - filemode='w') class BibleCSVImpl(BibleCommon): global log diff --git a/openlp/plugins/bibles/lib/bibleHTTPimpl.py b/openlp/plugins/bibles/lib/bibleHTTPimpl.py index 626c1ded9..38da45fbc 100644 --- a/openlp/plugins/bibles/lib/bibleHTTPimpl.py +++ b/openlp/plugins/bibles/lib/bibleHTTPimpl.py @@ -20,16 +20,11 @@ import os, os.path import sys import urllib2 -mypath=os.path.split(os.path.abspath(__file__))[0] -sys.path.insert(0,(os.path.join(mypath, '..', '..', '..'))) +#mypath=os.path.split(os.path.abspath(__file__))[0] +#sys.path.insert(0,(os.path.join(mypath, '..', '..', '..'))) from openlp.plugins.bibles.lib.biblecommon import BibleCommon import logging -logging.basicConfig(level=logging.DEBUG, - format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', - datefmt='%m-%d %H:%M', - filename='plugins.log', - filemode='w') class BGExtract(BibleCommon): global log diff --git a/openlp/plugins/bibles/lib/bibleOSISimpl.py b/openlp/plugins/bibles/lib/bibleOSISimpl.py index 671725547..7dcc1ff1c 100644 --- a/openlp/plugins/bibles/lib/bibleOSISimpl.py +++ b/openlp/plugins/bibles/lib/bibleOSISimpl.py @@ -19,16 +19,11 @@ import os, os.path import sys import urllib2 -mypath=os.path.split(os.path.abspath(__file__))[0] -sys.path.insert(0,(os.path.join(mypath, '..', '..', '..'))) +#mypath=os.path.split(os.path.abspath(__file__))[0] +#sys.path.insert(0,(os.path.join(mypath, '..', '..', '..'))) from openlp.plugins.bibles.lib.bibleDBimpl import BibleDBImpl import logging -logging.basicConfig(level=logging.DEBUG, - format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', - datefmt='%m-%d %H:%M', - filename='plugins.log', - filemode='w') class BibleOSISImpl(): global log diff --git a/openlp/plugins/bibles/lib/biblemanager.py b/openlp/plugins/bibles/lib/biblemanager.py index 81326f10a..bbd480dc4 100644 --- a/openlp/plugins/bibles/lib/biblemanager.py +++ b/openlp/plugins/bibles/lib/biblemanager.py @@ -58,12 +58,13 @@ class BibleManager(): self.bibleDBCache[bname] = BibleDBImpl(self.biblePath, bname, self.bibleSuffix) biblesource = self.bibleDBCache[bname].get_meta("WEB") # look to see if lazy load bible exists and get create getter. if biblesource: - print biblesource nhttp = BibleHTTPImpl() nhttp.setBibleSource(biblesource) # tell The Server where to get the verses from. self.bibleHTTPCache[bname] = nhttp proxy = self.bibleDBCache[bname].get_meta("proxy") # look to see if lazy load bible exists and get create getter. nhttp.setProxy(proxy) # tell The Server where to get the verses from. + else: + self.bibleHTTPCache[bname] = None # makes the Full / partial code easier. # log.debug( "Bible Initialised") @@ -145,12 +146,16 @@ class BibleManager(): def get_bibles(self, mode="full"): """ Returns a list of Books of the bible + Mode "Full" - Returns all the bibles for the Queck seearch + Mode "Partial" - Returns CSV and OSIS bbles for the Advanced Search """ r=[] for b , o in self.bibleDBCache.iteritems(): - if mode != "full": - print self.bibleHTTPCache[b] - r.append(b) + if mode == "full": + r.append(b) + else: + if self.bibleHTTPCache[b] == None: # we do not have an http bible + r.append(b) return r def get_bible_books(self,bible): diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 0bdee340b..07f945824 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -18,12 +18,14 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ +import os + from PyQt4 import QtCore, QtGui from openlp.core.resources import * -from openlp.core.lib import Plugin, MediaManagerItem +from openlp.core.lib import Plugin, PluginUtils, MediaManagerItem -class PresentationPlugin(Plugin): +class PresentationPlugin(Plugin, PluginUtils): def __init__(self): # Call the parent constructor Plugin.__init__(self, 'Presentations', '1.9.0') @@ -48,36 +50,66 @@ class PresentationPlugin(Plugin): ':/presentations/presentation_delete.png', self.onPresentationDeleteClick, 'PresentationDeleteItem') ## Separator Line ## self.MediaManagerItem.addToolbarSeparator() - ## Preview Song Button ## - self.MediaManagerItem.addToolbarButton('Preview Song', 'Preview the selected presentation', + ## Preview Presentation Button ## + self.MediaManagerItem.addToolbarButton('Preview Presentation', 'Preview the selected presentation', ':/system/system_preview.png', self.onPresentationPreviewClick, 'PresentationPreviewItem') - ## Live Song Button ## + ## Live Presentation Button ## self.MediaManagerItem.addToolbarButton('Go Live', 'Send the selected presentation live', ':/system/system_live.png', self.onPresentationLiveClick, 'PresentationLiveItem') - ## Add Song Button ## + ## Add Presentation Button ## self.MediaManagerItem.addToolbarButton('Add Presentation To Service', 'Add the selected presentation(s) to the service', ':/system/system_add.png', self.onPresentationAddClick, 'PresentationAddItem') - ## Add the songlist widget ## + ## Add the Presentation widget ## + self.PresentationListView = QtGui.QTableWidget() + self.PresentationListView.setColumnCount(2) + self.PresentationListView.setColumnHidden(0, True) + self.PresentationListView.setColumnWidth(1, 275) + self.PresentationListView.setShowGrid(False) + self.PresentationListView.setSortingEnabled(False) + self.PresentationListView.setAlternatingRowColors(True) + self.PresentationListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Name"])) - self.listView = QtGui.QListWidget() - self.listView.setGeometry(QtCore.QRect(10, 100, 256, 591)) - self.listView.setObjectName("listView") - self.MediaManagerItem.PageLayout.addWidget(self.listView) + self.PresentationListView.setGeometry(QtCore.QRect(10, 100, 256, 591)) + self.PresentationListView.setObjectName("PresentationListView") + self.PresentationListView.setAlternatingRowColors(True) + self.MediaManagerItem.PageLayout.addWidget(self.PresentationListView) + + #define and add the context menu + self.PresentationListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + + self.PresentationListView.addAction(self.add_to_context_menu(self.PresentationListView, ':/system/system_preview.png', "&Preview Presentation", self.onPresentationPreviewClick)) + self.PresentationListView.addAction(self.add_to_context_menu(self.PresentationListView, ':/system/system_live.png', "&Show Live", self.onPresentationLiveClick)) + self.PresentationListView.addAction(self.pluginutils.add_to_context_menu(self.PresentationListView, ':/system/system_add.png', "&Add to Service", self.onPresentationAddClick)) return self.MediaManagerItem def initialise(self): - self.onPresentationLoadClick() + list = self._load_display_list() + self._load_presentation_list(list) def onPresentationLoadClick(self): - files = self.config.get_files(u'ppt,pps,odi') - self.listView.clear() - for f in files: - self.listView.addItem(f) + files = self.MediaManagerItem.getInputFiles("Select Presentation(s)", self._get_last_dir(), "Images (*.ppt *.pps *.odi)") + if len(files) > 0: + self._load_presentation_list(files) + self._save_last_directory(files[0]) + self._save_display_list(self.PresentationListView) + + def _load_presentation_list(self, list): + for f in list: + fl , nm = os.path.split(str(f)) + c = self.PresentationListView.rowCount() + self.PresentationListView.setRowCount(c+1) + twi = QtGui.QTableWidgetItem(str(f)) + self.PresentationListView.setItem(c , 0, twi) + twi = QtGui.QTableWidgetItem(str(nm)) + self.PresentationListView.setItem(c , 1, twi) + self.PresentationListView.setRowHeight(c, 20) def onPresentationDeleteClick(self): - pass + cr = self.PresentationListView.currentRow() + self.PresentationListView.removeRow(int(cr)) + self._save_display_list(self.PresentationListView) def onPresentationPreviewClick(self): pass diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index d53307c45..e60302904 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -21,12 +21,12 @@ Place, Suite 330, Boston, MA 02111-1307 USA from PyQt4 import QtCore, QtGui from openlp.core.resources import * -from openlp.core.lib import Plugin, MediaManagerItem +from openlp.core.lib import Plugin,PluginUtils, MediaManagerItem from forms import EditSongForm, OpenLPImportForm, OpenSongImportForm, \ OpenLPExportForm, OpenSongExportForm from openlp.plugins.songs.lib import SongManager -class SongsPlugin(Plugin): +class SongsPlugin(Plugin, PluginUtils): def __init__(self): # Call the parent constructor Plugin.__init__(self, 'Songs', '1.9.0') @@ -108,7 +108,9 @@ class SongsPlugin(Plugin): self.MediaManagerItem.PageLayout.addWidget(self.SongWidget) self.SongListView = QtGui.QTableWidget() self.SongListView.setColumnCount(3) - self.SongListView.setColumnHidden(0, True) + self.SongListView.setColumnHidden(0, True) + self.SongListView.setColumnWidth(1, 200) + self.SongListView.setColumnWidth(2, 80) self.SongListView.setShowGrid(False) self.SongListView.setSortingEnabled(False) self.SongListView.setAlternatingRowColors(True) @@ -127,11 +129,11 @@ class SongsPlugin(Plugin): #define and add the context menu self.SongListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - self.SongListView.addAction(self.pluginutils.add_to_context_menu(self.SongListView, ':/songs/song_new.png', "&Edit Song", self.onSongEditClick)) - self.SongListView.addAction(self.pluginutils.add_separator(self.SongListView)) - self.SongListView.addAction(self.pluginutils.add_to_context_menu(self.SongListView, ':/system/system_preview.png', "&Preview Song", self.onSongPreviewClick)) - self.SongListView.addAction(self.pluginutils.add_to_context_menu(self.SongListView, ':/system/system_live.png', "&Show Live", self.onSongLiveClick)) - self.SongListView.addAction(self.pluginutils.add_to_context_menu(self.SongListView, ':/system/system_add.png', "&Add to Service", self.onSongEditClick)) + self.SongListView.addAction(self.add_to_context_menu(self.SongListView, ':/songs/song_new.png', "&Edit Song", self.onSongEditClick)) + self.SongListView.addAction(self.add_to_context_separator(self.SongListView)) + self.SongListView.addAction(self.add_to_context_menu(self.SongListView, ':/system/system_preview.png', "&Preview Song", self.onSongPreviewClick)) + self.SongListView.addAction(self.add_to_context_menu(self.SongListView, ':/system/system_live.png', "&Show Live", self.onSongLiveClick)) + self.SongListView.addAction(self.add_to_context_menu(self.SongListView, ':/system/system_add.png', "&Add to Service", self.onSongEditClick)) return self.MediaManagerItem @@ -253,7 +255,7 @@ class SongsPlugin(Plugin): def _display_results(self): self.SongListView.clear() # clear the results - self.SongListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Song Name","Author"])) + self.SongListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Song Name","Author"])) self.SongListView.setVerticalHeaderLabels(QtCore.QStringList([""])) self.SongListView.setRowCount(0) for id, txt, name in self.searchresults: