From 54ed65e5334ebc8b5bddcec9d26da2bbd506c58c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 23 Feb 2009 18:49:19 +0100 Subject: Notify: use QTimer --- nephilim/plugins/Notify.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'nephilim') 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]', -- cgit v1.2.3