forked from openlp/openlp
Move video and Image clean ups.
Transitions work again after last merge! bzr-revno: 908
This commit is contained in:
commit
9085bfd7c3
@ -35,7 +35,6 @@ import uuid
|
|||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
from openlp.core.lib import build_icon, resize_image
|
from openlp.core.lib import build_icon, resize_image
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -93,7 +92,6 @@ class ServiceItem(object):
|
|||||||
self.is_valid = True
|
self.is_valid = True
|
||||||
self.cache = {}
|
self.cache = {}
|
||||||
self.icon = None
|
self.icon = None
|
||||||
self.serviceItemPath = AppLocation.get_section_data_path(u'serviceItems')
|
|
||||||
|
|
||||||
def add_capability(self, capability):
|
def add_capability(self, capability):
|
||||||
"""
|
"""
|
||||||
@ -155,12 +153,9 @@ class ServiceItem(object):
|
|||||||
del self.cache[len(self._display_frames)]
|
del self.cache[len(self._display_frames)]
|
||||||
log.log(15, u'Formatting took %4s' % (time.time() - before))
|
log.log(15, u'Formatting took %4s' % (time.time() - before))
|
||||||
elif self.service_item_type == ServiceItemType.Image:
|
elif self.service_item_type == ServiceItemType.Image:
|
||||||
for count, slide in enumerate(self._raw_frames):
|
for slide in self._raw_frames:
|
||||||
slide[u'image'] = resize_image(slide[u'image'],
|
slide[u'image'] = resize_image(slide[u'image'],
|
||||||
self.render_manager.width, self.render_manager.height)
|
self.render_manager.width, self.render_manager.height)
|
||||||
path = os.path.join(self.serviceItemPath, self._uuid + unicode(count) + u'.png')
|
|
||||||
slide[u'image'].save(path)
|
|
||||||
slide[u'display'] = path
|
|
||||||
elif self.service_item_type == ServiceItemType.Command:
|
elif self.service_item_type == ServiceItemType.Command:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -376,8 +371,7 @@ class ServiceItem(object):
|
|||||||
if self.service_item_type == ServiceItemType.Text:
|
if self.service_item_type == ServiceItemType.Text:
|
||||||
return self.render_individual(row)
|
return self.render_individual(row)
|
||||||
else:
|
else:
|
||||||
return {u'main':self._raw_frames[row][u'image'],
|
return {u'main':self._raw_frames[row][u'image'], u'trans':None}
|
||||||
u'trans':None, u'display':self._raw_frames[row][u'display']}
|
|
||||||
|
|
||||||
def get_frame_title(self, row=0):
|
def get_frame_title(self, row=0):
|
||||||
"""
|
"""
|
||||||
|
@ -25,13 +25,13 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui, QtWebKit
|
from PyQt4 import QtCore, QtGui, QtWebKit
|
||||||
from PyQt4.phonon import Phonon
|
from PyQt4.phonon import Phonon
|
||||||
|
|
||||||
from openlp.core.lib import Receiver, resize_image
|
from openlp.core.lib import Receiver, resize_image
|
||||||
from openlp.core.ui import HideMode
|
from openlp.core.ui import HideMode
|
||||||
from openlp.core.utils import AppLocation
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -104,11 +104,17 @@ class DisplayManager(QtGui.QWidget):
|
|||||||
"""
|
"""
|
||||||
self.mainDisplay.addAlert(alertMessage, location)
|
self.mainDisplay.addAlert(alertMessage, location)
|
||||||
|
|
||||||
def displayImage(self, path):
|
def displayImageWithText(self, frame):
|
||||||
"""
|
"""
|
||||||
Handles the addition of a background Image to the displays
|
Handles the addition of a background Image to the displays
|
||||||
"""
|
"""
|
||||||
self.mainDisplay.displayImage(path)
|
self.mainDisplay.addImageWithText(frame)
|
||||||
|
|
||||||
|
def displayImage(self, frame):
|
||||||
|
"""
|
||||||
|
Handles the addition of a background Image to the displays
|
||||||
|
"""
|
||||||
|
self.mainDisplay.displayImage(frame)
|
||||||
|
|
||||||
def displayVideo(self, path):
|
def displayVideo(self, path):
|
||||||
"""
|
"""
|
||||||
@ -212,6 +218,7 @@ class MainDisplay(DisplayWidget):
|
|||||||
pass
|
pass
|
||||||
self.screens = screens
|
self.screens = screens
|
||||||
self.setupScene()
|
self.setupScene()
|
||||||
|
self.setupVideo()
|
||||||
self.setupImage()
|
self.setupImage()
|
||||||
self.setupText()
|
self.setupText()
|
||||||
self.setupAlert()
|
self.setupAlert()
|
||||||
@ -248,7 +255,7 @@ class MainDisplay(DisplayWidget):
|
|||||||
(self.screen[u'size'].width() - splash_image.width()) / 2,
|
(self.screen[u'size'].width() - splash_image.width()) / 2,
|
||||||
(self.screen[u'size'].height() - splash_image.height()) / 2,
|
(self.screen[u'size'].height() - splash_image.height()) / 2,
|
||||||
splash_image)
|
splash_image)
|
||||||
#self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.InitialFrame))
|
self.displayImage(self.InitialFrame)
|
||||||
self.repaint()
|
self.repaint()
|
||||||
#Build a Black screen
|
#Build a Black screen
|
||||||
painter = QtGui.QPainter()
|
painter = QtGui.QPainter()
|
||||||
@ -262,7 +269,7 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.transparent = QtGui.QPixmap(
|
self.transparent = QtGui.QPixmap(
|
||||||
self.screen[u'size'].width(), self.screen[u'size'].height())
|
self.screen[u'size'].width(), self.screen[u'size'].height())
|
||||||
self.transparent.fill(QtCore.Qt.transparent)
|
self.transparent.fill(QtCore.Qt.transparent)
|
||||||
# self.display_text.setPixmap(self.transparent)
|
# self.displayText.setPixmap(self.transparent)
|
||||||
#self.frameView(self.transparent)
|
#self.frameView(self.transparent)
|
||||||
# To display or not to display?
|
# To display or not to display?
|
||||||
if not self.screen[u'primary']:
|
if not self.screen[u'primary']:
|
||||||
@ -277,25 +284,30 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.scene.setSceneRect(0,0,self.size().width(), self.size().height())
|
self.scene.setSceneRect(0,0,self.size().width(), self.size().height())
|
||||||
self.setScene(self.scene)
|
self.setScene(self.scene)
|
||||||
|
|
||||||
def setupImage(self):
|
def setupVideo(self):
|
||||||
self.webView = QtWebKit.QWebView()
|
self.webView = QtWebKit.QWebView()
|
||||||
self.page = self.webView.page()
|
self.page = self.webView.page()
|
||||||
self.imageDisplay = self.page.mainFrame()
|
self.videoDisplay = self.page.mainFrame()
|
||||||
self.imageDisplay.setScrollBarPolicy(QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff)
|
self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Vertical, QtCore.Qt.ScrollBarAlwaysOff)
|
||||||
self.imageDisplay.setScrollBarPolicy(QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff)
|
self.videoDisplay.setScrollBarPolicy(QtCore.Qt.Horizontal, QtCore.Qt.ScrollBarAlwaysOff)
|
||||||
self.proxy = QtGui.QGraphicsProxyWidget()
|
self.proxy = QtGui.QGraphicsProxyWidget()
|
||||||
self.proxy.setWidget(self.webView)
|
self.proxy.setWidget(self.webView)
|
||||||
self.proxy.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint)
|
self.proxy.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.FramelessWindowHint)
|
||||||
self.proxy.setZValue(2)
|
self.proxy.setZValue(1)
|
||||||
self.scene.addItem(self.proxy)
|
self.scene.addItem(self.proxy)
|
||||||
|
|
||||||
|
def setupImage(self):
|
||||||
|
self.imageDisplay = QtGui.QGraphicsPixmapItem()
|
||||||
|
self.imageDisplay.setZValue(2)
|
||||||
|
self.scene.addItem(self.imageDisplay)
|
||||||
|
|
||||||
def setupText(self):
|
def setupText(self):
|
||||||
#self.display_text = QtGui.QGraphicsTextItem()
|
#self.displayText = QtGui.QGraphicsTextItem()
|
||||||
self.display_text = QtGui.QGraphicsPixmapItem()
|
self.displayText = QtGui.QGraphicsPixmapItem()
|
||||||
#self.display_text.setPos(0,0)
|
#self.displayText.setPos(0,0)
|
||||||
#self.display_text.setTextWidth(self.size().width())
|
#self.displayText.setTextWidth(self.size().width())
|
||||||
self.display_text.setZValue(4)
|
self.displayText.setZValue(4)
|
||||||
self.scene.addItem(self.display_text)
|
self.scene.addItem(self.displayText)
|
||||||
|
|
||||||
def setupAlert(self):
|
def setupAlert(self):
|
||||||
self.alertText = QtGui.QGraphicsTextItem()
|
self.alertText = QtGui.QGraphicsTextItem()
|
||||||
@ -304,9 +316,9 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.scene.addItem(self.alertText)
|
self.scene.addItem(self.alertText)
|
||||||
|
|
||||||
def setupBlank(self):
|
def setupBlank(self):
|
||||||
self.display_blank = QtGui.QGraphicsPixmapItem()
|
self.displayBlank = QtGui.QGraphicsPixmapItem()
|
||||||
self.display_blank.setZValue(10)
|
self.displayBlank.setZValue(10)
|
||||||
self.scene.addItem(self.display_blank)
|
self.scene.addItem(self.displayBlank)
|
||||||
|
|
||||||
def resetDisplay(self):
|
def resetDisplay(self):
|
||||||
log.debug(u'resetDisplay')
|
log.debug(u'resetDisplay')
|
||||||
@ -328,19 +340,19 @@ class MainDisplay(DisplayWidget):
|
|||||||
Store the images so they can be replaced when required
|
Store the images so they can be replaced when required
|
||||||
"""
|
"""
|
||||||
log.debug(u'hideDisplay mode = %d', mode)
|
log.debug(u'hideDisplay mode = %d', mode)
|
||||||
#self.display_text.setPixmap(self.transparent)
|
#self.displayText.setPixmap(self.transparent)
|
||||||
if mode == HideMode.Screen:
|
if mode == HideMode.Screen:
|
||||||
#self.display_image.setPixmap(self.transparent)
|
#self.display_image.setPixmap(self.transparent)
|
||||||
self.setVisible(False)
|
self.setVisible(False)
|
||||||
elif mode == HideMode.Blank:
|
elif mode == HideMode.Blank:
|
||||||
self.display_blank.setPixmap(
|
self.displayBlank.setPixmap(
|
||||||
QtGui.QPixmap.fromImage(self.blankFrame))
|
QtGui.QPixmap.fromImage(self.blankFrame))
|
||||||
else:
|
else:
|
||||||
if self.parent.renderManager.renderer.bg_frame:
|
if self.parent.renderManager.renderer.bg_frame:
|
||||||
self.display_blank.setPixmap(QtGui.QPixmap.fromImage(
|
self.displayBlank.setPixmap(QtGui.QPixmap.fromImage(
|
||||||
self.parent.renderManager.renderer.bg_frame))
|
self.parent.renderManager.renderer.bg_frame))
|
||||||
else:
|
else:
|
||||||
self.display_blank.setPixmap(
|
self.displayBlank.setPixmap(
|
||||||
QtGui.QPixmap.fromImage(self.blankFrame))
|
QtGui.QPixmap.fromImage(self.blankFrame))
|
||||||
|
|
||||||
def showDisplay(self, message=u''):
|
def showDisplay(self, message=u''):
|
||||||
@ -350,7 +362,7 @@ class MainDisplay(DisplayWidget):
|
|||||||
Make the stored images None to release memory.
|
Make the stored images None to release memory.
|
||||||
"""
|
"""
|
||||||
log.debug(u'showDisplay')
|
log.debug(u'showDisplay')
|
||||||
self.display_blank.setPixmap(self.transparent)
|
self.displayBlank.setPixmap(self.transparent)
|
||||||
#Trigger actions when display is active again
|
#Trigger actions when display is active again
|
||||||
Receiver.send_message(u'maindisplay_active')
|
Receiver.send_message(u'maindisplay_active')
|
||||||
|
|
||||||
@ -358,7 +370,8 @@ class MainDisplay(DisplayWidget):
|
|||||||
log.debug(u'addImageWithText')
|
log.debug(u'addImageWithText')
|
||||||
frame = resize_image(
|
frame = resize_image(
|
||||||
frame, self.screen[u'size'].width(), self.screen[u'size'].height())
|
frame, self.screen[u'size'].width(), self.screen[u'size'].height())
|
||||||
self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame))
|
self.imageDisplay.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||||
|
self.videoDisplay.setHtml(u'<html></html>')
|
||||||
|
|
||||||
def addAlert(self, message, location):
|
def addAlert(self, message, location):
|
||||||
"""
|
"""
|
||||||
@ -378,14 +391,18 @@ class MainDisplay(DisplayWidget):
|
|||||||
self.alertText.setPos(0,self.size().height() - 76)
|
self.alertText.setPos(0,self.size().height() - 76)
|
||||||
self.alertText.setHtml(message)
|
self.alertText.setHtml(message)
|
||||||
|
|
||||||
def displayImage(self, path):
|
def displayImage(self, frame):
|
||||||
"""
|
"""
|
||||||
Places the Image passed on the display screen
|
Places the Image passed on the display screen
|
||||||
``path``
|
``frame``
|
||||||
The path to the image to be displayed
|
The image to be displayed
|
||||||
"""
|
"""
|
||||||
log.debug(u'adddisplayImage')
|
log.debug(u'adddisplayImage')
|
||||||
self.imageDisplay.setHtml(HTMLIMAGE % path)
|
if isinstance(frame, QtGui.QImage):
|
||||||
|
self.imageDisplay.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||||
|
else:
|
||||||
|
self.imageDisplay.setPixmap(frame)
|
||||||
|
self.videoDisplay.setHtml(u'<html></html>')
|
||||||
|
|
||||||
def displayVideo(self, path):
|
def displayVideo(self, path):
|
||||||
"""
|
"""
|
||||||
@ -394,7 +411,8 @@ class MainDisplay(DisplayWidget):
|
|||||||
The path to the image to be displayed
|
The path to the image to be displayed
|
||||||
"""
|
"""
|
||||||
log.debug(u'adddisplayVideo')
|
log.debug(u'adddisplayVideo')
|
||||||
self.imageDisplay.setHtml(HTMLVIDEO %
|
self.displayImage(self.transparent)
|
||||||
|
self.videoDisplay.setHtml(HTMLVIDEO %
|
||||||
(path, self.screen[u'size'].width(), self.screen[u'size'].height()))
|
(path, self.screen[u'size'].width(), self.screen[u'size'].height()))
|
||||||
|
|
||||||
def frameView(self, frame, transition=False):
|
def frameView(self, frame, transition=False):
|
||||||
@ -409,42 +427,29 @@ class MainDisplay(DisplayWidget):
|
|||||||
log.debug(u'frameView')
|
log.debug(u'frameView')
|
||||||
if transition:
|
if transition:
|
||||||
if self.frame is not None:
|
if self.frame is not None:
|
||||||
self.display_text.setPixmap(
|
self.displayText.setPixmap(
|
||||||
QtGui.QPixmap.fromImage(self.frame))
|
QtGui.QPixmap.fromImage(self.frame))
|
||||||
self.update()
|
self.repaint()
|
||||||
|
Receiver.send_message(u'openlp_process_events')
|
||||||
|
time.sleep(0.1)
|
||||||
self.frame = None
|
self.frame = None
|
||||||
if frame[u'trans'] is not None:
|
if frame[u'trans'] is not None:
|
||||||
self.display_text.setPixmap(
|
self.displayText.setPixmap(
|
||||||
QtGui.QPixmap.fromImage(frame[u'trans']))
|
QtGui.QPixmap.fromImage(frame[u'trans']))
|
||||||
self.repaint()
|
self.repaint()
|
||||||
|
Receiver.send_message(u'openlp_process_events')
|
||||||
|
time.sleep(0.1)
|
||||||
self.frame = frame[u'trans']
|
self.frame = frame[u'trans']
|
||||||
self.display_text.setPixmap(
|
self.displayText.setPixmap(
|
||||||
QtGui.QPixmap.fromImage(frame[u'main']))
|
QtGui.QPixmap.fromImage(frame[u'main']))
|
||||||
self.display_frame = frame[u'main']
|
|
||||||
self.repaint()
|
|
||||||
else:
|
else:
|
||||||
if isinstance(frame, QtGui.QPixmap):
|
if isinstance(frame, QtGui.QPixmap):
|
||||||
self.display_text.setPixmap(frame)
|
self.displayText.setPixmap(frame)
|
||||||
else:
|
else:
|
||||||
self.display_text.setPixmap(QtGui.QPixmap.fromImage(frame))
|
self.displayText.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||||
self.display_frame = frame
|
|
||||||
if not self.isVisible() and self.screens.display:
|
if not self.isVisible() and self.screens.display:
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
|
|
||||||
def closeEvent(self, event):
|
|
||||||
"""
|
|
||||||
Shutting down cleans up background files
|
|
||||||
"""
|
|
||||||
serviceItemPath = AppLocation.get_section_data_path(u'serviceItems')
|
|
||||||
for file in os.listdir(serviceItemPath):
|
|
||||||
file_path = os.path.join(serviceItemPath, file)
|
|
||||||
try:
|
|
||||||
if os.path.isfile(file_path):
|
|
||||||
os.remove(file_path)
|
|
||||||
except OSError:
|
|
||||||
log.exception(u'Failed to clean up servicePath')
|
|
||||||
|
|
||||||
|
|
||||||
class VideoDisplay(Phonon.VideoWidget):
|
class VideoDisplay(Phonon.VideoWidget):
|
||||||
"""
|
"""
|
||||||
This is the form that is used to display videos on the projector.
|
This is the form that is used to display videos on the projector.
|
||||||
|
@ -785,7 +785,7 @@ class SlideController(QtGui.QWidget):
|
|||||||
if self.serviceItem.is_text():
|
if self.serviceItem.is_text():
|
||||||
self.mainDisplay.frameView(frame, True)
|
self.mainDisplay.frameView(frame, True)
|
||||||
else:
|
else:
|
||||||
self.displayManager.displayImage(frame[u'display'])
|
self.displayManager.displayImage(frame[u'main'])
|
||||||
self.selectedRow = row
|
self.selectedRow = row
|
||||||
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix,
|
Receiver.send_message(u'slidecontroller_%s_changed' % self.typePrefix,
|
||||||
row)
|
row)
|
||||||
|
@ -173,11 +173,12 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
if check_item_selected(self.ListView,
|
if check_item_selected(self.ListView,
|
||||||
translate('ImagePlugin.MediaItem',
|
translate('ImagePlugin.MediaItem',
|
||||||
'You must select an item to process.')):
|
'You must select an item to process.')):
|
||||||
item = self.buildServiceItem()
|
items = self.ListView.selectedIndexes()
|
||||||
item.render()
|
for item in items:
|
||||||
self.parent.live_controller.displayManager. \
|
bitem = self.ListView.item(item.row())
|
||||||
displayImage(item.get_rendered_frame(0)[u'display'])
|
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
|
||||||
|
frame = QtGui.QImage(unicode(filename))
|
||||||
|
self.parent.live_controller.displayManager.displayImageWithText(frame)
|
||||||
|
|
||||||
def onPreviewClick(self):
|
def onPreviewClick(self):
|
||||||
MediaManagerItem.onPreviewClick(self)
|
MediaManagerItem.onPreviewClick(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user