smileys support
|
@ -9,19 +9,23 @@ from util import curr_directory, convert_time
|
|||
from messages import FILE_TRANSFER_MESSAGE_STATUS
|
||||
from widgets import DataLabel, create_menu
|
||||
import cgi
|
||||
import smileys
|
||||
|
||||
|
||||
class MessageEdit(QtGui.QTextBrowser):
|
||||
|
||||
def __init__(self, text, width, parent=None):
|
||||
super(MessageEdit, self).__init__(parent)
|
||||
self.urls = {}
|
||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.setWordWrapMode(QtGui.QTextOption.WrapAtWordBoundaryOrAnywhere)
|
||||
self.document().setTextWidth(width)
|
||||
self.setOpenExternalLinks(True)
|
||||
self.setAcceptRichText(True)
|
||||
self.setOpenLinks(False)
|
||||
self.setTextWithLinks(text)
|
||||
self.setSearchPaths([smileys.SmileyLoader.get_instance().get_smileys_path()])
|
||||
self.setDecoratedText(text)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPixelSize(14)
|
||||
|
@ -47,7 +51,20 @@ class MessageEdit(QtGui.QTextBrowser):
|
|||
QtGui.QDesktopServices.openUrl(url)
|
||||
self.clearFocus()
|
||||
|
||||
def setTextWithLinks(self, text):
|
||||
def addAnimation(self, url, fileName):
|
||||
movie = QtGui.QMovie(self)
|
||||
movie.setFileName(fileName)
|
||||
self.urls[movie] = url
|
||||
movie.frameChanged[int].connect(lambda x: self.animate(movie))
|
||||
movie.start()
|
||||
|
||||
def animate(self, movie):
|
||||
self.document().addResource(QtGui.QTextDocument.ImageResource,
|
||||
self.urls[movie],
|
||||
movie.currentPixmap())
|
||||
self.setLineWrapColumnOrWidth(self.lineWrapColumnOrWidth())
|
||||
|
||||
def setDecoratedText(self, text):
|
||||
text = cgi.escape(text)
|
||||
exp = QtCore.QRegExp(
|
||||
'('
|
||||
|
@ -71,7 +88,9 @@ class MessageEdit(QtGui.QTextBrowser):
|
|||
for i in range(len(arr)):
|
||||
if arr[i].startswith('>'):
|
||||
arr[i] = '<font color="green">' + arr[i][4:] + '</font>'
|
||||
self.setHtml('<br>'.join(arr))
|
||||
text = '<br>'.join(arr)
|
||||
text = smileys.SmileyLoader.get_instance().add_smileys_to_text(text, self)
|
||||
self.setHtml(text)
|
||||
|
||||
|
||||
class MessageItem(QtGui.QWidget):
|
||||
|
|
|
@ -481,7 +481,7 @@ class NotificationsSettings(CenteredWidget):
|
|||
|
||||
class InterfaceSettings(CenteredWidget):
|
||||
"""Interface settings form"""
|
||||
|
||||
# TODO: add smileys support and drop themes support
|
||||
def __init__(self):
|
||||
super(InterfaceSettings, self).__init__()
|
||||
self.initUI()
|
||||
|
|
|
@ -332,7 +332,7 @@ class Profile(contact.Contact, Singleton):
|
|||
if text.startswith('/plugin '):
|
||||
plugin_support.PluginLoader.get_instance().command(text[8:])
|
||||
self._screen.messageEdit.clear()
|
||||
elif text:
|
||||
elif text and self._active_friend + 1:
|
||||
if text.startswith('/me '):
|
||||
message_type = TOX_MESSAGE_TYPE['ACTION']
|
||||
text = text[4:]
|
||||
|
|
|
@ -5,6 +5,7 @@ import locale
|
|||
from util import Singleton, curr_directory, log
|
||||
import pyaudio
|
||||
from toxencryptsave import LibToxEncryptSave
|
||||
import smileys
|
||||
|
||||
|
||||
class Settings(Singleton, dict):
|
||||
|
@ -31,6 +32,7 @@ class Settings(Singleton, dict):
|
|||
else:
|
||||
super(Settings, self).__init__(Settings.get_default_settings())
|
||||
self.save()
|
||||
smileys.SmileyLoader(self)
|
||||
p = pyaudio.PyAudio()
|
||||
self.audio = {'input': p.get_default_input_device_info()['index'],
|
||||
'output': p.get_default_output_device_info()['index']}
|
||||
|
@ -81,7 +83,9 @@ class Settings(Singleton, dict):
|
|||
'calls_sound': True,
|
||||
'blocked': [],
|
||||
'plugins': [],
|
||||
'notes': {}
|
||||
'notes': {},
|
||||
'smileys': True,
|
||||
'smiley_pack': 'default'
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
|
42
src/smileys.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import util
|
||||
import json
|
||||
try:
|
||||
from PySide import QtCore
|
||||
except ImportError:
|
||||
from PyQt4 import QtCore
|
||||
|
||||
|
||||
class SmileyLoader(util.Singleton):
|
||||
|
||||
def __init__(self, settings):
|
||||
self.settings = settings
|
||||
self.curr_pack = None
|
||||
self.smiles = {}
|
||||
self.load_pack()
|
||||
|
||||
def load_pack(self):
|
||||
pack_name = self.settings['smiley_pack']
|
||||
if self.settings['smileys'] and self.curr_pack != pack_name:
|
||||
self.curr_pack = pack_name
|
||||
path = self.get_smileys_path() + 'config.json'
|
||||
try:
|
||||
with open(path) as fl:
|
||||
self.smiles = json.loads(fl.read())
|
||||
print 'Smiley pack', pack_name, 'loaded'
|
||||
except:
|
||||
print 'Smiley pack', pack_name, 'was not loaded'
|
||||
|
||||
def get_smileys_path(self):
|
||||
return util.curr_directory() + '/smileys/' + self.curr_pack + '/'
|
||||
|
||||
def add_smileys_to_text(self, text, edit):
|
||||
if not self.settings['smileys']:
|
||||
return text
|
||||
arr = text.split(' ')
|
||||
for i in range(len(arr)):
|
||||
if arr[i] in self.smiles:
|
||||
file_name = self.smiles[arr[i]]
|
||||
arr[i] = u'<img title=\"{}\" src=\"{}\" />'.format(arr[i], file_name)
|
||||
if file_name.endswith('.gif'):
|
||||
edit.addAnimation(QtCore.QUrl(file_name), self.get_smileys_path() + file_name)
|
||||
return ' '.join(arr)
|
BIN
src/smileys/animated/_ao.gif
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
src/smileys/animated/aa.gif
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/smileys/animated/ab.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
src/smileys/animated/ac.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
src/smileys/animated/ad.gif
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
src/smileys/animated/ae.gif
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
src/smileys/animated/af.gif
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
src/smileys/animated/ag.gif
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
src/smileys/animated/ah.gif
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
src/smileys/animated/ai.gif
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
src/smileys/animated/aj.gif
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
src/smileys/animated/ak.gif
Normal file
After Width: | Height: | Size: 7.2 KiB |
BIN
src/smileys/animated/al.gif
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
src/smileys/animated/am.gif
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
src/smileys/animated/an.gif
Normal file
After Width: | Height: | Size: 9.8 KiB |
BIN
src/smileys/animated/ao.gif
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
src/smileys/animated/ap.gif
Normal file
After Width: | Height: | Size: 6 KiB |
BIN
src/smileys/animated/aq.gif
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
src/smileys/animated/ar.gif
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
src/smileys/animated/as.gif
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
src/smileys/animated/at.gif
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/smileys/animated/au.gif
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
src/smileys/animated/av.gif
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
src/smileys/animated/aw.gif
Normal file
After Width: | Height: | Size: 8.9 KiB |
BIN
src/smileys/animated/ax.gif
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
src/smileys/animated/ay.gif
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
src/smileys/animated/az.gif
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
src/smileys/animated/ba.gif
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
src/smileys/animated/bb.gif
Normal file
After Width: | Height: | Size: 868 B |
BIN
src/smileys/animated/bc.gif
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
src/smileys/animated/bd.gif
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
src/smileys/animated/be.gif
Normal file
After Width: | Height: | Size: 1,010 B |
BIN
src/smileys/animated/bf.gif
Normal file
After Width: | Height: | Size: 4.9 KiB |
BIN
src/smileys/animated/bg.gif
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
src/smileys/animated/bh.gif
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
src/smileys/animated/bi.gif
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
src/smileys/animated/bj.gif
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
src/smileys/animated/bk.gif
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
src/smileys/animated/bl.gif
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
src/smileys/animated/bm.gif
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
src/smileys/animated/bn.gif
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
src/smileys/animated/bo.gif
Normal file
After Width: | Height: | Size: 6.1 KiB |
BIN
src/smileys/animated/bp.gif
Normal file
After Width: | Height: | Size: 7.4 KiB |
BIN
src/smileys/animated/bq.gif
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
src/smileys/animated/br.gif
Normal file
After Width: | Height: | Size: 8.9 KiB |
BIN
src/smileys/animated/bs.gif
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
src/smileys/animated/bt.gif
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
src/smileys/animated/bu.gif
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
src/smileys/animated/bv.gif
Normal file
After Width: | Height: | Size: 1 KiB |
BIN
src/smileys/animated/bw.gif
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
src/smileys/animated/bx.gif
Normal file
After Width: | Height: | Size: 5 KiB |
BIN
src/smileys/animated/by.gif
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
src/smileys/animated/bz.gif
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
src/smileys/animated/ca.gif
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
src/smileys/animated/cb.gif
Normal file
After Width: | Height: | Size: 8 KiB |
BIN
src/smileys/animated/cd.gif
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
src/smileys/animated/ce.gif
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
src/smileys/animated/cf.gif
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
src/smileys/animated/cg.gif
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
src/smileys/animated/ch.gif
Normal file
After Width: | Height: | Size: 9.1 KiB |
BIN
src/smileys/animated/ci.gif
Normal file
After Width: | Height: | Size: 9.5 KiB |
BIN
src/smileys/animated/cj.gif
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
src/smileys/animated/ck.gif
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
src/smileys/animated/cl.gif
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
src/smileys/animated/cm.gif
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
src/smileys/animated/cn.gif
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
src/smileys/animated/co.gif
Normal file
After Width: | Height: | Size: 7.6 KiB |
1
src/smileys/animated/config.json
Normal file
|
@ -0,0 +1 @@
|
|||
{":/": "ao.gif", ":(": "ac.gif", ":)": "ab.gif", ":*": "aj.gif", ":rofl:": "bg.gif", ":$": "be.gif", "=|": "an.gif", ":!": "at.gif", ":#": "al.gif", ":spruse_up:": "ct.gif", "=b": "ae.gif", "%)": "be.gif", "O=)": "aa.gif", ":sorry:": "bh.gif", "=p": "ae.gif", "=P": "ae.gif", ":scratch:": "bw.gif", "=]": "bk.gif", "=)": "ab.gif", ":bb:": "br.gif", "O:)": "aa.gif", ":pardon:": "bk.gif", ":jokingly:": "ap.gif", ":wassup:": "bg.gif", ":sup:": "bg.gif", "=O": "ai.gif", ";'>": "ah.gif", ":lazy:": "dj.gif", "^.^": "aj.gif", ":kissed:": "as.gif", "=0": "ai.gif", ":tired:": "au.gif", ":b": "ae.gif", ":|": "an.gif", "0:)": "aa.gif", "O:-)": "aa.gif", ":yahoo!:": "bp.gif", ":censored:": "ch.gif", "}:>": "aq.gif", ":p": "ae.gif", "=(": "ac.gif", ":yeees!:": "bx.gif", "0_O": "ai.gif", ":training:": "du.gif", ":-'(": "ak.gif", ":D": "ag.gif", "B)": "af.gif", "LOVE*": "ba.gif", ":\\": "ao.gif", ":[": "ah.gif", ":P": "ae.gif", "8)": "af.gif", "X-)": "dc.gif", "+D": "ag.gif", ":'(": "ak.gif", ":-@": "am.gif", ":unknown:": "bn.gif", ":-D": "ag.gif", ":inlove:": "ba.gif", ":-[": "ah.gif", ":-X": "al.gif", "+P": "ae.gif", ":-\\": "ao.gif", ":friend:": "dk.gif", ":-P": "ae.gif", ":paint:": "dt.gif", ">:-]": "aq.gif", "+b": "ae.gif", "UP*": "ay.gif", ":diablo:": "aq.gif", ":-b": "ae.gif", "%-)": "be.gif", ":vava:": "cg.gif", ":yahoo:": "bp.gif", ":-x": "al.gif", "+p": "ae.gif", ":-~": "at.gif", ":-|": "an.gif", ";D": "bq.gif", ":-p": "ae.gif", ":v:": "dn.gif", ":sarcastic:": "ca.gif", "]:->": "aq.gif", "o_0": "ai.gif", ":mega_shok:": "dg.gif", ":hunter:": "cl.gif", "+{}": "aj.gif", ":pinkglasses:": "cq.gif", ";!": "at.gif", "8p": "ap.gif", "0+)": "aa.gif", ":-*": "aj.gif", ":-(": "ac.gif", ":-)": "ab.gif", ":-/": "ao.gif", ":sigh:": "db.gif", ":-#": "al.gif", "+)": "ab.gif", "+(": "ac.gif", ":hospital:": "co.gif", ":-{}": "aj.gif", "^_~": "ad.gif", ":thank:": "dh.gif", ":crazy:": "bm.gif", "o_O": "ai.gif", "8P": "ap.gif", "[:-}": "ar.gif", "@=": "bb.gif", ":this:": "ds.gif", ":beach:": "cj.gif", ":drink:": "az.gif", "@>}--`---": "ax.gif", ";)": "ad.gif", ">+o": "am.gif", "X)": "dc.gif", ":flirt:": "cu.gif", "=D": "ag.gif", ":tease:": "dp.gif", "\\m/": "bd.gif", ":focus:": "ck.gif", "X:": "al.gif", ":hysteric:": "cr.gif", ":happy:": "bu.gif", ":beee:": "by.gif", ":db:": "cd.gif", ":ok:": "bf.gif", ">+O": "am.gif", ":yes:": "df.gif", ":tender:": "cs.gif", ":kissing:": "aw.gif", ">:O": "am.gif", ":spiteful:": "do.gif", ":hi:": "bt.gif", "x:": "al.gif", ":{}": "aj.gif", ":girl_in_love:": "cp.gif", "={}": "aj.gif", ":dance:": "bo.gif", "]:>": "aq.gif", ">:]": "aq.gif", "8-)": "af.gif", "}:->": "aq.gif", ":girl_cray:": "cm.gif", ":acute:": "bq.gif", ":hoho:": "ce.gif", ">:o": "am.gif", "0=)": "aa.gif", ":girl_drink:": "cy.gif", ":bye:": "bs.gif", "|-0": "au.gif", ":lol:": "bv.gif", ":slow:": "dd.gif", ":help:": "bc.gif", "[:}": "ar.gif", ":-!": "at.gif", ":boss:": "bz.gif", "0_o": "ai.gif", ":shout:": "cf.gif", "0:-)": "aa.gif", "O_O": "ai.gif", ":wizard:": "dm.gif", ":curtsey:": "cw.gif", ":feminist:": "cx.gif", ":in_love:": "ba.gif", ":scare:": "dr.gif", ":girl_crazy:": "cn.gif", ":give_heart:": "cv.gif", ":bravo:": "bi.gif", ";-!": "at.gif", "O+)": "aa.gif", ";-.": "ah.gif", "O_o": "ai.gif", ";-)": "ad.gif", "=-O": "ai.gif", ":moil:": "de.gif", ":punish:": "dl.gif", ":good:": "ay.gif", ":boast:": "cb.gif", ":impossible:": "da.gif", ":party:": "dv.gif", ":stop:": "av.gif", "@}->--": "ax.gif", ":king:": "di.gif", "=-o": "ai.gif", ":dont_know:": "bn.gif", "O_0": "ai.gif", ";-~": "at.gif", "*IN": "ba.gif", ":no:": "bl.gif", "*THUMBS": "ay.gif", "@}-:--": "ax.gif", ":search:": "ci.gif", ":haha:": "cz.gif"}
|
BIN
src/smileys/animated/cp.gif
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
src/smileys/animated/cq.gif
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
src/smileys/animated/cr.gif
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
src/smileys/animated/cs.gif
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
src/smileys/animated/ct.gif
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
src/smileys/animated/cu.gif
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
src/smileys/animated/cv.gif
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
src/smileys/animated/cw.gif
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
src/smileys/animated/cx.gif
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
src/smileys/animated/cy.gif
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
src/smileys/animated/cz.gif
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
src/smileys/animated/da.gif
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
src/smileys/animated/db.gif
Normal file
After Width: | Height: | Size: 7 KiB |
BIN
src/smileys/animated/dc.gif
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
src/smileys/animated/dd.gif
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
src/smileys/animated/de.gif
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
src/smileys/animated/df.gif
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
src/smileys/animated/dg.gif
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
src/smileys/animated/dh.gif
Normal file
After Width: | Height: | Size: 4.5 KiB |
BIN
src/smileys/animated/di.gif
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
src/smileys/animated/dj.gif
Normal file
After Width: | Height: | Size: 7.1 KiB |
BIN
src/smileys/animated/dk.gif
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
src/smileys/animated/dl.gif
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
src/smileys/animated/dm.gif
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
src/smileys/animated/dn.gif
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
src/smileys/animated/do.gif
Normal file
After Width: | Height: | Size: 756 B |
BIN
src/smileys/animated/dp.gif
Normal file
After Width: | Height: | Size: 9.3 KiB |