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. Wrapper class to hold the display widgets.
I will provide API's in future to access the screens allow for I will provide API's in future to access the screens allow for
extra displays to be added. extra displays to be added.
RenderManager is poked in by MainWindow
""" """
def __init__(self, screens): def __init__(self, screens):
QtGui.QWidget.__init__(self) QtGui.QWidget.__init__(self)
@ -130,17 +131,14 @@ class MainDisplay(DisplayWidget):
self.displayBlank = False self.displayBlank = False
self.blankFrame = None self.blankFrame = None
self.frame = None self.frame = None
self.firstTime = True QtCore.QObject.connect(Receiver.get_receiver(),
self.hasTransition = False QtCore.SIGNAL(u'maindisplay_blank'), self.blankDisplay)
self.mediaBackground = False
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay) QtCore.SIGNAL(u'maindisplay_hide'), self.hideDisplay)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay) QtCore.SIGNAL(u'maindisplay_show'), self.showDisplay)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_hide_theme'), self.hideThemeDisplay) 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.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplay) QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplay)
@ -153,12 +151,12 @@ class MainDisplay(DisplayWidget):
self.setVisible(False) self.setVisible(False)
self.screen = self.screens.current self.screen = self.screens.current
#Sort out screen locations and sizes #Sort out screen locations and sizes
self.setGeometry(self.screen[u'size'])
self.display_alert.setGeometry(self.screen[u'size']) self.display_alert.setGeometry(self.screen[u'size'])
self.display_image.resize(self.screen[u'size'].width(), self.display_image.resize(self.screen[u'size'].width(),
self.screen[u'size'].height()) self.screen[u'size'].height())
self.display_text.resize(self.screen[u'size'].width(), self.display_text.resize(self.screen[u'size'].width(),
self.screen[u'size'].height()) self.screen[u'size'].height())
self.setGeometry(self.screen[u'size'])
#Build a custom splash screen #Build a custom splash screen
self.InitialFrame = QtGui.QImage( self.InitialFrame = QtGui.QImage(
self.screen[u'size'].width(), self.screen[u'size'].width(),
@ -205,16 +203,65 @@ class MainDisplay(DisplayWidget):
else: else:
self.showFullScreen() 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): 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') 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_image.setPixmap(self.transparent)
self.display_alert.setPixmap(self.transparent) self.display_alert.setPixmap(self.transparent)
self.display_text.setPixmap(self.transparent) self.display_text.setPixmap(self.transparent)
self.moveToTop() self.moveToTop()
def hideThemeDisplay(self): 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') 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_alert.setPixmap(self.transparent)
self.display_text.setPixmap(self.transparent) self.display_text.setPixmap(self.transparent)
self.moveToTop() self.moveToTop()
@ -226,10 +273,20 @@ class MainDisplay(DisplayWidget):
self.show() self.show()
def showDisplay(self): 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') log.debug(u'showDisplay')
if not self.primary: if self.storeImage:
self.setVisible(True) self.display_image.setPixmap(self.storeImage)
self.showFullScreen() 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') Receiver.send_message(u'maindisplay_active')
def addImageWithText(self, frame): def addImageWithText(self, frame):
@ -291,27 +348,6 @@ class MainDisplay(DisplayWidget):
self.waitingFrame = frame self.waitingFrame = frame
self.waitingFrameTrans = transition 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): 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.

View File

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

View File

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