Change background color of video

This commit is contained in:
Tim Bentley 2012-09-29 19:36:30 +01:00
parent a3e41b1ee7
commit ee126c9924
3 changed files with 65 additions and 5 deletions

View File

@ -295,7 +295,6 @@ class MediaController(object):
Loads and starts a video to run with the option of sound Loads and starts a video to run with the option of sound
""" """
log.debug(u'video') log.debug(u'video')
print "hallo mum"
isValid = False isValid = False
# stop running videos # stop running videos
self.video_reset(controller) self.video_reset(controller)

View File

@ -55,6 +55,28 @@ class PlayerTab(SettingsTab):
def setupUi(self): def setupUi(self):
self.setObjectName(u'MediaTab') self.setObjectName(u'MediaTab')
SettingsTab.setupUi(self) SettingsTab.setupUi(self)
self.bgColorGroupBox = QtGui.QGroupBox(self.leftColumn)
self.bgColorGroupBox.setObjectName(u'FontGroupBox')
self.formLayout = QtGui.QFormLayout(self.bgColorGroupBox)
self.formLayout.setObjectName(u'FormLayout')
self.colorLayout = QtGui.QHBoxLayout()
self.backgroundColorLabel = QtGui.QLabel(self.bgColorGroupBox)
self.backgroundColorLabel.setObjectName(u'BackgroundColorLabel')
self.colorLayout.addWidget(self.backgroundColorLabel)
self.backgroundColorButton = QtGui.QPushButton(self.bgColorGroupBox)
self.backgroundColorButton.setObjectName(u'BackgroundColorButton')
self.colorLayout.addWidget(self.backgroundColorButton)
self.formLayout.addRow(self.colorLayout)
self.informationLabel = QtGui.QLabel(self.bgColorGroupBox)
self.informationLabel.setObjectName(u'InformationLabel')
self.informationLabel.setWordWrap(True)
self.formLayout.addRow(self.informationLabel)
self.leftLayout.addWidget(self.bgColorGroupBox)
self.leftLayout.addStretch()
self.rightColumn.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
self.rightLayout.addStretch()
self.mediaPlayerGroupBox = QtGui.QGroupBox(self.leftColumn) self.mediaPlayerGroupBox = QtGui.QGroupBox(self.leftColumn)
self.mediaPlayerGroupBox.setObjectName(u'mediaPlayerGroupBox') self.mediaPlayerGroupBox.setObjectName(u'mediaPlayerGroupBox')
self.mediaPlayerLayout = QtGui.QVBoxLayout(self.mediaPlayerGroupBox) self.mediaPlayerLayout = QtGui.QVBoxLayout(self.mediaPlayerGroupBox)
@ -109,6 +131,9 @@ class PlayerTab(SettingsTab):
QtCore.QObject.connect(checkbox, QtCore.QObject.connect(checkbox,
QtCore.SIGNAL(u'stateChanged(int)'), QtCore.SIGNAL(u'stateChanged(int)'),
self.onPlayerCheckBoxChanged) self.onPlayerCheckBoxChanged)
# Signals and slots
QtCore.QObject.connect(self.backgroundColorButton,
QtCore.SIGNAL(u'clicked()'), self.onbackgroundColorButtonClicked)
def retranslateUi(self): def retranslateUi(self):
self.mediaPlayerGroupBox.setTitle( self.mediaPlayerGroupBox.setTitle(
@ -125,6 +150,22 @@ class PlayerTab(SettingsTab):
'%s (unavailable)')) % player.display_name) '%s (unavailable)')) % player.display_name)
self.playerOrderGroupBox.setTitle( self.playerOrderGroupBox.setTitle(
translate('OpenLP.PlayerTab', 'Player Search Order')) translate('OpenLP.PlayerTab', 'Player Search Order'))
self.bgColorGroupBox.setTitle(
translate('ImagesPlugin.ImageTab', 'Background Color'))
self.backgroundColorLabel.setText(
translate('ImagesPlugin.ImageTab', 'Default Color:'))
self.informationLabel.setText(
translate('ImagesPlugin.ImageTab', 'Visible background for images '
'with aspect ratio different to screen.'))
def onbackgroundColorButtonClicked(self):
new_color = QtGui.QColorDialog.getColor(
QtGui.QColor(self.bg_color), self)
if new_color.isValid():
self.bg_color = new_color.name()
self.backgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color)
def onPlayerCheckBoxChanged(self, check_state): def onPlayerCheckBoxChanged(self, check_state):
player = self.sender().playerName player = self.sender().playerName
@ -178,10 +219,24 @@ class PlayerTab(SettingsTab):
checkbox.setChecked(True) checkbox.setChecked(True)
else: else:
checkbox.setChecked(False) checkbox.setChecked(False)
settings = Settings()
settings.beginGroup(self.settingsSection)
self.updatePlayerList() self.updatePlayerList()
self.bg_color = unicode(settings.value(
u'background color', QtCore.QVariant(u'#000000')).toString())
self.initial_color = self.bg_color
settings.endGroup()
self.backgroundColorButton.setStyleSheet(
u'background-color: %s' % self.bg_color)
def save(self): def save(self):
player_string_changed = False player_string_changed = False
settings = Settings()
settings.beginGroup(self.settingsSection)
settings.setValue(u'background color', QtCore.QVariant(self.bg_color))
settings.endGroup()
if self.initial_color != self.bg_color:
Receiver.send_message(u'image_updated')
old_players, override_player = get_media_players() old_players, override_player = get_media_players()
if self.usedPlayers != old_players: if self.usedPlayers != old_players:
# clean old Media stuff # clean old Media stuff

View File

@ -26,24 +26,27 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from PyQt4 import QtCore, QtGui
import logging import logging
from openlp.core.ui.media import MediaState from openlp.core.ui.media import MediaState
from openlp.core.ui.media.mediaplayer import MediaPlayer from openlp.core.ui.media.mediaplayer import MediaPlayer
from openlp.core.lib.settings import Settings
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
VIDEO_CSS = u""" VIDEO_CSS = u"""
#videobackboard { #videobackboard {
z-index:3; z-index:3;
background-color: black; background-color: %s;
} }
#video1 { #video1 {
background-color: black; background-color: %s;
z-index:4; z-index:4;
} }
#video2 { #video2 {
background-color: black; background-color: %s;
z-index:4; z-index:4;
} }
""" """
@ -278,7 +281,10 @@ class WebkitPlayer(MediaPlayer):
""" """
Add css style sheets to htmlbuilder Add css style sheets to htmlbuilder
""" """
return VIDEO_CSS + FLASH_CSS background = unicode(QtGui.QColor(Settings().value(
u'players/background color', QtCore.QVariant(u'#000000'))).name())
css = VIDEO_CSS % (background,background,background)
return css + FLASH_CSS
def get_media_display_javascript(self): def get_media_display_javascript(self):
""" """