Fix up display buttons

This commit is contained in:
Tim Bentley 2010-04-29 20:33:45 +01:00
parent 92ef8471b0
commit 39a4593bd3
3 changed files with 104 additions and 63 deletions

View File

@ -40,6 +40,7 @@ class DisplayManager(QtGui.QWidget):
Wrapper class to hold the display widgets.
I will provide API's in future to access the screens allow for
extra displays to be added.
RenderManager is poked in by MainWindow
"""
def __init__(self, screens):
QtGui.QWidget.__init__(self)
@ -130,17 +131,14 @@ class MainDisplay(DisplayWidget):
self.displayBlank = False
self.blankFrame = None
self.frame = None
self.firstTime = True
self.hasTransition = False
self.mediaBackground = False
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_blank'), self.blankDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_hide_theme'), self.hideThemeDisplay)
# QtCore.QObject.connect(Receiver.get_receiver(),
# QtCore.SIGNAL(u'maindisplay_show_theme'), self.showThemeDisplay)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplay)
@ -153,12 +151,12 @@ class MainDisplay(DisplayWidget):
self.setVisible(False)
self.screen = self.screens.current
#Sort out screen locations and sizes
self.setGeometry(self.screen[u'size'])
self.display_alert.setGeometry(self.screen[u'size'])
self.display_image.resize(self.screen[u'size'].width(),
self.screen[u'size'].height())
self.display_text.resize(self.screen[u'size'].width(),
self.screen[u'size'].height())
self.setGeometry(self.screen[u'size'])
#Build a custom splash screen
self.InitialFrame = QtGui.QImage(
self.screen[u'size'].width(),
@ -205,16 +203,65 @@ class MainDisplay(DisplayWidget):
else:
self.showFullScreen()
def blankDisplay(self):#, blankType=HideMode.Blank, blanked=True):
log.debug(u'Blank main Display ')
"""
Hide the display by making all layers transparent
Store the images so they can be replaced when required
"""
self.storeImage = QtGui.QPixmap(self.display_image.pixmap())
self.storeText = QtGui.QPixmap(self.display_text.pixmap())
self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame))
self.display_alert.setPixmap(self.transparent)
self.display_text.setPixmap(self.transparent)
self.moveToTop()
# if blanked:
# self.displayBlank = True
# if blankType == HideMode.Blank:
# self.display_text.setPixmap(
# QtGui.QPixmap.fromImage(self.blankFrame))
# elif blankType == HideMode.Theme:
# theme = self.parent.RenderManager.renderer.bg_frame
# if not theme:
# theme = self.blankFrame
# self.display_text.setPixmap(QtGui.QPixmap.fromImage(theme))
# self.waitingFrame = None
# self.waitingFrameTrans = False
# else:
# self.displayBlank = False
# if self.waitingFrame:
# self.frameView(self.waitingFrame, self.waitingFrameTrans)
# elif self.display_frame:
# self.frameView(self.display_frame)
def hideDisplay(self):
"""
Hide the display by making all layers transparent
Store the images so they can be replaced when required
"""
log.debug(u'hideDisplay')
self.storeImage = QtGui.QPixmap(self.display_image.pixmap())
self.storeText = QtGui.QPixmap(self.display_text.pixmap())
self.display_image.setPixmap(self.transparent)
self.display_alert.setPixmap(self.transparent)
self.display_text.setPixmap(self.transparent)
self.moveToTop()
def hideThemeDisplay(self):
"""
Hide the display by making all layers transparent
Add the theme background to the image layer unless it has
not been generated in which case make it black.
Store the images so they can be replaced when required
"""
log.debug(u'hideDisplay')
self.display_image.setPixmap(self.transparent)
self.storeImage = QtGui.QPixmap(self.display_image.pixmap())
self.storeText = QtGui.QPixmap(self.display_text.pixmap())
if self.parent.renderManager.renderer.bg_frame:
self.display_image.setPixmap(QtGui.QPixmap.fromImage(\
self.parent.renderManager.renderer.bg_frame))
else:
self.display_image.setPixmap(QtGui.QPixmap.fromImage(self.blankFrame))
self.display_alert.setPixmap(self.transparent)
self.display_text.setPixmap(self.transparent)
self.moveToTop()
@ -226,10 +273,20 @@ class MainDisplay(DisplayWidget):
self.show()
def showDisplay(self):
"""
Show the stored layers so the screen reappears as it was
originally.
Make the stored images None to release memory.
"""
log.debug(u'showDisplay')
if not self.primary:
self.setVisible(True)
self.showFullScreen()
if self.storeImage:
self.display_image.setPixmap(self.storeImage)
self.display_alert.setPixmap(self.transparent)
if self.storeText:
self.display_text.setPixmap(self.storeText)
self.storeImage = None
self.store = None
self.moveToTop()
Receiver.send_message(u'maindisplay_active')
def addImageWithText(self, frame):
@ -291,27 +348,6 @@ class MainDisplay(DisplayWidget):
self.waitingFrame = frame
self.waitingFrameTrans = transition
def blankDisplay(self, blankType=HideMode.Blank, blanked=True):
log.debug(u'Blank main Display %d' % blanked)
if blanked:
self.displayBlank = True
if blankType == HideMode.Blank:
self.display_text.setPixmap(
QtGui.QPixmap.fromImage(self.blankFrame))
elif blankType == HideMode.Theme:
theme = self.parent.RenderManager.renderer.bg_frame
if not theme:
theme = self.blankFrame
self.display_text.setPixmap(QtGui.QPixmap.fromImage(theme))
self.waitingFrame = None
self.waitingFrameTrans = False
else:
self.displayBlank = False
if self.waitingFrame:
self.frameView(self.waitingFrame, self.waitingFrameTrans)
elif self.display_frame:
self.frameView(self.display_frame)
class VideoDisplay(Phonon.VideoWidget):
"""
This is the form that is used to display videos on the projector.

