diff options
author | jerous <jerous@gmail.com> | 2008-09-21 19:51:43 +0200 |
---|---|---|
committer | jerous <jerous@gmail.com> | 2008-09-21 19:51:43 +0200 |
commit | 6f0cb719695c0a420f1f0da1cac77293544b7b78 (patch) | |
tree | 04de3e78175f1e3ba6128d2d0066c101955df550 /plugins | |
parent | 0e4b3c53972ff0ce45ed1213e8c42af51f59a1d6 (diff) |
Notify: new settings notify.songformat and notify.timer
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Notify.py | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/plugins/Notify.py b/plugins/Notify.py index 5ed0711..56f1175 100644 --- a/plugins/Notify.py +++ b/plugins/Notify.py @@ -8,6 +8,9 @@ from clSettings import settings,mpdSettings from clMonty import monty from clPlugin import * +NOTIFY_DEFAULT_SONGFORMAT='$if($artist,$artist)$if($album, - [$album #$track])\n$title ($timems)'; +NOTIFY_DEFAULT_TIMER=3 + class winNotify(QtGui.QWidget): _timerID=None resizeWindow=True @@ -34,7 +37,7 @@ class winNotify(QtGui.QWidget): def mousePressEvent(self, event): self.hide() - def show(self, msg, song=None, xtra_tags={}): + def show(self, msg, song=None, xtra_tags={}, time=3): if not self.isVisible(): self.setVisible(True) self.resizeWindow=True @@ -43,8 +46,11 @@ class winNotify(QtGui.QWidget): self.xtra_tags=xtra_tags if self._timerID: self.killTimer(self._timerID) - self._timerID=self.startTimer(200) - self.timer=11 + self._timerID=self.startTimer(500) + try: + self.timer=int(time)*2 + except: + self.timer=3 self.raise_() self.timerEvent(None) @@ -128,21 +134,32 @@ class pluginNotify(Plugin): return "Show interesting events in a popup window." def onSongChange(self, params): - self.o.show('$if($artist,$artist)$if($album, [$album #$track])\n$title ($length))', monty.getCurrentSong()) + self.o.show(settings.get('notify.songformat', NOTIFY_DEFAULT_SONGFORMAT).replace("\n", "\\n"), monty.getCurrentSong() + , time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) def onReady(self, params): - self.o.show('montypc loaded!') + self.o.show('montypc loaded!', monty.getCurrentSong(), time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) def onDisconnect(self, params): - self.o.show('Disconnected!') + self.o.show('Disconnected!', time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) def onStateChange(self, params): - self.o.show(params['newState']) + self.o.show(params['newState'], monty.getCurrentSong(), time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) def onVolumeChange(self, params): - self.o.show('Volume: %i%%'%(params['newVolume'])) + self.o.show('Volume: %i%%'%(params['newVolume']), monty.getCurrentSong(), time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) def _getSettings(self): - return [] + txt=QtGui.QTextEdit() + txt.insertPlainText(settings.get('notify.songformat', NOTIFY_DEFAULT_SONGFORMAT)) + return [ + ['notify.songformat', 'Song format', 'How to format the current playing song.', txt], + ['notify.timer', 'Show seconds', 'How many seconds does the notification have to be shown.', QtGui.QLineEdit(str(settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)))], + ] def afterSaveSettings(self): - self.o.onSongChange(None) + try: + int(settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) + except: + settings.set('notify.timer', NOTIFY_DEFAULT_TIMER) + self.getSettingWidget('notify.timer').setText(str(NOTIFY_DEFAULT_TIMER)) + self.onSongChange(None) |