← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~trb143/openlp/bug-795980 into lp:openlp

 

Tim Bentley has proposed merging lp:~trb143/openlp/bug-795980 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #795980 in OpenLP: ""Replace Background" is reset when sending an item live but there has not been sent an item live before"
  https://bugs.launchpad.net/openlp/+bug/795980

For more details, see:
https://code.launchpad.net/~trb143/openlp/bug-795980/+merge/66717

Stop Media and Image plugins replacing backgrounds when there is no ServiceItem to interact with
-- 
https://code.launchpad.net/~trb143/openlp/bug-795980/+merge/66717
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/bug-795980 into lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2011-06-12 16:02:52 +0000
+++ openlp/core/lib/mediamanageritem.py	2011-07-03 08:21:10 +0000
@@ -288,6 +288,7 @@
                 self.listView, u':/general/general_add.png',
                 translate('OpenLP.MediaManagerItem',
                 '&Add to selected Service Item'), self.onAddEditClick)
+        self.addCustomContextActions()
         # Create the context menu and add all actions from the listView.
         self.menu = QtGui.QMenu()
         self.menu.addActions(self.listView.actions())
@@ -301,6 +302,13 @@
             QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
             self.contextMenu)
 
+    def addCustomContextActions(self):
+        """
+        Implement this method in your descendent media manager item to
+        add any context menu items. This method is called automatically.
+        """
+        pass
+
     def initialise(self):
         """
         Implement this method in your descendent media manager item to

=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2011-06-21 21:08:30 +0000
+++ openlp/core/ui/maindisplay.py	2011-07-03 08:21:10 +0000
@@ -233,10 +233,12 @@
         API for replacement backgrounds so Images are added directly to cache
         """
         self.image_manager.add_image(name, path)
-        self.image(name)
         if hasattr(self, u'serviceItem'):
             self.override[u'image'] = name
             self.override[u'theme'] = self.serviceItem.themedata.theme_name
+            self.image(name)
+            return True
+        return False
 
     def image(self, name):
         """
@@ -349,6 +351,9 @@
         """
         Loads and starts a video to run with the option of sound
         """
+        # We request a background video but have no service Item
+        if isBackground and not hasattr(self, u'serviceItem'):
+            return None
         if not self.mediaObject:
             self.createMediaObject()
         log.debug(u'video')

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2011-07-01 08:26:26 +0000
+++ openlp/core/ui/servicemanager.py	2011-07-03 08:21:10 +0000
@@ -48,18 +48,18 @@
     """
     Set up key bindings and mouse behaviour for the service list
     """
-    def __init__(self, mainwindow, parent=None, name=None):
+    def __init__(self, serviceManager, parent=None, name=None):
         QtGui.QTreeWidget.__init__(self, parent)
-        self.mainwindow = mainwindow
+        self.serviceManager = serviceManager
 
     def keyPressEvent(self, event):
         if isinstance(event, QtGui.QKeyEvent):
             # here accept the event and do something
             if event.key() == QtCore.Qt.Key_Up:
-                self.mainwindow.onMoveSelectionUp()
+                self.serviceManager.onMoveSelectionUp()
                 event.accept()
             elif event.key() == QtCore.Qt.Key_Down:
-                self.mainwindow.onMoveSelectionDown()
+                self.serviceManager.onMoveSelectionDown()
                 event.accept()
             event.ignore()
         else:

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2011-06-24 06:53:56 +0000
+++ openlp/core/ui/slidecontroller.py	2011-07-03 08:21:10 +0000
@@ -27,6 +27,7 @@
 
 import logging
 import os
+import time
 
 from PyQt4 import QtCore, QtGui
 from PyQt4.phonon import Phonon
@@ -412,9 +413,11 @@
         self.display.videoStop()
 
     def servicePrevious(self):
+        time.sleep(0.1)
         Receiver.send_message('servicemanager_previous_item')
 
     def serviceNext(self):
+        time.sleep(0.1)
         Receiver.send_message('servicemanager_next_item')
 
     def screenSizeChanged(self):

=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py	2011-06-12 17:56:11 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py	2011-07-03 08:21:10 +0000
@@ -34,7 +34,8 @@
     translate
 from openlp.core.lib.searchedit import SearchEdit
 from openlp.core.lib.ui import UiStrings, add_widget_completer, \
-    media_item_combo_box, critical_error_message_box, find_and_set_in_combo_box
+    media_item_combo_box, critical_error_message_box, \
+    find_and_set_in_combo_box, build_icon
 from openlp.plugins.bibles.forms import BibleImportForm
 from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
     VerseReferenceList, get_reference_match
@@ -57,8 +58,8 @@
 
     def __init__(self, parent, plugin, icon):
         self.IconPath = u'songs/song'
-        self.lockIcon = QtGui.QIcon(u':/bibles/bibles_search_lock.png')
-        self.unlockIcon = QtGui.QIcon(u':/bibles/bibles_search_unlock.png')
+        self.lockIcon = build_icon(u':/bibles/bibles_search_lock.png')
+        self.unlockIcon = build_icon(u':/bibles/bibles_search_unlock.png')
         MediaManagerItem.__init__(self, parent, plugin, icon)
         # Place to store the search results for both bibles.
         self.settings = self.plugin.settings_tab
@@ -983,7 +984,8 @@
         Search for some Bible verses (by reference).
         """
         bible = unicode(self.quickVersionComboBox.currentText())
