forked from openlp/openlp
Fix theme wizard so Outline and Shadow check boxes are checked
Latch image background changes until the theme changes. Turn off the rest background if the image or video has been changed from the plugin and the theme changes. bzr-revno: 1244
This commit is contained in:
commit
8e2b3a164c
@ -314,7 +314,7 @@ body {
|
||||
</html>
|
||||
"""
|
||||
|
||||
def build_html(item, screen, alert, islive):
|
||||
def build_html(item, screen, alert, islive, background):
|
||||
"""
|
||||
Build the full web paged structure for display
|
||||
|
||||
@ -332,7 +332,9 @@ def build_html(item, screen, alert, islive):
|
||||
theme = item.themedata
|
||||
webkitvers = webkit_version()
|
||||
# Image generated and poked in
|
||||
if item.bg_image_bytes:
|
||||
if background:
|
||||
image = u'src="data:image/png;base64,%s"' % background
|
||||
elif item.bg_image_bytes:
|
||||
image = u'src="data:image/png;base64,%s"' % item.bg_image_bytes
|
||||
else:
|
||||
image = u'style="display:none;"'
|
||||
|
@ -67,6 +67,7 @@ class MainDisplay(DisplayWidget):
|
||||
self.isLive = live
|
||||
self.alertTab = None
|
||||
self.hideMode = None
|
||||
self.override = {}
|
||||
mainIcon = build_icon(u':/icon/openlp-logo-16x16.png')
|
||||
self.setWindowIcon(mainIcon)
|
||||
self.retranslateUi()
|
||||
@ -111,7 +112,7 @@ class MainDisplay(DisplayWidget):
|
||||
self.page = self.webView.page()
|
||||
self.frame = self.page.mainFrame()
|
||||
QtCore.QObject.connect(self.webView,
|
||||
QtCore.SIGNAL(u'loadFinished(bool)'), self.isLoaded)
|
||||
QtCore.SIGNAL(u'loadFinished(bool)'), self.isWebLoaded)
|
||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.frame.setScrollBarPolicy(QtCore.Qt.Vertical,
|
||||
@ -137,14 +138,14 @@ class MainDisplay(DisplayWidget):
|
||||
painter_image.begin(initialFrame)
|
||||
painter_image.fillRect(initialFrame.rect(), QtCore.Qt.white)
|
||||
painter_image.drawImage(
|
||||
(self.screens.current[u'size'].width() -
|
||||
(self.screens.current[u'size'].width() -
|
||||
splash_image.width()) / 2,
|
||||
(self.screens.current[u'size'].height()
|
||||
- splash_image.height()) / 2, splash_image)
|
||||
serviceItem = ServiceItem()
|
||||
serviceItem.bg_image_bytes = image_to_byte(initialFrame)
|
||||
self.webView.setHtml(build_html(serviceItem, self.screen,
|
||||
self.parent.alertTab, self.isLive))
|
||||
self.parent.alertTab, self.isLive, None))
|
||||
self.initialFrame = True
|
||||
# To display or not to display?
|
||||
if not self.screen[u'primary']:
|
||||
@ -162,7 +163,7 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
log.debug(u'text to display')
|
||||
# Wait for the webview to update before displaying text.
|
||||
while not self.loaded:
|
||||
while not self.webLoaded:
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
self.frame.evaluateJavaScript(u'show_text("%s")' % \
|
||||
slide.replace(u'\\', u'\\\\').replace(u'\"', u'\\\"'))
|
||||
@ -204,14 +205,17 @@ class MainDisplay(DisplayWidget):
|
||||
"""
|
||||
self.imageManager.add_image(name, path)
|
||||
self.image(name)
|
||||
if hasattr(self, u'serviceItem'):
|
||||
self.override[u'image'] = name
|
||||
self.override[u'theme'] = self.serviceItem.themedata.theme_name
|
||||
|
||||
def image(self, name):
|
||||
"""
|
||||
Add an image as the background. The image is converted to a bytestream
|
||||
on route.
|
||||
Add an image as the background. The image has already been added
|
||||
to the cache.
|
||||
|
||||
`Image`
|
||||
The Image to be displayed can be QImage or QPixmap
|
||||
The name of the image to be displayed
|
||||
"""
|
||||
log.debug(u'image to display')
|
||||
image = self.imageManager.get_image_bytes(name)
|
||||
@ -313,7 +317,10 @@ class MainDisplay(DisplayWidget):
|
||||
Loads and starts a video to run with the option of sound
|
||||
"""
|
||||
log.debug(u'video')
|
||||
self.loaded = True
|
||||
self.webLoaded = True
|
||||
# We are running a background theme
|
||||
self.override[u'theme'] = u''
|
||||
self.override[u'video'] = True
|
||||
vol = float(volume)/float(10)
|
||||
if isBackground or not self.usePhonon:
|
||||
js = u'show_video("init", "%s", %s, true); show_video("play");' % \
|
||||
@ -333,12 +340,12 @@ class MainDisplay(DisplayWidget):
|
||||
Receiver.send_message(u'maindisplay_active')
|
||||
return self.preview()
|
||||
|
||||
def isLoaded(self):
|
||||
def isWebLoaded(self):
|
||||
"""
|
||||
Called by webView event to show display is fully loaded
|
||||
"""
|
||||
log.debug(u'loaded')
|
||||
self.loaded = True
|
||||
log.debug(u'Webloaded')
|
||||
self.webLoaded = True
|
||||
|
||||
def preview(self):
|
||||
"""
|
||||
@ -357,7 +364,7 @@ class MainDisplay(DisplayWidget):
|
||||
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:
|
||||
while not self.webLoaded:
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
# if was hidden keep it hidden
|
||||
if self.isLive:
|
||||
@ -379,18 +386,32 @@ class MainDisplay(DisplayWidget):
|
||||
HTML to the display
|
||||
"""
|
||||
log.debug(u'buildHtml')
|
||||
self.loaded = False
|
||||
self.webLoaded = False
|
||||
self.initialFrame = False
|
||||
self.serviceItem = serviceItem
|
||||
background = None
|
||||
# We have an image override so keep the image till the theme changes
|
||||
if self.override:
|
||||
# We have an video override so allow it to be stopped
|
||||
if u'video' in self.override:
|
||||
Receiver.send_message(u'video_background_replaced')
|
||||
self.override = {}
|
||||
elif self.override[u'theme'] != \
|
||||
serviceItem.themedata.theme_name:
|
||||
Receiver.send_message(u'live_theme_changed')
|
||||
self.override = {}
|
||||
else:
|
||||
background = self.imageManager. \
|
||||
get_image_bytes(self.override[u'image'])
|
||||
if self.serviceItem.themedata.background_filename:
|
||||
self.serviceItem.bg_image_bytes = self.imageManager. \
|
||||
get_image_bytes(self.serviceItem.themedata.theme_name)
|
||||
html = build_html(self.serviceItem, self.screen, self.parent.alertTab,
|
||||
self.isLive)
|
||||
self.isLive, background)
|
||||
log.debug(u'buildHtml - pre setHtml')
|
||||
self.webView.setHtml(html)
|
||||
log.debug(u'buildHtml - post setHtml')
|
||||
if serviceItem.foot_text and serviceItem.foot_text:
|
||||
if serviceItem.foot_text:
|
||||
self.footer(serviceItem.foot_text)
|
||||
# if was hidden keep it hidden
|
||||
if self.hideMode and self.isLive:
|
||||
|
@ -250,25 +250,27 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard):
|
||||
"""
|
||||
Change state as Outline check box changed
|
||||
"""
|
||||
if state == QtCore.Qt.Checked:
|
||||
self.theme.font_main_outline = True
|
||||
else:
|
||||
self.theme.font_main_outline = False
|
||||
self.outlineColorButton.setEnabled(self.theme.font_main_outline)
|
||||
self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline)
|
||||
self.calculateLines()
|
||||
if self.updateThemeAllowed:
|
||||
if state == QtCore.Qt.Checked:
|
||||
self.theme.font_main_outline = True
|
||||
else:
|
||||
self.theme.font_main_outline = False
|
||||
self.outlineColorButton.setEnabled(self.theme.font_main_outline)
|
||||
self.outlineSizeSpinBox.setEnabled(self.theme.font_main_outline)
|
||||
self.calculateLines()
|
||||
|
||||
def onShadowCheckCheckBoxStateChanged(self, state):
|
||||
"""
|
||||
Change state as Shadow check box changed
|
||||
"""
|
||||
if state == QtCore.Qt.Checked:
|
||||
self.theme.font_main_shadow = True
|
||||
else:
|
||||
self.theme.font_main_shadow = False
|
||||
self.shadowColorButton.setEnabled(self.theme.font_main_shadow)
|
||||
self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow)
|
||||
self.calculateLines()
|
||||
if self.updateThemeAllowed:
|
||||
if state == QtCore.Qt.Checked:
|
||||
self.theme.font_main_shadow = True
|
||||
else:
|
||||
self.theme.font_main_shadow = False
|
||||
self.shadowColorButton.setEnabled(self.theme.font_main_shadow)
|
||||
self.shadowSizeSpinBox.setEnabled(self.theme.font_main_shadow)
|
||||
self.calculateLines()
|
||||
|
||||
def onMainPositionCheckBoxStateChanged(self, value):
|
||||
"""
|
||||
|
@ -31,7 +31,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||
ItemCapabilities, SettingsManager, translate, check_item_selected, \
|
||||
check_directory_exists
|
||||
check_directory_exists, Receiver
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
from openlp.core.utils import AppLocation, delete_file, get_images_filter
|
||||
|
||||
@ -44,7 +44,6 @@ class ImageListView(BaseListWithDnD):
|
||||
self.PluginName = u'Images'
|
||||
BaseListWithDnD.__init__(self, parent)
|
||||
|
||||
|
||||
class ImageMediaItem(MediaManagerItem):
|
||||
"""
|
||||
This is the custom media manager item for images.
|
||||
@ -57,6 +56,8 @@ class ImageMediaItem(MediaManagerItem):
|
||||
# be instanced by the base MediaManagerItem.
|
||||
self.ListViewWithDnD_class = ImageListView
|
||||
MediaManagerItem.__init__(self, parent, self, icon)
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.OnNewPrompt = translate('ImagePlugin.MediaItem',
|
||||
@ -193,6 +194,12 @@ class ImageMediaItem(MediaManagerItem):
|
||||
self.resetAction.setVisible(False)
|
||||
self.parent.liveController.display.resetImage()
|
||||
|
||||
def liveThemeChanged(self):
|
||||
"""
|
||||
Triggered by the change of theme in the slide controller
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
Called to replace Live backgound with the image selected.
|
||||
|
@ -30,7 +30,7 @@ import os
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
|
||||
ItemCapabilities, SettingsManager, translate, check_item_selected
|
||||
ItemCapabilities, SettingsManager, translate, check_item_selected, Receiver
|
||||
from openlp.core.ui import criticalErrorMessageBox
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -58,6 +58,9 @@ class MediaMediaItem(MediaManagerItem):
|
||||
MediaManagerItem.__init__(self, parent, self, icon)
|
||||
self.singleServiceItem = False
|
||||
self.serviceItemIconName = u':/media/image_clapperboard.png'
|
||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||
QtCore.SIGNAL(u'video_background_replaced'),
|
||||
self.videobackgroundReplaced)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.OnNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media')
|
||||
@ -99,6 +102,12 @@ class MediaMediaItem(MediaManagerItem):
|
||||
self.resetAction.setVisible(False)
|
||||
self.parent.liveController.display.resetVideo()
|
||||
|
||||
def videobackgroundReplaced(self):
|
||||
"""
|
||||
Triggered by main display on change of serviceitem
|
||||
"""
|
||||
self.resetAction.setVisible(False)
|
||||
|
||||
def onReplaceClick(self):
|
||||
"""
|
||||
Called to replace Live backgound with the media selected.
|
||||
|
Loading…
Reference in New Issue
Block a user