forked from openlp/openlp
Remote searches presentations, media and images
This commit is contained in:
parent
3f21b3e2ca
commit
2655c1b133
@ -47,6 +47,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.IconPath = u'images/image'
|
self.IconPath = u'images/image'
|
||||||
MediaManagerItem.__init__(self, parent, self, icon)
|
MediaManagerItem.__init__(self, parent, self, icon)
|
||||||
self.quickPreviewAllowed = True
|
self.quickPreviewAllowed = True
|
||||||
|
self.hasSearch = True
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
|
QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
|
||||||
|
|
||||||
@ -130,51 +131,51 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.parent.formparent.finishedProgressBar()
|
self.parent.formparent.finishedProgressBar()
|
||||||
|
|
||||||
def generateSlideData(self, service_item, item=None, xmlVersion=False):
|
def generateSlideData(self, service_item, item=None, xmlVersion=False):
|
||||||
items = self.listView.selectedIndexes()
|
if item:
|
||||||
if items:
|
items = [item]
|
||||||
service_item.title = unicode(self.plugin.nameStrings[u'plural'])
|
|
||||||
service_item.add_capability(ItemCapabilities.AllowsMaintain)
|
|
||||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
|
||||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
|
||||||
service_item.add_capability(ItemCapabilities.AllowsAdditions)
|
|
||||||
# force a nonexistent theme
|
|
||||||
service_item.theme = -1
|
|
||||||
missing_items = []
|
|
||||||
missing_items_filenames = []
|
|
||||||
for item in items:
|
|
||||||
bitem = self.listView.item(item.row())
|
|
||||||
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
|
||||||
if not os.path.exists(filename):
|
|
||||||
missing_items.append(item)
|
|
||||||
missing_items_filenames.append(filename)
|
|
||||||
for item in missing_items:
|
|
||||||
items.remove(item)
|
|
||||||
# We cannot continue, as all images do not exist.
|
|
||||||
if not items:
|
|
||||||
critical_error_message_box(
|
|
||||||
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
|
|
||||||
unicode(translate('ImagePlugin.MediaItem',
|
|
||||||
'The following image(s) no longer exist: %s')) %
|
|
||||||
u'\n'.join(missing_items_filenames))
|
|
||||||
return False
|
|
||||||
# We have missing as well as existing images. We ask what to do.
|
|
||||||
elif missing_items and QtGui.QMessageBox.question(self,
|
|
||||||
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
|
|
||||||
unicode(translate('ImagePlugin.MediaItem', 'The following '
|
|
||||||
'image(s) no longer exist: %s\nDo you want to add the other '
|
|
||||||
'images anyway?')) % u'\n'.join(missing_items_filenames),
|
|
||||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
|
||||||
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
|
|
||||||
return False
|
|
||||||
# Continue with the existing images.
|
|
||||||
for item in items:
|
|
||||||
bitem = self.listView.item(item.row())
|
|
||||||
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
|
||||||
(path, name) = os.path.split(filename)
|
|
||||||
service_item.add_from_image(filename, name)
|
|
||||||
return True
|
|
||||||
else:
|
else:
|
||||||
|
items = self.listView.selectedItems()
|
||||||
|
if not items:
|
||||||
|
return False
|
||||||
|
service_item.title = unicode(self.plugin.nameStrings[u'plural'])
|
||||||
|
service_item.add_capability(ItemCapabilities.AllowsMaintain)
|
||||||
|
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||||
|
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||||
|
service_item.add_capability(ItemCapabilities.AllowsAdditions)
|
||||||
|
# force a nonexistent theme
|
||||||
|
service_item.theme = -1
|
||||||
|
missing_items = []
|
||||||
|
missing_items_filenames = []
|
||||||
|
for bitem in items:
|
||||||
|
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
||||||
|
if not os.path.exists(filename):
|
||||||
|
missing_items.append(item)
|
||||||
|
missing_items_filenames.append(filename)
|
||||||
|
for item in missing_items:
|
||||||
|
items.remove(item)
|
||||||
|
# We cannot continue, as all images do not exist.
|
||||||
|
if not items:
|
||||||
|
critical_error_message_box(
|
||||||
|
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
|
||||||
|
unicode(translate('ImagePlugin.MediaItem',
|
||||||
|
'The following image(s) no longer exist: %s')) %
|
||||||
|
u'\n'.join(missing_items_filenames))
|
||||||
return False
|
return False
|
||||||
|
# We have missing as well as existing images. We ask what to do.
|
||||||
|
elif missing_items and QtGui.QMessageBox.question(self,
|
||||||
|
translate('ImagePlugin.MediaItem', 'Missing Image(s)'),
|
||||||
|
unicode(translate('ImagePlugin.MediaItem', 'The following '
|
||||||
|
'image(s) no longer exist: %s\nDo you want to add the other '
|
||||||
|
'images anyway?')) % u'\n'.join(missing_items_filenames),
|
||||||
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
||||||
|
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
|
||||||
|
return False
|
||||||
|
# Continue with the existing images.
|
||||||
|
for bitem in items:
|
||||||
|
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
||||||
|
(path, name) = os.path.split(filename)
|
||||||
|
service_item.add_from_image(filename, name)
|
||||||
|
return True
|
||||||
|
|
||||||
def onResetClick(self):
|
def onResetClick(self):
|
||||||
"""
|
"""
|
||||||
@ -208,3 +209,14 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
unicode(translate('ImagePlugin.MediaItem',
|
unicode(translate('ImagePlugin.MediaItem',
|
||||||
'There was a problem replacing your background, '
|
'There was a problem replacing your background, '
|
||||||
'the image file "%s" no longer exists.')) % filename)
|
'the image file "%s" no longer exists.')) % filename)
|
||||||
|
|
||||||
|
def search(self, string):
|
||||||
|
list = SettingsManager.load_list(self.settingsSection,
|
||||||
|
self.settingsSection)
|
||||||
|
results = []
|
||||||
|
string = string.lower()
|
||||||
|
for file in list:
|
||||||
|
filename = os.path.split(unicode(file))[1]
|
||||||
|
if filename.lower().find(string) > -1:
|
||||||
|
results.append([file, filename])
|
||||||
|
return results
|
||||||
|
@ -50,6 +50,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
u':/media/media_video.png').toImage()
|
u':/media/media_video.png').toImage()
|
||||||
MediaManagerItem.__init__(self, parent, self, icon)
|
MediaManagerItem.__init__(self, parent, self, icon)
|
||||||
self.singleServiceItem = False
|
self.singleServiceItem = False
|
||||||
|
self.hasSearch = True
|
||||||
self.mediaObject = None
|
self.mediaObject = None
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'video_background_replaced'),
|
QtCore.SIGNAL(u'video_background_replaced'),
|
||||||
@ -212,3 +213,14 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
log.debug(u'CreatePhonon')
|
log.debug(u'CreatePhonon')
|
||||||
if not self.mediaObject:
|
if not self.mediaObject:
|
||||||
self.mediaObject = Phonon.MediaObject(self)
|
self.mediaObject = Phonon.MediaObject(self)
|
||||||
|
|
||||||
|
def search(self, string):
|
||||||
|
list = SettingsManager.load_list(self.settingsSection,
|
||||||
|
self.settingsSection)
|
||||||
|
results = []
|
||||||
|
string = string.lower()
|
||||||
|
for file in list:
|
||||||
|
filename = os.path.split(unicode(file))[1]
|
||||||
|
if filename.lower().find(string) > -1:
|
||||||
|
results.append([file, filename])
|
||||||
|
return results
|
||||||
|
@ -53,6 +53,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
self.Automatic = u''
|
self.Automatic = u''
|
||||||
MediaManagerItem.__init__(self, parent, self, icon)
|
MediaManagerItem.__init__(self, parent, self, icon)
|
||||||
self.message_listener = MessageListener(self)
|
self.message_listener = MessageListener(self)
|
||||||
|
self.hasSearch = True
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'mediaitem_presentation_rebuild'), self.rebuild)
|
QtCore.SIGNAL(u'mediaitem_presentation_rebuild'), self.rebuild)
|
||||||
|
|
||||||
@ -231,17 +232,19 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
in the slidecontroller. In the case of powerpoints, an image
|
in the slidecontroller. In the case of powerpoints, an image
|
||||||
for each slide
|
for each slide
|
||||||
"""
|
"""
|
||||||
items = self.listView.selectedIndexes()
|
if item:
|
||||||
if len(items) > 1:
|
items = [item]
|
||||||
return False
|
else:
|
||||||
|
items = self.listView.selectedItems()
|
||||||
|
if len(items) > 1:
|
||||||
|
return False
|
||||||
service_item.title = unicode(self.displayTypeComboBox.currentText())
|
service_item.title = unicode(self.displayTypeComboBox.currentText())
|
||||||
service_item.shortname = unicode(self.displayTypeComboBox.currentText())
|
service_item.shortname = unicode(self.displayTypeComboBox.currentText())
|
||||||
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
|
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
|
||||||
service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay)
|
service_item.add_capability(ItemCapabilities.AllowsDetailedTitleDisplay)
|
||||||
shortname = service_item.shortname
|
shortname = service_item.shortname
|
||||||
if shortname:
|
if shortname:
|
||||||
for item in items:
|
for bitem in items:
|
||||||
bitem = self.listView.item(item.row())
|
|
||||||
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
if shortname == self.Automatic:
|
if shortname == self.Automatic:
|
||||||
@ -303,3 +306,12 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
if filetype in self.controllers[controller].alsosupports:
|
if filetype in self.controllers[controller].alsosupports:
|
||||||
return controller
|
return controller
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def search(self, string):
|
||||||
|
list = SettingsManager.load_list(self.settingsSection, u'presentations')
|
||||||
|
results = []
|
||||||
|
string = string.lower()
|
||||||
|
for file in list:
|
||||||
|
if file.lower().find(string) > -1:
|
||||||
|
results.append([file, file])
|
||||||
|
return results
|
||||||
|
Loading…
Reference in New Issue
Block a user