Make media backend names translatable.

Fixes: https://launchpad.net/bugs/903683
This commit is contained in:
Mattias Põldaru 2012-03-05 23:09:31 +02:00
parent fc8e01ddd9
commit 1600e002cb
4 changed files with 14 additions and 9 deletions

View File

@ -31,7 +31,7 @@ from datetime import datetime
from PyQt4.phonon import Phonon from PyQt4.phonon import Phonon
from openlp.core.lib import Receiver from openlp.core.lib import Receiver, Translate
from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.lib.mediaplayer import MediaPlayer
from openlp.core.ui.media import MediaState from openlp.core.ui.media import MediaState
@ -63,6 +63,7 @@ class PhononPlayer(MediaPlayer):
def __init__(self, parent): def __init__(self, parent):
MediaPlayer.__init__(self, parent, u'phonon') MediaPlayer.__init__(self, parent, u'phonon')
self.display_name = translate('MediaPlugin.MediaTab', 'Phonon')
self.parent = parent self.parent = parent
self.additional_extensions = ADDITIONAL_EXT self.additional_extensions = ADDITIONAL_EXT
mimetypes.init() mimetypes.init()

View File

@ -43,7 +43,7 @@ except OSError, e:
raise raise
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver from openlp.core.lib import Receiver, translate
from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.lib.mediaplayer import MediaPlayer
from openlp.core.ui.media import MediaState from openlp.core.ui.media import MediaState
@ -89,6 +89,7 @@ class VlcPlayer(MediaPlayer):
def __init__(self, parent): def __init__(self, parent):
MediaPlayer.__init__(self, parent, u'vlc') MediaPlayer.__init__(self, parent, u'vlc')
self.display_name = translate('MediaPlugin.MediaTab', 'VLC')
self.parent = parent self.parent = parent
self.canFolder = True self.canFolder = True
self.audio_extensions_list = AUDIO_EXT self.audio_extensions_list = AUDIO_EXT

View File

@ -27,6 +27,7 @@
import logging import logging
from openlp.core.lib import translate
from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.lib.mediaplayer import MediaPlayer
from openlp.core.ui.media import MediaState from openlp.core.ui.media import MediaState
@ -260,6 +261,7 @@ class WebkitPlayer(MediaPlayer):
def __init__(self, parent): def __init__(self, parent):
MediaPlayer.__init__(self, parent, u'webkit') MediaPlayer.__init__(self, parent, u'webkit')
self.display_name = translate('MediaPlugin.MediaTab', 'WebKit')
self.parent = parent self.parent = parent
self.canBackground = True self.canBackground = True
self.audio_extensions_list = AUDIO_EXT self.audio_extensions_list = AUDIO_EXT

View File

@ -117,11 +117,11 @@ class MediaTab(SettingsTab):
player = self.mediaPlayers[key] player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name] checkbox = self.playerCheckBoxes[player.name]
if player.available: if player.available:
checkbox.setText(player.name) checkbox.setText(player.display_name)
else: else:
checkbox.setText( checkbox.setText(
unicode(translate('MediaPlugin.MediaTab', unicode(translate('MediaPlugin.MediaTab',
'%s (unavailable)')) % player.name) '%s (unavailable)')) % player.display_name)
self.playerOrderGroupBox.setTitle( self.playerOrderGroupBox.setTitle(
translate('MediaPlugin.MediaTab', 'Player Order')) translate('MediaPlugin.MediaTab', 'Player Order'))
self.orderingDownButton.setText( self.orderingDownButton.setText(
@ -134,7 +134,10 @@ class MediaTab(SettingsTab):
'Allow media player to be overriden')) 'Allow media player to be overriden'))
def onPlayerCheckBoxChanged(self, check_state): def onPlayerCheckBoxChanged(self, check_state):
player = self.sender().text() display_name = self.sender().text()
for key in self.mediaPlayers:
if self.mediaPlayers[key].display_name == display_name:
player = key
if check_state == QtCore.Qt.Checked: if check_state == QtCore.Qt.Checked:
if player not in self.usedPlayers: if player not in self.usedPlayers:
self.usedPlayers.append(player) self.usedPlayers.append(player)
@ -152,7 +155,8 @@ class MediaTab(SettingsTab):
self.playerCheckBoxes[u'%s' % player].setEnabled(False) self.playerCheckBoxes[u'%s' % player].setEnabled(False)
else: else:
self.playerCheckBoxes[u'%s' % player].setEnabled(True) self.playerCheckBoxes[u'%s' % player].setEnabled(True)
self.playerOrderlistWidget.addItem(player) self.playerOrderlistWidget.addItem(
self.mediaPlayers[unicode(player)].display_name)
def onOrderingUpButtonPressed(self): def onOrderingUpButtonPressed(self):
currentRow = self.playerOrderlistWidget.currentRow() currentRow = self.playerOrderlistWidget.currentRow()
@ -171,9 +175,6 @@ class MediaTab(SettingsTab):
self.usedPlayers.move(currentRow, currentRow + 1) self.usedPlayers.move(currentRow, currentRow + 1)
def load(self): def load(self):
if self.savedUsedPlayers:
self.usedPlayers = self.savedUsedPlayers
self.savedUsedPlayers = None
self.usedPlayers = QtCore.QSettings().value( self.usedPlayers = QtCore.QSettings().value(
self.settingsSection + u'/players', self.settingsSection + u'/players',
QtCore.QVariant(u'webkit')).toString().split(u',') QtCore.QVariant(u'webkit')).toString().split(u',')