Head r1903

This commit is contained in:
Jon Tibble 2012-03-12 22:16:52 +00:00
commit 8e7eca36c7
6 changed files with 30 additions and 15 deletions

View File

@ -578,12 +578,13 @@ class MediaController(object):
video_list.append(item)
return video_list
def override_player(self, override_player):
def override_player(self, override_player_index):
playerSettings = str(QtCore.QSettings().value(u'media/players',
QtCore.QVariant(u'webkit')).toString())
usedPlayers = playerSettings.split(u',')
if override_player in usedPlayers:
self.overriddenPlayer = override_player
if override_player_index >= 0 and \
override_player_index < len(usedPlayers):
self.overridenPlayer = usedPlayers[override_player_index]
else:
self.overriddenPlayer = ''

View File

@ -63,6 +63,8 @@ class PhononPlayer(MediaPlayer):
def __init__(self, parent):
MediaPlayer.__init__(self, parent, u'phonon')
self.original_name = u'Phonon'
self.display_name = u'&Phonon'
self.parent = parent
self.additional_extensions = ADDITIONAL_EXT
mimetypes.init()

View File

@ -89,6 +89,8 @@ class VlcPlayer(MediaPlayer):
def __init__(self, parent):
MediaPlayer.__init__(self, parent, u'vlc')
self.original_name = u'VLC'
self.display_name = u'&VLC'
self.parent = parent
self.canFolder = True
self.audio_extensions_list = AUDIO_EXT

View File

@ -260,6 +260,8 @@ class WebkitPlayer(MediaPlayer):
def __init__(self, parent):
MediaPlayer.__init__(self, parent, u'webkit')
self.original_name = u'WebKit'
self.display_name = u'&WebKit'
self.parent = parent
self.canBackground = True
self.audio_extensions_list = AUDIO_EXT

View File

@ -142,8 +142,8 @@ class MediaMediaItem(MediaManagerItem):
self.overridePlayerChanged)
def overridePlayerChanged(self, index):
Receiver.send_message(u'media_override_player', \
u'%s' % self.displayTypeComboBox.currentText())
# index - 1, because the first item is "Automatic".
Receiver.send_message(u'media_override_player', index - 1)
def onResetClick(self):
"""
@ -249,9 +249,10 @@ class MediaMediaItem(MediaManagerItem):
playerSettings = str(QtCore.QSettings().value(u'media/players',
QtCore.QVariant(u'webkit')).toString())
usedPlayers = playerSettings.split(u',')
for title in usedPlayers:
mediaPlayers = self.plugin.mediaController.mediaPlayers
for player in usedPlayers:
# load the drop down selection
self.displayTypeComboBox.addItem(title)
self.displayTypeComboBox.addItem(mediaPlayers[player].original_name)
if self.displayTypeComboBox.count() > 1:
self.displayTypeComboBox.insertItem(0, self.automatic)
self.displayTypeComboBox.setCurrentIndex(0)

View File

@ -30,6 +30,14 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import SettingsTab, translate, Receiver
from openlp.core.lib.ui import UiStrings, create_up_down_push_button_set
class MediaQCheckBox(QtGui.QCheckBox):
"""
MediaQCheckBox adds an extra property, playerName to the QCheckBox class.
"""
def setPlayerName(self, name):
self.playerName = name
class MediaTab(SettingsTab):
"""
MediaTab is the Media settings tab in the settings dialog.
@ -49,7 +57,7 @@ class MediaTab(SettingsTab):
self.playerCheckBoxes = {}
for key, player in self.mediaPlayers.iteritems():
player = self.mediaPlayers[key]
checkbox = QtGui.QCheckBox(self.mediaPlayerGroupBox)
checkbox = MediaQCheckBox(self.mediaPlayerGroupBox)
checkbox.setEnabled(player.available)
checkbox.setObjectName(player.name + u'CheckBox')
self.playerCheckBoxes[player.name] = checkbox
@ -109,12 +117,13 @@ class MediaTab(SettingsTab):
for key in self.mediaPlayers:
player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name]
checkbox.setPlayerName(player.name)
if player.available:
checkbox.setText(player.name)
checkbox.setText(player.display_name)
else:
checkbox.setText(
unicode(translate('MediaPlugin.MediaTab',
'%s (unavailable)')) % player.name)
'%s (unavailable)')) % player.display_name)
self.playerOrderGroupBox.setTitle(
translate('MediaPlugin.MediaTab', 'Player Order'))
self.advancedGroupBox.setTitle(UiStrings().Advanced)
@ -123,7 +132,7 @@ class MediaTab(SettingsTab):
'Allow media player to be overridden'))
def onPlayerCheckBoxChanged(self, check_state):
player = self.sender().text()
player = self.sender().playerName
if check_state == QtCore.Qt.Checked:
if player not in self.usedPlayers:
self.usedPlayers.append(player)
@ -141,7 +150,8 @@ class MediaTab(SettingsTab):
self.playerCheckBoxes[u'%s' % player].setEnabled(False)
else:
self.playerCheckBoxes[u'%s' % player].setEnabled(True)
self.playerOrderlistWidget.addItem(player)
self.playerOrderlistWidget.addItem(
self.mediaPlayers[unicode(player)].original_name)
def onUpButtonClicked(self):
row = self.playerOrderlistWidget.currentRow()
@ -162,9 +172,6 @@ class MediaTab(SettingsTab):
self.usedPlayers.move(row, row + 1)
def load(self):
if self.savedUsedPlayers:
self.usedPlayers = self.savedUsedPlayers
self.savedUsedPlayers = None
self.usedPlayers = QtCore.QSettings().value(
self.settingsSection + u'/players',
QtCore.QVariant(u'webkit')).toString().split(u',')