diff options
Diffstat (limited to 'plugins/Notify.py')
-rw-r--r-- | plugins/Notify.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/plugins/Notify.py b/plugins/Notify.py index 56f1175..85c1a92 100644 --- a/plugins/Notify.py +++ b/plugins/Notify.py @@ -4,17 +4,17 @@ from traceback import print_exc import format from misc import * -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 +NOTIFY_SONGFORMAT_DEFAULT='$if($artist,$artist)$if($album, - [$album #$track])\n$title ($timems)'; +NOTIFY_TIMER_DEFAULT=3 class winNotify(QtGui.QWidget): _timerID=None resizeWindow=True winMain=None + p=None # data used for showing off timer=None @@ -22,8 +22,9 @@ class winNotify(QtGui.QWidget): song=None xtra_tags=None - def __init__(self, winMain, parent=None): + def __init__(self, p, winMain, parent=None): QtGui.QWidget.__init__(self, parent) + self.p=p self.winMain=winMain self.setWindowFlags(QtCore.Qt.ToolTip) @@ -127,39 +128,39 @@ class pluginNotify(Plugin): self.addMontyListener('onVolumeChange', self.onVolumeChange) def _load(self): - self.o=winNotify(self.winMain) + self.o=winNotify(self, self.winMain) def _unload(self): self.o=None def getInfo(self): return "Show interesting events in a popup window." def onSongChange(self, params): - self.o.show(settings.get('notify.songformat', NOTIFY_DEFAULT_SONGFORMAT).replace("\n", "\\n"), monty.getCurrentSong() - , time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) + self.o.show(self.getSetting('songformat').replace("\n", "\\n"), monty.getCurrentSong() + , time=self.getSetting('timer')) def onReady(self, params): - self.o.show('montypc loaded!', monty.getCurrentSong(), time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) + self.o.show('montypc loaded!', monty.getCurrentSong(), time=self.getSetting('timer')) def onDisconnect(self, params): - self.o.show('Disconnected!', time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) + self.o.show('Disconnected!', time=self.getSetting('timer')) def onStateChange(self, params): - self.o.show(params['newState'], monty.getCurrentSong(), time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) + self.o.show(params['newState'], monty.getCurrentSong(), time=self.getSetting('timer')) def onVolumeChange(self, params): - self.o.show('Volume: %i%%'%(params['newVolume']), monty.getCurrentSong(), time=settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) + self.o.show('Volume: %i%%'%(params['newVolume']), monty.getCurrentSong(), time=self.getSetting('timer')) def _getSettings(self): txt=QtGui.QTextEdit() - txt.insertPlainText(settings.get('notify.songformat', NOTIFY_DEFAULT_SONGFORMAT)) + txt.insertPlainText(self.getSetting('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)))], + ['notify.timer', 'Show seconds', 'How many seconds does the notification have to be shown.', QtGui.QLineEdit(str(self.getSetting('timer')))], ] def afterSaveSettings(self): try: - int(settings.get('notify.timer', NOTIFY_DEFAULT_TIMER)) + int(self.getSetting('timer')) except: - settings.set('notify.timer', NOTIFY_DEFAULT_TIMER) + self.getSetting('timer') self.getSettingWidget('notify.timer').setText(str(NOTIFY_DEFAULT_TIMER)) self.onSongChange(None) |