forked from openlp/openlp
Alerts move to top and bottom
This commit is contained in:
parent
47a61a6581
commit
973d5e3dd8
@ -190,6 +190,7 @@ class MainDisplay(DisplayWidget):
|
||||
else:
|
||||
self.setVisible(False)
|
||||
self.primary = True
|
||||
Receiver.send_message(u'screen_changed')
|
||||
|
||||
def resetDisplay(self):
|
||||
if self.primary:
|
||||
@ -214,6 +215,11 @@ class MainDisplay(DisplayWidget):
|
||||
self.screen[u'size'].height() )
|
||||
self.display_image.setPixmap(QtGui.QPixmap.fromImage(frame))
|
||||
|
||||
def setAlertSize(self, top, height):
|
||||
self.display_alert.setGeometry(
|
||||
QtCore.QRect(0, top,
|
||||
self.screen[u'size'].width(), height))
|
||||
|
||||
def addAlertImage(self, frame, blank=False):
|
||||
if blank:
|
||||
self.display_alert.setPixmap(self.transparent)
|
||||
|
@ -21,6 +21,27 @@ class AlertsManager(QtCore.QObject):
|
||||
self.alertList = []
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'alert_text'), self.displayAlert)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'screen_changed'), self.screenChanged)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'config_updated'), self.screenChanged)
|
||||
|
||||
def screenChanged(self):
|
||||
log.debug(u'screen changed')
|
||||
self.screen = self.parent.maindisplay.screen
|
||||
self.alertTab = self.parent.alertsTab
|
||||
self.font = QtGui.QFont()
|
||||
self.font.setFamily(self.alertTab.font_face)
|
||||
self.font.setBold(True)
|
||||
self.font.setPointSize(self.alertTab.font_size)
|
||||
self.metrics = QtGui.QFontMetrics(self.font)
|
||||
self.alertHeight = self.metrics.height() + 4
|
||||
if self.alertTab.location == 0:
|
||||
self.alertScreenPosition = 0
|
||||
else:
|
||||
self.alertScreenPosition = self.screen[u'size'].height() - self.alertHeight
|
||||
self.alertHeight = self.screen[u'size'].height() - self.alertScreenPosition
|
||||
self.parent.maindisplay.setAlertSize(self.alertScreenPosition, self.alertHeight)
|
||||
|
||||
def displayAlert(self, text=u''):
|
||||
"""
|
||||
@ -30,11 +51,10 @@ class AlertsManager(QtCore.QObject):
|
||||
display text
|
||||
"""
|
||||
log.debug(u'display alert called %s' % text)
|
||||
self.screen = self.parent.maindisplay.screen
|
||||
self.parent.maindisplay.parent.StatusBar.showMessage(self.trUtf8(u''))
|
||||
self.alertList.append(text)
|
||||
if self.timer_id != 0 or self.parent.maindisplay.mediaLoaded:
|
||||
self.parent.StatusBar.showMessage(\
|
||||
self.parent.maindisplay.parent.StatusBar.showMessage(\
|
||||
self.trUtf8(u'Alert message created and delayed'))
|
||||
return
|
||||
self.generateAlert()
|
||||
@ -46,7 +66,7 @@ class AlertsManager(QtCore.QObject):
|
||||
text = self.alertList.pop(0)
|
||||
alertTab = self.parent.alertsTab
|
||||
alertframe = \
|
||||
QtGui.QPixmap(self.screen[u'size'].width(), self.parent.maindisplay.alertHeight)
|
||||
QtGui.QPixmap(self.screen[u'size'].width(), self.alertHeight)
|
||||
alertframe.fill(QtCore.Qt.transparent)
|
||||
painter = QtGui.QPainter(alertframe)
|
||||
painter.fillRect(alertframe.rect(), QtCore.Qt.transparent)
|
||||
@ -55,26 +75,21 @@ class AlertsManager(QtCore.QObject):
|
||||
QtCore.QRect(
|
||||
0, 0, alertframe.rect().width(),
|
||||
alertframe.rect().height()),
|
||||
QtGui.QColor(alertTab.bg_color))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily(alertTab.font_face)
|
||||
font.setBold(True)
|
||||
font.setPointSize(alertTab.font_size)
|
||||
painter.setFont(font)
|
||||
painter.setPen(QtGui.QColor(alertTab.font_color))
|
||||
x, y = (0, 0)
|
||||
metrics = QtGui.QFontMetrics(font)
|
||||
QtGui.QColor(self.alertTab.bg_color))
|
||||
painter.setFont(self.font)
|
||||
painter.setPen(QtGui.QColor(self.alertTab.font_color))
|
||||
x, y = (0, 2)
|
||||
painter.drawText(
|
||||
x, y + metrics.height() - metrics.descent() - 1, text)
|
||||
x, y + self.metrics.height() - self.metrics.descent() - 1, text)
|
||||
painter.end()
|
||||
self.parent.maindisplay.display_alert.setPixmap(alertframe)
|
||||
self.parent.maindisplay.addAlertImage(alertframe)
|
||||
# check to see if we have a timer running
|
||||
if self.timer_id == 0:
|
||||
self.timer_id = self.startTimer(int(alertTab.timeout) * 1000)
|
||||
|
||||
def timerEvent(self, event):
|
||||
if event.timerId() == self.timer_id:
|
||||
self.parent.maindisplay.display_alert.setPixmap(self.parent.maindisplay.transparent)
|
||||
self.parent.maindisplay.addAlertImage(None, True)
|
||||
self.killTimer(self.timer_id)
|
||||
self.timer_id = 0
|
||||
self.generateAlert()
|
||||
|
Loading…
Reference in New Issue
Block a user