Add ability to clone a song with a full copy of it.

Add missing build_icon and line wrap error.

Slow down event generation to stop flood of messages which crash the system. UI does not notice the change.

Changes for 795980 also included

bzr-revno: 1675
Fixes: https://launchpad.net/bugs/795980, https://launchpad.net/bugs/752374, https://launchpad.net/bugs/763583
This commit is contained in:
Tim Bentley 2011-07-07 21:14:12 +01:00
commit d02ee451f2
10 changed files with 68 additions and 14 deletions

View File

@ -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

View File

@ -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')

View File

@ -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:

View File

@ -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):

View File

@ -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]]

View File

@ -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',

View File

@ -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',

View File

@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

View File

@ -56,6 +56,7 @@
<file>general_save.png</file>
<file>general_email.png</file>
<file>general_revert.png</file>
<file>general_clone.png</file>
</qresource>
<qresource prefix="slides">
<file>slide_close.png</file>