Animated smilies

This commit is contained in:
Kiooeht 2011-05-03 16:41:40 -07:00
parent 4d81ea1dab
commit 7f776a8c54
3 changed files with 22 additions and 3 deletions

View file

@ -10,7 +10,6 @@ Features
* More complex quirks: by-sound
* Theme checking
* Spy mode
* Animated
* Turn @ and # links on/off?
Bugs

View file

@ -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

View file

@ -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"):