little corrections

This commit is contained in:
rimach 2012-03-21 20:30:18 +01:00
parent a0769ce544
commit 210f0e693b
4 changed files with 11 additions and 14 deletions

View File

@ -77,24 +77,21 @@ def get_media_players():
here an special media player is choosen for all media actions
"""
log.debug(u'get_media_players')
players = str(QtCore.QSettings().value(u'media/players',
QtCore.QVariant(u'webkit')).toString())
if len(players) == 0:
players = unicode(QtCore.QSettings().value(u'media/players').toString())
if not players:
players = u'webkit'
reg_ex = QtCore.QRegExp(".*\[(.*)\].*")
can_override = True if QtCore.QSettings().value(u'media/override player',
QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked else False
if can_override:
if QtCore.QSettings().value(u'media/override player',
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0] == QtCore.Qt.Checked:
if reg_ex.exactMatch(players):
overridden_player = u'%s' % reg_ex.cap(1)
else:
overridden_player = u'auto'
else:
overridden_player = u''
players_list = players.replace('[', '').replace(']', '').split(u',')
players_list = players.replace(u'[', u'').replace(u']', u'').split(u',')
return players_list, overridden_player
def set_media_players(players_list, overridden_player=u'auto'):
"""
This method saves the configured media players and overridden player to the
@ -107,9 +104,9 @@ def set_media_players(players_list, overridden_player=u'auto'):
"""
log.debug(u'set_media_players')
players = u','.join(players_list)
can_override = True if QtCore.QSettings().value(u'media/override player',
QtCore.QVariant(QtCore.Qt.Unchecked)) == QtCore.Qt.Checked else False
if can_override and overridden_player != u'auto':
if QtCore.QSettings().value(u'media/override player',
QtCore.QVariant(QtCore.Qt.Unchecked)).toInt()[0] == \
QtCore.Qt.Checked and overridden_player != u'auto':
players = players.replace(overridden_player, u'[%s]' % overridden_player)
QtCore.QSettings().setValue(u'media/players', QtCore.QVariant(players))

View File

@ -358,7 +358,7 @@ class MediaController(object):
Select the correct media Player type from the prioritized Player list
"""
usedPlayers, overriddenPlayer = get_media_players()
if overriddenPlayer != '' and overriddenPlayer != 'auto':
if overriddenPlayer and overriddenPlayer != u'auto':
usedPlayers = [overriddenPlayer]
if controller.media_info.file_info.isFile():
suffix = u'*.%s' % \

View File

@ -263,7 +263,7 @@ class MediaMediaItem(MediaManagerItem):
if self.displayTypeComboBox.count() > 1:
self.displayTypeComboBox.insertItem(0, self.automatic)
self.displayTypeComboBox.setCurrentIndex(currentIndex)
if overridePlayer != '':
if overridePlayer:
self.mediaWidget.show()
else:
self.mediaWidget.hide()

View File

@ -198,7 +198,7 @@ class MediaTab(SettingsTab):
player_string_changed = True
override_changed = True
setting_key = self.settingsSection + u'/override player'
if QtCore.QSettings().value(setting_key) != \
if QtCore.QSettings().value(setting_key).toInt()[0] != \
self.overridePlayerCheckBox.checkState():
QtCore.QSettings().setValue(setting_key,
QtCore.QVariant(self.overridePlayerCheckBox.checkState()))