From 7f776a8c54f2bc0e5df83837b6e00036abf622ca Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Tue, 3 May 2011 16:41:40 -0700 Subject: [PATCH] Animated smilies --- TODO.mkdn | 1 - convo.py | 19 ++++++++++++++++++- memos.py | 5 ++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/TODO.mkdn b/TODO.mkdn index 4fabf6b..020e582 100644 --- a/TODO.mkdn +++ b/TODO.mkdn @@ -10,7 +10,6 @@ Features * More complex quirks: by-sound * Theme checking * Spy mode -* Animated * Turn @ and # links on/off? Bugs diff --git a/convo.py b/convo.py index 101da6a..17deb8b 100644 --- a/convo.py +++ b/convo.py @@ -9,7 +9,7 @@ from PyQt4 import QtGui, QtCore from dataobjs import PesterProfile, Mood, PesterHistory from generic import PesterIcon -from parsetools import convertTags, lexMessage, splitMessage, mecmd, colorBegin, colorEnd, img2smiley +from parsetools import convertTags, lexMessage, splitMessage, mecmd, colorBegin, colorEnd, img2smiley, smiledict class PesterTabWindow(QtGui.QFrame): def __init__(self, mainwindow, parent=None, convo="convo"): @@ -206,6 +206,23 @@ class PesterText(QtGui.QTextEdit): self.textSelected = False self.connect(self, QtCore.SIGNAL('copyAvailable(bool)'), self, QtCore.SLOT('textReady(bool)')) + self.urls = {} + for k in smiledict: + 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(); + @QtCore.pyqtSlot() + def animate(self): + movie = self.sender() + self.document().addResource(QtGui.QTextDocument.ImageResource, + self.urls[movie], movie.currentPixmap()); + self.setLineWrapColumnOrWidth(self.lineWrapColumnOrWidth()); + @QtCore.pyqtSlot(bool) def textReady(self, ready): self.textSelected = ready diff --git a/memos.py b/memos.py index 443ee8a..2738f8f 100644 --- a/memos.py +++ b/memos.py @@ -8,7 +8,7 @@ from dataobjs import PesterProfile, Mood, PesterHistory from generic import PesterIcon, RightClickList, mysteryTime from convo import PesterConvo, PesterInput, PesterText, PesterTabWindow from parsetools import convertTags, addTimeInitial, timeProtocol, \ - lexMessage, colorBegin, colorEnd, mecmd + lexMessage, colorBegin, colorEnd, mecmd, smiledict from logviewer import PesterLogViewer @@ -241,6 +241,9 @@ class MemoText(PesterText): self.textSelected = False self.connect(self, QtCore.SIGNAL('copyAvailable(bool)'), self, QtCore.SLOT('textReady(bool)')) + self.urls = {} + for k in smiledict: + self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k])); def initTheme(self, theme): if theme.has_key("memos/scrollbar"):