summaryrefslogtreecommitdiff
path: root/nephilim/plugins/Systray.py
diff options
context:
space:
mode:
authorAnton Khirnov <wyskas@gmail.com>2009-03-07 09:52:41 +0100
committerAnton Khirnov <wyskas@gmail.com>2009-03-07 09:52:41 +0100
commit71794c14051cb80431d81cdcc352a3198849163a (patch)
treee9c0d0d5463b2272a4c07a26a162136bc6f2e683 /nephilim/plugins/Systray.py
parent39075f65d5f958565149661d35cfc54f4ad051c1 (diff)
clPlugin: get rid of CamelCase.
Diffstat (limited to 'nephilim/plugins/Systray.py')
-rw-r--r--nephilim/plugins/Systray.py60
1 files changed, 28 insertions, 32 deletions
diff --git a/nephilim/plugins/Systray.py b/nephilim/plugins/Systray.py
index 4a3c45d..6451090 100644
--- a/nephilim/plugins/Systray.py
+++ b/nephilim/plugins/Systray.py
@@ -5,40 +5,35 @@ from ..clPlugin import Plugin
from ..misc import sec2min, ORGNAME, APPNAME, appIcon, expand_tags
class Systray(Plugin):
- DEFAULTS = {'format': '$track - $title by $artist on $album ($length)'}
- o = None
- format = None
- eventObj = None
- time = None # indicator of current time [0..64]
- appIcon = None
- pixmap = None
- def __init__(self, winMain):
- Plugin.__init__(self, winMain, 'Systray')
- self.addListener('onSongChange', self.update)
- self.addListener('onReady', self.update)
- 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)
+ o = None
+ format = None
+ eventObj = None
+ time = None # indicator of current time [0..64]
+ appIcon = None
+ pixmap = None
+ DEFAULTS = {'format': '$track - $title by $artist on $album ($length)'}
+ LISTENERS = {'onSongChange' : 'update', 'onReady' : 'update', 'onConnect' : 'update',
+ 'onDisconnect' : 'update', 'onTimeChange' : 'update'}
def _load(self):
- self.format = self.settings.value(self.name + '/format').toString()
+ self.appIcon = QtGui.QIcon(appIcon)
+ self.format = self.settings().value(self.name() + '/format').toString()
class SystrayWheelEventObject(QtCore.QObject):
"""This class listens for systray-wheel events"""
def eventFilter(self, object, event):
if type(event)==QtGui.QWheelEvent:
numDegrees=event.delta() / 8
numSteps=5*numDegrees/15
- self.plugin.mpclient.set_volume(self.plugin.mpclient.volume() + numSteps)
+ self.plugin.mpclient()().set_volume(self.plugin.mpclient()().volume() + numSteps)
event.accept()
return True
return False
- self.o=QtGui.QSystemTrayIcon(QtGui.QIcon(appIcon), self.winMain)
+ self.o = QtGui.QSystemTrayIcon(QtGui.QIcon(appIcon), self.parent())
self.eventObj=SystrayWheelEventObject()
self.eventObj.plugin = self
self.o.installEventFilter(self.eventObj)
- self.winMain.connect(self.o, QtCore.SIGNAL('activated (QSystemTrayIcon::ActivationReason)')
+ self.parent().connect(self.o, QtCore.SIGNAL('activated (QSystemTrayIcon::ActivationReason)')
, self.onSysTrayClick)
self.o.show()
@@ -46,12 +41,12 @@ class Systray(Plugin):
self.o.hide()
self.o.setIcon(QtGui.QIcon(None))
self.o=None
- self.winMain._wheelEvent=None
+ self.parent()._wheelEvent=None
def getInfo(self):
return "Display the mpclientpc icon in the systray."
def update(self, params):
- status = self.mpclient.status()
+ status = self.mpclient().status()
if not status:
return
@@ -61,7 +56,7 @@ class Systray(Plugin):
values['length'] = sec2min(status['length'])
values['time'] = sec2min(status['time'])
- song = self.mpclient.current_song()
+ song = self.mpclient().current_song()
if song:
self.o.setToolTip(expand_tags(self.format, (song,)))
else:
@@ -76,27 +71,27 @@ class Systray(Plugin):
# redraw the systray icon
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))
+ painter.fillRect(1, curTime, 63, 64, self.parent().palette().brush(QtGui.QPalette.Base))
self.appIcon.paint(painter, 1, 0, 63, 64)
self.o.setIcon(QtGui.QIcon(self.pixmap))
elif not song:
- self.time=None
+ self.time = None
self.o.setIcon(QtGui.QIcon(appIcon))
def onSysTrayClick(self, reason):
if reason == QtGui.QSystemTrayIcon.Trigger or\
reason == QtGui.QSystemTrayIcon.Context:
- w = self.getWinMain()
+ w = self.parent()
# left mouse button
if w.isVisible():
w.setVisible(False)
else:
w.setVisible(True)
elif reason == QtGui.QSystemTrayIcon.MiddleClick:
- if self.mpclient.is_playing():
- self.mpclient.pause()
+ if self.mpclient().is_playing():
+ self.mpclient().pause()
else:
- self.mpclient.resume()
+ self.mpclient().resume()
class SettingsWidgetSystray(Plugin.SettingsWidget):
format = None
@@ -104,15 +99,16 @@ class Systray(Plugin):
def __init__(self, plugin):
Plugin.SettingsWidget.__init__(self, plugin)
- self.format = QtGui.QLineEdit(self.settings.value(self.plugin.getName() + '/format').toString())
+ self.format = QtGui.QLineEdit(self.settings().value(self.plugin.name() + '/format').toString())
self.setLayout(QtGui.QVBoxLayout())
self._add_widget(self.format, 'Tooltip format')
def save_settings(self):
- self.settings.beginGroup(self.plugin.getName())
- self.settings.setValue('format', QVariant(self.format.text()))
- self.settings.endGroup()
+ self.settings().beginGroup(self.plugin.name())
+ self.settings().setValue('format', QVariant(self.format.text()))
+ self.settings().endGroup()
def get_settings_widget(self):
return self.SettingsWidgetSystray(self)
+