Merge trunk.

This commit is contained in:
Mattias Põldaru 2012-01-15 03:34:08 +02:00
commit ba0ab63149
9 changed files with 109 additions and 39 deletions

View File

@ -45,6 +45,7 @@ HTMLSRC = u"""
padding: 0;
border: 0;
overflow: hidden;
-webkit-user-select: none;
}
body {
%s;
@ -129,10 +130,10 @@ sup {
var match = /-webkit-text-fill-color:[^;\"]+/gi;
if(timer != null)
clearTimeout(timer);
/*
QtWebkit bug with outlines and justify causing outline alignment
problems. (Bug 859950) Surround each word with a <span> to workaround,
but only in this scenario.
/*
QtWebkit bug with outlines and justify causing outline alignment
problems. (Bug 859950) Surround each word with a <span> to workaround,
but only in this scenario.
*/
var txt = document.getElementById('lyricsmain');
if(window.getComputedStyle(txt).textAlign == 'justify'){
@ -141,7 +142,7 @@ sup {
txt = outline;
if(window.getComputedStyle(txt).webkitTextStrokeWidth != '0px'){
newtext = newtext.replace(/(\s|&nbsp;)+(?![^<]*>)/g,
function(match) {
function(match) {
return '</span>' + match + '<span>';
});
newtext = '<span>' + newtext + '</span>';
@ -288,6 +289,9 @@ def build_background_css(item, width, height):
background = u'background-color: black'
if theme:
if theme.background_type == \
BackgroundType.to_string(BackgroundType.Transparent):
background = u''
elif theme.background_type == \
BackgroundType.to_string(BackgroundType.Solid):
background = u'background-color: %s' % theme.background_color
else:

View File

@ -100,6 +100,7 @@ class BackgroundType(object):
Solid = 0
Gradient = 1
Image = 2
Transparent = 3
@staticmethod
def to_string(background_type):
@ -112,6 +113,8 @@ class BackgroundType(object):
return u'gradient'
elif background_type == BackgroundType.Image:
return u'image'
elif background_type == BackgroundType.Transparent:
return u'transparent'
@staticmethod
def from_string(type_string):
@ -124,6 +127,8 @@ class BackgroundType(object):
return BackgroundType.Gradient
elif type_string == u'image':
return BackgroundType.Image
elif type_string == u'transparent':
return BackgroundType.Transparent
class BackgroundGradientType(object):
@ -246,7 +251,7 @@ class ThemeXML(object):
Add a transparent background.
"""
background = self.theme_xml.createElement(u'background')
background.setAttribute(u'mode', u'transparent')
background.setAttribute(u'type', u'transparent')
self.theme.appendChild(background)
def add_background_solid(self, bkcolor):
@ -487,25 +492,25 @@ class ThemeXML(object):
return
xml_iter = theme_xml.getiterator()
for element in xml_iter:
parent = element.getparent()
master = u''
if element.tag == u'background':
if element.attrib:
for attr in element.attrib:
self._create_attr(element.tag, attr, \
element.attrib[attr])
parent = element.getparent()
if parent is not None:
if element.getparent().tag == u'font':
master = element.getparent().tag + u'_' + \
element.getparent().attrib[u'type']
if parent.tag == u'font':
master = parent.tag + u'_' + parent.attrib[u'type']
# set up Outline and Shadow Tags and move to font_main
if element.getparent().tag == u'display':
if parent.tag == u'display':
if element.tag.startswith(u'shadow') or \
element.tag.startswith(u'outline'):
self._create_attr(u'font_main', element.tag,
element.text)
master = element.getparent().tag
if element.getparent().tag == u'background':
master = element.getparent().tag
if element.getparent().attrib:
for attr in element.getparent().attrib:
self._create_attr(master, attr, \
element.getparent().attrib[attr])
master = parent.tag
if parent.tag == u'background':
master = parent.tag
if master:
self._create_attr(master, element.tag, element.text)
if element.attrib:
@ -599,9 +604,13 @@ class ThemeXML(object):
self.background_start_color,
self.background_end_color,
self.background_direction)
else:
elif self.background_type == \
BackgroundType.to_string(BackgroundType.Image):
filename = os.path.split(self.background_filename)[1]
self.add_background_image(filename, self.background_border_color)
elif self.background_type == \
BackgroundType.to_string(BackgroundType.Transparent):
self.add_background_transparent()
self.add_font(self.font_main_name,
self.font_main_color,
self.font_main_size,

View File

@ -29,7 +29,7 @@ The :mod:`advancedtab` provides an advanced settings facility.
"""
from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate, build_icon
from openlp.core.lib import SettingsTab, translate, build_icon, Receiver
from openlp.core.lib.ui import UiStrings
from openlp.core.utils import get_images_filter
from datetime import datetime, timedelta
@ -44,6 +44,7 @@ class AdvancedTab(SettingsTab):
"""
Initialise the settings tab
"""
self.display_changed = False
advancedTranslated = translate('OpenLP.AdvancedTab', 'Advanced')
# 7 stands for now, 0 to 6 is Monday to Sunday.
self.default_service_day = 0
@ -186,6 +187,14 @@ class AdvancedTab(SettingsTab):
self.hideMouseCheckBox.setObjectName(u'hideMouseCheckBox')
self.hideMouseLayout.addWidget(self.hideMouseCheckBox)
self.rightLayout.addWidget(self.hideMouseGroupBox)
self.x11GroupBox = QtGui.QGroupBox(self.leftColumn)
self.x11GroupBox.setObjectName(u'x11GroupBox')
self.x11Layout = QtGui.QVBoxLayout(self.x11GroupBox)
self.x11Layout.setObjectName(u'x11Layout')
self.x11BypassCheckBox = QtGui.QCheckBox(self.x11GroupBox)
self.x11BypassCheckBox.setObjectName(u'x11BypassCheckBox')
self.x11Layout.addWidget(self.x11BypassCheckBox)
self.rightLayout.addWidget(self.x11GroupBox)
self.rightLayout.addStretch()
QtCore.QObject.connect(self.defaultServiceDay,
@ -206,6 +215,8 @@ class AdvancedTab(SettingsTab):
QtCore.SIGNAL(u'pressed()'), self.onDefaultBrowseButtonPressed)
QtCore.QObject.connect(self.defaultRevertButton,
QtCore.SIGNAL(u'pressed()'), self.onDefaultRevertButtonPressed)
QtCore.QObject.connect(self.x11BypassCheckBox,
QtCore.SIGNAL(u'toggled(bool)'), self.onX11BypassCheckBoxToggled)
def retranslateUi(self):
"""
@ -279,6 +290,10 @@ class AdvancedTab(SettingsTab):
'Browse for an image file to display.'))
self.defaultRevertButton.setToolTip(translate('OpenLP.AdvancedTab',
'Revert to the default OpenLP logo.'))
self.x11GroupBox.setTitle(translate('OpenLP.AdvancedTab',
'X11'))
self.x11BypassCheckBox.setText(translate('OpenLP.AdvancedTab',
'Bypass X11 Window Manager'))
def load(self):
"""
@ -322,6 +337,8 @@ class AdvancedTab(SettingsTab):
self.defaultServiceTime.setTime(
QtCore.QTime(self.service_hour, self.service_minute))
self.defaultServiceName.setText(self.service_name)
self.x11BypassCheckBox.setChecked(
settings.value(u'x11 bypass wm', QtCore.QVariant(True)).toBool())
self.default_color = settings.value(u'default color',
QtCore.QVariant(u'#ffffff')).toString()
self.defaultFileEdit.setText(settings.value(u'default image',
@ -364,9 +381,14 @@ class AdvancedTab(SettingsTab):
QtCore.QVariant(self.enableAutoCloseCheckBox.isChecked()))
settings.setValue(u'hide mouse',
QtCore.QVariant(self.hideMouseCheckBox.isChecked()))
settings.setValue(u'x11 bypass wm',
QtCore.QVariant(self.x11BypassCheckBox.isChecked()))
settings.setValue(u'default color', self.default_color)
settings.setValue(u'default image', self.defaultFileEdit.text())
settings.endGroup()
if self.display_changed:
Receiver.send_message(u'config_screen_changed')
self.display_changed = False
def generate_service_name_example(self):
preset_is_valid = True
@ -430,3 +452,12 @@ class AdvancedTab(SettingsTab):
def onDefaultRevertButtonPressed(self):
self.defaultFileEdit.setText(u':/graphics/openlp-splash-screen.png')
self.defaultFileEdit.setFocus()
def onX11BypassCheckBoxToggled(self, checked):
"""
Toggle X11 bypass flag on maindisplay depending on check box state.
``checked``
The state of the check box (boolean).
"""
self.display_changed = True

View File

@ -28,6 +28,7 @@
The :mod:`maindisplay` module provides the functionality to display screens
and play multimedia within OpenLP.
"""
import cgi
import logging
import os
import sys
@ -36,7 +37,7 @@ from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
from PyQt4.phonon import Phonon
from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte, \
translate, PluginManager
translate, PluginManager, expand_tags
from openlp.core.ui import HideMode, ScreenList, AlertLocation
@ -81,6 +82,10 @@ class Display(QtGui.QGraphicsView):
self.screen[u'size'].width(), self.screen[u'size'].height())
self.webView.settings().setAttribute(
QtWebKit.QWebSettings.PluginsEnabled, True)
palette = self.webView.palette()
palette.setBrush(QtGui.QPalette.Base, QtCore.Qt.transparent)
self.webView.page().setPalette(palette)
self.webView.setAttribute(QtCore.Qt.WA_OpaquePaintEvent, False)
self.page = self.webView.page()
self.frame = self.page.mainFrame()
if self.isLive and log.getEffectiveLevel() == logging.DEBUG:
@ -129,7 +134,8 @@ class MainDisplay(Display):
self.setStyleSheet(u'border: 0px; margin: 0px; padding: 0px;')
windowFlags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | \
QtCore.Qt.WindowStaysOnTopHint
if os.environ.get(u'XDG_CURRENT_DESKTOP') == u'Unity':
if QtCore.QSettings().value(u'advanced/x11 bypass wm',
QtCore.QVariant(True)).toBool():
windowFlags = windowFlags | QtCore.Qt.X11BypassWindowManagerHint
# FIXME: QtCore.Qt.SplashScreen is workaround to make display screen
# stay always on top on Mac OS X. For details see bug 906926.
@ -138,6 +144,7 @@ class MainDisplay(Display):
windowFlags = windowFlags | QtCore.Qt.SplashScreen
self.setWindowFlags(windowFlags)
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
if self.isLive:
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'live_display_hide'), self.hideDisplay)
@ -236,16 +243,17 @@ class MainDisplay(Display):
The text to be displayed.
"""
log.debug(u'alert to display')
# First we convert <>& marks to html variants, then apply
# formattingtags, finally we double all backslashes for JavaScript.
text_prepared = expand_tags(cgi.escape(text)) \
.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"')
if self.height() != self.screen[u'size'].height() or \
not self.isVisible():
shrink = True
js = u'show_alert("%s", "%s")' % (
text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'),
u'top')
js = u'show_alert("%s", "%s")' % (text_prepared, u'top')
else:
shrink = False
js = u'show_alert("%s", "")' % (
text.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'))
js = u'show_alert("%s", "")' % text_prepared
height = self.frame.evaluateJavaScript(js)
if shrink:
if text:
@ -346,13 +354,7 @@ class MainDisplay(Display):
self.setVisible(True)
else:
self.setVisible(True)
preview = QtGui.QPixmap(self.screen[u'size'].width(),
self.screen[u'size'].height())
painter = QtGui.QPainter(preview)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
self.frame.render(painter)
painter.end()
return preview
return QtGui.QPixmap.grabWidget(self)
def buildHtml(self, serviceItem, image=None):
"""

View File

@ -596,7 +596,10 @@ class ServiceManager(QtGui.QWidget):
self.mainwindow.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
if success:
shutil.copy(temp_file_name, path_file_name)
try:
shutil.copy(temp_file_name, path_file_name)
except:
return self.saveFileAs()
self.mainwindow.addRecentFile(path_file_name)
self.setModified(False)
try:

View File

@ -359,11 +359,15 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
self.gradientEndButton.setStyleSheet(u'background-color: %s' %
self.theme.background_end_color)
self.setField(u'background_type', QtCore.QVariant(1))
else:
elif self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Image):
self.imageColorButton.setStyleSheet(u'background-color: %s' %
self.theme.background_border_color)
self.imageFileEdit.setText(self.theme.background_filename)
self.setField(u'background_type', QtCore.QVariant(2))
elif self.theme.background_type == \
BackgroundType.to_string(BackgroundType.Transparent):
self.setField(u'background_type', QtCore.QVariant(3))
if self.theme.background_direction == \
BackgroundGradientType.to_string(BackgroundGradientType.Horizontal):
self.setField(u'gradient', QtCore.QVariant(0))

View File

@ -813,10 +813,13 @@ class ThemeManager(QtGui.QWidget):
unicode(theme.BackgroundParameter1.name())
newtheme.background_end_color = \
unicode(theme.BackgroundParameter2.name())
else:
elif theme.BackgroundType == 2:
newtheme.background_type = \
BackgroundType.to_string(BackgroundType.Image)
newtheme.background_filename = unicode(theme.BackgroundParameter1)
elif theme.BackgroundType == 3:
newtheme.background_type = \
BackgroundType.to_string(BackgroundType.Transparent)
newtheme.font_main_name = theme.FontName
newtheme.font_main_color = unicode(theme.FontColor.name())
newtheme.font_main_size = theme.FontProportion * 3

View File

@ -54,7 +54,7 @@ class Ui_ThemeWizard(object):
self.backgroundLabel = QtGui.QLabel(self.backgroundPage)
self.backgroundLabel.setObjectName(u'BackgroundLabel')
self.backgroundComboBox = QtGui.QComboBox(self.backgroundPage)
self.backgroundComboBox.addItems([u'', u'', u''])
self.backgroundComboBox.addItems([u'', u'', u'', u''])
self.backgroundComboBox.setObjectName(u'BackgroundComboBox')
self.backgroundTypeLayout.addRow(self.backgroundLabel,
self.backgroundComboBox)
@ -126,6 +126,12 @@ class Ui_ThemeWizard(object):
self.imageLayout.addRow(self.imageLabel, self.imageFileLayout)
self.imageLayout.setItem(2, QtGui.QFormLayout.LabelRole, self.spacer)
self.backgroundStack.addWidget(self.imageWidget)
self.transparentWidget = QtGui.QWidget(self.backgroundPage)
self.transparentWidget.setObjectName(u'TransparentWidget')
self.transparentLayout = QtGui.QFormLayout(self.transparentWidget)
self.transparentLayout.setMargin(0)
self.transparentLayout.setObjectName(u'TransparentLayout')
self.backgroundStack.addWidget(self.transparentWidget)
self.backgroundLayout.addLayout(self.backgroundStack)
themeWizard.addPage(self.backgroundPage)
# Main Area Page
@ -432,6 +438,8 @@ class Ui_ThemeWizard(object):
translate('OpenLP.ThemeWizard', 'Gradient'))
self.backgroundComboBox.setItemText(
BackgroundType.Image, UiStrings().Image)
self.backgroundComboBox.setItemText(BackgroundType.Transparent,
translate('OpenLP.ThemeWizard', 'Transparent'))
self.colorLabel.setText(translate('OpenLP.ThemeWizard', 'Color:'))
self.gradientStartLabel.setText(
translate(u'OpenLP.ThemeWizard', 'Starting color:'))

View File

@ -40,6 +40,7 @@ class PresentationTab(SettingsTab):
"""
self.controllers = controllers
SettingsTab.__init__(self, parent, title, visible_title, icon_path)
self.activated = False
def setupUi(self):
"""
@ -110,8 +111,12 @@ class PresentationTab(SettingsTab):
def save(self):
"""
Save the settings.
Save the settings. If the tab hasn't been made visible to the user
then there is nothing to do, so exit. This removes the need to
start presentation applications unnecessarily.
"""
if not self.activated:
return
changed = False
for key in self.controllers:
controller = self.controllers[key]
@ -140,6 +145,7 @@ class PresentationTab(SettingsTab):
"""
Tab has just been made visible to the user
"""
self.activated = True
for key in self.controllers:
controller = self.controllers[key]
checkbox = self.PresenterCheckboxes[controller.name]