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.videoDisplay = VideoDisplay(self, screens)
self.audioPlayer = AudioPlayer(self) self.audioPlayer = AudioPlayer(self)
self.mainDisplay = MainDisplay(self, screens) 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): def setup(self):
self.videoDisplay.setup() self.videoDisplay.setup()
self.mainDisplay.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): def addAlert(self, alertMessage, location):
""" """
Handles the add Alert Message to the Displays Handles the add Alert Message to the Displays
@ -145,14 +165,8 @@ class MainDisplay(DisplayWidget):
self.primary = True self.primary = True
self.blankFrame = None self.blankFrame = None
self.frame = None self.frame = None
QtCore.QObject.connect(Receiver.get_receiver(), #Hide desktop for now untill we know where to put it
QtCore.SIGNAL(u'videodisplay_start'), self.hideDisplayForVideo) #and what size it should be.
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)
self.setVisible(False) self.setVisible(False)
def setup(self): def setup(self):
@ -240,11 +254,11 @@ class MainDisplay(DisplayWidget):
else: else:
self.setVisible(True) self.setVisible(True)
def hideDisplayForVideo(self): # def hideDisplayForVideo(self):
""" # """
Hides the main display if for the video to be played # Hides the main display if for the video to be played
""" # """
self.hideDisplay(HideMode.Screen) # self.hideDisplay(HideMode.Screen)
def hideDisplay(self, mode=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 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.storeImage = QtGui.QPixmap(self.display_image.pixmap())
self.storeText = QtGui.QPixmap(self.display_text.pixmap())
#self.display_text.setPixmap(self.transparent) #self.display_text.setPixmap(self.transparent)
if mode == HideMode.Screen: if mode == HideMode.Screen:
#self.display_image.setPixmap(self.transparent) #self.display_image.setPixmap(self.transparent)
@ -269,19 +281,14 @@ class MainDisplay(DisplayWidget):
self.display_blank.setPixmap( self.display_blank.setPixmap(
QtGui.QPixmap.fromImage(self.blankFrame)) QtGui.QPixmap.fromImage(self.blankFrame))
def showDisplay(self): def showDisplay(self, message=u''):
""" """
Show the stored layers so the screen reappears as it was Show the stored layers so the screen reappears as it was
originally. originally.
Make the stored images None to release memory. Make the stored images None to release memory.
""" """
log.debug(u'showDisplay') log.debug(u'showDisplay')
if self.storeImage: self.display_blank.setPixmap(self.transparent)
self.display_image.setPixmap(self.storeImage)
if self.storeText:
self.display_text.setPixmap(self.storeText)
self.storeImage = None
self.store = None
Receiver.send_message(u'maindisplay_active') Receiver.send_message(u'maindisplay_active')
def addImageWithText(self, frame): def addImageWithText(self, frame):
@ -293,6 +300,11 @@ class MainDisplay(DisplayWidget):
def addAlert(self, message, location): def addAlert(self, message, location):
""" """
Places the Alert text on the display at the correct 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') log.debug(u'addAlertImage')
if location == 0: if location == 0:
@ -309,6 +321,8 @@ class MainDisplay(DisplayWidget):
if the alert is in progress the alert is added on top if the alert is in progress the alert is added on top
``frame`` ``frame``
Image frame to be rendered Image frame to be rendered
``transition``
Are transitions required.
""" """
log.debug(u'frameView %d' % display) log.debug(u'frameView %d' % display)
if display: if display:
@ -374,11 +388,6 @@ class VideoDisplay(Phonon.VideoWidget):
except AttributeError: except AttributeError:
pass pass
self.setWindowFlags(flags) 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.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'videodisplay_start'), self.onMediaQueue) QtCore.SIGNAL(u'videodisplay_start'), self.onMediaQueue)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -501,7 +510,7 @@ class VideoDisplay(Phonon.VideoWidget):
self.mediaObject.clearQueue() self.mediaObject.clearQueue()
self.setVisible(False) self.setVisible(False)
def mediaHide(self): def mediaHide(self, message=u''):
""" """
Hide the video display Hide the video display
""" """
@ -509,7 +518,7 @@ class VideoDisplay(Phonon.VideoWidget):
self.hidden = True self.hidden = True
self.setVisible(False) self.setVisible(False)
def mediaShow(self): def mediaShow(self, message=''):
""" """
Show the video disaply if it was already hidden 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) 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 = QtGui.QAction(QtGui.QIcon(u':/slides/slide_theme.png'), u'Blank to Theme', self.HideMenu)
self.ThemeScreen.setCheckable(True) 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 = QtGui.QAction(QtGui.QIcon(u':/slides/slide_desktop.png'), u'Show Desktop', self.HideMenu)
self.DesktopScreen.setCheckable(True) 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.setDefaultAction(self.BlankScreen)
self.HideMenu.menu().addAction(self.BlankScreen) self.HideMenu.menu().addAction(self.BlankScreen)
self.HideMenu.menu().addAction(self.ThemeScreen) self.HideMenu.menu().addAction(self.ThemeScreen)
@ -655,7 +655,7 @@ class SlideController(QtGui.QWidget):
""" """
log.debug(u'mainDisplaySetBackground') log.debug(u'mainDisplaySetBackground')
if not self.mainDisplay.primary: if not self.mainDisplay.primary:
self.blankButton.setChecked(True) self.onBlankDisplay(True)
def onSlideBlank(self): def onSlideBlank(self):
""" """
@ -673,64 +673,55 @@ class SlideController(QtGui.QWidget):
""" """
Handle the blank screen button actions Handle the blank screen button actions
""" """
log.debug(u'onBlankDisplay %d' % checked) log.debug(u'onBlankDisplay %s' % checked)
self.HideMenu.setDefaultAction(self.BlankScreen) self.HideMenu.setDefaultAction(self.BlankScreen)
self.BlankScreen.setCheckable(True) self.BlankScreen.setChecked(checked)
self.BlankScreen.setChecked(True)
self.ThemeScreen.setChecked(False) self.ThemeScreen.setChecked(False)
self.DesktopScreen.setChecked(False) self.DesktopScreen.setChecked(False)
self.canDisplay = not checked
QtCore.QSettings().setValue( QtCore.QSettings().setValue(
self.parent.generalSettingsSection + u'/screen blank', self.parent.generalSettingsSection + u'/screen blank',
QtCore.QVariant(checked)) QtCore.QVariant(checked))
if checked: if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Blank) Receiver.send_message(u'maindisplay_hide', HideMode.Blank)
self.blankPlugin(True)
else: else:
Receiver.send_message(u'maindisplay_show') Receiver.send_message(u'maindisplay_show')
self.blankPlugin(False) self.blankPlugin(checked)
def onThemeDisplay(self, checked): def onThemeDisplay(self, checked):
""" """
Handle the Theme screen button Handle the Theme screen button
""" """
log.debug(u'onThemeDisplay %d' % checked) log.debug(u'onThemeDisplay %s' % checked)
self.HideMenu.setDefaultAction(self.ThemeScreen) self.HideMenu.setDefaultAction(self.ThemeScreen)
self.ThemeScreen.setCheckable(True)
self.BlankScreen.setChecked(False) self.BlankScreen.setChecked(False)
self.ThemeScreen.setChecked(True) self.ThemeScreen.setChecked(checked)
self.DesktopScreen.setChecked(False) self.DesktopScreen.setChecked(False)
self.canDisplay = False
if checked: if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Theme) Receiver.send_message(u'maindisplay_hide', HideMode.Theme)
self.blankPlugin(True)
else: else:
Receiver.send_message(u'maindisplay_show') Receiver.send_message(u'maindisplay_show')
self.blankPlugin(False) self.blankPlugin(checked)
def onHideDisplay(self, checked): def onHideDisplay(self, checked):
""" """
Handle the Hide screen button Handle the Hide screen button
""" """
log.debug(u'onHideDisplay %d' % checked) log.debug(u'onHideDisplay %s' % checked)
self.HideMenu.setDefaultAction(self.DesktopScreen) self.HideMenu.setDefaultAction(self.DesktopScreen)
self.DesktopScreen.setCheckable(True)
self.BlankScreen.setChecked(False) self.BlankScreen.setChecked(False)
self.ThemeScreen.setChecked(False) self.ThemeScreen.setChecked(False)
self.DesktopScreen.setChecked(True) self.DesktopScreen.setChecked(checked)
self.canDisplay = False
if checked: if checked:
Receiver.send_message(u'maindisplay_hide', HideMode.Screen) Receiver.send_message(u'maindisplay_hide', HideMode.Screen)
self.hidePlugin(True)
else: else:
Receiver.send_message(u'maindisplay_show') Receiver.send_message(u'maindisplay_show')
self.hidePlugin(False) self.hidePlugin(checked)
def blankPlugin(self, blank): def blankPlugin(self, blank):
""" """
Blank the display screen within a plugin if required. 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 self.serviceItem is not None:
if blank: if blank:
Receiver.send_message(u'%s_blank' Receiver.send_message(u'%s_blank'
@ -743,8 +734,9 @@ class SlideController(QtGui.QWidget):
def hidePlugin(self, hide): 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 self.serviceItem is not None:
if hide: if hide:
Receiver.send_message(u'%s_hide' Receiver.send_message(u'%s_hide'

View File

@ -85,6 +85,9 @@ class AlertsManager(QtCore.QObject):
self.generateAlert() self.generateAlert()
def generateAlert(self): def generateAlert(self):
"""
Format and request the Alert and start the timer
"""
log.debug(u'Generate Alert called') log.debug(u'Generate Alert called')
if len(self.alertList) == 0: if len(self.alertList) == 0:
return return
@ -98,9 +101,17 @@ class AlertsManager(QtCore.QObject):
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
def timerEvent(self, event): 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') log.debug(u'timer event')
alertTab = self.parent.alertsTab
if event.timerId() == self.timer_id: 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.killTimer(self.timer_id)
self.timer_id = 0 self.timer_id = 0
self.generateAlert() self.generateAlert()