From beea65b5d1f676da84b067f91f8f4f1f87f47ab1 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Thu, 12 May 2011 13:08:25 -0700 Subject: [PATCH] Bug fix: Hopefully fix animated smilies slowing down over time --- convo.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/convo.py b/convo.py index b2b09c8..a73993c 100644 --- a/convo.py +++ b/convo.py @@ -221,20 +221,21 @@ class PesterText(QtGui.QTextEdit): self, QtCore.SLOT('textReady(bool)')) self.urls = {} for k in smiledict: - self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k])); + self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k])) def addAnimation(self, url, fileName): movie = QtGui.QMovie(self) movie.setFileName(fileName) self.urls[movie] = url self.connect(movie, QtCore.SIGNAL('frameChanged(int)'), - self, QtCore.SLOT('animate()')); - movie.start(); + self, QtCore.SLOT('animate()')) + movie.start() @QtCore.pyqtSlot() def animate(self): movie = self.sender() + self.document().resource(QtGui.QTextDocument.ImageResource, self.urls[movie]).clear() self.document().addResource(QtGui.QTextDocument.ImageResource, - self.urls[movie], movie.currentPixmap()); - self.setLineWrapColumnOrWidth(self.lineWrapColumnOrWidth()); + self.urls[movie], movie.currentPixmap()) + self.setLineWrapColumnOrWidth(self.lineWrapColumnOrWidth()) @QtCore.pyqtSlot(bool) def textReady(self, ready): @@ -331,7 +332,8 @@ class PesterText(QtGui.QTextEdit): QtGui.QTextEdit.focusInEvent(self, event) def keyPressEvent(self, event): - self.parent().textInput.keyPressEvent(event) + if hasattr(self.parent(), 'textInput'): + self.parent().textInput.keyPressEvent(event) QtGui.QTextEdit.keyPressEvent(self, event) def mousePressEvent(self, event):