diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py
index a79355c88..0cc25717c 100644
--- a/openlp/core/lib/mediamanageritem.py
+++ b/openlp/core/lib/mediamanageritem.py
@@ -288,6 +288,7 @@ class MediaManagerItem(QtGui.QWidget):
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 @@ class MediaManagerItem(QtGui.QWidget):
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
diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py
index b661b1e49..72a998efe 100644
--- a/openlp/core/ui/maindisplay.py
+++ b/openlp/core/ui/maindisplay.py
@@ -233,10 +233,12 @@ class MainDisplay(QtGui.QGraphicsView):
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 @@ class MainDisplay(QtGui.QGraphicsView):
"""
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')
diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py
index 439990008..6a34dc1e6 100644
--- a/openlp/core/ui/servicemanager.py
+++ b/openlp/core/ui/servicemanager.py
@@ -48,18 +48,18 @@ class ServiceManagerList(QtGui.QTreeWidget):
"""
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:
diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py
index 8e2c199a1..e86e2e760 100644
--- a/openlp/core/ui/slidecontroller.py
+++ b/openlp/core/ui/slidecontroller.py
@@ -27,6 +27,7 @@
import logging
import os
+import time
from PyQt4 import QtCore, QtGui
from PyQt4.phonon import Phonon
@@ -412,9 +413,11 @@ class SlideController(QtGui.QWidget):
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):
diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py
index cb8273327..0734df818 100644
--- a/openlp/plugins/bibles/lib/mediaitem.py
+++ b/openlp/plugins/bibles/lib/mediaitem.py
@@ -34,7 +34,8 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
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 @@ class BibleMediaItem(MediaManagerItem):
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 @@ class BibleMediaItem(MediaManagerItem):
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]]
diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py
index 481b55c09..3c4489bbc 100644
--- a/openlp/plugins/images/lib/mediaitem.py
+++ b/openlp/plugins/images/lib/mediaitem.py
@@ -208,8 +208,13 @@ class ImageMediaItem(MediaManagerItem):
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',
diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py
index 1e39a0426..77f91a529 100644
--- a/openlp/plugins/media/lib/mediaitem.py
+++ b/openlp/plugins/media/lib/mediaitem.py
@@ -114,8 +114,12 @@ class MediaMediaItem(MediaManagerItem):
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',
diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py
index e2efbe3df..a2814a1df 100644
--- a/openlp/plugins/songs/lib/mediaitem.py
+++ b/openlp/plugins/songs/lib/mediaitem.py
@@ -35,7 +35,8 @@ from sqlalchemy.sql import or_
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 @@ class SongMediaItem(MediaManagerItem):
QtCore.SIGNAL(u'searchTypeChanged(int)'),
self.onSearchTextButtonClick)
+ def addCustomContextActions(self):
+ context_menu_separator(self.listView)
+ context_menu_action(
+ self.listView, u':/general/general_clone.png',
+ translate('OpenLP.MediaManagerItem',
+ '&Clone'), self.onCloneClick)
+
def onFocus(self):
self.searchTextEdit.setFocus()
@@ -366,6 +374,24 @@ class SongMediaItem(MediaManagerItem):
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',
+ 'For song cloning'))
+ 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)
diff --git a/resources/images/general_clone.png b/resources/images/general_clone.png
new file mode 100644
index 000000000..db1d9fbaf
Binary files /dev/null and b/resources/images/general_clone.png differ
diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc
index fc76ad434..4dca475f4 100644
--- a/resources/images/openlp-2.qrc
+++ b/resources/images/openlp-2.qrc
@@ -56,6 +56,7 @@
general_save.png
general_email.png
general_revert.png
+ general_clone.png
slide_close.png