Alerts now work and more hiding cleanups

This commit is contained in:
Tim Bentley 2010-06-26 15:13:10 +01:00
parent d82f94e326
commit 4b38c22d30
3 changed files with 65 additions and 53 deletions

View File

@ -47,11 +47,31 @@ class DisplayManager(QtGui.QWidget):
self.videoDisplay = VideoDisplay(self, screens)
self.audioPlayer = AudioPlayer(self)
self.mainDisplay = MainDisplay(self, screens)
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'videodisplay_start'), self.hideDisplayForVideo)
def setup(self):
self.videoDisplay.setup()
self.mainDisplay.setup()
def hideDisplay(self, message):
"""
Hide the output displays
"""
self.videoDisplay.mediaHide(message)
self.mainDisplay.hideDisplay(message)
def showDisplay(self, message):
"""
Hide the output displays
"""
self.videoDisplay.mediaShow(message)
self.mainDisplay.showDisplay(message)
def addAlert(self, alertMessage, location):
"""
Handles the add Alert Message to the Displays
@ -145,14 +165,8 @@ class MainDisplay(DisplayWidget):
self.primary = True
self.blankFrame = None
self.frame = None
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplayForVideo)
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'videodisplay_background'), self.hideDisplayForVideo)
#Hide desktop for now untill we know where to put it
#and what size it should be.
self.setVisible(False)
def setup(self):
@ -240,11 +254,11 @@ class MainDisplay(DisplayWidget):
else:
self.setVisible(True)
def hideDisplayForVideo(self):
"""
Hides the main display if for the video to be played
"""
self.hideDisplay(HideMode.Screen)
# def hideDisplayForVideo(self):
# """
# Hides the main display if for the video to be played
# """
# self.hideDisplay(HideMode.Screen)
def hideDisplay(self, mode=HideMode.Screen):
"""
@ -252,8 +266,6 @@ class MainDisplay(DisplayWidget):
Store the images so they can be replaced when required
"""
log.debug(u'hideDisplay mode = %d', mode)
self.storeImage = QtGui.QPixmap(self.display_image.pixmap())
self.storeText = QtGui.QPixmap(self.display_text.pixmap())
#self.display_text.setPixmap(self.transparent)
if mode == HideMode.Screen:
#self.display_image.setPixmap(self.transparent)
@ -269,19 +281,14 @@ class MainDisplay(DisplayWidget):
self.display_blank.setPixmap(
QtGui.QPixmap.fromImage(self.blankFrame))
def showDisplay(self):
def showDisplay(self, message=u''):
"""
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 self.storeImage:
self.display_image.setPixmap(self.storeImage)
if self.storeText:
self.display_text.setPixmap(self.storeText)
self.storeImage = None
self.store = None
self.display_blank.setPixmap(self.transparent)
Receiver.send_message(u'maindisplay_active')
def addImageWithText(self, frame):
@ -293,6 +300,11 @@ class MainDisplay(DisplayWidget):
def addAlert(self, message, location):
"""
Places the Alert text on the display at the correct location
``messgae``
Text to be displayed
``location``
Where on the screen the text should be. From the AlertTab
Combo box.
"""
log.debug(u'addAlertImage')
if location == 0:
@ -309,6 +321,8 @@ class MainDisplay(DisplayWidget):
if the alert is in progress the alert is added on top
``frame``
Image frame to be rendered
``transition``
Are transitions required.
"""
log.debug(u'frameView %d' % display)
if display:
@ -374,11 +388,6 @@ class VideoDisplay(Phonon.VideoWidget):
except AttributeError:
pass
self.setWindowFlags(flags)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_hide'), self.mediaHide)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'maindisplay_show'), self.mediaShow)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_start'), self.onMediaQueue)
QtCore.QObject.connect(Receiver.get_receiver(),
@ -501,7 +510,7 @@ class VideoDisplay(Phonon.VideoWidget):
self.mediaObject.clearQueue()
self.setVisible(False)
def mediaHide(self):
def mediaHide(self, message=u''):
"""
Hide the video display
"""
@ -509,7 +518,7 @@ class VideoDisplay(Phonon.VideoWidget):
self.hidden = True
self.setVisible(False)
def mediaShow(self):
def mediaShow(self, message=''):
"""
Show the video disaply if it was already hidden
"""

View File

@ -207,10 +207,10 @@ class SlideController(QtGui.QWidget):
QtCore.QObject.connect(self.BlankScreen, QtCore.SIGNAL("triggered(bool)"), self.onBlankDisplay)
self.ThemeScreen = QtGui.QAction(QtGui.QIcon(u':/slides/slide_theme.png'), u'Blank to Theme', self.HideMenu)
self.ThemeScreen.setCheckable(True)
QtCore.QObject.connect(self.BlankScreen, QtCore.SIGNAL("triggered(bool)"), self.onThemeDisplay)
QtCore.QObject.connect(self.ThemeScreen, QtCore.SIGNAL("triggered(bool)"), self.onThemeDisplay)
self.DesktopScreen = QtGui.QAction(QtGui.QIcon(u':/slides/slide_desktop.png'), u'Show Desktop', self.HideMenu)
self.DesktopScreen.setCheckable(True)
QtCore.QObject.connect(self.BlankScreen, QtCore.SIGNAL("triggered(bool)"), self.onHideDisplay)
QtCore.QObject.connect(self.DesktopScreen, QtCore.SIGNAL("triggered(bool)"), self.onHideDisplay)
self.HideMenu.setDefaultAction(self.BlankScreen)
self.HideMenu.menu().addAction(self.BlankScreen)
self.HideMenu.menu().addAction(self.ThemeScreen)
@ -655,7 +655,7 @@ class SlideController(QtGui.QWidget):
"""
log.debug(u'mainDisplaySetBackground')
if not self.mainDisplay.primary:
self.blankButton.setChecked(True)
self.onBlankDisplay(True)
def onSlideBlank(self):
"""
@ -673,64 +673,55 @@ class SlideController(QtGui.QWidget):
"""
Handle the blank screen button actions
"""
log.debug(u'onBlankDisplay %d' % checked)
log.debug(u'onBlankDisplay %s' % checked)
self.HideMenu.setDefaultAction(self.BlankScreen)
self.BlankScreen.setCheckable(True)
self.BlankScreen.setChecked(True)
self.BlankScreen.setChecked(checked)
self.ThemeScreen.setChecked(False)
self.DesktopScreen.setChecked(False)
self.canDisplay = not checked
QtCore.QSettings().setValue(
self.parent.generalSettingsSection + u'/screen blank',
QtCore.QVariant(checked))
if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Blank)
self.blankPlugin(True)
else:
Receiver.send_message(u'maindisplay_show')
self.blankPlugin(False)
self.blankPlugin(checked)
def onThemeDisplay(self, checked):
"""
Handle the Theme screen button
"""
log.debug(u'onThemeDisplay %d' % checked)
log.debug(u'onThemeDisplay %s' % checked)
self.HideMenu.setDefaultAction(self.ThemeScreen)
self.ThemeScreen.setCheckable(True)
self.BlankScreen.setChecked(False)
self.ThemeScreen.setChecked(True)
self.ThemeScreen.setChecked(checked)
self.DesktopScreen.setChecked(False)
self.canDisplay = False
if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Theme)
self.blankPlugin(True)
else:
Receiver.send_message(u'maindisplay_show')
self.blankPlugin(False)
self.blankPlugin(checked)
def onHideDisplay(self, checked):
"""
Handle the Hide screen button
"""
log.debug(u'onHideDisplay %d' % checked)
log.debug(u'onHideDisplay %s' % checked)
self.HideMenu.setDefaultAction(self.DesktopScreen)
self.DesktopScreen.setCheckable(True)
self.BlankScreen.setChecked(False)
self.ThemeScreen.setChecked(False)
self.DesktopScreen.setChecked(True)
self.canDisplay = False
self.DesktopScreen.setChecked(checked)
if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
self.hidePlugin(True)
else:
Receiver.send_message(u'maindisplay_show')
self.hidePlugin(False)
self.hidePlugin(checked)
def blankPlugin(self, blank):
"""
Blank the display screen within a plugin if required.
"""
log.debug(u'blankPlugin %d ', blank)
log.debug(u'blankPlugin %s ', blank)
if self.serviceItem is not None:
if blank:
Receiver.send_message(u'%s_blank'
@ -743,8 +734,9 @@ class SlideController(QtGui.QWidget):
def hidePlugin(self, hide):
"""
Blank the display screen.
Tell the plugin to hide the display screen.
"""
log.debug(u'hidePlugin %s ', hide)
if self.serviceItem is not None:
if hide:
Receiver.send_message(u'%s_hide'

View File

@ -85,6 +85,9 @@ class AlertsManager(QtCore.QObject):
self.generateAlert()
def generateAlert(self):
"""
Format and request the Alert and start the timer
"""
log.debug(u'Generate Alert called')
if len(self.alertList) == 0:
return
@ -98,9 +101,17 @@ class AlertsManager(QtCore.QObject):
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
def timerEvent(self, event):
"""
Time has finished so if our time then request the next Alert
if there is one and reset the timer.
``event``
the QT event that has been triggered.
"""
log.debug(u'timer event')
alertTab = self.parent.alertsTab
if event.timerId() == self.timer_id:
self.parent.preview_controller.parent.displayManager.addAlert(u'', self.alertTab.location)
self.parent.preview_controller.parent.displayManager.addAlert(u'', alertTab.location)
self.killTimer(self.timer_id)
self.timer_id = 0
self.generateAlert()