From 1600e002cb464a1bea429ca3965c81481d0b0495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Mon, 5 Mar 2012 23:09:31 +0200 Subject: [PATCH] Make media backend names translatable. Fixes: https://launchpad.net/bugs/903683 --- openlp/core/ui/media/phononplayer.py | 3 ++- openlp/core/ui/media/vlcplayer.py | 3 ++- openlp/core/ui/media/webkitplayer.py | 2 ++ openlp/plugins/media/lib/mediatab.py | 15 ++++++++------- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 5a9a5f67d..5ba17f72a 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -31,7 +31,7 @@ from datetime import datetime 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.ui.media import MediaState @@ -63,6 +63,7 @@ class PhononPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'phonon') + self.display_name = translate('MediaPlugin.MediaTab', 'Phonon') self.parent = parent self.additional_extensions = ADDITIONAL_EXT mimetypes.init() diff --git a/openlp/core/ui/media/vlcplayer.py b/openlp/core/ui/media/vlcplayer.py index 2adf0a2d1..6b404cfde 100644 --- a/openlp/core/ui/media/vlcplayer.py +++ b/openlp/core/ui/media/vlcplayer.py @@ -43,7 +43,7 @@ except OSError, e: raise 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.ui.media import MediaState @@ -89,6 +89,7 @@ class VlcPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'vlc') + self.display_name = translate('MediaPlugin.MediaTab', 'VLC') self.parent = parent self.canFolder = True self.audio_extensions_list = AUDIO_EXT diff --git a/openlp/core/ui/media/webkitplayer.py b/openlp/core/ui/media/webkitplayer.py index abb5355d0..7420b8bf1 100644 --- a/openlp/core/ui/media/webkitplayer.py +++ b/openlp/core/ui/media/webkitplayer.py @@ -27,6 +27,7 @@ import logging +from openlp.core.lib import translate from openlp.core.lib.mediaplayer import MediaPlayer from openlp.core.ui.media import MediaState @@ -260,6 +261,7 @@ class WebkitPlayer(MediaPlayer): def __init__(self, parent): MediaPlayer.__init__(self, parent, u'webkit') + self.display_name = translate('MediaPlugin.MediaTab', 'WebKit') self.parent = parent self.canBackground = True self.audio_extensions_list = AUDIO_EXT diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index aed6b96cc..4dbefbffd 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -117,11 +117,11 @@ class MediaTab(SettingsTab): player = self.mediaPlayers[key] checkbox = self.playerCheckBoxes[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.orderingDownButton.setText( @@ -134,7 +134,10 @@ class MediaTab(SettingsTab): 'Allow media player to be overriden')) 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 player not in self.usedPlayers: self.usedPlayers.append(player) @@ -152,7 +155,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)].display_name) def onOrderingUpButtonPressed(self): currentRow = self.playerOrderlistWidget.currentRow() @@ -171,9 +175,6 @@ class MediaTab(SettingsTab): self.usedPlayers.move(currentRow, currentRow + 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',')