forked from openlp/openlp
Enable media additions to ServiceManager and fixes
This commit is contained in:
parent
1db3cda76b
commit
490b19ddc2
@ -319,8 +319,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
pass
|
||||
|
||||
def onFileClick(self):
|
||||
files = QtGui.QFileDialog.getOpenFileNames(
|
||||
self, self.trUtf8(self.OnNewPrompt),
|
||||
files = QtGui.QFileDialog.getOpenFileNames(self, self.OnNewPrompt,
|
||||
self.parent.config.get_last_dir(), self.OnNewFileMasks)
|
||||
log.info(u'New files(s)%s', unicode(files))
|
||||
if len(files) > 0:
|
||||
@ -382,8 +381,11 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
Common method for generating a service item
|
||||
"""
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(
|
||||
u':/media/media_' + self.PluginNameShort.lower() + u'.png')
|
||||
if self.ServiceItemIconName:
|
||||
service_item.addIcon(self.ServiceItemIconName)
|
||||
else:
|
||||
service_item.addIcon(
|
||||
u':/media/media_' + self.PluginNameShort.lower() + u'.png')
|
||||
if self.generateSlideData(service_item):
|
||||
self.ListView.clearSelection()
|
||||
return service_item
|
||||
|
@ -117,6 +117,11 @@ class ServiceItem(object):
|
||||
slide[u'image'] = \
|
||||
self.RenderManager.resize_image(slide[u'image'])
|
||||
self.frames = self.service_frames
|
||||
elif self.service_item_type == ServiceItemType.Video:
|
||||
for slide in self.service_frames:
|
||||
slide[u'image'] = \
|
||||
self.RenderManager.resize_image(slide[u'image'])
|
||||
self.frames = self.service_frames
|
||||
else:
|
||||
log.error(u'Invalid value renderer :%s' % self.service_item_type)
|
||||
|
||||
@ -152,7 +157,13 @@ class ServiceItem(object):
|
||||
self.service_item_type = ServiceItemType.Image
|
||||
self.service_item_path = path
|
||||
self.service_frames.append(
|
||||
{u'title': frame_title, u'text':None, u'image': image})
|
||||
{u'title': frame_title, u'text': None, u'image': image})
|
||||
|
||||
def add_from_media(self, path, frame_title, image):
|
||||
self.service_item_type = ServiceItemType.Video
|
||||
self.service_item_path = path
|
||||
self.service_frames.append(
|
||||
{u'title': frame_title, u'text': None, u'image': image})
|
||||
|
||||
def add_from_text(self, frame_title, raw_slide):
|
||||
"""
|
||||
@ -210,7 +221,8 @@ class ServiceItem(object):
|
||||
for slide in self.service_frames:
|
||||
service_data.append(slide[u'title'])
|
||||
elif self.service_item_type == ServiceItemType.Video:
|
||||
pass
|
||||
for slide in self.service_frames:
|
||||
service_data.append(slide[u'title'])
|
||||
return {u'header': service_header, u'data': service_data}
|
||||
|
||||
def set_from_service(self, serviceitem, path=None):
|
||||
|
@ -47,13 +47,10 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.PluginNameShort = u'Media'
|
||||
self.IconPath = u'images/image'
|
||||
self.ConfigSection = u'media'
|
||||
self.OnNewPrompt = u'Select Media(s)'
|
||||
self.OnNewFileMasks = \
|
||||
u'Videos (*.avi *.mpeg *.mpg *.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)'
|
||||
# this next is a class, not an instance of a class - it will
|
||||
# be instanced by the base MediaManagerItem
|
||||
self.ListViewWithDnD_class = MediaListView
|
||||
#self.ServiceItemIconName = u':/media/media_image.png'
|
||||
self.ServiceItemIconName = u':/media/media_video.png'
|
||||
self.PreviewFunction = self.video_get_preview
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
self.MainDisplay = self.parent.live_controller.parent.mainDisplay
|
||||
@ -61,13 +58,18 @@ class MediaMediaItem(MediaManagerItem):
|
||||
def initPluginNameVisible(self):
|
||||
self.PluginNameVisible = self.trUtf8(self.PluginNameShort)
|
||||
|
||||
def reTranslateUI(self):
|
||||
self.OnNewPrompt = self.trUtf8(u'Select Media')
|
||||
self.OnNewFileMasks = self.trUtf8(u'Videos (*.avi *.mpeg *.mpg'
|
||||
'*.mp4);;Audio (*.ogg *.mp3 *.wma);;All files (*)')
|
||||
|
||||
def requiredIcons(self):
|
||||
MediaManagerItem.requiredIcons(self)
|
||||
self.hasFileIcon = True
|
||||
self.hasNewIcon = False
|
||||
self.hasEditIcon = False
|
||||
|
||||
def video_get_preview(self, filename):
|
||||
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
|
||||
@ -77,15 +79,19 @@ class MediaMediaItem(MediaManagerItem):
|
||||
return image
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
indexes = self.ListView.selectedIndexes()
|
||||
if len(indexes) > 1:
|
||||
items = self.ListView.selectedIndexes()
|
||||
if len(items) > 1:
|
||||
return False
|
||||
service_item.title = u'Media'
|
||||
for index in indexes:
|
||||
filename = self.ListView.getFilename(index)
|
||||
frame = QtGui.QImage(unicode(filename))
|
||||
service_item.title = self.trUtf8(u'Media')
|
||||
for item in items:
|
||||
bitem = self.ListView.item(item.row())
|
||||
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
||||
frame = u':/media/media_video.png'
|
||||
(path, name) = os.path.split(filename)
|
||||
service_item.add_from_image(path, name, frame)
|
||||
#service_item.add_from_image(path, name, frame)
|
||||
print path
|
||||
print name
|
||||
service_item.add_from_media(path, name, frame)
|
||||
return True
|
||||
|
||||
def onPreviewClick(self):
|
||||
@ -129,7 +135,7 @@ class MediaMediaItem(MediaManagerItem):
|
||||
for file in list:
|
||||
(path, filename) = os.path.split(unicode(file))
|
||||
item_name = QtGui.QListWidgetItem(filename)
|
||||
img = self.video_get_preview(file)
|
||||
img = self.video_get_preview()
|
||||
item_name.setIcon(buildIcon(img))
|
||||
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(file))
|
||||
self.ListView.addItem(item_name)
|
||||
|
@ -52,8 +52,6 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
self.PluginNameShort = u'Presentation'
|
||||
self.ConfigSection = u'presentations'
|
||||
self.IconPath = u'presentations/presentation'
|
||||
self.OnNewPrompt = u'Select Presentation(s)'
|
||||
self.OnNewFileMasks = u'Presentations (*.ppt *.pps *.odp)'
|
||||
# this next is a class, not an instance of a class - it will
|
||||
# be instanced by the base MediaManagerItem
|
||||
self.ListViewWithDnD_class = PresentationListView
|
||||
@ -63,6 +61,10 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
def initPluginNameVisible(self):
|
||||
self.PluginNameVisible = self.trUtf8(self.PluginNameShort)
|
||||
|
||||
def reTranslateUI(self):
|
||||
self.OnNewPrompt = self.trUtf8(u'Select Presentation(s)')
|
||||
self.OnNewFileMasks = self.trUtf8(u'Presentations (*.ppt *.pps *.odp)')
|
||||
|
||||
def requiredIcons(self):
|
||||
MediaManagerItem.requiredIcons(self)
|
||||
self.hasFileIcon = True
|
||||
|
Loading…
Reference in New Issue
Block a user