summaryrefslogtreecommitdiff
path: root/nephilim/plugins/Systray.py
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-03-03 20:21:45 +0100
committerAnton Khirnov <wyskas@gmail.com>2009-03-03 20:21:45 +0100
commit016ee579cae44e69c9fe0bfa4a099f98fb6a6aa2 (patch)
tree0f30f09110b601bd9136947c85ec61736a088f70 /nephilim/plugins/Systray.py
parenta41d0a530af6cd96719e2864c6ee61a68047d0c9 (diff)
Systray: cosmetics.
Diffstat (limited to 'nephilim/plugins/Systray.py')
-rw-r--r--nephilim/plugins/Systray.py43
1 files changed, 18 insertions, 25 deletions
diff --git a/nephilim/plugins/Systray.py b/nephilim/plugins/Systray.py
index 3a773f1..1a9eca8 100644
--- a/nephilim/plugins/Systray.py
+++ b/nephilim/plugins/Systray.py
@@ -2,7 +2,7 @@ from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import QVariant
from ..clPlugin import Plugin
-from ..misc import sec2min, ORGNAME, APPNAME, appIcon
+from ..misc import sec2min, ORGNAME, APPNAME, appIcon, expand_tags
class Systray(Plugin):
DEFAULTS = {'format': '$track - $title by $artist on $album ($length)'}
@@ -19,7 +19,7 @@ class Systray(Plugin):
self.addListener('onConnect', self.update)
self.addListener('onDisconnect', self.update)
self.addListener('onTimeChange', self.update) # TODO only update this when necessary, i.e. mouse-hover etc
- self.appIcon=QtGui.QIcon(appIcon)
+ self.appIcon = QtGui.QIcon(appIcon)
def _load(self):
self.format = self.settings.value(self.name + '/format').toString()
@@ -54,28 +54,28 @@ class Systray(Plugin):
status = self.mpclient.getStatus()
if not status:
return
- song = self.mpclient.getCurrentSong()
- values={'state':''}
+ values = {'state':''}
values['state']={'play':'playing', 'stop':'stopped', 'pause':'paused'}[status['state']]
if 'time' in status:
- values['length']=sec2min(status['length'])
- values['time']=sec2min(status['time'])
+ values['length'] = sec2min(status['length'])
+ values['time'] = sec2min(status['time'])
+ song = self.mpclient.getCurrentSong()
if song:
- self.o.setToolTip(song.expand_tags(self.format))
+ self.o.setToolTip(expand_tags(self.format, (song,)))
else:
- self.o.setToolTip("mpclientpc not playing")
+ self.o.setToolTip('mpclientpc not playing')
try:
- curTime=(64*status['time'])/status['length']
+ curTime = (64*status['time'])/status['length']
except:
- curTime=-1
- if self.time!=curTime:
- self.time=curTime
+ curTime = -1
+ if self.time != curTime:
+ self.time = curTime
# redraw the systray icon
- self.pixmap=self.appIcon.pixmap(64,64)
- painter=QtGui.QPainter(self.pixmap)
+ self.pixmap = self.appIcon.pixmap(64,64)
+ painter = QtGui.QPainter(self.pixmap)
painter.fillRect(1, curTime, 63, 64, self.winMain.palette().brush(QtGui.QPalette.Base))
self.appIcon.paint(painter, 1, 0, 63, 64)
self.o.setIcon(QtGui.QIcon(self.pixmap))
@@ -84,22 +84,15 @@ class Systray(Plugin):
self.o.setIcon(QtGui.QIcon(appIcon))
def onSysTrayClick(self, reason):
- if reason==QtGui.QSystemTrayIcon.Trigger \
- or reason==QtGui.QSystemTrayIcon.Context:
- w=self.getWinMain()
+ if reason == QtGui.QSystemTrayIcon.Trigger or\
+ reason == QtGui.QSystemTrayIcon.Context:
+ w = self.getWinMain()
# left mouse button
if w.isVisible():
- settings.setIntTuple('winMain.pos', w.x(), w.y())
w.setVisible(False)
else:
w.setVisible(True)
- try:
- x,y=settings.getIntTuple('winMain.pos')
- except:
- x,y=0,0
- w.move(x, y)
- elif reason==QtGui.QSystemTrayIcon.MiddleClick:
- # middle mouse button
+ elif reason == QtGui.QSystemTrayIcon.MiddleClick:
if self.mpclient.isPlaying():
self.mpclient.pause()
else: