Fix image qstring

This commit is contained in:
Jonathan Corwin 2010-05-01 23:02:31 +01:00
commit 456d35f2d4
8 changed files with 64 additions and 27 deletions

View File

@ -429,7 +429,7 @@ class MediaManagerItem(QtGui.QWidget):
service_item = self.buildServiceItem() service_item = self.buildServiceItem()
if service_item: if service_item:
service_item.from_plugin = False service_item.from_plugin = False
self.parent.service_manager.addServiceItem(service_item, self.parent.service_manager.addServiceItem(service_item,
replace=self.remoteTriggered) replace=self.remoteTriggered)
else: else:
items = self.ListView.selectedIndexes() items = self.ListView.selectedIndexes()
@ -454,7 +454,7 @@ class MediaManagerItem(QtGui.QWidget):
'You must select an existing service item to add to.')) 'You must select an existing service item to add to.'))
elif self.title.lower() == service_item.name.lower(): elif self.title.lower() == service_item.name.lower():
self.generateSlideData(service_item) self.generateSlideData(service_item)
self.parent.service_manager.addServiceItem(service_item, self.parent.service_manager.addServiceItem(service_item,
replace=True) replace=True)
else: else:
#Turn off the remote edit update message indicator #Turn off the remote edit update message indicator

View File

@ -215,13 +215,16 @@ class Plugin(QtCore.QObject):
""" """
pass pass
def process_add_service_event(self): def process_add_service_event(self, replace=False):
""" """
Generic Drag and drop handler triggered from service_manager. Generic Drag and drop handler triggered from service_manager.
""" """
log.debug(u'process_add_service_event event called for plugin %s' % log.debug(u'process_add_service_event event called for plugin %s' %
self.name) self.name)
self.media_item.onAddClick() if replace:
self.media_item.onAddEditClick()
else:
self.media_item.onAddClick()
def about(self): def about(self):
""" """

View File

@ -48,6 +48,7 @@ class ItemCapabilities(object):
AllowsMaintain = 3 AllowsMaintain = 3
RequiresMedia = 4 RequiresMedia = 4
AllowsLoop = 5 AllowsLoop = 5
AllowsAdditions = 6
class ServiceItem(object): class ServiceItem(object):
""" """

View File

@ -200,12 +200,18 @@ class ServiceManager(QtGui.QWidget):
self.parent.serviceSettingsSection + u'/service theme', self.parent.serviceSettingsSection + u'/service theme',
QtCore.QVariant(u'')).toString()) QtCore.QVariant(u'')).toString())
self.servicePath = AppLocation.get_section_data_path(u'servicemanager') self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
#build the drag and drop context menu
self.dndMenu = QtGui.QMenu()
self.newAction = self.dndMenu.addAction(self.trUtf8('&Add New Item'))
self.newAction.setIcon(build_icon(u':/general/general_edit.png'))
self.addToAction = self.dndMenu.addAction(self.trUtf8('&Add to Selected Item'))
self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
#build the context menu #build the context menu
self.menu = QtGui.QMenu() self.menu = QtGui.QMenu()
self.editAction = self.menu.addAction(self.trUtf8('&Edit Item')) self.editAction = self.menu.addAction(self.trUtf8('&Edit Item'))
self.editAction.setIcon(build_icon(u':/general/general_edit.png')) self.editAction.setIcon(build_icon(u':/general/general_edit.png'))
self.maintainAction = self.menu.addAction(self.trUtf8('&Maintain Item')) self.maintainAction = self.menu.addAction(self.trUtf8('&Maintain Item'))
self.editAction.setIcon(build_icon(u':/general/general_edit.png')) self.maintainAction.setIcon(build_icon(u':/general/general_edit.png'))
self.notesAction = self.menu.addAction(self.trUtf8('&Notes')) self.notesAction = self.menu.addAction(self.trUtf8('&Notes'))
self.notesAction.setIcon(build_icon(u':/services/service_notes.png')) self.notesAction.setIcon(build_icon(u':/services/service_notes.png'))
self.deleteAction = self.menu.addAction( self.deleteAction = self.menu.addAction(
@ -836,6 +842,7 @@ class ServiceManager(QtGui.QWidget):
if link.hasText(): if link.hasText():
plugin = event.mimeData().text() plugin = event.mimeData().text()
item = self.ServiceManagerList.itemAt(event.pos()) item = self.ServiceManagerList.itemAt(event.pos())
#ServiceManager started the drag and drop
if plugin == u'ServiceManager': if plugin == u'ServiceManager':
startpos, startCount = self.findServiceItem() startpos, startCount = self.findServiceItem()
if item is None: if item is None:
@ -851,11 +858,28 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems.insert(newpos, serviceItem) self.serviceItems.insert(newpos, serviceItem)
self.repaintServiceList(endpos, startCount) self.repaintServiceList(endpos, startCount)
else: else:
#we are not over anything so drop
replace = False
if item == None: if item == None:
self.droppos = len(self.serviceItems) self.droppos = len(self.serviceItems)
else: else:
self.droppos = self._getParentItemData(item) #we are over somthing so lets investigate
Receiver.send_message(u'%s_add_service_item' % plugin) pos = self._getParentItemData(item) - 1
serviceItem = self.serviceItems[pos]
if plugin == serviceItem[u'service_item'].name \
and serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsAdditions):
action = self.dndMenu.exec_(QtGui.QCursor.pos())
#New action required
if action == self.newAction:
self.droppos = self._getParentItemData(item)
#Append to existing action
if action == self.addToAction:
self.droppos = self._getParentItemData(item)
item.setSelected(True)
replace = True
else:
self.droppos = self._getParentItemData(item)
Receiver.send_message(u'%s_add_service_item' % plugin, replace)
def updateThemeList(self, theme_list): def updateThemeList(self, theme_list):
""" """

View File

@ -449,6 +449,7 @@ class BibleMediaItem(MediaManagerItem):
bible_text = u'' bible_text = u''
service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsPreview)
service_item.add_capability(ItemCapabilities.AllowsLoop) service_item.add_capability(ItemCapabilities.AllowsLoop)
service_item.add_capability(ItemCapabilities.AllowsAdditions)
#If we want to use a 2nd translation / version #If we want to use a 2nd translation / version
bible2 = u'' bible2 = u''
if self.SearchTabWidget.currentIndex() == 0: if self.SearchTabWidget.currentIndex() == 0:

View File

@ -143,10 +143,11 @@ class ImageMediaItem(MediaManagerItem):
def generateSlideData(self, service_item, item=None): 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 = unicode(self.trUtf8('Image(s)'))
service_item.add_capability(ItemCapabilities.AllowsMaintain) service_item.add_capability(ItemCapabilities.AllowsMaintain)
service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsPreview)
service_item.add_capability(ItemCapabilities.AllowsLoop) service_item.add_capability(ItemCapabilities.AllowsLoop)
service_item.add_capability(ItemCapabilities.AllowsAdditions)
for item in items: for item in items:
bitem = self.ListView.item(item.row()) bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())

View File

@ -187,26 +187,29 @@ class PresentationMediaItem(MediaManagerItem):
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())
shortname = service_item.shortname shortname = service_item.shortname
for item in items: if shortname:
bitem = self.ListView.item(item.row()) for item in items:
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString()) bitem = self.ListView.item(item.row())
if shortname == self.Automatic: filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
service_item.shortname = self.findControllerByType(filename) if shortname == self.Automatic:
if not service_item.shortname: service_item.shortname = self.findControllerByType(filename)
return False if not service_item.shortname:
controller = self.controllers[service_item.shortname] return False
(path, name) = os.path.split(filename) controller = self.controllers[service_item.shortname]
doc = controller.add_doc(filename) (path, name) = os.path.split(filename)
if doc.get_slide_preview_file(1) is None: doc = controller.add_doc(filename)
doc.load_presentation() if doc.get_slide_preview_file(1) is None:
i = 1 doc.load_presentation()
img = doc.get_slide_preview_file(i) i = 1
while img:
service_item.add_from_command(path, name, img)
i = i + 1
img = doc.get_slide_preview_file(i) img = doc.get_slide_preview_file(i)
doc.close_presentation() while img:
return True service_item.add_from_command(path, name, img)
i = i + 1
img = doc.get_slide_preview_file(i)
doc.close_presentation()
return True
else:
return False
def findControllerByType(self, filename): def findControllerByType(self, filename):
filetype = os.path.splitext(filename)[1] filetype = os.path.splitext(filename)[1]

View File

@ -204,6 +204,7 @@ class HttpConnection(object):
""" """
Decode the query string parameters sent from the browser Decode the query string parameters sent from the browser
""" """
log.debug(u'loading params %s' % query)
params = urlparse.parse_qs(query) params = urlparse.parse_qs(query)
if not params: if not params:
return None return None
@ -216,6 +217,7 @@ class HttpConnection(object):
Currently lets anything through. Later we should restrict and perform Currently lets anything through. Later we should restrict and perform
basic parameter checking, otherwise rogue clients could crash openlp basic parameter checking, otherwise rogue clients could crash openlp
""" """
log.debug(u'Processing event %s' % event)
if params: if params:
Receiver.send_message(event, params) Receiver.send_message(event, params)
else: else:
@ -233,6 +235,7 @@ class HttpConnection(object):
is just waiting for slide change/song change activity. This can wait is just waiting for slide change/song change activity. This can wait
longer (one minute) longer (one minute)
""" """
log.debug(u'Processing request %s' % event)
if not event.endswith(u'_request'): if not event.endswith(u'_request'):
return False return False
self.event = event self.event = event
@ -258,6 +261,7 @@ class HttpConnection(object):
The recipient of a _request signal has sent data. Convert this to The recipient of a _request signal has sent data. Convert this to
json and return it to client json and return it to client
""" """
log.debug(u'Processing response for %s' % self.event)
if not self.socket: if not self.socket:
return return
self.timer.stop() self.timer.stop()