View File

@ -505,6 +505,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
#ThemeManager needs to call RenderManager
self.RenderManager = RenderManager(
self.ThemeManagerContents, self.screens)
self.displayManager.renderManager = self.RenderManager
#Define the media Dock Manager
self.mediaDockManager = MediaDockManager(self.MediaToolBox)
log.info(u'Load Plugins')

View File

@ -199,8 +199,6 @@ class SlideController(QtGui.QWidget):
self.hideButton = self.Toolbar.addToolbarButton(
u'Hide screen', u':/slides/slide_desktop.png',
self.trUtf8('Hide Screen'), self.onHideDisplay, True)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_blank'), self.blankScreen)
if not self.isLive:
self.Toolbar.addToolbarSeparator(u'Close Separator')
self.Toolbar.addToolbarButton(
@ -590,58 +588,64 @@ class SlideController(QtGui.QWidget):
self.PreviewListWidget.selectRow(0)
self.onSlideSelected()
def onBlankDisplay(self, force=False):
def onBlankDisplay(self, checked):
"""
Handle the blank screen button
"""
log.debug(u'onBlankDisplay %d' % force)
if force:
self.blankButton.setChecked(True)
self.blankScreen(HideMode.Blank, self.blankButton.isChecked())
log.debug(u'onBlankDisplay %d' % checked)
self.hideButton.setChecked(False)
self.themeButton.setChecked(False)
QtCore.QSettings().setValue(
self.generalSettingsSection + u'/screen blank',
QtCore.QVariant(self.blankButton.isChecked()))
QtCore.QVariant(checked))
if checked:
Receiver.send_message(u'maindisplay_blank')
else:
Receiver.send_message(u'maindisplay_show')
def onThemeDisplay(self, force=False):
def onThemeDisplay(self, checked):
"""
Handle the Theme screen button
"""
log.debug(u'onThemeDisplay %d' % force)
if force:
self.themeButton.setChecked(True)
if self.themeButton.isChecked():
Receiver.send_message(u'maindisplay_show_theme')
else:
log.debug(u'onThemeDisplay %d' % checked)
self.blankButton.setChecked(False)
self.hideButton.setChecked(False)
if checked:
Receiver.send_message(u'maindisplay_hide_theme')
else:
Receiver.send_message(u'maindisplay_show')
def onHideDisplay(self, force=False):
def onHideDisplay(self, checked):
"""
Handle the Hide screen button
"""
log.debug(u'onHideDisplay %d' % force)
if force:
self.hideButton.setChecked(True)
if self.hideButton.isChecked():
log.debug(u'onHideDisplay %d' % checked)
self.blankButton.setChecked(False)
self.themeButton.setChecked(False)
if checked:
Receiver.send_message(u'maindisplay_hide')
else:
Receiver.send_message(u'maindisplay_show')
def blankScreen(self, blankType, blanked=False):
def blankScreen(self, checked):
"""
Blank the display screen.
"""
if self.serviceItem is not None:
if blanked:
Receiver.send_message(
u'%s_blank' % self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
self.hideButton.setChecked(False)
self.themeButton.setChecked(False)
# if self.serviceItem is not None:
# if checked:
# Receiver.send_message(
# u'%s_blank' % self.serviceItem.name.lower(),
# [self.serviceItem, self.isLive])
# else:
# Receiver.send_message(u'%s_unblank'
# % self.serviceItem.name.lower(),
# [self.serviceItem, self.isLive])
if checked:
Receiver.send_message(u'maindisplay_blank')
else:
Receiver.send_message(u'%s_unblank'
% self.serviceItem.name.lower(),
[self.serviceItem, self.isLive])
self.parent.displayManager.mainDisplay.blankDisplay(blankType, blanked)
else:
self.parent.displayManager.mainDisplay.blankDisplay(blankType, blanked)
Receiver.send_message(u'maindisplay_show4')
def onSlideSelected(self):
"""