This commit is contained in:
Raoul Snyman 2011-12-18 20:39:28 +02:00
commit 8f708a462e
3 changed files with 65 additions and 37 deletions

View File

@ -54,7 +54,7 @@ class MediaMediaItem(MediaManagerItem):
self.iconPath = u'images/image'
self.background = False
self.previewFunction = CLAPPERBOARD
self.Automatic = u''
self.automatic = u''
MediaManagerItem.__init__(self, parent, plugin, icon)
self.singleServiceItem = False
self.hasSearch = True
@ -101,7 +101,7 @@ class MediaMediaItem(MediaManagerItem):
self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG)
self.resetAction.setText(UiStrings().ResetBG)
self.resetAction.setToolTip(UiStrings().ResetLiveBG)
self.Automatic = translate('MediaPlugin.MediaItem',
self.automatic = translate('MediaPlugin.MediaItem',
'Automatic')
self.displayTypeLabel.setText(
translate('MediaPlugin.MediaItem', 'Use Player:'))
@ -253,7 +253,7 @@ class MediaMediaItem(MediaManagerItem):
# load the drop down selection
self.displayTypeComboBox.addItem(title)
if self.displayTypeComboBox.count() > 1:
self.displayTypeComboBox.insertItem(0, self.Automatic)
self.displayTypeComboBox.insertItem(0, self.automatic)
self.displayTypeComboBox.setCurrentIndex(0)
if QtCore.QSettings().value(self.settingsSection + u'/override player',
QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:

View File

@ -35,7 +35,7 @@ class MediaTab(SettingsTab):
MediaTab is the Media settings tab in the settings dialog.
"""
def __init__(self, parent, title, visible_title, media_players, icon_path):
self.media_players = media_players
self.mediaPlayers = media_players
SettingsTab.__init__(self, parent, title, visible_title, icon_path)
def setupUi(self):
@ -45,13 +45,13 @@ class MediaTab(SettingsTab):
self.mediaPlayerGroupBox.setObjectName(u'mediaPlayerGroupBox')
self.mediaPlayerLayout = QtGui.QVBoxLayout(self.mediaPlayerGroupBox)
self.mediaPlayerLayout.setObjectName(u'mediaPlayerLayout')
self.PlayerCheckBoxes = {}
for key in self.media_players:
player = self.media_players[key]
self.playerCheckBoxes = {}
for key, player in self.mediaPlayers.iteritems():
player = self.mediaPlayers[key]
checkbox = QtGui.QCheckBox(self.mediaPlayerGroupBox)
checkbox.setEnabled(player.available)
checkbox.setObjectName(player.name + u'CheckBox')
self.PlayerCheckBoxes[player.name] = checkbox
self.playerCheckBoxes[player.name] = checkbox
self.mediaPlayerLayout.addWidget(checkbox)
self.leftLayout.addWidget(self.mediaPlayerGroupBox)
self.playerOrderGroupBox = QtGui.QGroupBox(self.leftColumn)
@ -88,19 +88,19 @@ class MediaTab(SettingsTab):
self.orderingButtonLayout.addWidget(self.orderingUpButton)
self.playerOrderLayout.addWidget(self.orderingButtonsWidget)
self.leftLayout.addWidget(self.playerOrderGroupBox)
self.AdvancedGroupBox = QtGui.QGroupBox(self.leftColumn)
self.AdvancedGroupBox.setObjectName(u'AdvancedGroupBox')
self.AdvancedLayout = QtGui.QVBoxLayout(self.AdvancedGroupBox)
self.AdvancedLayout.setObjectName(u'AdvancedLayout')
self.OverridePlayerCheckBox = QtGui.QCheckBox(self.AdvancedGroupBox)
self.OverridePlayerCheckBox.setObjectName(u'OverridePlayerCheckBox')
self.AdvancedLayout.addWidget(self.OverridePlayerCheckBox)
self.leftLayout.addWidget(self.AdvancedGroupBox)
self.advancedGroupBox = QtGui.QGroupBox(self.leftColumn)
self.advancedGroupBox.setObjectName(u'advancedGroupBox')
self.advancedLayout = QtGui.QVBoxLayout(self.advancedGroupBox)
self.advancedLayout.setObjectName(u'advancedLayout')
self.overridePlayerCheckBox = QtGui.QCheckBox(self.advancedGroupBox)
self.overridePlayerCheckBox.setObjectName(u'overridePlayerCheckBox')
self.advancedLayout.addWidget(self.overridePlayerCheckBox)
self.leftLayout.addWidget(self.advancedGroupBox)
self.leftLayout.addStretch()
self.rightLayout.addStretch()
for key in self.media_players:
player = self.media_players[key]
checkbox = self.PlayerCheckBoxes[player.name]
for key in self.mediaPlayers:
player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name]
QtCore.QObject.connect(checkbox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onPlayerCheckBoxChanged)
@ -112,9 +112,9 @@ class MediaTab(SettingsTab):
def retranslateUi(self):
self.mediaPlayerGroupBox.setTitle(
translate('MediaPlugin.MediaTab', 'Available Media Players'))
for key in self.media_players:
player = self.media_players[key]
checkbox = self.PlayerCheckBoxes[player.name]
for key in self.mediaPlayers:
player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name]
if player.available:
checkbox.setText(player.name)
else:
@ -127,8 +127,8 @@ class MediaTab(SettingsTab):
translate('MediaPlugin.MediaTab', 'Down'))
self.orderingUpButton.setText(
translate('MediaPlugin.MediaTab', 'Up'))
self.AdvancedGroupBox.setTitle(UiStrings().Advanced)
self.OverridePlayerCheckBox.setText(
self.advancedGroupBox.setTitle(UiStrings().Advanced)
self.overridePlayerCheckBox.setText(
translate('MediaPlugin.MediaTab',
'Allow media player to be overriden'))
@ -144,12 +144,12 @@ class MediaTab(SettingsTab):
def updatePlayerList(self):
self.playerOrderlistWidget.clear()
for player in self.usedPlayers:
if player in self.PlayerCheckBoxes.keys():
if player in self.playerCheckBoxes.keys():
if len(self.usedPlayers) == 1:
# at least one media player have to stay active
self.PlayerCheckBoxes[u'%s' % player].setEnabled(False)
self.playerCheckBoxes[u'%s' % player].setEnabled(False)
else:
self.PlayerCheckBoxes[u'%s' % player].setEnabled(True)
self.playerCheckBoxes[u'%s' % player].setEnabled(True)
self.playerOrderlistWidget.addItem(player)
def onOrderingUpButtonPressed(self):
@ -172,34 +172,34 @@ class MediaTab(SettingsTab):
self.usedPlayers = QtCore.QSettings().value(
self.settingsSection + u'/players',
QtCore.QVariant(u'webkit')).toString().split(u',')
for key in self.media_players:
player = self.media_players[key]
checkbox = self.PlayerCheckBoxes[player.name]
for key in self.mediaPlayers:
player = self.mediaPlayers[key]
checkbox = self.playerCheckBoxes[player.name]
if player.available and player.name in self.usedPlayers:
checkbox.setChecked(True)
self.updatePlayerList()
self.OverridePlayerCheckBox.setChecked(QtCore.QSettings().value(
self.overridePlayerCheckBox.setChecked(QtCore.QSettings().value(
self.settingsSection + u'/override player',
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0])
def save(self):
override_changed = False
player_string_changed = False
oldPlayerString = QtCore.QSettings().value(
old_players = QtCore.QSettings().value(
self.settingsSection + u'/players',
QtCore.QVariant(u'webkit')).toString()
newPlayerString = self.usedPlayers.join(u',')
if oldPlayerString != newPlayerString:
new_players = self.usedPlayers.join(u',')
if old_players != new_players:
# clean old Media stuff
QtCore.QSettings().setValue(self.settingsSection + u'/players',
QtCore.QVariant(newPlayerString))
QtCore.QVariant(new_players))
player_string_changed = True
override_changed = True
setting_key = self.settingsSection + u'/override player'
if QtCore.QSettings().value(setting_key) != \
self.OverridePlayerCheckBox.checkState():
self.overridePlayerCheckBox.checkState():
QtCore.QSettings().setValue(setting_key,
QtCore.QVariant(self.OverridePlayerCheckBox.checkState()))
QtCore.QVariant(self.overridePlayerCheckBox.checkState()))
override_changed = True
if override_changed:
Receiver.send_message(u'mediaitem_media_rebuild')

View File

@ -27,6 +27,8 @@
import logging
from PyQt4 import QtCore
from openlp.core.lib import Plugin, StringContent, build_icon, translate
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
@ -117,3 +119,29 @@ class MediaPlugin(Plugin):
Add html code to htmlbuilder
"""
return self.mediaController.get_media_display_html()
def appStartup(self):
"""
Do a couple of things when the app starts up. In this particular case
we want to check if we have the old "Use Phonon" setting, and convert
it to "enable Phonon" and "make it the first one in the list".
"""
settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection)
if settings.contains(u'use phonon'):
log.info(u'Found old Phonon setting')
players = self.mediaController.mediaPlayers.keys()
has_phonon = u'phonon' in players
if settings.value(u'use phonon').toBool() and has_phonon:
log.debug(u'Converting old setting to new setting')
new_players = []
if players:
new_players = [player for player in players \
if player != u'phonon']
new_players.insert(0, u'phonon')
self.mediaController.mediaPlayers[u'phonon'].isActive = True
settings.setValue(u'players', \
QtCore.QVariant(u','.join(new_players)))
self.settings_tab.load()
settings.remove(u'use phonon')
settings.endGroup()