openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #01393
[Merge] lp:~trb143/openlp/bugs1 into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/bugs1 into lp:openlp.
Requested reviews:
Raoul Snyman (raoul-snyman)
Cleanups and fixes
Presentations now delete
Try to compress presentation images - does not work not sure why?
Allow songs, custom, presentations to add multiple service manager items.
add missing "s" from last merge
--
https://code.launchpad.net/~trb143/openlp/bugs1/+merge/22963
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2010-04-03 09:06:05 +0000
+++ openlp/core/lib/mediamanageritem.py 2010-04-07 18:40:39 +0000
@@ -114,6 +114,7 @@
self.Toolbar = None
self.remoteTriggered = None
self.ServiceItemIconName = None
+ self.singleServiceItem = True
self.addToServiceItem = False
self.PageLayout = QtGui.QVBoxLayout(self)
self.PageLayout.setSpacing(0)
@@ -351,6 +352,24 @@
count += 1
return filelist
+ def validate(self, file, thumb):
+ """
+ Validates to see if the file still exists or
+ thumbnail is up to date
+ """
+ filedate = os.stat(file).st_mtime
+ thumbdate = os.stat(thumb).st_mtime
+ #if file updated rebuild icon
+ if filedate > thumbdate:
+ self.IconFromFile(file, thumb)
+
+ def IconFromFile(self, file, thumb):
+ icon = build_icon(unicode(file))
+ pixmap = icon.pixmap(QtCore.QSize(88,50))
+ ext = os.path.splitext(thumb)[1].lower()
+ pixmap.save(thumb, ext[1:])
+ return icon
+
def loadList(self, list):
raise NotImplementedError(u'MediaManagerItem.loadList needs to be '
u'defined by the plugin')
@@ -367,7 +386,7 @@
raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to '
u'be defined by the plugin')
- def generateSlideData(self, item):
+ def generateSlideData(self, service_item, item):
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs '
u'to be defined by the plugin')
@@ -401,11 +420,21 @@
self.trUtf8('No Items Selected'),
self.trUtf8('You must select one or more items.'))
else:
- log.debug(self.PluginNameShort + u' Add requested')
- service_item = self.buildServiceItem()
- if service_item:
- service_item.from_plugin = False
- self.parent.service_manager.addServiceItem(service_item)
+ #Is it posssible to process multiple list items to generate multiple
+ #service items?
+ if self.singleServiceItem:
+ log.debug(self.PluginNameShort + u' Add requested')
+ service_item = self.buildServiceItem()
+ if service_item:
+ service_item.from_plugin = False
+ self.parent.service_manager.addServiceItem(service_item)
+ else:
+ items = self.ListView.selectedIndexes()
+ for item in items:
+ service_item = self.buildServiceItem(item)
+ if service_item:
+ service_item.from_plugin = False
+ self.parent.service_manager.addServiceItem(service_item)
def onAddEditClick(self):
if not self.ListView.selectedIndexes() and not self.remoteTriggered:
@@ -429,7 +458,7 @@
self.trUtf8('Invalid Service Item'),
self.trUtf8(unicode('You must select a %s service item.' % self.title)))
- def buildServiceItem(self):
+ def buildServiceItem(self, item=None):
"""
Common method for generating a service item
"""
@@ -439,7 +468,7 @@
else:
service_item.addIcon(
u':/media/media_' + self.PluginNameShort.lower() + u'.png')
- if self.generateSlideData(service_item):
+ if self.generateSlideData(service_item, item):
return service_item
else:
- return None
+ return None
\ No newline at end of file
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2010-04-03 08:42:51 +0000
+++ openlp/core/ui/servicemanager.py 2010-04-07 18:40:39 +0000
@@ -235,7 +235,8 @@
self.notesAction.setVisible(False)
if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsEdit):
self.editAction.setVisible(True)
- if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsMaintain):
+ if serviceItem[u'service_item']\
+ .is_capable(ItemCapabilities.AllowsMaintain):
self.maintainAction.setVisible(True)
if item.parent() is None:
self.notesAction.setVisible(True)
@@ -713,7 +714,7 @@
get_config(u'auto preview', u'False')):
item += 1
if self.serviceItems and item < len(self.serviceItems) and \
- serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsPreview):
+ self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.AllowsPreview):
self.parent.PreviewController.addServiceManagerItem(
self.serviceItems[item][u'service_item'], 0)
@@ -722,8 +723,8 @@
Posts a remote edit message to a plugin to allow item to be edited.
"""
item, count = self.findServiceItem()
- if self.serviceItems[item][u'service_item'].\
- is_capable(ItemCapabilities.AllowsEdit):
+ if self.serviceItems[item][u'service_item']\
+ .is_capable(ItemCapabilities.AllowsEdit):
self.remoteEditTriggered = True
Receiver.send_message(u'%s_edit' %
self.serviceItems[item][u'service_item'].name, u'L:%s' %
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2010-04-03 07:10:31 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2010-04-07 18:40:39 +0000
@@ -57,7 +57,6 @@
self.ConfigSection = title
self.IconPath = u'songs/song'
self.ListViewWithDnD_class = BibleListView
- self.servicePath = None
self.lastReference = []
self.addToServiceItem = True
MediaManagerItem.__init__(self, parent, icon, title)
@@ -440,7 +439,7 @@
if self.search_results:
self.displayResults(bible)
- def generateSlideData(self, service_item):
+ def generateSlideData(self, service_item, item=None):
log.debug(u'generating slide data')
items = self.ListView.selectedIndexes()
if len(items) == 0:
=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py 2010-04-03 07:10:31 +0000
+++ openlp/plugins/custom/lib/mediaitem.py 2010-04-07 18:40:39 +0000
@@ -50,8 +50,8 @@
# this next is a class, not an instance of a class - it will
# be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = CustomListView
- self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title)
+ self.singleServiceItem = False
# Holds information about whether the edit is remotly triggered and
# which Custom is required.
self.remoteCustom = -1
@@ -132,18 +132,21 @@
row = self.ListView.row(item)
self.ListView.takeItem(row)
- def generateSlideData(self, service_item):
+ def generateSlideData(self, service_item, item=None):
raw_slides =[]
raw_footer = []
slide = None
theme = None
- if self.remoteTriggered is None:
- item = self.ListView.currentItem()
- if item is None:
- return False
+ if item is None:
+ if self.remoteTriggered is None:
+ item = self.ListView.currentItem()
+ if item is None:
+ return False
+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+ else:
+ item_id = self.remoteCustom
+ else:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
- else:
- item_id = self.remoteCustom
service_item.add_capability(ItemCapabilities.AllowsEdit)
service_item.add_capability(ItemCapabilities.AllowsPreview)
customSlide = self.parent.custommanager.get_custom(item_id)
@@ -166,4 +169,4 @@
else:
raw_footer.append(u'')
service_item.raw_footer = raw_footer
- return True
+ return True
\ No newline at end of file
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2010-04-03 07:10:31 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2010-04-07 18:40:39 +0000
@@ -52,7 +52,6 @@
# this next is a class, not an instance of a class - it will
# be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = ImageListView
- self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title)
def initPluginNameVisible(self):
@@ -125,18 +124,16 @@
(path, filename) = os.path.split(unicode(file))
thumb = os.path.join(self.servicePath, filename)
if os.path.exists(thumb):
+ self.validate(file, thumb)
icon = build_icon(thumb)
else:
- icon = build_icon(unicode(file))
- pixmap = icon.pixmap(QtCore.QSize(88,50))
- ext = os.path.splitext(thumb)[1].lower()
- pixmap.save(thumb, ext[1:])
+ icon = self.IconFromFile(file, thumb)
item_name = QtGui.QListWidgetItem(filename)
item_name.setIcon(icon)
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
self.ListView.addItem(item_name)
- def generateSlideData(self, service_item):
+ def generateSlideData(self, service_item, item=None):
items = self.ListView.selectedIndexes()
if items:
service_item.title = self.trUtf8('Image(s)')
@@ -165,4 +162,4 @@
self.parent.maindisplay.addImageWithText(frame)
def onPreviewClick(self):
- MediaManagerItem.onPreviewClick(self)
+ MediaManagerItem.onPreviewClick(self)
\ No newline at end of file
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2010-04-03 08:42:51 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2010-04-07 18:40:39 +0000
@@ -52,10 +52,10 @@
# this next is a class, not an instance of a class - it will
# be instanced by the base MediaManagerItem
self.ListViewWithDnD_class = MediaListView
- self.PreviewFunction = self.video_get_preview
+ self.PreviewFunction = QtGui.QPixmap(u':/media/media_video.png').toImage()
MediaManagerItem.__init__(self, parent, icon, title)
+ self.singleServiceItem = False
self.ServiceItemIconName = u':/media/media_video.png'
- self.MainDisplay = self.parent.maindisplay
def initPluginNameVisible(self):
self.PluginNameVisible = self.trUtf8('Media')
@@ -72,24 +72,17 @@
self.hasNewIcon = False
self.hasEditIcon = False
- def video_get_preview(self):
- # For now cross platform is an icon. Phonon does not support
- # individual frame access (yet?) and GStreamer is not available
- # on Windows
- return QtGui.QPixmap(u':/media/media_video.png').toImage()
-
- def generateSlideData(self, service_item):
- items = self.ListView.selectedIndexes()
- if len(items) > 1:
- return False
+ def generateSlideData(self, service_item, item=None):
+ if item is None:
+ item = self.ListView.currentItem()
+ if item is None:
+ return False
+ filename = unicode((item.data(QtCore.Qt.UserRole)).toString())
service_item.title = unicode(self.trUtf8('Media'))
service_item.add_capability(ItemCapabilities.RequiresMedia)
- for item in items:
- bitem = self.ListView.item(item.row())
- filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
- frame = u':/media/image_clapperboard.png'
- (path, name) = os.path.split(filename)
- service_item.add_from_command(path, name, frame)
+ frame = u':/media/image_clapperboard.png'
+ (path, name) = os.path.split(filename)
+ service_item.add_from_command(path, name, frame)
return True
def initialise(self):
@@ -110,7 +103,7 @@
for file in list:
(path, filename) = os.path.split(unicode(file))
item_name = QtGui.QListWidgetItem(filename)
- img = self.video_get_preview()
+ img = QtGui.QPixmap(u':/media/media_video.png').toImage()
item_name.setIcon(build_icon(img))
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
- self.ListView.addItem(item_name)
+ self.ListView.addItem(item_name)
\ No newline at end of file
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py 2010-03-23 21:51:20 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py 2010-04-07 18:40:39 +0000
@@ -37,6 +37,8 @@
import os
import time
+from openlp.core.lib import resize_image
+
if os.name == u'nt':
from win32com.client import Dispatch
else:
@@ -239,17 +241,22 @@
for idx in range(pages.getCount()):
page = pages.getByIndex(idx)
doc.getCurrentController().setCurrentPage(page)
- path = u'%s/%s%s.png'% (thumbdir, self.controller.thumbnailprefix,
+ path = u'%s/%s%s.png' % (thumbdir, self.controller.thumbnailprefix,
unicode(idx + 1))
try:
doc.storeToURL(path , props)
+ preview = resize_image(path, 640, 480)
+ if os.path.exists(path):
+ os.remove(path)
+ preview.save(path, u'png')
except:
- log.exception(u'%s\nUnable to store preview' % path)
+ log.exception(u'%s - Unable to store openoffice preview' % path)
def create_property(self, name, value):
log.debug(u'create property OpenOffice')
if os.name == u'nt':
- prop = self.controller.manager.Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
+ prop = self.controller.manager.\
+ Bridge_GetStruct(u'com.sun.star.beans.PropertyValue')
else:
prop = PropertyValue()
prop.Name = name
@@ -356,7 +363,8 @@
def get_slide_preview_file(self, slide_no):
"""
- Returns an image path containing a preview for the requested slide
+ Returns an image path containing a preview for the
+ requested slide
``slide_no``
The slide an image is required for, starting at 1
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2010-04-03 07:10:31 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2010-04-07 18:40:39 +0000
@@ -140,12 +140,14 @@
self.parent.config.set_list(
self.ConfigSection, self.getFileList())
filepath = unicode((item.data(QtCore.Qt.UserRole)).toString())
+ #not sure of this has errors
+ #John please can you look at .
for cidx in self.controllers:
doc = self.controllers[cidx].add_doc(filepath)
doc.presentation_deleted()
doc.close_presentation()
- def generateSlideData(self, service_item):
+ def generateSlideData(self, service_item, item=None):
items = self.ListView.selectedIndexes()
if len(items) > 1:
return False
=== modified file 'openlp/plugins/presentations/lib/presentationcontroller.py'
--- openlp/plugins/presentations/lib/presentationcontroller.py 2010-03-21 23:58:01 +0000
+++ openlp/plugins/presentations/lib/presentationcontroller.py 2010-04-07 18:40:39 +0000
@@ -115,7 +115,6 @@
"""
return False
-
def start_process(self):
"""
Loads a running version of the presentation application in the background.
@@ -138,13 +137,18 @@
self.docs.append(doc)
return doc
- def remove_doc(self, doc):
+ def remove_doc(self, doc=None):
"""
Called to remove an open document from the collection
"""
log.debug(u'remove_doc Presentation')
- self.docs.remove(doc)
+ if doc is None:
+ return
+ if doc in self.docs:
+ self.docs.remove(doc)
+ def close_presentation(self):
+ pass
class PresentationDocument(object):
"""
@@ -256,7 +260,7 @@
Close presentation and clean up objects
Triggered by new object being added to SlideController
"""
- self.controller.delete_doc(self)
+ self.controller.close_presentation()
def is_active(self):
"""
=== modified file 'openlp/plugins/songs/forms/editverseform.py'
--- openlp/plugins/songs/forms/editverseform.py 2010-04-03 08:04:41 +0000
+++ openlp/plugins/songs/forms/editverseform.py 2010-04-07 18:40:39 +0000
@@ -148,7 +148,7 @@
def getVerseAll(self):
text = self.VerseTextEdit.toPlainText()
if not text.startsWith(u'---['):
- text = u'---[%s:1]---\n%s' % (self.trUtf8('Verse'), text)
+ text = u'---[Verse:1]---\n%s' % text
return text
def onVerseComboChanged(self, id):
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2010-04-04 08:26:53 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2010-04-07 18:40:39 +0000
@@ -49,8 +49,8 @@
self.ConfigSection = title
self.IconPath = u'songs/song'
self.ListViewWithDnD_class = SongListView
- self.servicePath = None
MediaManagerItem.__init__(self, parent, icon, title)
+ self.singleServiceItem = False
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
self.song_maintenance_form = SongMaintenanceForm(
self.parent.songmanager, self)
@@ -276,31 +276,34 @@
if len(items) == 1:
del_message = self.trUtf8('Delete song?')
else:
- del_message = unicode(self.trUtf8('Delete %d song?')) % len(items)
+ del_message = unicode(self.trUtf8('Delete %d songs?')) % len(items)
ans = QtGui.QMessageBox.question(self,
self.trUtf8('Delete Confirmation'), del_message,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok|
QtGui.QMessageBox.Cancel),
QtGui.QMessageBox.Ok)
if ans == QtGui.QMessageBox.Cancel:
- return
+ return
for item in items:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
self.parent.songmanager.delete_song(item_id)
self.onSearchTextButtonClick()
- def generateSlideData(self, service_item):
+ def generateSlideData(self, service_item, item=None):
raw_footer = []
author_list = u''
author_audit = []
ccli = u''
- if self.remoteTriggered is None:
- item = self.ListView.currentItem()
- if item is None:
- return False
+ if item is None:
+ if self.remoteTriggered is None:
+ item = self.ListView.currentItem()
+ if item is None:
+ return False
+ item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
+ else:
+ item_id = self.remoteSong
+ else:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
- else:
- item_id = self.remoteSong
service_item.add_capability(ItemCapabilities.AllowsEdit)
service_item.add_capability(ItemCapabilities.AllowsPreview)
song = self.parent.songmanager.get_song(item_id)
@@ -358,4 +361,4 @@
service_item.audit = [
song.title, author_audit, song.copyright, song.ccli_number
]
- return True
+ return True
\ No newline at end of file
Follow ups