Alert workings

This commit is contained in:
Tim Bentley 2010-08-01 09:28:31 +01:00
parent e95ea60d9b
commit f10e478438
5 changed files with 40 additions and 32 deletions

View File

@ -130,8 +130,10 @@ HTMLSRC = u"""
<table class="lyricsshadowtable lyricscommon">
<tr><td id="lyricsshadow2" class="lyricsshadow lyrics"></td></tr>
</table>
<table class="alerttable alertcommon">
<tr><td id="alertmain" class="alert"></td></tr>
</table>
<div id="footer" class="footer"></div>
<div id="alert"></div>
<video id="video"></video>
<blank id="blank"></blank>
%s
@ -162,7 +164,6 @@ def build_html(item, screen, alert):
build_blank(width, height),
"true" if theme and theme.display_slideTransition else "false",
build_image_src(item.bg_frame))
print html
return html
def build_video(width, height):
@ -315,20 +316,31 @@ def build_footer(item):
valign = u'vertical-align:top;'
text = u'color:%s; %s %s' % (theme.font_footer_color, align, valign)
lyrics_html = lyrics % (position, font, text)
print lyrics_html
return lyrics_html
def build_alert(width, alertTab):
alert = """
#alert { position: absolute; left: 0px; top: 70px;
width: %spx; height: 10px; z-index:6; font-size: %spx;
}
#alert p {
background-color: %s;
}
def build_alert(width, alertTab):#
style = """
.alertcommon { position: absolute; %s }
.alerttable { z-index:8; %s }
.alert { %s }
table {border=0; margin=0; padding=0; }
"""
alertText = u''
alertcommon = u''
alerttable = u''
valign = u''
if alertTab:
alertText = alert % (width, alertTab.font_size, alertTab.bg_color)
return alertText
alertcommon = u'width: %spx; height: %spx; ' \
u'font-family %s; font-size: %spx; color: %s; ' % \
(width, 70, alertTab.font_face, alertTab.font_size,
alertTab.bg_color)
alerttable = u'left: %spx; top: %spx;' % (0, 0)
if alertTab.location == 2:
valign = u'vertical-align:bottom;'
elif alertTab.location == 1:
valign = u'vertical-align:middle;'
else:
valign = u'vertical-align:top;'
alert_html = style % (alertcommon, alerttable, valign)
print alert_html
return alert_html

View File

@ -90,6 +90,7 @@ class MainDisplay(DisplayWidget):
self.parent = parent
self.screens = screens
self.isLive = live
self.alertTab = None
self.setWindowTitle(u'OpenLP Display')
self.setWindowFlags(QtCore.Qt.FramelessWindowHint |
QtCore.Qt.WindowStaysOnTopHint)
@ -115,7 +116,6 @@ class MainDisplay(DisplayWidget):
self.webView.setGeometry(0, 0, self.screen[u'size'].width(), self.screen[u'size'].height())
self.page = self.webView.page()
self.frame = self.page.mainFrame()
self.alertTab = None
QtCore.QObject.connect(self.webView,
QtCore.SIGNAL(u'loadFinished(bool)'), self.loaded)
self.frame.setScrollBarPolicy(QtCore.Qt.Vertical,
@ -175,7 +175,7 @@ class MainDisplay(DisplayWidget):
The slide text to be displayed
"""
log.debug(u'alert')
self.frame.findFirstElement('div#alert').setInnerXml(text)
self.frame.findFirstElement('td#alertmain').setInnerXml(text)
def image(self, image):
"""
@ -247,7 +247,7 @@ class MainDisplay(DisplayWidget):
log.debug(u'buildHtml')
self.loaded = False
self.serviceItem = serviceItem
html = build_html(self.serviceItem, self.screen, self.alertTab)
html = build_html(self.serviceItem, self.screen, self.parent.alertTab)
self.webView.setHtml(html)
if serviceItem.footer and serviceItem.foot_text:
self.frame.findFirstElement('div#footer').setInnerXml(serviceItem.foot_text)

View File

@ -103,9 +103,9 @@ class SlideController(QtGui.QWidget):
self.songEdit = False
self.selectedRow = 0
self.serviceItem = None
self.alertTab = None
self.Panel = QtGui.QWidget(parent.ControlSplitter)
self.slideList = {}
self.canDisplay = True
# Layout for holding panel
self.PanelLayout = QtGui.QVBoxLayout(self.Panel)
self.PanelLayout.setSpacing(0)
@ -388,6 +388,7 @@ class SlideController(QtGui.QWidget):
log.debug(u'screenSizeChanged live = %s' % self.isLive)
# rebuild display as screen size changed
self.display = MainDisplay(self, self.screens, self.isLive)
self.display.alertTab = self.alertTab
self.ratio = float(self.screens.current[u'size'].width()) / \
float(self.screens.current[u'size'].height())
self.display.setup()

View File

@ -81,9 +81,10 @@ class AlertsPlugin(Plugin):
log.info(u'Alerts Initialising')
Plugin.initialise(self)
self.toolsAlertItem.setVisible(True)
self.liveController.alertTab = self.alertsTab
def finalise(self):
log.info(u'Plugin Finalise')
log.info(u'Alerts Finaliseing')
Plugin.finalise(self)
self.toolsAlertItem.setVisible(False)

View File

@ -261,7 +261,7 @@ class AlertsTab(SettingsTab):
self.font_face = unicode(settings.value(
u'font face', QtCore.QVariant(QtGui.QFont().family())).toString())
self.location = settings.value(
u'location', QtCore.QVariant(0)).toInt()[0]
u'location', QtCore.QVariant(1)).toInt()[0]
settings.endGroup()
self.FontSizeSpinBox.setValue(self.font_size)
self.TimeoutSpinBox.setValue(self.timeout)
@ -297,9 +297,3 @@ class AlertsTab(SettingsTab):
self.FontPreview.setStyleSheet(u'background-color: %s; color: %s' %
(self.bg_color, self.font_color))
def postSetUp(self):
"""
Reset screens after initial definition
"""
self.parent.previewController.display.alertTab = self
self.parent.liveController.display.alertTab = self