forked from openlp/openlp
Head
This commit is contained in:
commit
1a57939c73
@ -114,6 +114,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
self.Toolbar = None
|
self.Toolbar = None
|
||||||
self.remoteTriggered = None
|
self.remoteTriggered = None
|
||||||
self.ServiceItemIconName = None
|
self.ServiceItemIconName = None
|
||||||
|
self.singleServiceItem = True
|
||||||
self.addToServiceItem = False
|
self.addToServiceItem = False
|
||||||
self.PageLayout = QtGui.QVBoxLayout(self)
|
self.PageLayout = QtGui.QVBoxLayout(self)
|
||||||
self.PageLayout.setSpacing(0)
|
self.PageLayout.setSpacing(0)
|
||||||
@ -351,6 +352,24 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
count += 1
|
count += 1
|
||||||
return filelist
|
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):
|
def loadList(self, list):
|
||||||
raise NotImplementedError(u'MediaManagerItem.loadList needs to be '
|
raise NotImplementedError(u'MediaManagerItem.loadList needs to be '
|
||||||
u'defined by the plugin')
|
u'defined by the plugin')
|
||||||
@ -367,7 +386,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to '
|
raise NotImplementedError(u'MediaManagerItem.onDeleteClick needs to '
|
||||||
u'be defined by the plugin')
|
u'be defined by the plugin')
|
||||||
|
|
||||||
def generateSlideData(self, item):
|
def generateSlideData(self, service_item, item):
|
||||||
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs '
|
raise NotImplementedError(u'MediaManagerItem.generateSlideData needs '
|
||||||
u'to be defined by the plugin')
|
u'to be defined by the plugin')
|
||||||
|
|
||||||
@ -401,11 +420,21 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
self.trUtf8('No Items Selected'),
|
self.trUtf8('No Items Selected'),
|
||||||
self.trUtf8('You must select one or more items.'))
|
self.trUtf8('You must select one or more items.'))
|
||||||
else:
|
else:
|
||||||
log.debug(self.PluginNameShort + u' Add requested')
|
#Is it posssible to process multiple list items to generate multiple
|
||||||
service_item = self.buildServiceItem()
|
#service items?
|
||||||
if service_item:
|
if self.singleServiceItem:
|
||||||
service_item.from_plugin = False
|
log.debug(self.PluginNameShort + u' Add requested')
|
||||||
self.parent.service_manager.addServiceItem(service_item)
|
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):
|
def onAddEditClick(self):
|
||||||
if not self.ListView.selectedIndexes() and not self.remoteTriggered:
|
if not self.ListView.selectedIndexes() and not self.remoteTriggered:
|
||||||
@ -429,7 +458,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
self.trUtf8('Invalid Service Item'),
|
self.trUtf8('Invalid Service Item'),
|
||||||
self.trUtf8(unicode('You must select a %s service item.' % self.title)))
|
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
|
Common method for generating a service item
|
||||||
"""
|
"""
|
||||||
@ -439,7 +468,7 @@ class MediaManagerItem(QtGui.QWidget):
|
|||||||
else:
|
else:
|
||||||
service_item.addIcon(
|
service_item.addIcon(
|
||||||
u':/media/media_' + self.PluginNameShort.lower() + u'.png')
|
u':/media/media_' + self.PluginNameShort.lower() + u'.png')
|
||||||
if self.generateSlideData(service_item):
|
if self.generateSlideData(service_item, item):
|
||||||
return service_item
|
return service_item
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
@ -235,7 +235,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
self.notesAction.setVisible(False)
|
self.notesAction.setVisible(False)
|
||||||
if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsEdit):
|
if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsEdit):
|
||||||
self.editAction.setVisible(True)
|
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)
|
self.maintainAction.setVisible(True)
|
||||||
if item.parent() is None:
|
if item.parent() is None:
|
||||||
self.notesAction.setVisible(True)
|
self.notesAction.setVisible(True)
|
||||||
@ -713,7 +714,7 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
get_config(u'auto preview', u'False')):
|
get_config(u'auto preview', u'False')):
|
||||||
item += 1
|
item += 1
|
||||||
if self.serviceItems and item < len(self.serviceItems) and \
|
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.parent.PreviewController.addServiceManagerItem(
|
||||||
self.serviceItems[item][u'service_item'], 0)
|
self.serviceItems[item][u'service_item'], 0)
|
||||||
|
|
||||||
@ -722,8 +723,8 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
Posts a remote edit message to a plugin to allow item to be edited.
|
Posts a remote edit message to a plugin to allow item to be edited.
|
||||||
"""
|
"""
|
||||||
item, count = self.findServiceItem()
|
item, count = self.findServiceItem()
|
||||||
if self.serviceItems[item][u'service_item'].\
|
if self.serviceItems[item][u'service_item']\
|
||||||
is_capable(ItemCapabilities.AllowsEdit):
|
.is_capable(ItemCapabilities.AllowsEdit):
|
||||||
self.remoteEditTriggered = True
|
self.remoteEditTriggered = True
|
||||||
Receiver.send_message(u'%s_edit' %
|
Receiver.send_message(u'%s_edit' %
|
||||||
self.serviceItems[item][u'service_item'].name, u'L:%s' %
|
self.serviceItems[item][u'service_item'].name, u'L:%s' %
|
||||||
|
@ -57,7 +57,6 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.ConfigSection = title
|
self.ConfigSection = title
|
||||||
self.IconPath = u'songs/song'
|
self.IconPath = u'songs/song'
|
||||||
self.ListViewWithDnD_class = BibleListView
|
self.ListViewWithDnD_class = BibleListView
|
||||||
self.servicePath = None
|
|
||||||
self.lastReference = []
|
self.lastReference = []
|
||||||
self.addToServiceItem = True
|
self.addToServiceItem = True
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
@ -440,7 +439,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
if self.search_results:
|
if self.search_results:
|
||||||
self.displayResults(bible)
|
self.displayResults(bible)
|
||||||
|
|
||||||
def generateSlideData(self, service_item):
|
def generateSlideData(self, service_item, item=None):
|
||||||
log.debug(u'generating slide data')
|
log.debug(u'generating slide data')
|
||||||
items = self.ListView.selectedIndexes()
|
items = self.ListView.selectedIndexes()
|
||||||
if len(items) == 0:
|
if len(items) == 0:
|
||||||
|
@ -50,8 +50,8 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
# this next is a class, not an instance of a class - it will
|
# this next is a class, not an instance of a class - it will
|
||||||
# be instanced by the base MediaManagerItem
|
# be instanced by the base MediaManagerItem
|
||||||
self.ListViewWithDnD_class = CustomListView
|
self.ListViewWithDnD_class = CustomListView
|
||||||
self.servicePath = None
|
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
|
self.singleServiceItem = False
|
||||||
# Holds information about whether the edit is remotly triggered and
|
# Holds information about whether the edit is remotly triggered and
|
||||||
# which Custom is required.
|
# which Custom is required.
|
||||||
self.remoteCustom = -1
|
self.remoteCustom = -1
|
||||||
@ -132,18 +132,21 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
row = self.ListView.row(item)
|
row = self.ListView.row(item)
|
||||||
self.ListView.takeItem(row)
|
self.ListView.takeItem(row)
|
||||||
|
|
||||||
def generateSlideData(self, service_item):
|
def generateSlideData(self, service_item, item=None):
|
||||||
raw_slides =[]
|
raw_slides =[]
|
||||||
raw_footer = []
|
raw_footer = []
|
||||||
slide = None
|
slide = None
|
||||||
theme = None
|
theme = None
|
||||||
if self.remoteTriggered is None:
|
if item is None:
|
||||||
item = self.ListView.currentItem()
|
if self.remoteTriggered is None:
|
||||||
if item is None:
|
item = self.ListView.currentItem()
|
||||||
return False
|
if item is None:
|
||||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
return False
|
||||||
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
|
else:
|
||||||
|
item_id = self.remoteCustom
|
||||||
else:
|
else:
|
||||||
item_id = self.remoteCustom
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||||
customSlide = self.parent.custommanager.get_custom(item_id)
|
customSlide = self.parent.custommanager.get_custom(item_id)
|
||||||
@ -166,4 +169,4 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
else:
|
else:
|
||||||
raw_footer.append(u'')
|
raw_footer.append(u'')
|
||||||
service_item.raw_footer = raw_footer
|
service_item.raw_footer = raw_footer
|
||||||
return True
|
return True
|
@ -52,7 +52,6 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
# this next is a class, not an instance of a class - it will
|
# this next is a class, not an instance of a class - it will
|
||||||
# be instanced by the base MediaManagerItem
|
# be instanced by the base MediaManagerItem
|
||||||
self.ListViewWithDnD_class = ImageListView
|
self.ListViewWithDnD_class = ImageListView
|
||||||
self.servicePath = None
|
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
|
|
||||||
def initPluginNameVisible(self):
|
def initPluginNameVisible(self):
|
||||||
@ -125,18 +124,16 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
(path, filename) = os.path.split(unicode(file))
|
(path, filename) = os.path.split(unicode(file))
|
||||||
thumb = os.path.join(self.servicePath, filename)
|
thumb = os.path.join(self.servicePath, filename)
|
||||||
if os.path.exists(thumb):
|
if os.path.exists(thumb):
|
||||||
|
self.validate(file, thumb)
|
||||||
icon = build_icon(thumb)
|
icon = build_icon(thumb)
|
||||||
else:
|
else:
|
||||||
icon = build_icon(unicode(file))
|
icon = self.IconFromFile(file, thumb)
|
||||||
pixmap = icon.pixmap(QtCore.QSize(88,50))
|
|
||||||
ext = os.path.splitext(thumb)[1].lower()
|
|
||||||
pixmap.save(thumb, ext[1:])
|
|
||||||
item_name = QtGui.QListWidgetItem(filename)
|
item_name = QtGui.QListWidgetItem(filename)
|
||||||
item_name.setIcon(icon)
|
item_name.setIcon(icon)
|
||||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||||
self.ListView.addItem(item_name)
|
self.ListView.addItem(item_name)
|
||||||
|
|
||||||
def generateSlideData(self, service_item):
|
def generateSlideData(self, service_item, item=None):
|
||||||
items = self.ListView.selectedIndexes()
|
items = self.ListView.selectedIndexes()
|
||||||
if items:
|
if items:
|
||||||
service_item.title = self.trUtf8('Image(s)')
|
service_item.title = self.trUtf8('Image(s)')
|
||||||
@ -165,4 +162,4 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.parent.maindisplay.addImageWithText(frame)
|
self.parent.maindisplay.addImageWithText(frame)
|
||||||
|
|
||||||
def onPreviewClick(self):
|
def onPreviewClick(self):
|
||||||
MediaManagerItem.onPreviewClick(self)
|
MediaManagerItem.onPreviewClick(self)
|
@ -52,10 +52,10 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
# this next is a class, not an instance of a class - it will
|
# this next is a class, not an instance of a class - it will
|
||||||
# be instanced by the base MediaManagerItem
|
# be instanced by the base MediaManagerItem
|
||||||
self.ListViewWithDnD_class = MediaListView
|
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)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
|
self.singleServiceItem = False
|
||||||
self.ServiceItemIconName = u':/media/media_video.png'
|
self.ServiceItemIconName = u':/media/media_video.png'
|
||||||
self.MainDisplay = self.parent.maindisplay
|
|
||||||
|
|
||||||
def initPluginNameVisible(self):
|
def initPluginNameVisible(self):
|
||||||
self.PluginNameVisible = self.trUtf8('Media')
|
self.PluginNameVisible = self.trUtf8('Media')
|
||||||
@ -72,24 +72,17 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
self.hasNewIcon = False
|
self.hasNewIcon = False
|
||||||
self.hasEditIcon = False
|
self.hasEditIcon = False
|
||||||
|
|
||||||
def video_get_preview(self):
|
def generateSlideData(self, service_item, item=None):
|
||||||
# For now cross platform is an icon. Phonon does not support
|
if item is None:
|
||||||
# individual frame access (yet?) and GStreamer is not available
|
item = self.ListView.currentItem()
|
||||||
# on Windows
|
if item is None:
|
||||||
return QtGui.QPixmap(u':/media/media_video.png').toImage()
|
return False
|
||||||
|
filename = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
||||||
def generateSlideData(self, service_item):
|
|
||||||
items = self.ListView.selectedIndexes()
|
|
||||||
if len(items) > 1:
|
|
||||||
return False
|
|
||||||
service_item.title = unicode(self.trUtf8('Media'))
|
service_item.title = unicode(self.trUtf8('Media'))
|
||||||
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
service_item.add_capability(ItemCapabilities.RequiresMedia)
|
||||||
for item in items:
|
frame = u':/media/image_clapperboard.png'
|
||||||
bitem = self.ListView.item(item.row())
|
(path, name) = os.path.split(filename)
|
||||||
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
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
|
return True
|
||||||
|
|
||||||
def initialise(self):
|
def initialise(self):
|
||||||
@ -110,7 +103,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
for file in list:
|
for file in list:
|
||||||
(path, filename) = os.path.split(unicode(file))
|
(path, filename) = os.path.split(unicode(file))
|
||||||
item_name = QtGui.QListWidgetItem(filename)
|
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.setIcon(build_icon(img))
|
||||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||||
self.ListView.addItem(item_name)
|
self.ListView.addItem(item_name)
|
@ -37,6 +37,8 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from openlp.core.lib import resize_image
|
||||||
|
|
||||||
if os.name == u'nt':
|
if os.name == u'nt':
|
||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
else:
|
else:
|
||||||
@ -239,17 +241,22 @@ class ImpressDocument(PresentationDocument):
|
|||||||
for idx in range(pages.getCount()):
|
for idx in range(pages.getCount()):
|
||||||
page = pages.getByIndex(idx)
|
page = pages.getByIndex(idx)
|
||||||
doc.getCurrentController().setCurrentPage(page)
|
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))
|
unicode(idx + 1))
|
||||||
try:
|
try:
|
||||||
doc.storeToURL(path , props)
|
doc.storeToURL(path , props)
|
||||||
|
preview = resize_image(path, 640, 480)
|
||||||
|
if os.path.exists(path):
|
||||||
|
os.remove(path)
|
||||||
|
preview.save(path, u'png')
|
||||||
except:
|
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):
|
def create_property(self, name, value):
|
||||||
log.debug(u'create property OpenOffice')
|
log.debug(u'create property OpenOffice')
|
||||||
if os.name == u'nt':
|
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:
|
else:
|
||||||
prop = PropertyValue()
|
prop = PropertyValue()
|
||||||
prop.Name = name
|
prop.Name = name
|
||||||
@ -356,7 +363,8 @@ class ImpressDocument(PresentationDocument):
|
|||||||
|
|
||||||
def get_slide_preview_file(self, slide_no):
|
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``
|
``slide_no``
|
||||||
The slide an image is required for, starting at 1
|
The slide an image is required for, starting at 1
|
||||||
|
@ -140,12 +140,14 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
self.parent.config.set_list(
|
self.parent.config.set_list(
|
||||||
self.ConfigSection, self.getFileList())
|
self.ConfigSection, self.getFileList())
|
||||||
filepath = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
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:
|
for cidx in self.controllers:
|
||||||
doc = self.controllers[cidx].add_doc(filepath)
|
doc = self.controllers[cidx].add_doc(filepath)
|
||||||
doc.presentation_deleted()
|
doc.presentation_deleted()
|
||||||
doc.close_presentation()
|
doc.close_presentation()
|
||||||
|
|
||||||
def generateSlideData(self, service_item):
|
def generateSlideData(self, service_item, item=None):
|
||||||
items = self.ListView.selectedIndexes()
|
items = self.ListView.selectedIndexes()
|
||||||
if len(items) > 1:
|
if len(items) > 1:
|
||||||
return False
|
return False
|
||||||
|
@ -115,7 +115,6 @@ class PresentationController(object):
|
|||||||
"""
|
"""
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def start_process(self):
|
def start_process(self):
|
||||||
"""
|
"""
|
||||||
Loads a running version of the presentation application in the background.
|
Loads a running version of the presentation application in the background.
|
||||||
@ -138,13 +137,18 @@ class PresentationController(object):
|
|||||||
self.docs.append(doc)
|
self.docs.append(doc)
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
def remove_doc(self, doc):
|
def remove_doc(self, doc=None):
|
||||||
"""
|
"""
|
||||||
Called to remove an open document from the collection
|
Called to remove an open document from the collection
|
||||||
"""
|
"""
|
||||||
log.debug(u'remove_doc Presentation')
|
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):
|
class PresentationDocument(object):
|
||||||
"""
|
"""
|
||||||
@ -256,7 +260,7 @@ class PresentationDocument(object):
|
|||||||
Close presentation and clean up objects
|
Close presentation and clean up objects
|
||||||
Triggered by new object being added to SlideController
|
Triggered by new object being added to SlideController
|
||||||
"""
|
"""
|
||||||
self.controller.delete_doc(self)
|
self.controller.close_presentation()
|
||||||
|
|
||||||
def is_active(self):
|
def is_active(self):
|
||||||
"""
|
"""
|
||||||
|
@ -148,7 +148,7 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
|
|||||||
def getVerseAll(self):
|
def getVerseAll(self):
|
||||||
text = self.VerseTextEdit.toPlainText()
|
text = self.VerseTextEdit.toPlainText()
|
||||||
if not text.startsWith(u'---['):
|
if not text.startsWith(u'---['):
|
||||||
text = u'---[%s:1]---\n%s' % (self.trUtf8('Verse'), text)
|
text = u'---[Verse:1]---\n%s' % text
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def onVerseComboChanged(self, id):
|
def onVerseComboChanged(self, id):
|
||||||
|
@ -49,8 +49,8 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
self.ConfigSection = title
|
self.ConfigSection = title
|
||||||
self.IconPath = u'songs/song'
|
self.IconPath = u'songs/song'
|
||||||
self.ListViewWithDnD_class = SongListView
|
self.ListViewWithDnD_class = SongListView
|
||||||
self.servicePath = None
|
|
||||||
MediaManagerItem.__init__(self, parent, icon, title)
|
MediaManagerItem.__init__(self, parent, icon, title)
|
||||||
|
self.singleServiceItem = False
|
||||||
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
|
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
|
||||||
self.song_maintenance_form = SongMaintenanceForm(
|
self.song_maintenance_form = SongMaintenanceForm(
|
||||||
self.parent.songmanager, self)
|
self.parent.songmanager, self)
|
||||||
@ -276,31 +276,34 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
if len(items) == 1:
|
if len(items) == 1:
|
||||||
del_message = self.trUtf8('Delete song?')
|
del_message = self.trUtf8('Delete song?')
|
||||||
else:
|
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,
|
ans = QtGui.QMessageBox.question(self,
|
||||||
self.trUtf8('Delete Confirmation'), del_message,
|
self.trUtf8('Delete Confirmation'), del_message,
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok|
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok|
|
||||||
QtGui.QMessageBox.Cancel),
|
QtGui.QMessageBox.Cancel),
|
||||||
QtGui.QMessageBox.Ok)
|
QtGui.QMessageBox.Ok)
|
||||||
if ans == QtGui.QMessageBox.Cancel:
|
if ans == QtGui.QMessageBox.Cancel:
|
||||||
return
|
return
|
||||||
for item in items:
|
for item in items:
|
||||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
self.parent.songmanager.delete_song(item_id)
|
self.parent.songmanager.delete_song(item_id)
|
||||||
self.onSearchTextButtonClick()
|
self.onSearchTextButtonClick()
|
||||||
|
|
||||||
def generateSlideData(self, service_item):
|
def generateSlideData(self, service_item, item=None):
|
||||||
raw_footer = []
|
raw_footer = []
|
||||||
author_list = u''
|
author_list = u''
|
||||||
author_audit = []
|
author_audit = []
|
||||||
ccli = u''
|
ccli = u''
|
||||||
if self.remoteTriggered is None:
|
if item is None:
|
||||||
item = self.ListView.currentItem()
|
if self.remoteTriggered is None:
|
||||||
if item is None:
|
item = self.ListView.currentItem()
|
||||||
return False
|
if item is None:
|
||||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
return False
|
||||||
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
|
else:
|
||||||
|
item_id = self.remoteSong
|
||||||
else:
|
else:
|
||||||
item_id = self.remoteSong
|
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||||
song = self.parent.songmanager.get_song(item_id)
|
song = self.parent.songmanager.get_song(item_id)
|
||||||
@ -358,4 +361,4 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
service_item.audit = [
|
service_item.audit = [
|
||||||
song.title, author_audit, song.copyright, song.ccli_number
|
song.title, author_audit, song.copyright, song.ccli_number
|
||||||
]
|
]
|
||||||
return True
|
return True
|
Binary file not shown.
@ -58,6 +58,7 @@ create_statements = [
|
|||||||
id INTEGER NOT NULL,
|
id INTEGER NOT NULL,
|
||||||
song_book_id INTEGER,
|
song_book_id INTEGER,
|
||||||
title VARCHAR(255) NOT NULL,
|
title VARCHAR(255) NOT NULL,
|
||||||
|
alternate_title VARCHAR(255),
|
||||||
lyrics TEXT NOT NULL,
|
lyrics TEXT NOT NULL,
|
||||||
verse_order VARCHAR(128),
|
verse_order VARCHAR(128),
|
||||||
copyright VARCHAR(255),
|
copyright VARCHAR(255),
|
||||||
@ -183,16 +184,18 @@ def import_songs():
|
|||||||
xml_verse_template = u'<verse label="%d" type="Verse"><![CDATA[%s]]></verse>'
|
xml_verse_template = u'<verse label="%d" type="Verse"><![CDATA[%s]]></verse>'
|
||||||
for row in rows:
|
for row in rows:
|
||||||
clean_title = unicode(row[1], u'cp1252')
|
clean_title = unicode(row[1], u'cp1252')
|
||||||
clean_lyrics = unicode(row[2], u'cp1252')
|
clean_lyrics = unicode(row[2], u'cp1252').replace(u'\r\n', u'\n')
|
||||||
clean_copyright = unicode(row[3], u'cp1252')
|
clean_copyright = unicode(row[3], u'cp1252')
|
||||||
verse_order = u''
|
verse_order = u''
|
||||||
text_lyrics = clean_lyrics.split(u'\n\n')
|
text_lyrics = clean_lyrics.split(u'\n\n')
|
||||||
xml_verse = u''
|
xml_verse = u''
|
||||||
|
verses = []
|
||||||
for line, verse in enumerate(text_lyrics):
|
for line, verse in enumerate(text_lyrics):
|
||||||
if not verse:
|
if not verse:
|
||||||
continue
|
continue
|
||||||
xml_verse += (xml_verse_template % (line + 1, verse))
|
xml_verse += (xml_verse_template % (line + 1, verse))
|
||||||
verse_order += '%d ' % (line + 1)
|
verses.append(u'V%d' % (line + 1))
|
||||||
|
verse_order = u' '.join(verses)
|
||||||
xml_lyrics = xml_lyrics_template % xml_verse
|
xml_lyrics = xml_lyrics_template % xml_verse
|
||||||
search_title = prepare_string(clean_title)
|
search_title = prepare_string(clean_title)
|
||||||
search_lyrics = prepare_string(clean_lyrics)
|
search_lyrics = prepare_string(clean_lyrics)
|
||||||
|
Loading…
Reference in New Issue
Block a user