diff options
author | Anton Khirnov <wyskas@gmail.com> | 2009-03-07 09:52:41 +0100 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2009-03-07 09:52:41 +0100 |
commit | 71794c14051cb80431d81cdcc352a3198849163a (patch) | |
tree | e9c0d0d5463b2272a4c07a26a162136bc6f2e683 /nephilim/plugins/Notify.py | |
parent | 39075f65d5f958565149661d35cfc54f4ad051c1 (diff) |
clPlugin: get rid of CamelCase.
Diffstat (limited to 'nephilim/plugins/Notify.py')
-rw-r--r-- | nephilim/plugins/Notify.py | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/nephilim/plugins/Notify.py b/nephilim/plugins/Notify.py index f086693..4e1486c 100644 --- a/nephilim/plugins/Notify.py +++ b/nephilim/plugins/Notify.py @@ -11,7 +11,7 @@ NOTIFY_PRIORITY_VOLUME = 2 class winNotify(QtGui.QWidget): _timerID = None - winMain = None + parent = None p = None _current_priority = 0 @@ -20,10 +20,10 @@ class winNotify(QtGui.QWidget): cover_label = None text_label = None - def __init__(self, p, winMain, parent=None): - QtGui.QWidget.__init__(self, parent) - self.p = p - self.winMain = winMain + def __init__(self, p): + QtGui.QWidget.__init__(self, p.parent()) + self.p = p + self.parent = p.parent() self.timer = QtCore.QTimer(self) self.timer.setSingleShot(True) @@ -54,7 +54,7 @@ class winNotify(QtGui.QWidget): self._current_priority = priority self.cover_label.clear() - ac = self.winMain.plugins.plugin('AlbumCover') + ac = self.parent.plugins.plugin('AlbumCover') if ac: cover = ac.get_cover() if cover: @@ -80,43 +80,39 @@ class winNotify(QtGui.QWidget): class Notify(Plugin): o=None - DEFAULTS = {'songformat' : '$track - $artist - $title ($album) [$length]', - 'timer' : 3000} - def __init__(self, winMain): - Plugin.__init__(self, winMain, 'Notify') - self.addListener('onSongChange', self.onSongChange) - self.addListener('onReady', self.onReady) - self.addListener('onDisconnect', self.onDisconnect) - self.addListener('onStateChange', self.onStateChange) - self.addListener('onVolumeChange', self.onVolumeChange) + DEFAULTS = {'songformat' : '$track - $artist - $title ($album) [$length]', + 'timer' : 3000} + LISTENERS = {'onSongChange': 'onSongChange', 'onReady' : 'onReady', + 'onDisconnect': 'onDisconnect', 'onStateChange' : 'onStateChange', + 'onVolumeChange' : 'onVolumeChange'} def _load(self): - self.o = winNotify(self, self.winMain) + self.o = winNotify(self) def _unload(self): self.o=None def getInfo(self): return "Show interesting events in a popup window." def onSongChange(self, params): - song = self.mpclient.current_song() + song = self.mpclient().current_song() if not song: return - self.settings.beginGroup(self.name) - self.o.show(expand_tags(self.settings.value('songformat').toString(), (song,)), self.settings.value('timer').toInt()[0], + self.settings().beginGroup(self.name()) + self.o.show(expand_tags(self.settings().value('songformat').toString(), (song,)), self.settings().value('timer').toInt()[0], NOTIFY_PRIORITY_SONG) - self.settings.endGroup() + self.settings().endGroup() def onReady(self, params): - self.o.show('%s loaded'%APPNAME, self.settings.value(self.name + '/timer').toInt()[0]) + self.o.show('%s loaded'%APPNAME, self.settings().value(self.name() + '/timer').toInt()[0]) def onDisconnect(self, params): - self.o.show('Disconnected!', self.settings.value(self.name + '/timer').toInt()[0]) + self.o.show('Disconnected!', self.settings().value(self.name() + '/timer').toInt()[0]) def onStateChange(self, params): - self.o.show(params['newState'], self.settings.value(self.name + '/timer').toInt()[0]) + self.o.show(params['newState'], self.settings().value(self.name() + '/timer').toInt()[0]) def onVolumeChange(self, params): - self.o.show('Volume: %i%%'%(params['newVolume']), self.settings.value(self.name + '/timer').toInt()[0], priority = NOTIFY_PRIORITY_VOLUME) + self.o.show('Volume: %i%%'%(params['newVolume']), self.settings().value(self.name() + '/timer').toInt()[0], priority = NOTIFY_PRIORITY_VOLUME) class SettingsWidgetNotify(Plugin.SettingsWidget): format = None @@ -124,11 +120,11 @@ class Notify(Plugin): def __init__(self, plugin): Plugin.SettingsWidget.__init__(self, plugin) - self.settings.beginGroup(self.plugin.getName()) + self.settings().beginGroup(self.plugin.name()) - self.format = QtGui.QLineEdit(self.settings.value('songformat').toString()) + self.format = QtGui.QLineEdit(self.settings().value('songformat').toString()) - self.timer = QtGui.QLineEdit(self.settings.value('timer').toString()) + self.timer = QtGui.QLineEdit(self.settings().value('timer').toString()) self.timer.setValidator(QtGui.QIntValidator(self.timer)) self.setLayout(QtGui.QVBoxLayout()) @@ -136,14 +132,15 @@ class Notify(Plugin): 'will be expanded to their values for current song,\n' 'e.g. $track, $title, $artist, $album, $length, $date, etc.') self._add_widget(self.timer, 'Duration', 'How long should notifications be displayed in ms.') - self.settings.endGroup() + self.settings().endGroup() def save_settings(self): - self.settings.beginGroup(self.plugin.getName()) - self.settings.setValue('songformat', QVariant(self.format.text())) - self.settings.setValue('timer', QVariant(self.timer.text().toInt()[0])) - self.settings.endGroup() + self.settings().beginGroup(self.plugin.name()) + self.settings().setValue('songformat', QVariant(self.format.text())) + self.settings().setValue('timer', QVariant(self.timer.text().toInt()[0])) + self.settings().endGroup() self.plugin.onSongChange(None) def get_settings_widget(self): return self.SettingsWidgetNotify(self) + |