diff options
author | Anton Khirnov <wyskas@gmail.com> | 2009-02-23 18:49:19 +0100 |
---|---|---|
committer | Anton Khirnov <wyskas@gmail.com> | 2009-02-23 18:49:19 +0100 |
commit | 54ed65e5334ebc8b5bddcec9d26da2bbd506c58c (patch) | |
tree | 4dfb01e5147a9d872244b0ff5897e61d940144cd /nephilim/plugins | |
parent | cd290e58fa5c45f2d2d68f457f18284a526ac59c (diff) |
Notify: use QTimer
Diffstat (limited to 'nephilim/plugins')
-rw-r--r-- | nephilim/plugins/Notify.py | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/nephilim/plugins/Notify.py b/nephilim/plugins/Notify.py index 2ef5be4..3c25d13 100644 --- a/nephilim/plugins/Notify.py +++ b/nephilim/plugins/Notify.py @@ -10,29 +10,33 @@ NOTIFY_PRIORITY_SONG = 1 NOTIFY_PRIORITY_VOLUME = 2 class winNotify(QtGui.QWidget): - _timerID=None - winMain=None - p=None + _timerID = None + winMain = None + p =None _current_priority = 0 - timer=None - + timer = None cover_label = None text_label = None def __init__(self, p, winMain, parent=None): QtGui.QWidget.__init__(self, parent) - self.p=p - self.winMain=winMain + self.p = p + self.winMain = winMain + + self.timer = QtCore.QTimer(self) + self.timer.setSingleShot(True) + self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.hide) layout = QtGui.QHBoxLayout() self.cover_label = QtGui.QLabel() self.text_label = QtGui.QLabel() self.text_label.setWordWrap(True) - layout.addWidget(self.cover_label) - layout.addWidget(self.text_label) - self.setLayout(layout) + + self.setLayout(QtGui.QHBoxLayout()) + self.layout().addWidget(self.cover_label) + self.layout().addWidget(self.text_label) self.setWindowFlags(QtCore.Qt.ToolTip | QtCore.Qt.WindowStaysOnTopHint) self.setWindowOpacity(0.7) @@ -57,14 +61,10 @@ class winNotify(QtGui.QWidget): self.cover_label.setPixmap(cover.scaledToHeight(self.fontInfo().pixelSize()*4)) self.text_label.setText(text) - if self._timerID: - self.killTimer(self._timerID) - self._timerID=self.startTimer(500) - self.timer = time*2 self.resize(self.layout().sizeHint()) self.centerH() self.setVisible(True) - self.timerEvent(None) + self.timer.start(time*1000) def hide(self): if self._timerID: @@ -78,12 +78,6 @@ class winNotify(QtGui.QWidget): size = self.geometry() self.move((screen.width()-size.width())/2, 100) - def timerEvent(self, event): - self.timer-=1 - if self.timer<=0: - self.hide() - self.update() - class Notify(Plugin): o=None DEFAULTS = {'songformat' : '$track - $artist - $title ($album) [$length]', |