forked from openlp/openlp
Display fixes amd theme updates
This commit is contained in:
parent
bec051a502
commit
efd5c60dfd
@ -35,6 +35,9 @@ HTMLSRC = u"""
|
||||
margin: 0;
|
||||
padding:0
|
||||
}
|
||||
body {
|
||||
background-color: black;
|
||||
}
|
||||
%s
|
||||
%s
|
||||
%s
|
||||
@ -47,27 +50,105 @@ HTMLSRC = u"""
|
||||
var t = null;
|
||||
var transition = %s;
|
||||
|
||||
function video(state, path, volume, loop){
|
||||
var vid = document.getElementById('video');
|
||||
if(path!=null)
|
||||
vid.src = path;
|
||||
if(loop!=null){
|
||||
if(loop)
|
||||
vid.loop = 'loop';
|
||||
else
|
||||
vid.loop = '';
|
||||
}
|
||||
switch(state){
|
||||
case 'play':
|
||||
vid.play();
|
||||
vid.style.display = 'block';
|
||||
break;
|
||||
case 'pause':
|
||||
vid.pause();
|
||||
vid.style.display = 'block';
|
||||
break;
|
||||
case 'stop':
|
||||
vid.pause();
|
||||
vid.style.display = 'none';
|
||||
break;
|
||||
case 'close':
|
||||
vid.pause();
|
||||
vid.style.display = 'none';
|
||||
vid.setAttribute('src', '');
|
||||
break;
|
||||
if(volume!=null)
|
||||
vid.volume = volume;
|
||||
}
|
||||
}
|
||||
|
||||
function setImage(src){
|
||||
var img = document.getElementById('image');
|
||||
img.src = src;
|
||||
if(src=='')
|
||||
img.style.display = 'none';
|
||||
else
|
||||
img.style.display = 'block';
|
||||
}
|
||||
function blankState(state){
|
||||
var black = 'none';
|
||||
var lyrics = '';
|
||||
var pause = false;
|
||||
switch(state){
|
||||
case 'theme':
|
||||
lyrics = 'none';
|
||||
lyrics = 'hidden';
|
||||
pause = true;
|
||||
break;
|
||||
case 'black':
|
||||
black = 'inline';
|
||||
black = 'block';
|
||||
pause = true;
|
||||
break;
|
||||
case 'desktop':
|
||||
pause = true;
|
||||
break;
|
||||
}
|
||||
document.getElementById('black').style.display = black;
|
||||
document.getElementById('lyricsmain').style.display = lyrics;
|
||||
document.getElementById('lyricsoutline').style.display = lyrics;
|
||||
document.getElementById('lyricsshadow').style.display = lyrics;
|
||||
document.getElementById('footer').style.display = lyrics;
|
||||
document.getElementById('lyricsmain').style.visibility = lyrics;
|
||||
document.getElementById('lyricsoutline').style.visibility = lyrics;
|
||||
document.getElementById('lyricsshadow').style.visibility = lyrics;
|
||||
document.getElementById('footer').style.visibility = lyrics;
|
||||
var vid = document.getElementById('video');
|
||||
if(vid.src != ''){
|
||||
if(pause)
|
||||
vid.pause();
|
||||
else
|
||||
vid.play();
|
||||
}
|
||||
}
|
||||
|
||||
function displayAlert(alerttext){
|
||||
var text1 = document.getElementById('alertmain');
|
||||
text1.innerHTML = alerttext;
|
||||
function displayAlert(alerttext, shrink){
|
||||
var text = document.getElementById('alert');
|
||||
text.innerHTML = alerttext;
|
||||
if(alerttext=='') {
|
||||
text.style.visibility = 'hidden';
|
||||
return 0;
|
||||
}
|
||||
if(shrink){
|
||||
text.style.top = '0px';
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(window.getComputedStyle(text, '').verticalAlign)
|
||||
{
|
||||
case 'top':
|
||||
text.style.top = '0px';
|
||||
break;
|
||||
case 'middle':
|
||||
text.style.top = ((window.innerHeight - text.clientHeight) / 2) + 'px';
|
||||
break;
|
||||
case 'bottom':
|
||||
text.style.top = (window.innerHeight - text.clientHeight) + 'px';
|
||||
break;
|
||||
}
|
||||
}
|
||||
text.style.visibility = 'visible';
|
||||
return text.clientHeight;
|
||||
}
|
||||
|
||||
function startfade(newtext){
|
||||
@ -125,12 +206,12 @@ HTMLSRC = u"""
|
||||
if((parseFloat(text1.style.opacity) < 1)||(parseFloat(text2.style.opacity) > 0))
|
||||
t = setTimeout('fade()', 50);
|
||||
else{
|
||||
text1.style.opacity = 1
|
||||
texto1.style.opacity = 1
|
||||
texts1.style.opacity = 1
|
||||
text2.style.opacity = 0
|
||||
texto2.style.opacity = 0
|
||||
texts2.style.opacity = 0
|
||||
text1.style.opacity = 1;
|
||||
texto1.style.opacity = 1;
|
||||
texts1.style.opacity = 1;
|
||||
text2.style.opacity = 0;
|
||||
texto2.style.opacity = 0;
|
||||
texts2.style.opacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,11 +239,14 @@ HTMLSRC = u"""
|
||||
<table class="lyricsshadowtable lyricscommon">
|
||||
<tr><td id="lyricsshadow2" class="lyricsshadow lyrics"></td></tr>
|
||||
</table>
|
||||
<!--
|
||||
<table class="alerttable">
|
||||
<tr><td class="alertcell">
|
||||
<div class="alert" id="alertmain"></div>
|
||||
</td></tr>
|
||||
</table>
|
||||
-->
|
||||
<div id="alert" style="visibility:hidden;"></div>
|
||||
<div id="footer" class="footer"></div>
|
||||
<video id="video"></video>
|
||||
<div id="black"></div>
|
||||
@ -223,7 +307,7 @@ def build_black(width, height):
|
||||
"""
|
||||
black = """
|
||||
#black { position: absolute; left: 0px; top: 0px;
|
||||
width: %spx; height: %spx; z-index:10;
|
||||
width: %spx; height: %spx; z-index:8;
|
||||
background-color: black; display: none;
|
||||
}
|
||||
"""
|
||||
@ -252,10 +336,12 @@ def build_image_src(image):
|
||||
`image`
|
||||
Image to be displayed
|
||||
"""
|
||||
image_src = """
|
||||
<img src="data:image/png;base64,%s">
|
||||
"""
|
||||
return image_src % image_to_byte(image)
|
||||
if image:
|
||||
return '<img id="image" src="data:image/png;base64,%s" />' % \
|
||||
image_to_byte(image)
|
||||
else:
|
||||
return '<img id="image" />'
|
||||
|
||||
|
||||
def build_lyrics(item):
|
||||
"""
|
||||
@ -283,7 +369,7 @@ def build_lyrics(item):
|
||||
outline = u'display: none;'
|
||||
shadow = u'display: none;'
|
||||
if theme:
|
||||
lyricscommon = u'width: %spx; height: %spx; ' \
|
||||
lyricscommon = u'width: %spx; height: %spx; word-wrap: break-word ' \
|
||||
u'font-family %s; font-size: %spx; color: %s; line-height: %d%%' % \
|
||||
(item.main.width(), item.main.height(),
|
||||
theme.font_main_name, theme.font_main_proportion,
|
||||
@ -367,10 +453,13 @@ def build_alert(width, height, alertTab):
|
||||
Details from the Alert tab for fonts etc
|
||||
"""
|
||||
style = """
|
||||
.alerttable { position: absolute; z-index:8; left 0px; top 0px; %s }
|
||||
.alerttable { position: absolute; z-index:10; left 0px; top 0px; %s }
|
||||
.alertcell { %s }
|
||||
.alert { %s }
|
||||
"""
|
||||
style2 = """
|
||||
#alert {position: absolute; z-index:10; left 0px; top 0px; width: %spx; %s %s}
|
||||
"""
|
||||
alerttable = u''
|
||||
alertcell = u''
|
||||
alert = u''
|
||||
@ -386,5 +475,7 @@ def build_alert(width, height, alertTab):
|
||||
u'background-color: %s' % \
|
||||
(alertTab.font_face, alertTab.font_size, alertTab.font_color,
|
||||
alertTab.bg_color)
|
||||
alert_html = style % (alerttable, alertcell, alert)
|
||||
#alert_html = style % (alerttable, alertcell, alert)
|
||||
alert_html = style2 % (width, alertcell, alert)
|
||||
print alert_html
|
||||
return alert_html
|
||||
|
@ -68,17 +68,17 @@ class Ui_AmendThemeDialog(object):
|
||||
self.backgroundLayout.setMargin(8)
|
||||
self.backgroundLayout.setSpacing(8)
|
||||
self.backgroundLayout.setObjectName(u'backgroundLayout')
|
||||
self.backgroundLabel = QtGui.QLabel(self.backgroundTab)
|
||||
self.backgroundLabel.setObjectName(u'backgroundLabel')
|
||||
self.backgroundLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
|
||||
self.backgroundLabel)
|
||||
self.backgroundComboBox = QtGui.QComboBox(self.backgroundTab)
|
||||
self.backgroundComboBox.setObjectName(u'backgroundComboBox')
|
||||
self.backgroundLabel.setBuddy(self.backgroundComboBox)
|
||||
self.backgroundComboBox.addItem(QtCore.QString())
|
||||
self.backgroundComboBox.addItem(QtCore.QString())
|
||||
self.backgroundLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
|
||||
self.backgroundComboBox)
|
||||
# self.backgroundLabel = QtGui.QLabel(self.backgroundTab)
|
||||
# self.backgroundLabel.setObjectName(u'backgroundLabel')
|
||||
# self.backgroundLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
|
||||
# self.backgroundLabel)
|
||||
# self.backgroundComboBox = QtGui.QComboBox(self.backgroundTab)
|
||||
# self.backgroundComboBox.setObjectName(u'backgroundComboBox')
|
||||
# self.backgroundLabel.setBuddy(self.backgroundComboBox)
|
||||
# self.backgroundComboBox.addItem(QtCore.QString())
|
||||
# self.backgroundComboBox.addItem(QtCore.QString())
|
||||
# self.backgroundLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
|
||||
# self.backgroundComboBox)
|
||||
self.backgroundTypeLabel = QtGui.QLabel(self.backgroundTab)
|
||||
self.backgroundTypeLabel.setObjectName(u'backgroundTypeLabel')
|
||||
self.backgroundLayout.setWidget(1, QtGui.QFormLayout.LabelRole,
|
||||
@ -661,12 +661,12 @@ class Ui_AmendThemeDialog(object):
|
||||
translate('OpenLP.AmendThemeForm', 'Theme Maintenance'))
|
||||
self.themeNameLabel.setText(
|
||||
translate('OpenLP.AmendThemeForm', 'Theme &name:'))
|
||||
self.backgroundLabel.setText(
|
||||
translate('OpenLP.AmendThemeForm', '&Visibility:'))
|
||||
self.backgroundComboBox.setItemText(0,
|
||||
translate('OpenLP.AmendThemeForm', 'Opaque'))
|
||||
self.backgroundComboBox.setItemText(1,
|
||||
translate('OpenLP.AmendThemeForm', 'Transparent'))
|
||||
# self.backgroundLabel.setText(
|
||||
# translate('OpenLP.AmendThemeForm', '&Visibility:'))
|
||||
# self.backgroundComboBox.setItemText(0,
|
||||
# translate('OpenLP.AmendThemeForm', 'Opaque'))
|
||||
# self.backgroundComboBox.setItemText(1,
|
||||
# translate('OpenLP.AmendThemeForm', 'Transparent'))
|
||||
self.backgroundTypeLabel.setText(
|
||||
translate('OpenLP.AmendThemeForm', 'Type:'))
|
||||
self.backgroundTypeComboBox.setItemText(0,
|
||||
|
@ -68,8 +68,8 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
QtCore.QObject.connect(self.imageToolButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onImageToolButtonClicked)
|
||||
# Combo boxes
|
||||
QtCore.QObject.connect(self.backgroundComboBox,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onBackgroundComboBoxSelected)
|
||||
# QtCore.QObject.connect(self.backgroundComboBox,
|
||||
# QtCore.SIGNAL(u'activated(int)'), self.onBackgroundComboBoxSelected)
|
||||
QtCore.QObject.connect(self.backgroundTypeComboBox,
|
||||
QtCore.SIGNAL(u'activated(int)'),
|
||||
self.onBackgroundTypeComboBoxSelected)
|
||||
@ -151,23 +151,23 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
new_theme.new_document(theme_name)
|
||||
save_from = None
|
||||
save_to = None
|
||||
if self.theme.background_mode == u'transparent':
|
||||
new_theme.add_background_transparent()
|
||||
# if self.theme.background_mode == u'transparent':
|
||||
# new_theme.add_background_transparent()
|
||||
# else:
|
||||
if self.theme.background_type == u'solid':
|
||||
new_theme.add_background_solid(
|
||||
unicode(self.theme.background_color))
|
||||
elif self.theme.background_type == u'gradient':
|
||||
new_theme.add_background_gradient(
|
||||
unicode(self.theme.background_startColor),
|
||||
unicode(self.theme.background_endColor),
|
||||
self.theme.background_direction)
|
||||
else:
|
||||
if self.theme.background_type == u'solid':
|
||||
new_theme.add_background_solid(
|
||||
unicode(self.theme.background_color))
|
||||
elif self.theme.background_type == u'gradient':
|
||||
new_theme.add_background_gradient(
|
||||
unicode(self.theme.background_startColor),
|
||||
unicode(self.theme.background_endColor),
|
||||
self.theme.background_direction)
|
||||
else:
|
||||
filename = \
|
||||
os.path.split(unicode(self.theme.background_filename))[1]
|
||||
new_theme.add_background_image(filename)
|
||||
save_to = os.path.join(self.path, theme_name, filename)
|
||||
save_from = self.theme.background_filename
|
||||
filename = \
|
||||
os.path.split(unicode(self.theme.background_filename))[1]
|
||||
new_theme.add_background_image(filename)
|
||||
save_to = os.path.join(self.path, theme_name, filename)
|
||||
save_from = self.theme.background_filename
|
||||
new_theme.add_font(unicode(self.theme.font_main_name),
|
||||
unicode(self.theme.font_main_color),
|
||||
unicode(self.theme.font_main_proportion),
|
||||
@ -230,7 +230,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.previewTheme()
|
||||
|
||||
#
|
||||
#Main Font Tab
|
||||
# Main Font Tab
|
||||
#
|
||||
def onFontMainComboBoxSelected(self):
|
||||
self.theme.font_main_name = self.fontMainComboBox.currentFont().family()
|
||||
@ -323,7 +323,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.previewTheme()
|
||||
|
||||
#
|
||||
#Footer Font Tab
|
||||
# Footer Font Tab
|
||||
#
|
||||
def onFontFooterComboBoxSelected(self):
|
||||
self.theme.font_footer_name = \
|
||||
@ -404,19 +404,19 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.previewTheme()
|
||||
|
||||
#
|
||||
#Background Tab
|
||||
# Background Tab
|
||||
#
|
||||
def onGradientComboBoxSelected(self, currentIndex):
|
||||
self.setBackground(self.backgroundTypeComboBox.currentIndex(),
|
||||
currentIndex)
|
||||
|
||||
def onBackgroundComboBoxSelected(self, currentIndex):
|
||||
if currentIndex == 0: # Opaque
|
||||
self.theme.background_mode = u'opaque'
|
||||
else:
|
||||
self.theme.background_mode = u'transparent'
|
||||
self.stateChanging(self.theme)
|
||||
self.previewTheme()
|
||||
# def onBackgroundComboBoxSelected(self, currentIndex):
|
||||
# if currentIndex == 0: # Opaque
|
||||
# self.theme.background_mode = u'opaque'
|
||||
# else:
|
||||
# self.theme.background_mode = u'transparent'
|
||||
# self.stateChanging(self.theme)
|
||||
# self.previewTheme()
|
||||
|
||||
def onBackgroundTypeComboBoxSelected(self, currentIndex):
|
||||
self.setBackground(currentIndex, self.gradientComboBox.currentIndex())
|
||||
@ -472,7 +472,7 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.previewTheme()
|
||||
|
||||
#
|
||||
#Other Tab
|
||||
# Other Tab
|
||||
#
|
||||
def onOutlineCheckBoxChanged(self, value):
|
||||
if value == 2: # checked
|
||||
@ -537,16 +537,16 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.previewTheme()
|
||||
|
||||
#
|
||||
#Local Methods
|
||||
# Local Methods
|
||||
#
|
||||
def paintUi(self, theme):
|
||||
self.stateChanging(theme)
|
||||
self.themeNameEdit.setText(self.theme.theme_name)
|
||||
# Background Tab
|
||||
if self.theme.background_mode == u'opaque':
|
||||
self.backgroundComboBox.setCurrentIndex(0)
|
||||
else:
|
||||
self.backgroundComboBox.setCurrentIndex(1)
|
||||
# if self.theme.background_mode == u'opaque':
|
||||
# self.backgroundComboBox.setCurrentIndex(0)
|
||||
# else:
|
||||
# self.backgroundComboBox.setCurrentIndex(1)
|
||||
self.imageLineEdit.setText(u'')
|
||||
if theme.background_type == u'solid':
|
||||
self.backgroundTypeComboBox.setCurrentIndex(0)
|
||||
@ -641,9 +641,28 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.verticalComboBox.setCurrentIndex(self.theme.display_verticalAlign)
|
||||
|
||||
def stateChanging(self, theme):
|
||||
if theme.background_mode == u'transparent':
|
||||
self.color1Label.setVisible(False)
|
||||
self.color1PushButton.setVisible(False)
|
||||
# if theme.background_mode == u'transparent':
|
||||
# self.color1Label.setVisible(False)
|
||||
# self.color1PushButton.setVisible(False)
|
||||
# self.color2Label.setVisible(False)
|
||||
# self.color2PushButton.setVisible(False)
|
||||
# self.imageLabel.setVisible(False)
|
||||
# self.imageLineEdit.setVisible(False)
|
||||
# self.imageFilenameWidget.setVisible(False)
|
||||
# self.gradientLabel.setVisible(False)
|
||||
# self.gradientComboBox.setVisible(False)
|
||||
# self.backgroundTypeComboBox.setVisible(False)
|
||||
# self.backgroundTypeLabel.setVisible(False)
|
||||
# else:
|
||||
self.backgroundTypeComboBox.setVisible(True)
|
||||
self.backgroundTypeLabel.setVisible(True)
|
||||
if theme.background_type == u'solid':
|
||||
self.color1PushButton.setStyleSheet(
|
||||
u'background-color: %s' % unicode(theme.background_color))
|
||||
self.color1Label.setText(
|
||||
translate('OpenLP.AmendThemeForm', 'Color:'))
|
||||
self.color1Label.setVisible(True)
|
||||
self.color1PushButton.setVisible(True)
|
||||
self.color2Label.setVisible(False)
|
||||
self.color2PushButton.setVisible(False)
|
||||
self.imageLabel.setVisible(False)
|
||||
@ -651,53 +670,34 @@ class AmendThemeForm(QtGui.QDialog, Ui_AmendThemeDialog):
|
||||
self.imageFilenameWidget.setVisible(False)
|
||||
self.gradientLabel.setVisible(False)
|
||||
self.gradientComboBox.setVisible(False)
|
||||
self.backgroundTypeComboBox.setVisible(False)
|
||||
self.backgroundTypeLabel.setVisible(False)
|
||||
else:
|
||||
self.backgroundTypeComboBox.setVisible(True)
|
||||
self.backgroundTypeLabel.setVisible(True)
|
||||
if theme.background_type == u'solid':
|
||||
self.color1PushButton.setStyleSheet(
|
||||
u'background-color: %s' % unicode(theme.background_color))
|
||||
self.color1Label.setText(
|
||||
translate('OpenLP.AmendThemeForm', 'Color:'))
|
||||
self.color1Label.setVisible(True)
|
||||
self.color1PushButton.setVisible(True)
|
||||
self.color2Label.setVisible(False)
|
||||
self.color2PushButton.setVisible(False)
|
||||
self.imageLabel.setVisible(False)
|
||||
self.imageLineEdit.setVisible(False)
|
||||
self.imageFilenameWidget.setVisible(False)
|
||||
self.gradientLabel.setVisible(False)
|
||||
self.gradientComboBox.setVisible(False)
|
||||
elif theme.background_type == u'gradient':
|
||||
self.color1PushButton.setStyleSheet(u'background-color: %s' \
|
||||
% unicode(theme.background_startColor))
|
||||
self.color2PushButton.setStyleSheet(u'background-color: %s' \
|
||||
% unicode(theme.background_endColor))
|
||||
self.color1Label.setText(
|
||||
translate('OpenLP.AmendThemeForm', 'First color:'))
|
||||
self.color2Label.setText(
|
||||
translate('OpenLP.AmendThemeForm', 'Second color:'))
|
||||
self.color1Label.setVisible(True)
|
||||
self.color1PushButton.setVisible(True)
|
||||
self.color2Label.setVisible(True)
|
||||
self.color2PushButton.setVisible(True)
|
||||
self.imageLabel.setVisible(False)
|
||||
self.imageLineEdit.setVisible(False)
|
||||
self.imageFilenameWidget.setVisible(False)
|
||||
self.gradientLabel.setVisible(True)
|
||||
self.gradientComboBox.setVisible(True)
|
||||
else: # must be image
|
||||
self.color1Label.setVisible(False)
|
||||
self.color1PushButton.setVisible(False)
|
||||
self.color2Label.setVisible(False)
|
||||
self.color2PushButton.setVisible(False)
|
||||
self.imageLabel.setVisible(True)
|
||||
self.imageLineEdit.setVisible(True)
|
||||
self.imageFilenameWidget.setVisible(True)
|
||||
self.gradientLabel.setVisible(False)
|
||||
self.gradientComboBox.setVisible(False)
|
||||
elif theme.background_type == u'gradient':
|
||||
self.color1PushButton.setStyleSheet(u'background-color: %s' \
|
||||
% unicode(theme.background_startColor))
|
||||
self.color2PushButton.setStyleSheet(u'background-color: %s' \
|
||||
% unicode(theme.background_endColor))
|
||||
self.color1Label.setText(
|
||||
translate('OpenLP.AmendThemeForm', 'First color:'))
|
||||
self.color2Label.setText(
|
||||
translate('OpenLP.AmendThemeForm', 'Second color:'))
|
||||
self.color1Label.setVisible(True)
|
||||
self.color1PushButton.setVisible(True)
|
||||
self.color2Label.setVisible(True)
|
||||
self.color2PushButton.setVisible(True)
|
||||
self.imageLabel.setVisible(False)
|
||||
self.imageLineEdit.setVisible(False)
|
||||
self.imageFilenameWidget.setVisible(False)
|
||||
self.gradientLabel.setVisible(True)
|
||||
self.gradientComboBox.setVisible(True)
|
||||
else: # must be image
|
||||
self.color1Label.setVisible(False)
|
||||
self.color1PushButton.setVisible(False)
|
||||
self.color2Label.setVisible(False)
|
||||
self.color2PushButton.setVisible(False)
|
||||
self.imageLabel.setVisible(True)
|
||||
self.imageLineEdit.setVisible(True)
|
||||
self.imageFilenameWidget.setVisible(True)
|
||||
self.gradientLabel.setVisible(False)
|
||||
self.gradientComboBox.setVisible(False)
|
||||
if not theme.font_main_override:
|
||||
self.fontMainXSpinBox.setEnabled(False)
|
||||
self.fontMainYSpinBox.setEnabled(False)
|
||||
|
@ -166,7 +166,7 @@ class MainDisplay(DisplayWidget):
|
||||
slide.replace("\\", "\\\\").replace("\'", "\\\'") + "')")
|
||||
return self.preview()
|
||||
|
||||
def alert(self, text):
|
||||
def alert(self, text, shrink=False):
|
||||
"""
|
||||
Add the alert text
|
||||
|
||||
@ -174,8 +174,15 @@ class MainDisplay(DisplayWidget):
|
||||
The slide text to be displayed
|
||||
"""
|
||||
log.debug(u'alert')
|
||||
self.frame.evaluateJavaScript( "displayAlert('" + \
|
||||
text.replace("\\", "\\\\").replace("\'", "\\\'") + "')")
|
||||
js = "displayAlert('" + \
|
||||
text.replace("\\", "\\\\").replace("\'", "\\\'") + "', %s)" % \
|
||||
('true' if shrink else 'false')
|
||||
height = self.frame.evaluateJavaScript(js)
|
||||
if shrink:
|
||||
if text:
|
||||
self.resize(self.width(), int(height.toString()))
|
||||
else:
|
||||
self.setGeometry(self.screen[u'size'])
|
||||
|
||||
def image(self, image):
|
||||
"""
|
||||
@ -188,10 +195,19 @@ class MainDisplay(DisplayWidget):
|
||||
log.debug(u'image')
|
||||
image = resize_image(image, self.screen[u'size'].width(),
|
||||
self.screen[u'size'].height())
|
||||
self.frame.evaluateJavaScript(
|
||||
"document.getElementById('video').style.visibility = 'hidden'")
|
||||
self.frame.findFirstElement(u'img').setAttribute(
|
||||
u'src', unicode(u'data:image/png;base64,%s' % image_to_byte(image)))
|
||||
self.resetVideo()
|
||||
self.displayImage(image)
|
||||
|
||||
def displayImage(self, image):
|
||||
"""
|
||||
Display an image, as is.
|
||||
"""
|
||||
if image:
|
||||
js = "setImage('" + \
|
||||
u'data:image/png;base64,%s' % image_to_byte(image) + "');"
|
||||
else:
|
||||
js = "setImage('');"
|
||||
self.frame.evaluateJavaScript(js)
|
||||
|
||||
def resetImage(self):
|
||||
"""
|
||||
@ -199,49 +215,42 @@ class MainDisplay(DisplayWidget):
|
||||
Used after Image plugin has changed the background
|
||||
"""
|
||||
log.debug(u'resetImage')
|
||||
self.frame.findFirstElement(u'img').setAttribute(
|
||||
u'src', unicode(u'data:image/png;base64,%s' % \
|
||||
image_to_byte(self.serviceItem.bg_frame)))
|
||||
self.displayImage(self.serviceItem.bg_frame)
|
||||
|
||||
def resetVideo(self):
|
||||
"""
|
||||
Reset the backgound image to the service item image.
|
||||
Used after Video plugin has changed the background
|
||||
"""
|
||||
log.debug(u'resetVideo')
|
||||
self.frame.evaluateJavaScript(
|
||||
"document.getElementById('video').style.visibility = 'hidden'")
|
||||
self.frame.evaluateJavaScript('video("close");')
|
||||
|
||||
def videoPlay(self):
|
||||
"""
|
||||
Responds to the request to play a loaded video
|
||||
"""
|
||||
log.debug(u'videoPlay')
|
||||
self.frame.evaluateJavaScript("document.getElementById('video').play()")
|
||||
self.frame.evaluateJavaScript('video("play");')
|
||||
|
||||
def videoPause(self):
|
||||
"""
|
||||
Responds to the request to pause a loaded video
|
||||
"""
|
||||
log.debug(u'videoPause')
|
||||
self.frame.evaluateJavaScript("document.getElementById('video').pause()")
|
||||
self.frame.evaluateJavaScript('video("pause");')
|
||||
|
||||
def videoStop(self):
|
||||
"""
|
||||
Responds to the request to stop a loaded video
|
||||
"""
|
||||
log.debug(u'videoStop')
|
||||
self.frame.evaluateJavaScript("document.getElementById('video').pause()")
|
||||
self.frame.evaluateJavaScript(
|
||||
"document.getElementById('video').style.visibility = 'hidden'")
|
||||
self.frame.evaluateJavaScript('video("stop");')
|
||||
|
||||
def videoVolume(self, volume):
|
||||
"""
|
||||
Changes the volume of a running video
|
||||
"""
|
||||
log.debug(u'videoVolume %d' % volume)
|
||||
self.frame.evaluateJavaScript(
|
||||
"document.getElementById('video').volume = %s" %
|
||||
self.frame.evaluateJavaScript('video(null,null,%s);' %
|
||||
str(float(volume)/float(10)))
|
||||
|
||||
def video(self, videoPath, volume):
|
||||
@ -249,17 +258,18 @@ class MainDisplay(DisplayWidget):
|
||||
Loads and starts a video to run with the option of sound
|
||||
"""
|
||||
log.debug(u'video')
|
||||
self.frame.findFirstElement('video').setAttribute('src', videoPath)
|
||||
self.frame.evaluateJavaScript(
|
||||
"document.getElementById('video').style.visibility = 'visible'")
|
||||
self.videoPlay()
|
||||
self.videoVolume(volume)
|
||||
self.loaded = True
|
||||
js = 'video("play","%s",%s,true);' % \
|
||||
(videoPath.replace("\\", "\\\\"), str(float(volume)/float(10)))
|
||||
self.frame.evaluateJavaScript(js)
|
||||
print js
|
||||
return self.preview()
|
||||
|
||||
def loaded(self):
|
||||
"""
|
||||
Called by webView event to show display is fully loaded
|
||||
"""
|
||||
log.debug(u'loaded')
|
||||
self.loaded = True
|
||||
|
||||
def preview(self):
|
||||
@ -267,10 +277,12 @@ class MainDisplay(DisplayWidget):
|
||||
Generates a preview of the image displayed.
|
||||
"""
|
||||
log.debug(u'preview')
|
||||
# Wait for the webview to update before geting the preview.
|
||||
# Important otherwise first preview will miss the background !
|
||||
# Wait for the fade to finish before geting the preview.
|
||||
# Important otherwise preview will have incorrect text if at all !
|
||||
while self.frame.evaluateJavaScript("fadeFinished()").toString() == u'false':
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
# Wait for the webview to update before geting the preview.
|
||||
# Important otherwise first preview will miss the background !
|
||||
while not self.loaded:
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
preview = QtGui.QImage(self.screen[u'size'].width(),
|
||||
@ -308,6 +320,7 @@ class MainDisplay(DisplayWidget):
|
||||
self.frame.evaluateJavaScript(
|
||||
"document.getElementById('blank').style.visibility = 'visible'")
|
||||
if mode == HideMode.Screen:
|
||||
self.frame.evaluateJavaScript('blankState("desktop");')
|
||||
self.setVisible(False)
|
||||
elif mode == HideMode.Blank or self.initialFrame:
|
||||
self.frame.evaluateJavaScript('blankState("black");')
|
||||
|
@ -758,5 +758,6 @@ class ThemeManager(QtGui.QWidget):
|
||||
#theme.theme_version
|
||||
# Remove the Transparent settings as they are not relevent
|
||||
if theme.background_mode == u'transparent':
|
||||
theme.background_mode = u'opaque'
|
||||
theme.background_type = u'solid'
|
||||
theme.background_startColor = u'#000000'
|
||||
|
Loading…
Reference in New Issue
Block a user