From 0780f4761408065bdffd75d8884cca5b064868aa Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Mon, 16 May 2011 22:42:56 -0700 Subject: [PATCH] Bug fix: YAAFFA (Yet Another Attempted Fix For Animations) --- convo.py | 24 ++++++++++++++++++------ parsetools.py | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/convo.py b/convo.py index c08f1c9..2b26625 100644 --- a/convo.py +++ b/convo.py @@ -230,17 +230,29 @@ class PesterText(QtGui.QTextEdit): movie = QtGui.QMovie(self) movie.setFileName(fileName) self.urls[movie] = url + + for f in range(movie.frameCount()): + yes = movie.jumpToFrame(f) + if yes: + url = "%s_%s" % (self.urls[movie].toString(), f) + self.document().addResource(QtGui.QTextDocument.ImageResource, + QtCore.QUrl(url), movie.currentPixmap()) + self.connect(movie, QtCore.SIGNAL('frameChanged(int)'), - self, QtCore.SLOT('animate()')) + self, QtCore.SLOT('animate(int)')) movie.start() - @QtCore.pyqtSlot() - def animate(self): + @QtCore.pyqtSlot(int) + def animate(self, frame): if self.mainwindow.config.animations(): + scrollPos = self.verticalScrollBar().sliderPosition() movie = self.sender() - self.document().resource(QtGui.QTextDocument.ImageResource, self.urls[movie]).clear() - self.document().addResource(QtGui.QTextDocument.ImageResource, - self.urls[movie], movie.currentPixmap()) + url = self.urls[movie].toString() + def stuff(mo): + return '' % (url, frame) + html = re.sub(r'' % (url), stuff, str(self.toHtml())) + self.setHtml(html) self.setLineWrapColumnOrWidth(self.lineWrapColumnOrWidth()) + self.verticalScrollBar().setSliderPosition(scrollPos) @QtCore.pyqtSlot(bool) diff --git a/parsetools.py b/parsetools.py index b8f1d27..051adbf 100644 --- a/parsetools.py +++ b/parsetools.py @@ -424,7 +424,7 @@ smiledict = { ":manipulative:": "manipulative.png", ":vigorous:": "vigorous.png", ":perky:": "perky.png", - ":acceptant:": "acceptant.png", + ":acceptant:": "acceptant.gif", } reverse_smiley = dict((v,k) for k, v in smiledict.iteritems())