Actually read directly from the media controller, and then update the settings tab.

This commit is contained in:
Raoul Snyman 2011-12-15 23:06:50 +02:00
parent 19fac1e84a
commit d800951800
1 changed files with 6 additions and 3 deletions

View File

@ -126,19 +126,22 @@ class MediaPlugin(Plugin):
we want to check if we have the old "Use Phonon" setting, and convert 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". it to "enable Phonon" and "make it the first one in the list".
""" """
has_phonon = u'phonon' in self.mediaController.mediaPlayers.keys()
settings = QtCore.QSettings() settings = QtCore.QSettings()
settings.beginGroup(self.settingsSection) settings.beginGroup(self.settingsSection)
if settings.contains(u'use phonon'): if settings.contains(u'use phonon'):
log.info(u'Found old Phonon setting') 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: if settings.value(u'use phonon').toBool() and has_phonon:
log.debug(u'Converting old setting to new setting') log.debug(u'Converting old setting to new setting')
players = unicode(settings.value(u'players').toString())
new_players = [] new_players = []
if players: if players:
new_players = [player for player in players.split(u',') \ new_players = [player for player in players \
if player != u'phonon'] if player != u'phonon']
new_players.insert(0, u'phonon') new_players.insert(0, u'phonon')
self.mediaController.mediaPlayers[u'phonon'].isActive = True
settings.setValue(u'players', \ settings.setValue(u'players', \
QtCore.QVariant(u','.join(new_players))) QtCore.QVariant(u','.join(new_players)))
self.settings_tab.load()
settings.remove(u'use phonon') settings.remove(u'use phonon')
settings.endGroup()