forked from openlp/openlp
Plugin Clean up for trying to display non selected items
This commit is contained in:
parent
94a3513bb1
commit
3ba22197dd
@ -234,16 +234,19 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
def onPreviewClick(self):
|
||||
log.debug(self.PluginTextShort+u' Preview Requested')
|
||||
service_item = self.buildServiceItem()
|
||||
if service_item is not None:
|
||||
self.parent.preview_controller.addServiceItem(service_item)
|
||||
|
||||
def onLiveClick(self):
|
||||
log.debug(self.PluginTextShort + u' Live Requested')
|
||||
service_item = self.buildServiceItem()
|
||||
if service_item is not None:
|
||||
self.parent.live_controller.addServiceItem(service_item)
|
||||
|
||||
def onAddClick(self):
|
||||
log.debug(self.PluginTextShort+u' Add Requested')
|
||||
service_item = self.buildServiceItem()
|
||||
if service_item is not None:
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
|
||||
def buildServiceItem(self):
|
||||
@ -252,6 +255,8 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
"""
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_'+self.PluginTextShort.lower()+u'.png')
|
||||
self.generateSlideData(service_item)
|
||||
if self.generateSlideData(service_item):
|
||||
self.ListView.clearSelection()
|
||||
return service_item
|
||||
else:
|
||||
return None
|
||||
|
@ -342,7 +342,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
log.debug(u'generating slide data')
|
||||
items = self.ListView.selectedIndexes()
|
||||
if len(items) > 1:
|
||||
return
|
||||
return False
|
||||
old_chapter = u''
|
||||
raw_slides = []
|
||||
raw_footer = []
|
||||
@ -391,6 +391,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
for slide in raw_slides:
|
||||
service_item.add_from_text(slide[:30], slide)
|
||||
service_item.raw_footer = raw_footer
|
||||
return True
|
||||
|
||||
def formatVerse(self, old_chapter, chapter, verse, opening, closing):
|
||||
loc = opening
|
||||
|
@ -68,17 +68,17 @@ class CustomMediaItem(MediaManagerItem):
|
||||
self.addToolbarButton(
|
||||
translate(u'CustomMediaItem',u'Preview Custom Item'),
|
||||
translate(u'CustomMediaItem',u'Preview the selected Custom Item'),
|
||||
u':/system/system_preview.png', self.onCustomPreviewClick, u'CustomPreviewItem')
|
||||
u':/system/system_preview.png', self.onPreviewClick, u'CustomPreviewItem')
|
||||
## Live Custom Button ##
|
||||
self.addToolbarButton(
|
||||
translate(u'CustomMediaItem',u'Go Live'),
|
||||
translate(u'CustomMediaItem', u'Send the selected Custom live'),
|
||||
u':/system/system_live.png', self.onCustomLiveClick, u'CustomLiveItem')
|
||||
u':/system/system_live.png', self.onLiveClick, u'CustomLiveItem')
|
||||
## Add Custom Button ##
|
||||
self.addToolbarButton(
|
||||
translate(u'CustomMediaItem',u'Add Custom To Service'),
|
||||
translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'),
|
||||
u':/system/system_add.png', self.onCustomAddClick, u'CustomAddItem')
|
||||
u':/system/system_add.png', self.onAddClick, u'CustomAddItem')
|
||||
# Add the CustomListView widget
|
||||
self.CustomWidget = QtGui.QWidget(self)
|
||||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
@ -95,7 +95,7 @@ class CustomMediaItem(MediaManagerItem):
|
||||
self.PageLayout.addWidget(self.ListView)
|
||||
# Signals
|
||||
QtCore.QObject.connect(self.ListView,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onCustomPreviewClick)
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
|
||||
#define and add the context menu
|
||||
self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
|
||||
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||
@ -104,13 +104,13 @@ class CustomMediaItem(MediaManagerItem):
|
||||
self.ListView.addAction(contextMenuSeparator(self.ListView))
|
||||
self.ListView.addAction(contextMenuAction(
|
||||
self.ListView, ':/system/system_preview.png',
|
||||
translate(u'CustomMediaItem',u'&Preview Custom'), self.onCustomPreviewClick))
|
||||
translate(u'CustomMediaItem',u'&Preview Custom'), self.onPreviewClick))
|
||||
self.ListView.addAction(contextMenuAction(
|
||||
self.ListView, ':/system/system_live.png',
|
||||
translate(u'CustomMediaItem',u'&Show Live'), self.onCustomLiveClick))
|
||||
translate(u'CustomMediaItem',u'&Show Live'), self.onLiveClick))
|
||||
self.ListView.addAction(contextMenuAction(
|
||||
self.ListView, ':/system/system_add.png',
|
||||
translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick))
|
||||
translate(u'CustomMediaItem',u'&Add to Service'), self.onAddClick))
|
||||
|
||||
def initialise(self):
|
||||
self.loadCustomListView(self.parent.custommanager.get_all_slides())
|
||||
@ -143,26 +143,26 @@ class CustomMediaItem(MediaManagerItem):
|
||||
row = self.ListView.row(item)
|
||||
self.ListView.takeItem(row)
|
||||
|
||||
def onCustomPreviewClick(self):
|
||||
log.debug(u'Custom Preview Requested')
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_song.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.preview_controller.addServiceItem(service_item)
|
||||
|
||||
def onCustomLiveClick(self):
|
||||
log.debug(u'Custom Live Requested')
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_song.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.live_controller.addServiceItem(service_item)
|
||||
|
||||
def onCustomAddClick(self):
|
||||
log.debug(u'Custom Add Requested')
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_song.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
# def onCustomPreviewClick(self):
|
||||
# log.debug(u'Custom Preview Requested')
|
||||
# service_item = ServiceItem(self.parent)
|
||||
# service_item.addIcon(u':/media/media_song.png')
|
||||
# self.generateSlideData(service_item)
|
||||
# self.parent.preview_controller.addServiceItem(service_item)
|
||||
#
|
||||
# def onCustomLiveClick(self):
|
||||
# log.debug(u'Custom Live Requested')
|
||||
# service_item = ServiceItem(self.parent)
|
||||
# service_item.addIcon(u':/media/media_song.png')
|
||||
# self.generateSlideData(service_item)
|
||||
# self.parent.live_controller.addServiceItem(service_item)
|
||||
#
|
||||
# def onCustomAddClick(self):
|
||||
# log.debug(u'Custom Add Requested')
|
||||
# service_item = ServiceItem(self.parent)
|
||||
# service_item.addIcon(u':/media/media_song.png')
|
||||
# self.generateSlideData(service_item)
|
||||
# self.parent.service_manager.addServiceItem(service_item)
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
raw_slides =[]
|
||||
@ -170,6 +170,8 @@ class CustomMediaItem(MediaManagerItem):
|
||||
slide = None
|
||||
theme = None
|
||||
item = self.ListView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
customSlide = self.parent.custommanager.get_custom(item_id)
|
||||
title = customSlide.title
|
||||
@ -187,3 +189,4 @@ class CustomMediaItem(MediaManagerItem):
|
||||
for slide in raw_slides:
|
||||
service_item.add_from_text(slide[:30], slide)
|
||||
service_item.raw_footer = raw_footer
|
||||
return True
|
||||
|
@ -95,6 +95,8 @@ class ImageMediaItem(MediaManagerItem):
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
items = self.ListView.selectedIndexes()
|
||||
if len(items) > 1:
|
||||
return False
|
||||
service_item.title = u'Image(s)'
|
||||
for item in items:
|
||||
bitem = self.ListView.item(item.row())
|
||||
@ -102,3 +104,4 @@ class ImageMediaItem(MediaManagerItem):
|
||||
frame = QtGui.QImage(unicode(filename))
|
||||
(path, name) = os.path.split(filename)
|
||||
service_item.add_from_image(path, name, frame)
|
||||
return True
|
||||
|
@ -100,12 +100,15 @@ class MediaMediaItem(MediaManagerItem):
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
indexes = self.ListView.selectedIndexes()
|
||||
if len(items) > 1:
|
||||
return False
|
||||
service_item.title = u'Media'
|
||||
for index in indexes:
|
||||
filename = self.ListData.getFilename(index)
|
||||
frame = QtGui.QImage(unicode(filename))
|
||||
(path, name) = os.path.split(filename)
|
||||
service_item.add_from_image(path, name, frame)
|
||||
return True
|
||||
|
||||
def onPreviewClick(self):
|
||||
log.debug(u'Media Preview Button pressed')
|
||||
|
@ -99,6 +99,8 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
items = self.ListView.selectedIndexes()
|
||||
if len(items) > 1:
|
||||
return False
|
||||
service_item.title = unicode(self.DisplayTypeComboBox.currentText())
|
||||
service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
|
||||
for item in items:
|
||||
@ -106,3 +108,4 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
||||
(path, name) = os.path.split(filename)
|
||||
service_item.add_from_command(path, name)
|
||||
return True
|
||||
|
@ -68,15 +68,15 @@ class SongMediaItem(MediaManagerItem):
|
||||
## Preview Song Button ##
|
||||
self.addToolbarButton(translate(u'SongMediaItem', u'Preview Song'),
|
||||
translate(u'SongMediaItem', u'Preview the selected song'),
|
||||
':/system/system_preview.png', self.onSongPreviewClick, 'SongPreviewItem')
|
||||
':/system/system_preview.png', self.onPreviewClick, 'SongPreviewItem')
|
||||
## Live Song Button ##
|
||||
self.addToolbarButton(translate(u'SongMediaItem', u'Go Live'),
|
||||
translate(u'SongMediaItem', u'Send the selected song live'),
|
||||
':/system/system_live.png', self.onSongLiveClick, 'SongLiveItem')
|
||||
':/system/system_live.png', self.onLiveClick, 'SongLiveItem')
|
||||
## Add Song Button ##
|
||||
self.addToolbarButton(translate(u'SongMediaItem', u'Add Song To Service'),
|
||||
translate(u'SongMediaItem', u'Add the selected song(s) to the service'),
|
||||
':/system/system_add.png', self.onSongAddClick, 'SongAddItem')
|
||||
':/system/system_add.png', self.onAddClick, 'SongAddItem')
|
||||
self.addToolbarSeparator()
|
||||
## Song Maintenance Button ##
|
||||
self.addToolbarButton(translate(u'SongMediaItem', u'Song Maintenance'),
|
||||
@ -127,7 +127,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
QtCore.QObject.connect(self.SearchTextEdit,
|
||||
QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)
|
||||
QtCore.QObject.connect(self.ListView,
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
|
||||
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onPreviewClick)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'load_song_list'), self.onSearchTextButtonClick)
|
||||
|
||||
@ -139,13 +139,13 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.ListView.addAction(contextMenuSeparator(self.ListView))
|
||||
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||
':/system/system_preview.png', translate(u'SongMediaItem', u'&Preview Song'),
|
||||
self.onSongPreviewClick))
|
||||
self.onPreviewClick))
|
||||
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||
':/system/system_live.png', translate(u'SongMediaItem', u'&Show Live'),
|
||||
self.onSongLiveClick))
|
||||
self.onLiveClick))
|
||||
self.ListView.addAction(contextMenuAction(self.ListView,
|
||||
':/system/system_add.png', translate(u'SongMediaItem', u'&Add to Service'),
|
||||
self.onSongAddClick))
|
||||
self.onAddClick))
|
||||
|
||||
def retranslateUi(self):
|
||||
self.SearchTypeLabel.setText(translate(u'SongMediaItem', u'Search Type:'))
|
||||
@ -246,12 +246,12 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.parent.songmanager.delete_song(item_id)
|
||||
row = self.ListView.row(item)
|
||||
self.ListView.takeItem(row)
|
||||
|
||||
def onSongPreviewClick(self):
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_song.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.preview_controller.addServiceItem(service_item)
|
||||
#
|
||||
# def onSongPreviewClick(self):
|
||||
# service_item = ServiceItem(self.parent)
|
||||
# service_item.addIcon(u':/media/media_song.png')
|
||||
# self.generateSlideData(service_item)
|
||||
# self.parent.preview_controller.addServiceItem(service_item)
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
raw_slides =[]
|
||||
@ -259,6 +259,8 @@ class SongMediaItem(MediaManagerItem):
|
||||
author_list = u''
|
||||
ccl = u''
|
||||
item = self.ListView.currentItem()
|
||||
if item is None:
|
||||
return False
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
song = self.parent.songmanager.get_song(item_id)
|
||||
service_item.theme = song.theme_name
|
||||
@ -286,15 +288,16 @@ class SongMediaItem(MediaManagerItem):
|
||||
raw_footer.append(song.copyright )
|
||||
raw_footer.append(unicode(translate(u'SongMediaItem', u'CCL Licence: ') + ccl ))
|
||||
service_item.raw_footer = raw_footer
|
||||
return True
|
||||
|
||||
def onSongLiveClick(self):
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon(u':/media/media_song.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.live_controller.addServiceItem(service_item)
|
||||
|
||||
def onSongAddClick(self):
|
||||
service_item = ServiceItem(self.parent)
|
||||
service_item.addIcon( u':/media/media_song.png')
|
||||
self.generateSlideData(service_item)
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
# def onSongLiveClick(self):
|
||||
# service_item = ServiceItem(self.parent)
|
||||
# service_item.addIcon(u':/media/media_song.png')
|
||||
# self.generateSlideData(service_item)
|
||||
# self.parent.live_controller.addServiceItem(service_item)
|
||||
#
|
||||
# def onSongAddClick(self):
|
||||
# service_item = ServiceItem(self.parent)
|
||||
# service_item.addIcon( u':/media/media_song.png')
|
||||
# self.generateSlideData(service_item)
|
||||
# self.parent.service_manager.addServiceItem(service_item)
|
||||
|
Loading…
Reference in New Issue
Block a user