diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index dba0f5ace..edf430604 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -257,5 +257,7 @@ class Plugin(object): """ Called by plugin to replace toolbar """ - self.mediadock.insertDock(self.name) - self.settings.insertTab(self.name) + if self.media_item is not None: + self.mediadock.insertDock(self.media_item, self.icon, self.weight) + if self.settings_tab is not None: + self.settings.insertTab(self.settings_tab, self.weight) diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index c99bbc934..860f7a4bc 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -90,7 +90,8 @@ class PluginManager(object): try: __import__(modulename, globals(), locals(), []) except ImportError, e: - log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, e.args[0]) + log.error(u'Failed to import module %s on path %s for reason %s', + modulename, path, e.args[0]) plugin_classes = Plugin.__subclasses__() self.plugins = [] plugin_objects = [] @@ -139,8 +140,7 @@ class PluginManager(object): if plugin.media_item is not None: log.debug(u'Inserting media manager item from %s' % \ plugin.name) - mediadock.addDock(plugin.name, - plugin.media_item, plugin.icon) + mediadock.addDock(plugin.media_item, plugin.icon, plugin.weight) def hook_settings_tabs(self, settingsform=None): """ diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index 9462cd423..018ee416f 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -31,21 +31,31 @@ class MediaDockManager(object): def __init__(self, mediaDock): self.mediaDock = mediaDock - def addDock(self, name, media_item, icon): - log.info(u'Adding %s dock' % name) + def addDock(self, media_item, icon, weight): + log.info(u'Adding %s dock' % media_item.title) id = self.mediaDock.addItem( - media_item, icon, media_item.title) + media_item, icon, media_item.title) + + def insertDock(self, media_item, icon, weight): + """ + This should insert a dock item at a given location + This does not work as it gives a Segmentation error. + For now add at end of stack if not present + """ + log.debug(u'Inserting %s dock' % media_item.title) + match = False + for dock_index in range(0, self.mediaDock.count()): + if self.mediaDock.widget(dock_index).ConfigSection == media_item.title.lower(): + match = True + break + if not match: + self.mediaDock.addItem(media_item, icon, media_item.title) - def insertDock(self, name): - log.debug(u'Inserting %s dock' % name) - for tab_index in range(0, self.mediaDock.count()): - #print self.mediaDock.widget(tab_index).ConfigSection, name - if self.mediaDock.widget(tab_index).ConfigSection == name.lower(): - self.mediaDock.setItemEnabled(tab_index, True) def removeDock(self, name): log.debug(u'remove %s dock' % name) - for tab_index in range(0, self.mediaDock.count()): - #print "rd", self.mediaDock.widget(tab_index).ConfigSection, name - if self.mediaDock.widget(tab_index).ConfigSection == name.lower(): - self.mediaDock.setItemEnabled(tab_index, False) + for dock_index in range(0, self.mediaDock.count()): + if self.mediaDock.widget(dock_index) is not None: + if self.mediaDock.widget(dock_index).ConfigSection == name.lower(): + self.mediaDock.widget(dock_index).hide() + self.mediaDock.removeItem(dock_index) diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index 9d3c5e3f7..6203b5982 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -48,16 +48,18 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def addTab(self, name, tab): log.info(u'Adding %s tab' % tab.title()) - id = self.SettingsTabWidget.addTab(tab, tab.title()) + self.SettingsTabWidget.addTab(tab, tab.title()) - def insertTab(self, name): - log.debug(u'Inserting %s tab' % name) - for tab_index in range(0, self.SettingsTabWidget.count()): + def insertTab(self, tab, location): + log.debug(u'Inserting %s tab' % tab.title()) + self.SettingsTabWidget.insertTab(location + 13, tab, tab.title()) + #for tab_index in range(0, self.SettingsTabWidget.count()): #print self.SettingsTabWidget.widget(tab_index).title() - if self.SettingsTabWidget.widget(tab_index).title() == name: + #if self.SettingsTabWidget.widget(tab_index).title() == name: #print "Insert match" #print self.SettingsTabWidget.widget(tab_index).isVisible() - self.SettingsTabWidget.setTabEnabled(tab_index, True) + #self.SettingsTabWidget.setTabEnabled(tab_index, True) + #self.SettingsTabWidget.removeTab(tab_index) #print self.SettingsTabWidget.widget(tab_index).isVisible() @@ -65,12 +67,14 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): log.debug(u'remove %s tab' % name) #print ">>>>>>>>>>> remove settings" for tab_index in range(0, self.SettingsTabWidget.count()): - #print "rt", self.SettingsTabWidget.widget(tab_index).title(), name - if self.SettingsTabWidget.widget(tab_index).title() == name: - #print "remove match" - #print self.SettingsTabWidget.widget(tab_index).isVisible() - self.SettingsTabWidget.setTabEnabled(tab_index, False) - #print self.SettingsTabWidget.widget(tab_index).isVisible() + if self.SettingsTabWidget.widget(tab_index) is not None: + #print "rt", self.SettingsTabWidget.widget(tab_index).title(), name + if self.SettingsTabWidget.widget(tab_index).title() == name: + #print "remove match" + #print self.SettingsTabWidget.widget(tab_index).isVisible() + #self.SettingsTabWidget.setTabEnabled(tab_index, False) + self.SettingsTabWidget.removeTab(tab_index) + #print self.SettingsTabWidget.widget(tab_index).isVisible() def accept(self): for tab_index in range(0, self.SettingsTabWidget.count()): diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 6b79bd083..944e94b18 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -67,7 +67,7 @@ class BiblePlugin(Plugin): def get_media_manager_item(self): # Create the BibleManagerItem object - return BibleMediaItem(self, self.icon, u'Bible Verses') + return BibleMediaItem(self, self.icon, u'Bibles') def add_import_menu_item(self, import_menu): self.ImportBibleItem = QtGui.QAction(import_menu) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 5cba902f4..e880fb0c1 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -110,17 +110,22 @@ class BibleMediaItem(MediaManagerItem): self.ClearQuickSearchComboBox.setObjectName(u'ClearQuickSearchComboBox') self.QuickLayout.addWidget(self.ClearQuickSearchComboBox, 3, 1, 1, 1) self.QuickVerticalLayout.addLayout(self.QuickLayout) + self.QuickSecondBibleComboBox = QtGui.QComboBox(self.QuickTab) + self.QuickSecondBibleComboBox.setObjectName(u'SecondBible') + self.QuickVerticalLayout.addWidget(self.QuickSecondBibleComboBox) self.QuickMessage = QtGui.QLabel(self.QuickTab) self.QuickMessage.setObjectName(u'QuickMessage') self.QuickVerticalLayout.addWidget(self.QuickMessage) self.SearchTabWidget.addTab(self.QuickTab, 'Quick') - QuickSpacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, + QuickSpacerItem = QtGui.QSpacerItem(20, 35, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.QuickLayout.addItem(QuickSpacerItem, 4, 2, 1, 1) # Add the Advanced Search tab self.AdvancedTab = QtGui.QWidget() self.AdvancedTab.setObjectName(u'AdvancedTab') - self.AdvancedLayout = QtGui.QGridLayout(self.AdvancedTab) + self.AdvancedVerticalLayout = QtGui.QVBoxLayout(self.AdvancedTab) + self.AdvancedVerticalLayout.setObjectName("verticalLayout") + self.AdvancedLayout = QtGui.QGridLayout() self.AdvancedLayout.setMargin(5) self.AdvancedLayout.setSpacing(4) self.AdvancedLayout.setObjectName(u'AdvancedLayout') @@ -171,6 +176,10 @@ class BibleMediaItem(MediaManagerItem): self.AdvancedSearchButton = QtGui.QPushButton(self.AdvancedTab) self.AdvancedSearchButton.setObjectName(u'AdvancedSearchButton') self.AdvancedLayout.addWidget(self.AdvancedSearchButton, 5, 3, 1, 1) + self.AdvancedVerticalLayout.addLayout(self.AdvancedLayout) + self.AdvancedSecondBibleComboBox = QtGui.QComboBox(self.AdvancedTab) + self.AdvancedSecondBibleComboBox.setObjectName(u'SecondBible') + self.AdvancedVerticalLayout.addWidget(self.AdvancedSecondBibleComboBox) self.SearchTabWidget.addTab(self.AdvancedTab, u'Advanced') # Add the search tab widget to the page layout self.PageLayout.addWidget(self.SearchTabWidget) @@ -240,17 +249,23 @@ class BibleMediaItem(MediaManagerItem): def loadBibles(self): log.debug(u'Loading Bibles') self.QuickVersionComboBox.clear() + self.QuickSecondBibleComboBox.clear() self.AdvancedVersionComboBox.clear() + self.AdvancedSecondBibleComboBox.clear() + self.QuickSecondBibleComboBox.addItem(u'') + self.AdvancedSecondBibleComboBox.addItem(u'') bibles = self.parent.biblemanager.get_bibles(BibleMode.Full) # load bibles into the combo boxes for bible in bibles: self.QuickVersionComboBox.addItem(bible) + self.QuickSecondBibleComboBox.addItem(bible) # Without HTTP bibles = self.parent.biblemanager.get_bibles(BibleMode.Partial) first = True # load bibles into the combo boxes for bible in bibles: self.AdvancedVersionComboBox.addItem(bible) + self.AdvancedSecondBibleComboBox.addItem(bible) if first: first = False # use the first bible as the trigger @@ -337,16 +352,13 @@ class BibleMediaItem(MediaManagerItem): for item in items: bitem = self.ListView.item(item.row()) text = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) - verse = text[:text.find(u'(')] + search_verse = text[:text.find(u'(')] bible = text[text.find(u'(') + 1:-1] - self.searchByReference(bible, verse) + self.searchByReference(bible, search_verse) book = self.search_results[0].book.name chapter = unicode(self.search_results[0].chapter) verse = unicode(self.search_results[0].verse) text = self.search_results[0].text - #Paragraph style force new line per verse - if self.parent.settings_tab.layout_style == 1: - text = text + u'\n\n' if self.parent.settings_tab.display_style == 1: loc = self.formatVerse(old_chapter, chapter, verse, u'(u', u')') elif self.parent.settings_tab.display_style == 2: @@ -356,18 +368,41 @@ class BibleMediaItem(MediaManagerItem): else: loc = self.formatVerse(old_chapter, chapter, verse, u'', u'') old_chapter = chapter - bible_text = bible_text + u' '+ loc + u' '+ text - #if we are verse per slide then create slide - if self.parent.settings_tab.layout_style == 0: - raw_slides.append(bible_text) - bible_text = u'' - service_item.title = book + u' ' + loc - footer = book + u' (' + self.version + u' ' + self.copyright +u')' + footer = u'%s (%s %s)' % (book, self.version, self.copyright) #If not found throws and error so add.s try: raw_footer.index(footer) except: raw_footer.append(footer) + #If we want to use a 2nd translation / version + bible2 = u'' + if self.SearchTabWidget.currentIndex() == 0: + bible2 = unicode(self.QuickSecondBibleComboBox.currentText()) + else: + bible2 = unicode(self.AdvancedSecondBibleComboBox.currentText()) + if len(bible2) > 0: + self.searchByReference(bible2, search_verse) + footer = u'%s (%s %s)' % (book, self.version, self.copyright) + #If not found throws and error so add.s + try: + raw_footer.index(footer) + except: + raw_footer.append(footer) + bible_text = u'%s %s \n\n\n %s %s)' % \ + (loc, text, loc, self.search_results[0].text) + raw_slides.append(bible_text) + bible_text = u'' + else: + #Paragraph style force new line per verse + if self.parent.settings_tab.layout_style == 1: + text = text + u'\n\n' + bible_text = u'%s %s %s' % (bible_text, loc, text) + #if we are verse per slide then create slide + if self.parent.settings_tab.layout_style == 0: + raw_slides.append(bible_text) + bible_text = u'' + service_item.title = u'%s %s' % (book, loc) + if len(self.parent.settings_tab.bible_theme) == 0: service_item.theme = None else: diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index b68f4a5e5..fef589715 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -54,7 +54,19 @@ class CustomPlugin(Plugin): def get_media_manager_item(self): # Create the CustomManagerItem object - return CustomMediaItem(self, self.icon, u'Custom Slides') + return CustomMediaItem(self, self.icon, u'Custom') + + def can_be_disabled(self): + return True + + def initialise(self): + log.info(u'Plugin Initialising') + Plugin.initialise(self) + self.insert_toolbox_item() + + def finalise(self): + log.info(u'Plugin Finalise') + self.remove_toolbox_item() def about(self): return u'Custom Plugin
This plugin allows slides to be displayed on the screen in the same way songs are. The difference between this plugin and songs is this plugin provides greater freedom.

This is a core plugin and cannot be made inactive'