-        search_results = self.plugin.manager.get_verses(bible, string, False, False)
+        search_results = self.plugin.manager.get_verses(bible, string, False,
+            False)
         if search_results:
             versetext = u' '.join([verse.text for verse in search_results])
             return [[string, versetext]]

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2011-06-12 17:56:11 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2011-07-03 08:21:10 +0000
@@ -208,8 +208,13 @@
             filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
             if os.path.exists(filename):
                 (path, name) = os.path.split(filename)
-                self.plugin.liveController.display.directImage(name, filename)
-                self.resetAction.setVisible(True)
+                if self.plugin.liveController.display.directImage(name,
+                    filename):
+                    self.resetAction.setVisible(True)
+                else:
+                    critical_error_message_box(UiStrings().LiveBGError,
+                        translate('ImagePlugin.MediaItem',
+                        'There was no display item to amend.'))
             else:
                 critical_error_message_box(UiStrings().LiveBGError,
                     unicode(translate('ImagePlugin.MediaItem',

=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2011-06-12 17:56:11 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2011-07-03 08:21:10 +0000
@@ -114,8 +114,12 @@
             filename = unicode(item.data(QtCore.Qt.UserRole).toString())
             if os.path.exists(filename):
                 (path, name) = os.path.split(filename)
-                self.plugin.liveController.display.video(filename, 0, True)
-                self.resetAction.setVisible(True)
+                if self.plugin.liveController.display.video(filename, 0, True):
+                    self.resetAction.setVisible(True)
+                else:
+                    critical_error_message_box(UiStrings().LiveBGError,
+                        translate('MediaPlugin.MediaItem',
+                        'There was no display item to amend.'))
             else:
                 critical_error_message_box(UiStrings().LiveBGError,
                     unicode(translate('MediaPlugin.MediaItem',

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2011-06-29 06:53:15 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2011-07-03 08:21:10 +0000
@@ -35,7 +35,8 @@
 from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
     translate, check_item_selected, PluginStatus
 from openlp.core.lib.searchedit import SearchEdit
-from openlp.core.lib.ui import UiStrings
+from openlp.core.lib.ui import UiStrings, context_menu_action, \
+    context_menu_separator
 from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
     SongImportForm, SongExportForm
 from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, \
@@ -128,6 +129,13 @@
             QtCore.SIGNAL(u'searchTypeChanged(int)'),
             self.onSearchTextButtonClick)
 
+    def addCustomContextActions(self):
+        context_menu_separator(self.listView)
+        context_menu_action(
+            self.listView, u':/general/general_add.png',
+            translate('OpenLP.MediaManagerItem',
+            '&Clone.'), self.onCloneClick)
+
     def onFocus(self):
         self.searchTextEdit.setFocus()
 
@@ -366,6 +374,23 @@
                 self.plugin.manager.delete_object(Song, item_id)
             self.onSearchTextButtonClick()
 
+    def onCloneClick(self):
+        """
+        Clone a Song
+        """
+        log.debug(u'onCloneClick')
+        if check_item_selected(self.listView, UiStrings().SelectEdit):
+            self.editItem = self.listView.currentItem()
+            item_id = (self.editItem.data(QtCore.Qt.UserRole)).toInt()[0]
+            old_song = self.plugin.manager.get_object(Song, item_id)
+            song_xml = self.openLyrics.song_to_xml(old_song)
+            new_song_id = self.openLyrics.xml_to_song(song_xml)
+            new_song = self.plugin.manager.get_object(Song, new_song_id)
+            new_song.title = u'%s <%s>' % (new_song.title,
+                translate('SongsPlugin.MediaItem', 'copy'))
+            self.plugin.manager.save_object(new_song)
+        self.onSongListLoad()
+
     def generateSlideData(self, service_item, item=None, xmlVersion=False):
         log.debug(u'generateSlideData (%s:%s)' % (service_item, item))
         item_id = self._getIdOfItemToGenerate(item, self.remoteSong)