Bug fix: Hopefully fix animated smilies slowing down over time

This commit is contained in:
Kiooeht 2011-05-12 13:08:25 -07:00
parent 06835f4cfb
commit beea65b5d1

View file

@ -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,6 +332,7 @@ class PesterText(QtGui.QTextEdit):
QtGui.QTextEdit.focusInEvent(self, event)
def keyPressEvent(self, event):
if hasattr(self.parent(), 'textInput'):
self.parent().textInput.keyPressEvent(event)
QtGui.QTextEdit.keyPressEvent(self, event)