forked from openlp/openlp
Fix bug #900387: Converted a user's old Phonon setting to the new media players format.
bzr-revno: 1842 Fixes: https://launchpad.net/bugs/900387
This commit is contained in:
commit
d701316923
@ -54,7 +54,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
self.iconPath = u'images/image'
|
self.iconPath = u'images/image'
|
||||||
self.background = False
|
self.background = False
|
||||||
self.previewFunction = CLAPPERBOARD
|
self.previewFunction = CLAPPERBOARD
|
||||||
self.Automatic = u''
|
self.automatic = u''
|
||||||
MediaManagerItem.__init__(self, parent, plugin, icon)
|
MediaManagerItem.__init__(self, parent, plugin, icon)
|
||||||
self.singleServiceItem = False
|
self.singleServiceItem = False
|
||||||
self.hasSearch = True
|
self.hasSearch = True
|
||||||
@ -101,7 +101,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG)
|
self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG)
|
||||||
self.resetAction.setText(UiStrings().ResetBG)
|
self.resetAction.setText(UiStrings().ResetBG)
|
||||||
self.resetAction.setToolTip(UiStrings().ResetLiveBG)
|
self.resetAction.setToolTip(UiStrings().ResetLiveBG)
|
||||||
self.Automatic = translate('MediaPlugin.MediaItem',
|
self.automatic = translate('MediaPlugin.MediaItem',
|
||||||
'Automatic')
|
'Automatic')
|
||||||
self.displayTypeLabel.setText(
|
self.displayTypeLabel.setText(
|
||||||
translate('MediaPlugin.MediaItem', 'Use Player:'))
|
translate('MediaPlugin.MediaItem', 'Use Player:'))
|
||||||
@ -253,7 +253,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
# load the drop down selection
|
# load the drop down selection
|
||||||
self.displayTypeComboBox.addItem(title)
|
self.displayTypeComboBox.addItem(title)
|
||||||
if self.displayTypeComboBox.count() > 1:
|
if self.displayTypeComboBox.count() > 1:
|
||||||
self.displayTypeComboBox.insertItem(0, self.Automatic)
|
self.displayTypeComboBox.insertItem(0, self.automatic)
|
||||||
self.displayTypeComboBox.setCurrentIndex(0)
|
self.displayTypeComboBox.setCurrentIndex(0)
|
||||||
if QtCore.QSettings().value(self.settingsSection + u'/override player',
|
if QtCore.QSettings().value(self.settingsSection + u'/override player',
|
||||||
QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked:
|
||||||
|
@ -35,7 +35,7 @@ class MediaTab(SettingsTab):
|
|||||||
MediaTab is the Media settings tab in the settings dialog.
|
MediaTab is the Media settings tab in the settings dialog.
|
||||||
"""
|
"""
|
||||||
def __init__(self, parent, title, visible_title, media_players, icon_path):
|
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)
|
SettingsTab.__init__(self, parent, title, visible_title, icon_path)
|
||||||
|
|
||||||
def setupUi(self):
|
def setupUi(self):
|
||||||
@ -45,13 +45,13 @@ class MediaTab(SettingsTab):
|
|||||||
self.mediaPlayerGroupBox.setObjectName(u'mediaPlayerGroupBox')
|
self.mediaPlayerGroupBox.setObjectName(u'mediaPlayerGroupBox')
|
||||||
self.mediaPlayerLayout = QtGui.QVBoxLayout(self.mediaPlayerGroupBox)
|
self.mediaPlayerLayout = QtGui.QVBoxLayout(self.mediaPlayerGroupBox)
|
||||||
self.mediaPlayerLayout.setObjectName(u'mediaPlayerLayout')
|
self.mediaPlayerLayout.setObjectName(u'mediaPlayerLayout')
|
||||||
self.PlayerCheckBoxes = {}
|
self.playerCheckBoxes = {}
|
||||||
for key in self.media_players:
|
for key, player in self.mediaPlayers.iteritems():
|
||||||
player = self.media_players[key]
|
player = self.mediaPlayers[key]
|
||||||
checkbox = QtGui.QCheckBox(self.mediaPlayerGroupBox)
|
checkbox = QtGui.QCheckBox(self.mediaPlayerGroupBox)
|
||||||
checkbox.setEnabled(player.available)
|
checkbox.setEnabled(player.available)
|
||||||
checkbox.setObjectName(player.name + u'CheckBox')
|
checkbox.setObjectName(player.name + u'CheckBox')
|
||||||
self.PlayerCheckBoxes[player.name] = checkbox
|
self.playerCheckBoxes[player.name] = checkbox
|
||||||
self.mediaPlayerLayout.addWidget(checkbox)
|
self.mediaPlayerLayout.addWidget(checkbox)
|
||||||
self.leftLayout.addWidget(self.mediaPlayerGroupBox)
|
self.leftLayout.addWidget(self.mediaPlayerGroupBox)
|
||||||
self.playerOrderGroupBox = QtGui.QGroupBox(self.leftColumn)
|
self.playerOrderGroupBox = QtGui.QGroupBox(self.leftColumn)
|
||||||
@ -88,19 +88,19 @@ class MediaTab(SettingsTab):
|
|||||||
self.orderingButtonLayout.addWidget(self.orderingUpButton)
|
self.orderingButtonLayout.addWidget(self.orderingUpButton)
|
||||||
self.playerOrderLayout.addWidget(self.orderingButtonsWidget)
|
self.playerOrderLayout.addWidget(self.orderingButtonsWidget)
|
||||||
self.leftLayout.addWidget(self.playerOrderGroupBox)
|
self.leftLayout.addWidget(self.playerOrderGroupBox)
|
||||||
self.AdvancedGroupBox = QtGui.QGroupBox(self.leftColumn)
|
self.advancedGroupBox = QtGui.QGroupBox(self.leftColumn)
|
||||||
self.AdvancedGroupBox.setObjectName(u'AdvancedGroupBox')
|
self.advancedGroupBox.setObjectName(u'advancedGroupBox')
|
||||||
self.AdvancedLayout = QtGui.QVBoxLayout(self.AdvancedGroupBox)
|
self.advancedLayout = QtGui.QVBoxLayout(self.advancedGroupBox)
|
||||||
self.AdvancedLayout.setObjectName(u'AdvancedLayout')
|
self.advancedLayout.setObjectName(u'advancedLayout')
|
||||||
self.OverridePlayerCheckBox = QtGui.QCheckBox(self.AdvancedGroupBox)
|
self.overridePlayerCheckBox = QtGui.QCheckBox(self.advancedGroupBox)
|
||||||
self.OverridePlayerCheckBox.setObjectName(u'OverridePlayerCheckBox')
|
self.overridePlayerCheckBox.setObjectName(u'overridePlayerCheckBox')
|
||||||
self.AdvancedLayout.addWidget(self.OverridePlayerCheckBox)
|
self.advancedLayout.addWidget(self.overridePlayerCheckBox)
|
||||||
self.leftLayout.addWidget(self.AdvancedGroupBox)
|
self.leftLayout.addWidget(self.advancedGroupBox)
|
||||||
self.leftLayout.addStretch()
|
self.leftLayout.addStretch()
|
||||||
self.rightLayout.addStretch()
|
self.rightLayout.addStretch()
|
||||||
for key in self.media_players:
|
for key in self.mediaPlayers:
|
||||||
player = self.media_players[key]
|
player = self.mediaPlayers[key]
|
||||||
checkbox = self.PlayerCheckBoxes[player.name]
|
checkbox = self.playerCheckBoxes[player.name]
|
||||||
QtCore.QObject.connect(checkbox,
|
QtCore.QObject.connect(checkbox,
|
||||||
QtCore.SIGNAL(u'stateChanged(int)'),
|
QtCore.SIGNAL(u'stateChanged(int)'),
|
||||||
self.onPlayerCheckBoxChanged)
|
self.onPlayerCheckBoxChanged)
|
||||||
@ -112,9 +112,9 @@ class MediaTab(SettingsTab):
|
|||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
self.mediaPlayerGroupBox.setTitle(
|
self.mediaPlayerGroupBox.setTitle(
|
||||||
translate('MediaPlugin.MediaTab', 'Available Media Players'))
|
translate('MediaPlugin.MediaTab', 'Available Media Players'))
|
||||||
for key in self.media_players:
|
for key in self.mediaPlayers:
|
||||||
player = self.media_players[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.name)
|
||||||
else:
|
else:
|
||||||
@ -127,8 +127,8 @@ class MediaTab(SettingsTab):
|
|||||||
translate('MediaPlugin.MediaTab', 'Down'))
|
translate('MediaPlugin.MediaTab', 'Down'))
|
||||||
self.orderingUpButton.setText(
|
self.orderingUpButton.setText(
|
||||||
translate('MediaPlugin.MediaTab', 'Up'))
|
translate('MediaPlugin.MediaTab', 'Up'))
|
||||||
self.AdvancedGroupBox.setTitle(UiStrings().Advanced)
|
self.advancedGroupBox.setTitle(UiStrings().Advanced)
|
||||||
self.OverridePlayerCheckBox.setText(
|
self.overridePlayerCheckBox.setText(
|
||||||
translate('MediaPlugin.MediaTab',
|
translate('MediaPlugin.MediaTab',
|
||||||
'Allow media player to be overriden'))
|
'Allow media player to be overriden'))
|
||||||
|
|
||||||
@ -144,12 +144,12 @@ class MediaTab(SettingsTab):
|
|||||||
def updatePlayerList(self):
|
def updatePlayerList(self):
|
||||||
self.playerOrderlistWidget.clear()
|
self.playerOrderlistWidget.clear()
|
||||||
for player in self.usedPlayers:
|
for player in self.usedPlayers:
|
||||||
if player in self.PlayerCheckBoxes.keys():
|
if player in self.playerCheckBoxes.keys():
|
||||||
if len(self.usedPlayers) == 1:
|
if len(self.usedPlayers) == 1:
|
||||||
# at least one media player have to stay active
|
# at least one media player have to stay active
|
||||||
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(player)
|
||||||
|
|
||||||
def onOrderingUpButtonPressed(self):
|
def onOrderingUpButtonPressed(self):
|
||||||
@ -172,34 +172,34 @@ class MediaTab(SettingsTab):
|
|||||||
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',')
|
||||||
for key in self.media_players:
|
for key in self.mediaPlayers:
|
||||||
player = self.media_players[key]
|
player = self.mediaPlayers[key]
|
||||||
checkbox = self.PlayerCheckBoxes[player.name]
|
checkbox = self.playerCheckBoxes[player.name]
|
||||||
if player.available and player.name in self.usedPlayers:
|
if player.available and player.name in self.usedPlayers:
|
||||||
checkbox.setChecked(True)
|
checkbox.setChecked(True)
|
||||||
self.updatePlayerList()
|
self.updatePlayerList()
|
||||||
self.OverridePlayerCheckBox.setChecked(QtCore.QSettings().value(
|
self.overridePlayerCheckBox.setChecked(QtCore.QSettings().value(
|
||||||
self.settingsSection + u'/override player',
|
self.settingsSection + u'/override player',
|
||||||
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0])
|
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0])
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
override_changed = False
|
override_changed = False
|
||||||
player_string_changed = False
|
player_string_changed = False
|
||||||
oldPlayerString = QtCore.QSettings().value(
|
old_players = QtCore.QSettings().value(
|
||||||
self.settingsSection + u'/players',
|
self.settingsSection + u'/players',
|
||||||
QtCore.QVariant(u'webkit')).toString()
|
QtCore.QVariant(u'webkit')).toString()
|
||||||
newPlayerString = self.usedPlayers.join(u',')
|
new_players = self.usedPlayers.join(u',')
|
||||||
if oldPlayerString != newPlayerString:
|
if old_players != new_players:
|
||||||
# clean old Media stuff
|
# clean old Media stuff
|
||||||
QtCore.QSettings().setValue(self.settingsSection + u'/players',
|
QtCore.QSettings().setValue(self.settingsSection + u'/players',
|
||||||
QtCore.QVariant(newPlayerString))
|
QtCore.QVariant(new_players))
|
||||||
player_string_changed = True
|
player_string_changed = True
|
||||||
override_changed = True
|
override_changed = True
|
||||||
setting_key = self.settingsSection + u'/override player'
|
setting_key = self.settingsSection + u'/override player'
|
||||||
if QtCore.QSettings().value(setting_key) != \
|
if QtCore.QSettings().value(setting_key) != \
|
||||||
self.OverridePlayerCheckBox.checkState():
|
self.overridePlayerCheckBox.checkState():
|
||||||
QtCore.QSettings().setValue(setting_key,
|
QtCore.QSettings().setValue(setting_key,
|
||||||
QtCore.QVariant(self.OverridePlayerCheckBox.checkState()))
|
QtCore.QVariant(self.overridePlayerCheckBox.checkState()))
|
||||||
override_changed = True
|
override_changed = True
|
||||||
if override_changed:
|
if override_changed:
|
||||||
Receiver.send_message(u'mediaitem_media_rebuild')
|
Receiver.send_message(u'mediaitem_media_rebuild')
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from PyQt4 import QtCore
|
||||||
|
|
||||||
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
from openlp.core.lib import Plugin, StringContent, build_icon, translate
|
||||||
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
|
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
|
||||||
|
|
||||||
@ -117,3 +119,29 @@ class MediaPlugin(Plugin):
|
|||||||
Add html code to htmlbuilder
|
Add html code to htmlbuilder
|
||||||
"""
|
"""
|
||||||
return self.mediaController.get_media_display_html()
|
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()
|
||||||
|
Loading…
Reference in New Issue
Block a user