Slide Controller cleanups and Media bug fixes

bzr-revno: 669
This commit is contained in:
Tim Bentley 2009-11-12 19:51:58 +00:00
commit 8da19172a7
7 changed files with 59 additions and 62 deletions

View File

@ -81,6 +81,8 @@ class OpenLP(QtGui.QApplication):
bits = unicode(line).split(u'-')
applicationVersion = {u'Full':unicode(line).rstrip(),
u'version':bits[0], u'build':bits[1]}
log.info(u'Openlp version %s build %s' %
(applicationVersion[u'version'],applicationVersion[u'build'] ))
except:
applicationVersion = {u'Full':u'1.9.0-000',
u'version':u'1.9.0', u'build':u'000'}
@ -139,6 +141,7 @@ def main():
logfile.setFormatter(logging.Formatter(
u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s'))
log.addHandler(logfile)
logging.addLevelName(15, u'Timer')
# Parse command line options and deal with them.
(options, args) = parser.parse_args()
if options.debug:

View File

@ -38,7 +38,6 @@ class ServiceItemType(object):
Text = 1
Image = 2
Command = 3
Video = 4
class ServiceItem(object):
"""
@ -156,12 +155,6 @@ class ServiceItem(object):
self.service_frames.append(
{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):
"""
Add a text slide to the service item.
@ -216,10 +209,7 @@ class ServiceItem(object):
service_data.append(slide[u'title'])
elif self.service_item_type == ServiceItemType.Command:
for slide in self.service_frames:
service_data.append(slide[u'title'])
elif self.service_item_type == ServiceItemType.Video:
for slide in self.service_frames:
service_data.append(slide[u'title'])
service_data.append({u'title':slide[u'title'], u'image':slide[u'image']})
return {u'header': service_header, u'data': service_data}
def set_from_service(self, serviceitem, path=None):
@ -252,10 +242,8 @@ class ServiceItem(object):
self.add_from_image(path, text_image, real_image)
elif self.service_item_type == ServiceItemType.Command:
for text_image in serviceitem[u'serviceitem'][u'data']:
filename = os.path.join(path, text_image)
self.add_from_command(path, text_image)
elif self.service_item_type == ServiceItemType.Video:
pass
filename = os.path.join(path, text_image[u'title'])
self.add_from_command(path, text_image[u'title'], text_image[u'image'] )
def merge(self, other):
"""
@ -279,3 +267,17 @@ class ServiceItem(object):
"""
return self.uuid != other.uuid
def isSong(self):
return self.name == u'Songs'
def isMedia(self):
return self.name.lower() == u'media'
def isCommand(self):
return self.service_item_type == ServiceItemType.Command
def isImage(self):
return self.service_item_type == ServiceItemType.Image
def isText(self):
return self.service_item_type == ServiceItemType.Text

View File

@ -24,6 +24,7 @@
import logging
import os
import time
from PyQt4 import QtCore, QtGui
from PyQt4.phonon import Phonon
@ -196,10 +197,16 @@ class MainDisplay(DisplayWidget):
if self.timer_id != 0 :
self.displayAlert()
elif not self.displayBlank:
# self.setWindowOpacity(0.5)
# self.show()
self.display.setPixmap(QtGui.QPixmap.fromImage(frame))
# QtCore.QTimer.singleShot(500, self.aa )
if not self.isVisible():
self.setVisible(True)
self.showFullScreen()
#
# def aa(self):
# self.setWindowOpacity(1)
def blankDisplay(self):
if not self.displayBlank:
@ -262,17 +269,16 @@ class MainDisplay(DisplayWidget):
self.firstTime = False
else:
self.mediaObject.enqueue(Phonon.MediaSource(file))
self.onMediaPlay(message[3])
self.onMediaPlay()
def onMediaPlay(self, live=True):
log.debug(u'Play the new media, Live %s', live)
def onMediaPlay(self):
log.debug(u'Play the new media, Live ')
if not self.mediaLoaded and not self.displayBlank:
self.blankDisplay()
self.firstTime = True
self.mediaLoaded = True
if live:
self.display.hide()
self.video.setFullScreen(True)
self.display.hide()
self.video.setFullScreen(True)
self.mediaObject.play()
if self.primary:
self.setVisible(True)

View File

@ -56,7 +56,6 @@ class ServiceManagerList(QtGui.QTreeWidget):
# else:
# event.ignore()
def keyPressEvent(self, event):
if type(event) == QtGui.QKeyEvent:
#here accept the event and do something
@ -99,7 +98,6 @@ class ServiceManagerList(QtGui.QTreeWidget):
mimeData.setText(u'ServiceManager')
dropAction = drag.start(QtCore.Qt.CopyAction)
class ServiceManager(QtGui.QWidget):
"""
Manages the services. This involves taking text strings from plugins and

View File

@ -230,7 +230,6 @@ class SlideController(QtGui.QWidget):
self.grid = QtGui.QGridLayout(self.PreviewFrame)
self.grid.setMargin(8)
self.grid.setObjectName(u'grid')
self.SlideLayout = QtGui.QVBoxLayout()
self.SlideLayout.setSpacing(0)
self.SlideLayout.setMargin(0)
@ -242,7 +241,6 @@ class SlideController(QtGui.QWidget):
Phonon.createPath(self.mediaObject, self.video)
Phonon.createPath(self.mediaObject, self.audio)
self.SlideLayout.insertWidget(0, self.video)
# Actual preview screen
self.SlidePreview = QtGui.QLabel(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,
@ -260,9 +258,6 @@ class SlideController(QtGui.QWidget):
self.SlidePreview.setScaledContents(True)
self.SlidePreview.setObjectName(u'SlidePreview')
self.SlideLayout.insertWidget(0, self.SlidePreview)
self.grid.addLayout(self.SlideLayout, 0, 0, 1, 1)
# Signals
QtCore.QObject.connect(self.PreviewListWidget,
@ -350,9 +345,9 @@ class SlideController(QtGui.QWidget):
self.Songbar.setVisible(False)
self.Mediabar.setVisible(False)
self.Toolbar.makeWidgetsInvisible(self.image_list)
if item.service_item_type == ServiceItemType.Text:
if item.isText():
self.Toolbar.makeWidgetsInvisible(self.image_list)
if item.name == u'Songs' and \
if item.isSong() and \
str_to_bool(self.songsconfig.get_config(u'display songbar', True)):
for action in self.Songbar.actions:
self.Songbar.actions[action].setVisible(False)
@ -367,12 +362,11 @@ class SlideController(QtGui.QWidget):
#More than 20 verses hard luck
pass
self.Songbar.setVisible(True)
elif item.service_item_type == ServiceItemType.Image:
elif item.isImage():
#Not sensible to allow loops with 1 frame
if len(item.frames) > 1:
self.Toolbar.makeWidgetsVisible(self.image_list)
elif item.service_item_type == ServiceItemType.Command and \
item.name == u'Media':
elif item.isMedia():
self.Toolbar.setVisible(False)
self.Mediabar.setVisible(True)
self.volumeSlider.setAudioOutput(self.parent.mainDisplay.audio)
@ -384,10 +378,9 @@ class SlideController(QtGui.QWidget):
self.Toolbar.setVisible(True)
self.Mediabar.setVisible(False)
self.Toolbar.makeWidgetsInvisible(self.song_edit_list)
if (item.name == u'Songs' or item.name == u'Custom') and item.fromPlugin:
if item.editEnabled and item.fromPlugin:
self.Toolbar.makeWidgetsVisible(self.song_edit_list)
elif item.service_item_type == ServiceItemType.Command and \
item.name == u'Media':
elif item.isMedia():
self.Toolbar.setVisible(False)
self.Mediabar.setVisible(True)
self.volumeSlider.setAudioOutput(self.audio)
@ -400,21 +393,20 @@ class SlideController(QtGui.QWidget):
"""
log.debug(u'addServiceItem')
#If old item was a command tell it to stop
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
if self.commandItem and self.commandItem.isCommand():
self.onMediaStop()
self.commandItem = item
before = time.time()
item.render()
log.info(u'Rendering took %4s' % (time.time() - before))
log.log(15, u'Rendering took %4s' % (time.time() - before))
self.enableToolBar(item)
if item.service_item_type == ServiceItemType.Command:
if item.isCommand():
if self.isLive:
Receiver().send_message(u'%s_start' % item.name.lower(), \
[item.shortname, item.service_item_path,
item.service_frames[0][u'title'], self.isLive])
else:
if item.name == u'Media':
if item.isMedia():
self.onMediaStart(item)
slideno = 0
if self.songEdit:
@ -437,18 +429,17 @@ class SlideController(QtGui.QWidget):
"""
log.debug(u'addServiceManagerItem')
#If old item was a command tell it to stop
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
if self.commandItem and self.commandItem.isCommand():
self.onMediaStop()
self.commandItem = item
self.enableToolBar(item)
if item.service_item_type == ServiceItemType.Command:
if item.isCommand():
if self.isLive:
Receiver().send_message(u'%s_start' % item.name.lower(), \
[item.shortname, item.service_item_path,
item.service_frames[0][u'title'], slideno, self.isLive])
else:
if item.name == u'Media':
if item.isMedia():
self.onMediaStart(item)
self.displayServiceManagerItems(item, slideno)
@ -495,7 +486,7 @@ class SlideController(QtGui.QWidget):
self.PreviewListWidget.selectRow(slideno)
self.onSlideSelected()
self.PreviewListWidget.setFocus()
log.info(u'Display Rendering took %4s' % (time.time() - before))
log.log(15, u'Display Rendering took %4s' % (time.time() - before))
if self.serviceitem.audit and self.isLive:
Receiver().send_message(u'songusage_live', self.serviceitem.audit)
log.debug(u'displayServiceManagerItems End')
@ -505,8 +496,7 @@ class SlideController(QtGui.QWidget):
"""
Go to the first slide.
"""
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
if self.commandItem and self.commandItem.isCommand():
Receiver().send_message(u'%s_first'% self.commandItem.name.lower())
self.updatePreview()
else:
@ -517,8 +507,7 @@ class SlideController(QtGui.QWidget):
"""
Blank the screen.
"""
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
if self.commandItem and self.commandItem.isCommand():
if blanked:
Receiver().send_message(u'%s_blank'% self.commandItem.name.lower())
else:
@ -534,7 +523,7 @@ class SlideController(QtGui.QWidget):
row = self.PreviewListWidget.currentRow()
self.row = 0
if row > -1 and row < self.PreviewListWidget.rowCount():
if self.commandItem.service_item_type == ServiceItemType.Command:
if self.commandItem.isCommand():
Receiver().send_message(u'%s_slide'% self.commandItem.name.lower(), [row])
if self.isLive:
self.updatePreview()
@ -544,7 +533,7 @@ class SlideController(QtGui.QWidget):
if frame is None:
frame = self.serviceitem.render_individual(row)
self.SlidePreview.setPixmap(QtGui.QPixmap.fromImage(frame))
log.info(u'Slide Rendering took %4s' % (time.time() - before))
log.log(15, u'Slide Rendering took %4s' % (time.time() - before))
if self.isLive:
self.parent.mainDisplay.frameView(frame)
self.row = row
@ -563,22 +552,23 @@ class SlideController(QtGui.QWidget):
QtCore.QTimer.singleShot(0.5, self.grabMainDisplay)
QtCore.QTimer.singleShot(2.5, self.grabMainDisplay)
else:
label = self.PreviewListWidget.cellWidget(self.PreviewListWidget.currentRow(), 0)
label = self.PreviewListWidget.cellWidget(
self.PreviewListWidget.currentRow(), 0)
self.SlidePreview.setPixmap(label.pixmap())
def grabMainDisplay(self):
rm = self.parent.RenderManager
winid = QtGui.QApplication.desktop().winId()
rect = rm.screen_list[rm.current_display][u'size']
winimg = QtGui.QPixmap.grabWindow(winid, rect.x(), rect.y(), rect.width(), rect.height())
winimg = QtGui.QPixmap.grabWindow(winid, rect.x(),
rect.y(), rect.width(), rect.height())
self.SlidePreview.setPixmap(winimg)
def onSlideSelectedNext(self):
"""
Go to the next slide.
"""
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
if self.commandItem and self.commandItem.isCommand():
Receiver().send_message(u'%s_next'% self.commandItem.name.lower())
self.updatePreview()
else:
@ -592,8 +582,7 @@ class SlideController(QtGui.QWidget):
"""
Go to the previous slide.
"""
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
if self.commandItem and self.commandItem.isCommand():
Receiver().send_message(
u'%s_previous'% self.commandItem.name.lower())
self.updatePreview()
@ -608,8 +597,7 @@ class SlideController(QtGui.QWidget):
"""
Go to the last slide.
"""
if self.commandItem and \
self.commandItem.service_item_type == ServiceItemType.Command:
if self.commandItem and self.commandItem.isCommand():
Receiver().send_message(u'%s_last'% self.commandItem.name.lower())
self.updatePreview()
else:

View File

@ -79,7 +79,7 @@ class MediaMediaItem(MediaManagerItem):
items = self.ListView.selectedIndexes()
if len(items) > 1:
return False
service_item.title = self.trUtf8(u'Media')
service_item.title = unicode(self.trUtf8(u'Media'))
for item in items:
bitem = self.ListView.item(item.row())
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())

View File

@ -1 +1 @@
1.9.0-668
1.9.0-669