diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 8d10c6509..50eb5638b 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -21,7 +21,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA import logging from openlp.core.lib import PluginConfig -from openlp.core.lib import PluginUtils class Plugin(object): """ @@ -86,7 +85,6 @@ class Plugin(object): self.version = version self.icon = None self.config = PluginConfig(self.name) - self.pluginutils = PluginUtils() self.weight = 0 # Set up logging self.log = logging.getLogger(self.name) diff --git a/openlp/core/lib/pluginconfig.py b/openlp/core/lib/pluginconfig.py index 571ae3752..6e204caba 100644 --- a/openlp/core/lib/pluginconfig.py +++ b/openlp/core/lib/pluginconfig.py @@ -37,6 +37,12 @@ class PluginConfig(object): Get a configuration value from the configuration registry. """ return ConfigHelper.get_config(self.section, key, default) + + def delete_config(self, key): + """ + Delete a configuration value from the configuration registry. + """ + return ConfigHelper.delete_config(self.section, key) def set_config(self, key, value): """ diff --git a/openlp/core/lib/pluginutils.py b/openlp/core/lib/pluginutils.py index 5ff5b3416..453905ba9 100644 --- a/openlp/core/lib/pluginutils.py +++ b/openlp/core/lib/pluginutils.py @@ -64,13 +64,17 @@ class PluginUtils(object): def _save_display_list(self, displaylist): """ - Save display list from the config files + Save display list from the config files tidy up the list """ - 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())) - + oldcount = self.config.get_config("List Count") + newcount = displaylist.rowCount() + self.config.set_config("List Count", str(newcount)) + for i in range (0, int(newcount)): + self.config.set_config("List Item "+str(i), str(displaylist.item(i, 0).text())) + if oldcount > newcount: # Tidy up any old list itrms if list is smaller now + for i in range(int(newcount) , int(oldcount)): + self.config.delete_config("List Item "+str(i)) + def _get_last_dir(self): """ Read the last directory used for plugin @@ -80,9 +84,9 @@ class PluginUtils(object): lastdir = "" return lastdir - def _save_last_directory(self, list): + def _save_last_directory(self, filename): """ Save the last directory used for plugin """ - path , nm = os.path.split(str(list)) + path , nm = os.path.split(str(filename)) self.config.set_config("Last Dir", path) diff --git a/openlp/core/utils/confighelper.py b/openlp/core/utils/confighelper.py index 5c30976ee..26e764473 100644 --- a/openlp/core/utils/confighelper.py +++ b/openlp/core/utils/confighelper.py @@ -57,6 +57,11 @@ class ConfigHelper(object): reg.create_section(section) return reg.set_value(section, key, value) + @staticmethod + def delete_config(section, key): + reg = ConfigHelper.get_registry() + reg.delete_value(section, key) + @staticmethod def get_registry(): """ diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 9ae5a96f0..6a309f18d 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -23,11 +23,11 @@ import logging 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 openlp.plugins.bibles.lib import BibleManager from openlp.plugins.bibles.forms import BibleImportForm -class BiblePlugin(Plugin): +class BiblePlugin(Plugin, PluginUtils): global log log=logging.getLogger("BiblePlugin") log.info("Bible Plugin loaded") @@ -170,11 +170,19 @@ class BiblePlugin(Plugin): # Add the search tab widget to the page layout self.MediaManagerItem.PageLayout.addWidget(self.SearchTabWidget) - self.listView = QtGui.QListWidget() - self.listView.setGeometry(QtCore.QRect(10, 200, 256, 391)) - self.listView.setObjectName("listView") - self.listView.setAlternatingRowColors(True) - self.MediaManagerItem.PageLayout.addWidget(self.listView) + self.BibleListView = QtGui.QTableWidget() + self.BibleListView.setColumnCount(2) + self.BibleListView.setColumnHidden(0, True) + self.BibleListView.setColumnWidth(1, 275) + self.BibleListView.setShowGrid(False) + self.BibleListView.setSortingEnabled(False) + self.BibleListView.setAlternatingRowColors(True) + self.BibleListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Bible Verses"])) + + self.BibleListView.setGeometry(QtCore.QRect(10, 200, 256, 391)) + self.BibleListView.setObjectName("listView") + self.BibleListView.setAlternatingRowColors(True) + self.MediaManagerItem.PageLayout.addWidget(self.BibleListView) #QtCore.QObject.connect(self.QuickTab, QtCore.SIGNAL("triggered()"), self.onQuickTabClick) QtCore.QObject.connect( self.SearchTabWidget, QtCore.SIGNAL("currentChanged ( QWidget * )" ), self.onQuickTabClick) @@ -188,11 +196,11 @@ class BiblePlugin(Plugin): QtCore.QObject.connect(self.QuickSearchButton, QtCore.SIGNAL("pressed()"), self.onQuickSearchButton) #define and add the context menu - self.listView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.BibleListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - self.listView.addAction(self.pluginutils.add_to_context_menu(self.listView, ':/system/system_preview.png', "&Preview Verse", self.onBiblePreviewClick)) - self.listView.addAction(self.pluginutils.add_to_context_menu(self.listView, ':/system/system_live.png', "&Show Live", self.onBibleLiveClick)) - self.listView.addAction(self.pluginutils.add_to_context_menu(self.listView, ':/system/system_add.png', "&Add to Service", self.onBibleAddClick)) + self.BibleListView.addAction(self.add_to_context_menu(self.BibleListView, ':/system/system_preview.png', "&Preview Verse", self.onBiblePreviewClick)) + self.BibleListView.addAction(self.add_to_context_menu(self.BibleListView, ':/system/system_live.png', "&Show Live", self.onBibleLiveClick)) + self.BibleListView.addAction(self.add_to_context_menu(self.BibleListView, ':/system/system_add.png', "&Add to Service", self.onBibleAddClick)) return self.MediaManagerItem def add_import_menu_item(self, import_menu): @@ -241,21 +249,19 @@ class BiblePlugin(Plugin): pass def _initialise_form(self): - bibles = self.biblemanager.get_bibles() + bibles = self.biblemanager.get_bibles("full") self.QuickSearchComboBox.addItem("Text Search") self.QuickSearchComboBox.addItem("Verse Search") - first = True for b in bibles: # load bibles into the combo boxes self.QuickVersionComboBox.addItem(b) + + bibles = self.biblemanager.get_bibles("partial") # Without HTTP + first = True + for b in bibles: # load bibles into the combo boxes self.AdvancedVersionComboBox.addItem(b) if first: first = False - self._initialise_bible(b) # use the fist bible as the trigger - - def _initialise_bible(self, bible): - log.debug("_initialise_bible %s ", bible) - self._initialise_bible_quick(bible) - self._initialise_bible_advanced(bible) + self._initialise_bible_advanced(b) # use the first bible as the trigger def _initialise_bible_advanced(self, bible): log.debug("_initialise_bible_advanced %s ", bible) @@ -318,7 +324,7 @@ class BiblePlugin(Plugin): versefrom = int(self.AdvancedFromVerse.currentText()) verseto = int(self.AdvancedToVerse.currentText()) self.searchresults = self.biblemanager.get_verse_text(bible, book, chapfrom, chapto, versefrom, verseto) - self._display_results() + self._display_results(bible) def onQuickSearchButton(self): self.log.debug("onQuickSearchButton") @@ -333,15 +339,24 @@ class BiblePlugin(Plugin): def _search_text(self, bible, text): self.log.debug("_search Text %s,%s", bible, text) self.searchresults = self.biblemanager.get_verse_from_text(bible,text) - self._display_results() + self._display_results(bible) - def _verse_search(self): - self._display_results() +# def _verse_search(self): +# self._display_results() - def _display_results(self): - self.listView.clear() # clear the results + def _display_results(self, bible): + self.BibleListView.clear() # clear the results + self.BibleListView.setRowCount(0) + self.BibleListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Bible Verses"])) for book, chap, vse , txt in self.searchresults: - self.listView.addItem(book + " " +str(chap) + ":"+ str(vse)) + c = self.BibleListView.rowCount() + self.BibleListView.setRowCount(c+1) + twi = QtGui.QTableWidgetItem(str(bible)) + self.BibleListView.setItem(c , 0, twi) + twi = QtGui.QTableWidgetItem(str(book + " " +str(chap) + ":"+ str(vse))) + self.BibleListView.setItem(c , 1, twi) + self.BibleListView.setRowHeight(c, 20) + def _initialise_bible_quick(self, bible): # not sure if needed yet! a=1 diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index 2ca377390..44bd9abac 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -17,13 +17,13 @@ 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 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 -class ImagePlugin(Plugin): +class ImagePlugin(Plugin, PluginUtils): def __init__(self): # Call the parent constructor Plugin.__init__(self, 'Images', '1.9.0') @@ -59,25 +59,54 @@ class ImagePlugin(Plugin): 'Add the selected image(s) to the service', ':/system/system_add.png', self.onImageAddClick, 'ImageAddItem') ## Add the songlist widget ## + self.ImageListView = QtGui.QTableWidget() + self.ImageListView.setColumnCount(2) + self.ImageListView.setColumnHidden(0, True) + self.ImageListView.setColumnWidth(1, 275) + self.ImageListView.setShowGrid(False) + self.ImageListView.setSortingEnabled(False) + self.ImageListView.setAlternatingRowColors(True) + self.ImageListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Name"])) + self.ImageListView.setAlternatingRowColors(True) + self.ImageListView.setGeometry(QtCore.QRect(10, 100, 256, 591)) + self.ImageListView.setObjectName("ImageListView") + self.MediaManagerItem.PageLayout.addWidget(self.ImageListView) + + #define and add the context menu + self.ImageListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - self.listView = QtGui.QListWidget() - self.listView.setGeometry(QtCore.QRect(10, 100, 256, 591)) - self.listView.setObjectName("listView") - self.MediaManagerItem.PageLayout.addWidget(self.listView) + self.ImageListView.addAction(self.add_to_context_menu(self.ImageListView, ':/system/system_preview.png', "&Preview Image", self.onImagePreviewClick)) + self.ImageListView.addAction(self.add_to_context_menu(self.ImageListView, ':/system/system_live.png', "&Show Live", self.onImageLiveClick)) + self.ImageListView.addAction(self.add_to_context_menu(self.ImageListView, ':/system/system_add.png', "&Add to Service", self.onImageAddClick)) return self.MediaManagerItem def initialise(self): - self.onImagesNewClick() + list = self._load_display_list() + self._load_image_list(list) def onImagesNewClick(self): - files = self.config.get_files(u'jpg,gif,png,bmp') - self.listView.clear() - for f in files: - self.listView.addItem(f) + files = self.MediaManagerItem.getInputFiles("Select Image(s)", self._get_last_dir(), "Images (*.jpg *.gif *.png *.bmp)") + if len(files) > 0: + self._load_image_list(files) + self._save_last_directory(files[0]) + self._save_display_list(self.ImageListView) + def _load_image_list(self, list): + for f in list: + fl , nm = os.path.split(str(f)) + c = self.ImageListView.rowCount() + self.ImageListView.setRowCount(c+1) + twi = QtGui.QTableWidgetItem(str(f)) + self.ImageListView.setItem(c , 0, twi) + twi = QtGui.QTableWidgetItem(str(nm)) + self.ImageListView.setItem(c , 1, twi) + self.ImageListView.setRowHeight(c, 20) + def onImageDeleteClick(self): - pass + cr = self.ImageListView.currentRow() + self.ImageListView.removeRow(int(cr)) + self._save_display_list(self.ImageListView) def onImagePreviewClick(self): pass diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 07f945824..115a78cee 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -80,7 +80,7 @@ class PresentationPlugin(Plugin, PluginUtils): 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)) + self.PresentationListView.addAction(self.add_to_context_menu(self.PresentationListView, ':/system/system_add.png', "&Add to Service", self.onPresentationAddClick)) return self.MediaManagerItem diff --git a/openlp/plugins/videos/videoplugin.py b/openlp/plugins/videos/videoplugin.py index 1b5189feb..9d606692a 100644 --- a/openlp/plugins/videos/videoplugin.py +++ b/openlp/plugins/videos/videoplugin.py @@ -17,13 +17,13 @@ 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 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 VideoPlugin(Plugin): +class VideoPlugin(Plugin, PluginUtils): def __init__(self): # Call the parent constructor Plugin.__init__(self, 'Videos', '1.9.0') @@ -40,8 +40,8 @@ class VideoPlugin(Plugin): self.MediaManagerItem.addToolbar() # Create buttons for the toolbar ## New Song Button ## - self.MediaManagerItem.addToolbarButton('Load Video', 'Load videos into openlp.org', - ':/videos/video_load.png', self.onVideoLoadClick, 'VideoLoadItem') + self.MediaManagerItem.addToolbarButton('New Video', 'Load videos into openlp.org', + ':/videos/video_load.png', self.onVideoNewClick, 'VideoNewItem') ## Delete Song Button ## self.MediaManagerItem.addToolbarButton('Delete Video', 'Delete the selected video', ':/videos/video_delete.png', self.onVideoDeleteClick, 'VideoDeleteItem') @@ -57,26 +57,54 @@ class VideoPlugin(Plugin): self.MediaManagerItem.addToolbarButton('Add Video To Service', 'Add the selected video(s) to the service', ':/system/system_add.png', self.onVideoAddClick, 'VideoAddItem') - ## Add the songlist widget ## - - self.listView = QtGui.QListWidget() - self.listView.setGeometry(QtCore.QRect(10, 100, 256, 591)) - self.listView.setObjectName("listView") - self.MediaManagerItem.PageLayout.addWidget(self.listView) + ## Add the videolist widget ## + self.VideoListView = QtGui.QTableWidget() + self.VideoListView.setColumnCount(2) + self.VideoListView.setColumnHidden(0, True) + self.VideoListView.setColumnWidth(1, 275) + self.VideoListView.setShowGrid(False) + self.VideoListView.setSortingEnabled(False) + self.VideoListView.setAlternatingRowColors(True) + self.VideoListView.setHorizontalHeaderLabels(QtCore.QStringList(["","Name"])) + self.VideoListView.setAlternatingRowColors(True) + self.VideoListView.setGeometry(QtCore.QRect(10, 100, 256, 591)) + self.VideoListView.setObjectName("VideoListView") + self.MediaManagerItem.PageLayout.addWidget(self.VideoListView) + + #define and add the context menu + self.VideoListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.VideoListView.addAction(self.add_to_context_menu(self.VideoListView, ':/system/system_preview.png', "&Preview Video", self.onVideoPreviewClick)) + self.VideoListView.addAction(self.add_to_context_menu(self.VideoListView, ':/system/system_live.png', "&Show Live", self.onVideoLiveClick)) + self.VideoListView.addAction(self.add_to_context_menu(self.VideoListView, ':/system/system_add.png', "&Add to Service", self.onVideoAddClick)) return self.MediaManagerItem def initialise(self): - self.onVideoLoadClick() + list = self._load_display_list() + self._load_video_list(list) - def onVideoLoadClick(self): - files = self.config.get_files(u'avi,mpeg') - self.listView.clear() - for f in files: - self.listView.addItem(f) + def onVideoNewClick(self): + files = self.MediaManagerItem.getInputFiles("Select Image(s)", self._get_last_dir(), "Images (*.avi *.mpeg)") + if len(files) > 0: + self._load_video_list(files) + self._save_last_directory(files[0]) + self._save_display_list(self.VideoListView) + def _load_video_list(self, list): + for f in list: + fl , nm = os.path.split(str(f)) + c = self.VideoListView.rowCount() + self.VideoListView.setRowCount(c+1) + twi = QtGui.QTableWidgetItem(str(f)) + self.VideoListView.setItem(c , 0, twi) + twi = QtGui.QTableWidgetItem(str(nm)) + self.VideoListView.setItem(c , 1, twi) + self.VideoListView.setRowHeight(c, 20) + def onVideoDeleteClick(self): - pass + cr = self.VideoListView.currentRow() + self.VideoListView.removeRow(int(cr)) + self._save_display_list(self.VideoListView) def onVideoPreviewClick(self): pass