~openlp-core/openlp/trunk

« back to all changes in this revision

Viewing changes to openlp/plugins/media/mediaplugin.py

  • Committer: Raoul Snyman
  • Date: 2011-12-17 06:43:36 UTC
  • mfrom: (1837.2.2 bug-900387)
  • Revision ID: raoul.snyman@saturnlaboratories.co.za-20111217064336-g4mrbw7z6nvwid1w
Fix bug #900387: Converted a user's old Phonon setting to the new media players format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
import logging
29
29
 
 
30
from PyQt4 import QtCore
 
31
 
30
32
from openlp.core.lib import Plugin, StringContent, build_icon, translate
31
33
from openlp.plugins.media.lib import MediaMediaItem, MediaTab
32
34
 
117
119
        Add html code to htmlbuilder
118
120
        """
119
121
        return self.mediaController.get_media_display_html()
 
122
 
 
123
    def appStartup(self):
 
124
        """
 
125
        Do a couple of things when the app starts up. In this particular case
 
126
        we want to check if we have the old "Use Phonon" setting, and convert
 
127
        it to "enable Phonon" and "make it the first one in the list".
 
128
        """
 
129
        settings = QtCore.QSettings()
 
130
        settings.beginGroup(self.settingsSection)
 
131
        if settings.contains(u'use phonon'):
 
132
            log.info(u'Found old Phonon setting')
 
133
            players = self.mediaController.mediaPlayers.keys()
 
134
            has_phonon = u'phonon' in players
 
135
            if settings.value(u'use phonon').toBool() and has_phonon:
 
136
                log.debug(u'Converting old setting to new setting')
 
137
                new_players = []
 
138
                if players:
 
139
                    new_players = [player for player in players \
 
140
                        if player != u'phonon']
 
141
                new_players.insert(0, u'phonon')
 
142
                self.mediaController.mediaPlayers[u'phonon'].isActive = True
 
143
                settings.setValue(u'players', \
 
144
                    QtCore.QVariant(u','.join(new_players)))
 
145
                self.settings_tab.load()
 
146
            settings.remove(u'use phonon')
 
147
        settings.endGroup()