2011-01-21 05:18:22 -05:00
|
|
|
# pesterchum
|
|
|
|
import logging
|
2011-01-27 21:21:02 -05:00
|
|
|
import os, sys
|
|
|
|
import os.path
|
2011-01-28 03:10:00 -05:00
|
|
|
from datetime import *
|
2011-02-01 06:14:56 -05:00
|
|
|
from string import Template
|
2011-01-27 21:21:02 -05:00
|
|
|
import random
|
2011-01-21 05:18:22 -05:00
|
|
|
import json
|
2011-01-29 06:31:41 -05:00
|
|
|
import re
|
2011-01-21 05:18:22 -05:00
|
|
|
from PyQt4 import QtGui, QtCore
|
2011-01-29 06:31:41 -05:00
|
|
|
import pygame
|
2011-01-21 05:18:22 -05:00
|
|
|
|
2011-02-04 16:17:27 -05:00
|
|
|
from menus import PesterChooseQuirks, PesterChooseTheme, \
|
2011-02-04 19:50:56 -05:00
|
|
|
PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList, \
|
|
|
|
LoadingScreen
|
2011-02-04 16:17:27 -05:00
|
|
|
from dataobjs import PesterProfile, Mood, pesterQuirk, pesterQuirks
|
2011-02-05 12:17:33 -05:00
|
|
|
from generic import PesterIcon, RightClickList, MultiTextDialog, PesterList
|
2011-02-04 16:17:27 -05:00
|
|
|
from convo import PesterTabWindow, PesterText, PesterInput, PesterConvo
|
|
|
|
from parsetools import convertTags
|
2011-02-04 19:50:56 -05:00
|
|
|
from memos import PesterMemo, MemoTabWindow
|
2011-02-05 12:17:33 -05:00
|
|
|
from irc import PesterIRC
|
2011-01-21 05:18:22 -05:00
|
|
|
|
2011-01-29 06:31:41 -05:00
|
|
|
class waitingMessageHolder(object):
|
|
|
|
def __init__(self, mainwindow, **msgfuncs):
|
|
|
|
self.mainwindow = mainwindow
|
|
|
|
self.funcs = msgfuncs
|
|
|
|
self.queue = msgfuncs.keys()
|
|
|
|
if len(self.queue) > 0:
|
|
|
|
self.mainwindow.updateSystemTray()
|
|
|
|
def answerMessage(self):
|
|
|
|
func = self.funcs[self.queue[0]]
|
|
|
|
func()
|
|
|
|
def messageAnswered(self, handle):
|
|
|
|
if handle not in self.queue:
|
|
|
|
return
|
|
|
|
self.queue = [q for q in self.queue if q != handle]
|
|
|
|
del self.funcs[handle]
|
|
|
|
if len(self.queue) == 0:
|
|
|
|
self.mainwindow.updateSystemTray()
|
|
|
|
def addMessage(self, handle, func):
|
|
|
|
if not self.funcs.has_key(handle):
|
|
|
|
self.queue.append(handle)
|
|
|
|
self.funcs[handle] = func
|
|
|
|
if len(self.queue) > 0:
|
|
|
|
self.mainwindow.updateSystemTray()
|
|
|
|
def __len__(self):
|
|
|
|
return len(self.queue)
|
|
|
|
|
|
|
|
class NoneSound(object):
|
|
|
|
def play(self): pass
|
|
|
|
|
2011-02-02 03:20:48 -05:00
|
|
|
class PesterLog(object):
|
|
|
|
def __init__(self, handle):
|
|
|
|
self.handle = handle
|
|
|
|
if not os.path.exists("logs/%s" % (handle)):
|
|
|
|
os.mkdir("logs/%s" % (handle))
|
|
|
|
self.convos = {}
|
|
|
|
def log(self, handle, msg):
|
|
|
|
if not self.convos.has_key(handle):
|
2011-02-04 16:17:27 -05:00
|
|
|
time = datetime.now().strftime("%Y-%m-%d.%H.%M.txt")
|
2011-02-02 03:20:48 -05:00
|
|
|
if not os.path.exists("logs/%s/%s" % (self.handle, handle)):
|
|
|
|
os.mkdir("logs/%s/%s" % (self.handle, handle))
|
|
|
|
fp = open("logs/%s/%s/%s.%s" % (self.handle, handle, handle, time), 'a')
|
|
|
|
self.convos[handle] = fp
|
|
|
|
self.convos[handle].write(msg+"\n")
|
|
|
|
self.convos[handle].flush()
|
|
|
|
def finish(self, handle):
|
|
|
|
if not self.convos.has_key(handle):
|
|
|
|
return
|
|
|
|
self.convos[handle].close()
|
|
|
|
del self.convos[handle]
|
|
|
|
def close(self):
|
|
|
|
for h in self.convos.keys():
|
2011-02-02 19:06:03 -05:00
|
|
|
self.convos[h].close()
|
2011-02-02 03:20:48 -05:00
|
|
|
|
2011-01-31 18:43:49 -05:00
|
|
|
class PesterProfileDB(dict):
|
|
|
|
def __init__(self):
|
|
|
|
try:
|
|
|
|
fp = open("logs/chums.js", 'r')
|
|
|
|
chumdict = json.load(fp)
|
|
|
|
fp.close()
|
|
|
|
except IOError:
|
|
|
|
chumdict = {}
|
|
|
|
fp = open("logs/chums.js", 'w')
|
|
|
|
json.dump(chumdict, fp)
|
|
|
|
fp.close()
|
2011-02-01 02:46:25 -05:00
|
|
|
converted = dict([(handle, PesterProfile(handle, color=QtGui.QColor(c['color']), mood=Mood(c['mood']))) for (handle, c) in chumdict.iteritems()])
|
2011-01-31 18:43:49 -05:00
|
|
|
self.update(converted)
|
|
|
|
|
|
|
|
def save(self):
|
|
|
|
fp = open("logs/chums.js", 'w')
|
|
|
|
chumdict = dict([p.plaindict() for p in self.itervalues()])
|
|
|
|
json.dump(chumdict, fp)
|
|
|
|
fp.close()
|
|
|
|
def getColor(self, handle, default=None):
|
|
|
|
if not self.has_key(handle):
|
|
|
|
return default
|
|
|
|
else:
|
2011-02-01 06:14:56 -05:00
|
|
|
return self[handle].color
|
2011-01-31 18:43:49 -05:00
|
|
|
def setColor(self, handle, color):
|
|
|
|
if self.has_key(handle):
|
|
|
|
self[handle].color = color
|
|
|
|
else:
|
|
|
|
self[handle] = PesterProfile(handle, color)
|
|
|
|
def __setitem__(self, key, val):
|
|
|
|
dict.__setitem__(self, key, val)
|
|
|
|
self.save()
|
|
|
|
|
2011-01-24 02:34:07 -05:00
|
|
|
class pesterTheme(dict):
|
2011-01-22 04:36:24 -05:00
|
|
|
def __init__(self, name):
|
|
|
|
self.path = "themes/%s" % (name)
|
2011-01-28 06:17:42 -05:00
|
|
|
self.name = name
|
2011-01-22 04:36:24 -05:00
|
|
|
fp = open(self.path+"/style.js")
|
2011-01-24 02:34:07 -05:00
|
|
|
theme = json.load(fp, object_hook=self.pathHook)
|
|
|
|
self.update(theme)
|
2011-01-22 04:36:24 -05:00
|
|
|
fp.close()
|
2011-01-24 02:34:07 -05:00
|
|
|
def __getitem__(self, key):
|
|
|
|
keys = key.split("/")
|
|
|
|
v = dict.__getitem__(self, keys.pop(0))
|
|
|
|
for k in keys:
|
|
|
|
v = v[k]
|
|
|
|
return v
|
2011-01-22 04:36:24 -05:00
|
|
|
def pathHook(self, d):
|
|
|
|
for (k, v) in d.iteritems():
|
|
|
|
if type(v) is unicode:
|
|
|
|
s = Template(v)
|
2011-02-01 06:14:56 -05:00
|
|
|
d[k] = s.safe_substitute(path=self.path)
|
2011-01-22 04:36:24 -05:00
|
|
|
return d
|
2011-01-21 05:18:22 -05:00
|
|
|
|
2011-01-29 07:33:35 -05:00
|
|
|
|
2011-01-21 05:18:22 -05:00
|
|
|
class userConfig(object):
|
2011-01-27 04:46:47 -05:00
|
|
|
def __init__(self):
|
|
|
|
fp = open("pesterchum.js")
|
2011-01-21 05:18:22 -05:00
|
|
|
self.config = json.load(fp)
|
|
|
|
fp.close()
|
2011-01-27 21:21:02 -05:00
|
|
|
if self.config.has_key("defaultprofile"):
|
2011-01-28 01:08:56 -05:00
|
|
|
self.userprofile = userProfile(self.config["defaultprofile"])
|
2011-01-27 21:21:02 -05:00
|
|
|
else:
|
2011-01-28 01:08:56 -05:00
|
|
|
self.userprofile = None
|
2011-01-21 05:18:22 -05:00
|
|
|
def chums(self):
|
|
|
|
return self.config['chums']
|
2011-01-28 01:08:56 -05:00
|
|
|
def defaultprofile(self):
|
|
|
|
try:
|
|
|
|
return self.config['defaultprofile']
|
|
|
|
except KeyError:
|
|
|
|
return None
|
2011-01-26 05:32:35 -05:00
|
|
|
def tabs(self):
|
|
|
|
return self.config["tabs"]
|
2011-01-29 06:31:41 -05:00
|
|
|
def addChum(self, chum):
|
|
|
|
newchums = self.config['chums'] + [chum.handle]
|
|
|
|
self.set("chums", newchums)
|
|
|
|
def removeChum(self, chum):
|
2011-02-02 19:06:03 -05:00
|
|
|
if type(chum) is PesterProfile:
|
|
|
|
handle = chum.handle
|
|
|
|
else:
|
|
|
|
handle = chum
|
|
|
|
newchums = [c for c in self.config['chums'] if c != handle]
|
2011-01-29 06:31:41 -05:00
|
|
|
self.set("chums", newchums)
|
2011-02-02 19:06:03 -05:00
|
|
|
def getBlocklist(self):
|
|
|
|
if not self.config.has_key('block'):
|
|
|
|
self.set('block', [])
|
|
|
|
return self.config['block']
|
|
|
|
def addBlocklist(self, handle):
|
|
|
|
l = self.getBlocklist()
|
|
|
|
if handle not in l:
|
|
|
|
l.append(handle)
|
|
|
|
self.set('block', l)
|
|
|
|
def delBlocklist(self, handle):
|
|
|
|
l = self.getBlocklist()
|
|
|
|
l.pop(l.index(handle))
|
|
|
|
self.set('block', l)
|
2011-01-27 04:46:47 -05:00
|
|
|
def set(self, item, setting):
|
|
|
|
self.config[item] = setting
|
2011-02-03 01:20:37 -05:00
|
|
|
try:
|
|
|
|
jsonoutput = json.dumps(self.config)
|
|
|
|
except ValueError, e:
|
|
|
|
raise e
|
2011-01-27 04:46:47 -05:00
|
|
|
fp = open("pesterchum.js", 'w')
|
2011-02-03 01:20:37 -05:00
|
|
|
fp.write(jsonoutput)
|
2011-01-27 04:46:47 -05:00
|
|
|
fp.close()
|
2011-01-28 06:17:42 -05:00
|
|
|
def availableThemes(self):
|
|
|
|
themes = []
|
|
|
|
for dirname, dirnames, filenames in os.walk('themes'):
|
|
|
|
for d in dirnames:
|
|
|
|
themes.append(d)
|
|
|
|
themes.sort()
|
|
|
|
return themes
|
2011-01-27 21:21:02 -05:00
|
|
|
def availableProfiles(self):
|
|
|
|
profs = []
|
|
|
|
for dirname, dirnames, filenames in os.walk('profiles'):
|
|
|
|
for filename in filenames:
|
|
|
|
l = len(filename)
|
|
|
|
if filename[l-3:l] == ".js":
|
|
|
|
profs.append(filename[0:l-3])
|
|
|
|
profs.sort()
|
|
|
|
return [userProfile(p) for p in profs]
|
|
|
|
class userProfile(object):
|
|
|
|
def __init__(self, user):
|
|
|
|
if type(user) is PesterProfile:
|
|
|
|
self.chat = user
|
|
|
|
self.userprofile = {"handle":user.handle,
|
|
|
|
"color": unicode(user.color.name()),
|
|
|
|
"quirks": [],
|
|
|
|
"theme": "pesterchum"}
|
|
|
|
self.theme = pesterTheme("pesterchum")
|
2011-01-28 21:36:12 -05:00
|
|
|
self.chat.mood = Mood(self.theme["main/defaultmood"])
|
2011-01-27 21:21:02 -05:00
|
|
|
self.quirks = pesterQuirks([])
|
|
|
|
else:
|
|
|
|
fp = open("profiles/%s.js" % (user))
|
|
|
|
self.userprofile = json.load(fp)
|
|
|
|
fp.close()
|
2011-01-31 18:43:49 -05:00
|
|
|
try:
|
|
|
|
self.theme = pesterTheme(self.userprofile["theme"])
|
|
|
|
except ValueError, e:
|
|
|
|
self.theme = pesterTheme("pesterchum")
|
|
|
|
|
2011-01-27 21:21:02 -05:00
|
|
|
self.chat = PesterProfile(self.userprofile["handle"],
|
|
|
|
QtGui.QColor(self.userprofile["color"]),
|
2011-01-28 21:36:12 -05:00
|
|
|
Mood(self.theme["main/defaultmood"]))
|
2011-01-27 21:21:02 -05:00
|
|
|
self.quirks = pesterQuirks(self.userprofile["quirks"])
|
2011-01-28 21:36:12 -05:00
|
|
|
def setMood(self, mood):
|
|
|
|
self.chat.mood = mood
|
2011-01-28 06:26:13 -05:00
|
|
|
def setTheme(self, theme):
|
|
|
|
self.theme = theme
|
|
|
|
self.userprofile["theme"] = theme.name
|
|
|
|
self.save()
|
|
|
|
def setColor(self, color):
|
|
|
|
self.chat.color = color
|
2011-01-29 07:33:35 -05:00
|
|
|
self.userprofile["color"] = unicode(color.name())
|
2011-01-28 06:26:13 -05:00
|
|
|
self.save()
|
|
|
|
def setQuirks(self, quirks):
|
|
|
|
self.quirks = quirks
|
2011-01-29 16:55:35 -05:00
|
|
|
self.userprofile["quirks"] = self.quirks.plainList()
|
2011-01-28 06:26:13 -05:00
|
|
|
self.save()
|
2011-01-27 21:21:02 -05:00
|
|
|
def getTheme(self):
|
|
|
|
return self.theme
|
|
|
|
def save(self):
|
|
|
|
handle = self.chat.handle
|
2011-02-03 01:20:37 -05:00
|
|
|
try:
|
2011-02-03 01:56:59 -05:00
|
|
|
jsonoutput = json.dumps(self.userprofile)
|
2011-02-03 01:20:37 -05:00
|
|
|
except ValueError, e:
|
|
|
|
raise e
|
2011-01-27 21:21:02 -05:00
|
|
|
fp = open("profiles/%s.js" % (handle), 'w')
|
2011-02-03 01:20:37 -05:00
|
|
|
fp.write(jsonoutput)
|
2011-01-27 21:21:02 -05:00
|
|
|
fp.close()
|
|
|
|
@staticmethod
|
|
|
|
def newUserProfile(chatprofile):
|
|
|
|
if os.path.exists("profiles/%s.js" % (chatprofile.handle)):
|
|
|
|
newprofile = userProfile(chatprofile.handle)
|
|
|
|
else:
|
|
|
|
newprofile = userProfile(chatprofile)
|
|
|
|
newprofile.save()
|
|
|
|
return newprofile
|
2011-01-29 16:55:35 -05:00
|
|
|
|
2011-01-21 05:18:22 -05:00
|
|
|
|
2011-01-27 04:46:47 -05:00
|
|
|
class WMButton(QtGui.QPushButton):
|
2011-01-21 05:18:22 -05:00
|
|
|
def __init__(self, icon, parent=None):
|
|
|
|
QtGui.QPushButton.__init__(self, icon, "", parent)
|
2011-02-02 03:20:48 -05:00
|
|
|
self.setIconSize(icon.realsize())
|
2011-01-21 05:18:22 -05:00
|
|
|
self.setFlat(True)
|
2011-01-22 04:36:24 -05:00
|
|
|
self.setStyleSheet("QPushButton { padding: 0px; }")
|
|
|
|
self.setAutoDefault(False)
|
|
|
|
|
|
|
|
class chumListing(QtGui.QListWidgetItem):
|
2011-01-28 01:08:56 -05:00
|
|
|
def __init__(self, chum, window):
|
2011-01-24 02:34:07 -05:00
|
|
|
QtGui.QListWidgetItem.__init__(self, chum.handle)
|
2011-01-28 03:59:03 -05:00
|
|
|
self.mainwindow = window
|
2011-01-24 02:34:07 -05:00
|
|
|
self.chum = chum
|
|
|
|
self.handle = chum.handle
|
2011-01-22 04:36:24 -05:00
|
|
|
self.setMood(Mood("offline"))
|
|
|
|
def setMood(self, mood):
|
2011-01-24 04:10:44 -05:00
|
|
|
self.chum.mood = mood
|
|
|
|
self.updateMood()
|
2011-01-28 04:07:20 -05:00
|
|
|
def setColor(self, color):
|
|
|
|
self.chum.color = color
|
2011-02-02 07:26:17 -05:00
|
|
|
def updateMood(self, unblock=False):
|
2011-01-24 04:10:44 -05:00
|
|
|
mood = self.chum.mood
|
2011-01-22 04:36:24 -05:00
|
|
|
self.mood = mood
|
2011-02-03 03:51:22 -05:00
|
|
|
icon = self.mood.icon(self.mainwindow.theme)
|
|
|
|
self.setIcon(icon)
|
2011-02-03 01:20:37 -05:00
|
|
|
try:
|
|
|
|
self.setTextColor(QtGui.QColor(self.mainwindow.theme["main/chums/moods"][self.mood.name()]["color"]))
|
|
|
|
except KeyError:
|
|
|
|
self.setTextColor(QtGui.QColor(self.mainwindow.theme["main/chums/moods/chummy/color"]))
|
2011-01-28 06:17:42 -05:00
|
|
|
def changeTheme(self, theme):
|
2011-02-03 03:51:22 -05:00
|
|
|
icon = self.mood.icon(theme)
|
|
|
|
self.setIcon(icon)
|
2011-02-03 01:20:37 -05:00
|
|
|
try:
|
|
|
|
self.setTextColor(QtGui.QColor(self.mainwindow.theme["main/chums/moods"][self.mood.name()]["color"]))
|
|
|
|
except KeyError:
|
|
|
|
self.setTextColor(QtGui.QColor(self.mainwindow.theme["main/chums/moods/chummy/color"]))
|
2011-01-22 04:36:24 -05:00
|
|
|
def __lt__(self, cl):
|
|
|
|
h1 = self.handle.lower()
|
|
|
|
h2 = cl.handle.lower()
|
|
|
|
return (h1 < h2)
|
2011-01-21 05:18:22 -05:00
|
|
|
|
2011-02-02 19:32:35 -05:00
|
|
|
class chumArea(RightClickList):
|
2011-01-28 01:08:56 -05:00
|
|
|
def __init__(self, chums, parent=None):
|
2011-01-21 05:18:22 -05:00
|
|
|
QtGui.QListWidget.__init__(self, parent)
|
2011-01-28 03:59:03 -05:00
|
|
|
self.mainwindow = parent
|
|
|
|
theme = self.mainwindow.theme
|
2011-01-24 02:34:07 -05:00
|
|
|
geometry = theme["main/chums/loc"] + theme["main/chums/size"]
|
2011-01-22 04:36:24 -05:00
|
|
|
self.setGeometry(*geometry)
|
2011-01-24 02:34:07 -05:00
|
|
|
self.setStyleSheet(theme["main/chums/style"])
|
2011-01-21 05:18:22 -05:00
|
|
|
self.chums = chums
|
|
|
|
for c in self.chums:
|
2011-01-24 02:34:07 -05:00
|
|
|
chandle = c.handle
|
|
|
|
if not self.findItems(chandle, QtCore.Qt.MatchFlags(0)):
|
2011-01-28 03:59:03 -05:00
|
|
|
chumLabel = chumListing(c, self.mainwindow)
|
2011-01-22 04:36:24 -05:00
|
|
|
self.addItem(chumLabel)
|
2011-01-29 06:31:41 -05:00
|
|
|
|
|
|
|
self.optionsMenu = QtGui.QMenu(self)
|
2011-02-01 06:14:56 -05:00
|
|
|
self.pester = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self)
|
|
|
|
self.connect(self.pester, QtCore.SIGNAL('triggered()'),
|
2011-01-29 06:31:41 -05:00
|
|
|
self, QtCore.SLOT('activateChum()'))
|
2011-02-01 06:14:56 -05:00
|
|
|
self.removechum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/removechum"], self)
|
|
|
|
self.connect(self.removechum, QtCore.SIGNAL('triggered()'),
|
2011-01-29 06:31:41 -05:00
|
|
|
self, QtCore.SLOT('removeChum()'))
|
2011-02-02 07:26:17 -05:00
|
|
|
self.blockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self)
|
|
|
|
self.connect(self.blockchum, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('blockChum()'))
|
2011-02-01 06:14:56 -05:00
|
|
|
self.optionsMenu.addAction(self.pester)
|
2011-02-02 07:26:17 -05:00
|
|
|
self.optionsMenu.addAction(self.blockchum)
|
2011-02-01 06:14:56 -05:00
|
|
|
self.optionsMenu.addAction(self.removechum)
|
2011-01-29 06:31:41 -05:00
|
|
|
|
2011-01-22 04:36:24 -05:00
|
|
|
self.sortItems()
|
2011-01-29 06:31:41 -05:00
|
|
|
def addChum(self, chum):
|
|
|
|
if len([c for c in self.chums if c.handle == chum.handle]) != 0:
|
|
|
|
return
|
|
|
|
self.chums.append(chum)
|
|
|
|
chumLabel = chumListing(chum, self.mainwindow)
|
|
|
|
self.addItem(chumLabel)
|
|
|
|
self.sortItems()
|
|
|
|
|
2011-02-02 07:26:17 -05:00
|
|
|
def getChums(self, handle):
|
2011-01-24 02:34:07 -05:00
|
|
|
chums = self.findItems(handle, QtCore.Qt.MatchFlags(0))
|
2011-02-02 07:26:17 -05:00
|
|
|
return chums
|
|
|
|
def updateMood(self, handle, mood):
|
|
|
|
chums = self.getChums(handle)
|
2011-01-22 04:36:24 -05:00
|
|
|
for c in chums:
|
|
|
|
c.setMood(mood)
|
2011-01-28 04:07:20 -05:00
|
|
|
def updateColor(self, handle, color):
|
|
|
|
chums = self.findItems(handle, QtCore.Qt.MatchFlags(0))
|
|
|
|
for c in chums:
|
|
|
|
c.setColor(color)
|
2011-01-28 06:17:42 -05:00
|
|
|
def changeTheme(self, theme):
|
|
|
|
self.setGeometry(*(theme["main/chums/loc"]+theme["main/chums/size"]))
|
|
|
|
self.setStyleSheet(theme["main/chums/style"])
|
2011-02-01 06:14:56 -05:00
|
|
|
self.pester.setText(theme["main/menus/rclickchumlist/pester"])
|
|
|
|
self.removechum.setText(theme["main/menus/rclickchumlist/removechum"])
|
2011-02-02 07:26:17 -05:00
|
|
|
self.blockchum.setText(theme["main/menus/rclickchumlist/blockchum"])
|
2011-02-01 06:14:56 -05:00
|
|
|
|
2011-01-29 06:31:41 -05:00
|
|
|
chumlistings = [self.item(i) for i in range(0, self.count())]
|
|
|
|
for c in chumlistings:
|
2011-01-28 06:17:42 -05:00
|
|
|
c.changeTheme(theme)
|
2011-01-29 06:31:41 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def activateChum(self):
|
|
|
|
self.itemActivated.emit(self.currentItem())
|
|
|
|
@QtCore.pyqtSlot()
|
2011-02-02 19:06:03 -05:00
|
|
|
def removeChum(self, handle = None):
|
|
|
|
if handle:
|
|
|
|
clistings = self.getChums(handle)
|
|
|
|
for c in clistings:
|
|
|
|
self.setCurrentItem(c)
|
|
|
|
if not self.currentItem():
|
|
|
|
return
|
2011-01-29 06:31:41 -05:00
|
|
|
currentChum = self.currentItem().chum
|
|
|
|
self.chums = [c for c in self.chums if c.handle != currentChum.handle]
|
|
|
|
self.removeChumSignal.emit(self.currentItem())
|
|
|
|
oldlist = self.takeItem(self.currentRow())
|
|
|
|
del oldlist
|
2011-02-02 07:26:17 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def blockChum(self):
|
|
|
|
currentChum = self.currentItem()
|
2011-02-02 19:06:03 -05:00
|
|
|
if not currentChum:
|
|
|
|
return
|
2011-02-02 07:26:17 -05:00
|
|
|
self.blockChumSignal.emit(self.currentItem().chum.handle)
|
2011-01-29 06:31:41 -05:00
|
|
|
|
|
|
|
removeChumSignal = QtCore.pyqtSignal(QtGui.QListWidgetItem)
|
2011-02-02 07:26:17 -05:00
|
|
|
blockChumSignal = QtCore.pyqtSignal(QtCore.QString)
|
2011-02-02 19:06:03 -05:00
|
|
|
|
|
|
|
class trollSlum(chumArea):
|
|
|
|
def __init__(self, trolls, mainwindow, parent=None):
|
|
|
|
QtGui.QListWidget.__init__(self, parent)
|
|
|
|
self.mainwindow = mainwindow
|
|
|
|
theme = self.mainwindow.theme
|
|
|
|
self.setStyleSheet(theme["main/trollslum/chumroll/style"])
|
|
|
|
self.chums = trolls
|
|
|
|
for c in self.chums:
|
|
|
|
chandle = c.handle
|
|
|
|
if not self.findItems(chandle, QtCore.Qt.MatchFlags(0)):
|
|
|
|
chumLabel = chumListing(c, self.mainwindow)
|
|
|
|
self.addItem(chumLabel)
|
|
|
|
|
2011-02-02 19:32:35 -05:00
|
|
|
self.optionsMenu = QtGui.QMenu(self)
|
2011-02-02 19:06:03 -05:00
|
|
|
self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
|
|
|
|
self.connect(self.unblockchum, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SIGNAL('unblockChumSignal()'))
|
2011-02-02 19:32:35 -05:00
|
|
|
self.optionsMenu.addAction(self.unblockchum)
|
2011-02-02 19:06:03 -05:00
|
|
|
|
|
|
|
self.sortItems()
|
|
|
|
def changeTheme(self, theme):
|
|
|
|
self.setStyleSheet(theme["main/trollslum/chumroll/style"])
|
|
|
|
self.removechum.setText(theme["main/menus/rclickchumlist/removechum"])
|
|
|
|
self.unblockchum.setText(theme["main/menus/rclickchumlist/blockchum"])
|
|
|
|
|
|
|
|
chumlistings = [self.item(i) for i in range(0, self.count())]
|
|
|
|
for c in chumlistings:
|
|
|
|
c.changeTheme(theme)
|
|
|
|
|
|
|
|
unblockChumSignal = QtCore.pyqtSignal(QtCore.QString)
|
|
|
|
|
|
|
|
class TrollSlumWindow(QtGui.QFrame):
|
|
|
|
def __init__(self, trolls, mainwindow, parent=None):
|
|
|
|
QtGui.QFrame.__init__(self, parent)
|
|
|
|
self.mainwindow = mainwindow
|
|
|
|
theme = self.mainwindow.theme
|
|
|
|
self.slumlabel = QtGui.QLabel(self)
|
|
|
|
self.initTheme(theme)
|
|
|
|
|
|
|
|
self.trollslum = trollSlum(trolls, self.mainwindow, self)
|
|
|
|
self.connect(self.trollslum, QtCore.SIGNAL('unblockChumSignal()'),
|
|
|
|
self, QtCore.SLOT('removeCurrentTroll()'))
|
|
|
|
layout_1 = QtGui.QHBoxLayout()
|
|
|
|
self.addButton = QtGui.QPushButton("ADD", self)
|
|
|
|
self.connect(self.addButton, QtCore.SIGNAL('clicked()'),
|
|
|
|
self, QtCore.SLOT('addTrollWindow()'))
|
|
|
|
self.removeButton = QtGui.QPushButton("REMOVE", self)
|
|
|
|
self.connect(self.removeButton, QtCore.SIGNAL('clicked()'),
|
|
|
|
self, QtCore.SLOT('removeCurrentTroll()'))
|
|
|
|
layout_1.addWidget(self.addButton)
|
|
|
|
layout_1.addWidget(self.removeButton)
|
|
|
|
|
|
|
|
layout_0 = QtGui.QVBoxLayout()
|
|
|
|
layout_0.addWidget(self.slumlabel)
|
|
|
|
layout_0.addWidget(self.trollslum)
|
|
|
|
layout_0.addLayout(layout_1)
|
|
|
|
self.setLayout(layout_0)
|
|
|
|
|
|
|
|
def initTheme(self, theme):
|
|
|
|
self.resize(*theme["main/trollslum/size"])
|
|
|
|
self.setStyleSheet(theme["main/trollslum/style"])
|
|
|
|
self.slumlabel.setText(theme["main/trollslum/label/text"])
|
|
|
|
self.slumlabel.setStyleSheet(theme["main/trollslum/label/style"])
|
|
|
|
if not self.parent():
|
|
|
|
self.setWindowTitle(theme["main/menus/profile/block"])
|
|
|
|
self.setWindowIcon(self.mainwindow.windowIcon())
|
|
|
|
def changeTheme(self, theme):
|
|
|
|
self.initTheme(theme)
|
|
|
|
self.trollslum.changeTheme(theme)
|
|
|
|
# move unblocked trolls from slum to chumarea
|
|
|
|
def closeEvent(self, event):
|
|
|
|
self.mainwindow.closeTrollSlum()
|
|
|
|
|
|
|
|
def updateMood(self, handle, mood):
|
|
|
|
self.trollslum.updateMood(handle, mood)
|
|
|
|
def addTroll(self, chum):
|
|
|
|
self.trollslum.addChum(chum)
|
|
|
|
def removeTroll(self, handle):
|
|
|
|
self.trollslum.removeChum(handle)
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def removeCurrentTroll(self):
|
|
|
|
currentListing = self.trollslum.currentItem()
|
|
|
|
if not currentListing:
|
|
|
|
return
|
|
|
|
self.unblockChumSignal.emit(currentListing.chum.handle)
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def addTrollWindow(self):
|
|
|
|
if not hasattr(self, 'addtrolldialog'):
|
|
|
|
self.addtrolldialog = None
|
|
|
|
if self.addtrolldialog:
|
|
|
|
return
|
|
|
|
self.addtrolldialog = QtGui.QInputDialog(self)
|
|
|
|
(handle, ok) = self.addtrolldialog.getText(self, "Add Troll", "Enter Troll Handle:")
|
|
|
|
if ok:
|
|
|
|
handle = unicode(handle)
|
|
|
|
if not (PesterProfile.checkLength(handle) and
|
|
|
|
PesterProfile.checkValid(handle)):
|
|
|
|
errormsg = QtGui.QErrorMessage(self)
|
|
|
|
errormsg.showMessage("THIS IS NOT A VALID CHUMTAG!")
|
|
|
|
self.addchumdialog = None
|
|
|
|
return
|
|
|
|
self.blockChumSignal.emit(handle)
|
|
|
|
self.addtrolldialog = None
|
|
|
|
|
|
|
|
blockChumSignal = QtCore.pyqtSignal(QtCore.QString)
|
2011-02-02 07:26:17 -05:00
|
|
|
unblockChumSignal = QtCore.pyqtSignal(QtCore.QString)
|
2011-01-21 05:18:22 -05:00
|
|
|
|
2011-01-28 21:36:12 -05:00
|
|
|
class PesterMoodHandler(QtCore.QObject):
|
|
|
|
def __init__(self, parent, *buttons):
|
|
|
|
QtCore.QObject.__init__(self)
|
|
|
|
self.buttons = {}
|
|
|
|
self.mainwindow = parent
|
|
|
|
for b in buttons:
|
|
|
|
self.buttons[b.mood.value()] = b
|
|
|
|
if b.mood.value() == self.mainwindow.profile().mood.value():
|
|
|
|
b.setSelected(True)
|
|
|
|
self.connect(b, QtCore.SIGNAL('clicked()'),
|
|
|
|
b, QtCore.SLOT('updateMood()'))
|
|
|
|
self.connect(b, QtCore.SIGNAL('moodUpdated(int)'),
|
|
|
|
self, QtCore.SLOT('updateMood(int)'))
|
|
|
|
def removeButtons(self):
|
|
|
|
for b in self.buttons.values():
|
|
|
|
b.close()
|
|
|
|
def showButtons(self):
|
|
|
|
for b in self.buttons.values():
|
|
|
|
b.show()
|
|
|
|
b.raise_()
|
|
|
|
@QtCore.pyqtSlot(int)
|
|
|
|
def updateMood(self, m):
|
|
|
|
oldmood = self.mainwindow.profile().mood
|
2011-02-03 01:20:37 -05:00
|
|
|
try:
|
|
|
|
oldbutton = self.buttons[oldmood.value()]
|
|
|
|
oldbutton.setSelected(False)
|
|
|
|
except KeyError:
|
|
|
|
pass
|
2011-01-28 21:36:12 -05:00
|
|
|
newbutton = self.buttons[m]
|
|
|
|
newbutton.setSelected(True)
|
|
|
|
newmood = Mood(m)
|
|
|
|
self.mainwindow.userprofile.chat.mood = newmood
|
|
|
|
self.mainwindow.moodUpdated.emit()
|
|
|
|
|
|
|
|
class PesterMoodButton(QtGui.QPushButton):
|
|
|
|
def __init__(self, parent, **options):
|
2011-02-02 03:20:48 -05:00
|
|
|
icon = PesterIcon(options["icon"])
|
2011-01-28 21:36:12 -05:00
|
|
|
QtGui.QPushButton.__init__(self, icon, options["text"], parent)
|
2011-02-02 03:20:48 -05:00
|
|
|
self.setIconSize(icon.realsize())
|
2011-01-28 21:36:12 -05:00
|
|
|
self.setFlat(True)
|
|
|
|
self.resize(*options["size"])
|
|
|
|
self.move(*options["loc"])
|
|
|
|
self.unselectedSheet = options["style"]
|
|
|
|
self.selectedSheet = options["selected"]
|
|
|
|
self.setStyleSheet(self.unselectedSheet)
|
|
|
|
self.mainwindow = parent
|
|
|
|
self.mood = Mood(options["mood"])
|
|
|
|
def setSelected(self, selected):
|
|
|
|
if selected:
|
|
|
|
self.setStyleSheet(self.selectedSheet)
|
|
|
|
else:
|
|
|
|
self.setStyleSheet(self.unselectedSheet)
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def updateMood(self):
|
|
|
|
self.moodUpdated.emit(self.mood.value())
|
|
|
|
moodUpdated = QtCore.pyqtSignal(int)
|
|
|
|
|
2011-02-02 03:20:48 -05:00
|
|
|
|
2011-01-22 04:36:24 -05:00
|
|
|
class MovingWindow(QtGui.QFrame):
|
|
|
|
def __init__(self, *x, **y):
|
|
|
|
QtGui.QFrame.__init__(self, *x, **y)
|
2011-01-21 05:18:22 -05:00
|
|
|
self.moving = None
|
2011-01-21 19:37:02 -05:00
|
|
|
self.moveupdate = 0
|
2011-01-21 05:18:22 -05:00
|
|
|
def mouseMoveEvent(self, event):
|
|
|
|
if self.moving:
|
|
|
|
move = event.globalPos() - self.moving
|
2011-01-21 19:37:02 -05:00
|
|
|
self.move(move)
|
|
|
|
self.moveupdate += 1
|
|
|
|
if self.moveupdate > 5:
|
|
|
|
self.moveupdate = 0
|
|
|
|
self.update()
|
2011-01-21 05:18:22 -05:00
|
|
|
def mousePressEvent(self, event):
|
|
|
|
if event.button() == 1:
|
2011-01-21 19:37:02 -05:00
|
|
|
self.moving = event.globalPos() - self.pos()
|
2011-01-21 05:18:22 -05:00
|
|
|
def mouseReleaseEvent(self, event):
|
|
|
|
if event.button() == 1:
|
2011-01-21 19:37:02 -05:00
|
|
|
self.update()
|
2011-01-21 05:18:22 -05:00
|
|
|
self.moving = None
|
2011-01-22 04:36:24 -05:00
|
|
|
|
2011-02-02 03:20:48 -05:00
|
|
|
|
2011-01-22 04:36:24 -05:00
|
|
|
class PesterWindow(MovingWindow):
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
MovingWindow.__init__(self, parent,
|
2011-02-02 03:20:48 -05:00
|
|
|
flags=(QtCore.Qt.CustomizeWindowHint |
|
|
|
|
QtCore.Qt.FramelessWindowHint))
|
2011-01-31 06:04:03 -05:00
|
|
|
|
|
|
|
self.convos = {}
|
2011-02-04 16:17:27 -05:00
|
|
|
self.memos = {}
|
2011-01-31 06:04:03 -05:00
|
|
|
self.tabconvo = None
|
2011-02-04 19:50:56 -05:00
|
|
|
self.tabmemo = None
|
2011-01-31 06:04:03 -05:00
|
|
|
|
2011-01-22 04:36:24 -05:00
|
|
|
self.setObjectName("main")
|
|
|
|
self.config = userConfig()
|
2011-01-28 01:08:56 -05:00
|
|
|
if self.config.defaultprofile():
|
|
|
|
self.userprofile = userProfile(self.config.defaultprofile())
|
|
|
|
self.theme = self.userprofile.getTheme()
|
|
|
|
else:
|
|
|
|
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0)))
|
|
|
|
self.theme = self.userprofile.getTheme()
|
|
|
|
|
2011-02-02 03:20:48 -05:00
|
|
|
self.chatlog = PesterLog(self.profile().handle)
|
|
|
|
|
2011-01-31 06:04:03 -05:00
|
|
|
self.move(100, 100)
|
2011-01-22 04:36:24 -05:00
|
|
|
|
2011-02-01 06:14:56 -05:00
|
|
|
opts = QtGui.QAction(self.theme["main/menus/client/options"], self)
|
|
|
|
self.opts = opts
|
2011-01-27 04:46:47 -05:00
|
|
|
self.connect(opts, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('openOpts()'))
|
2011-02-01 06:14:56 -05:00
|
|
|
exitaction = QtGui.QAction(self.theme["main/menus/client/exit"], self)
|
|
|
|
self.exitaction = exitaction
|
2011-01-27 04:46:47 -05:00
|
|
|
self.connect(exitaction, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('close()'))
|
2011-02-03 01:20:37 -05:00
|
|
|
userlistaction = QtGui.QAction(self.theme["main/menus/client/userlist"], self)
|
|
|
|
self.userlistaction = userlistaction
|
|
|
|
self.connect(userlistaction, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('showAllUsers()'))
|
2011-02-04 16:17:27 -05:00
|
|
|
memoaction = QtGui.QAction(self.theme["main/menus/client/memos"], self)
|
|
|
|
self.memoaction = memoaction
|
|
|
|
self.connect(memoaction, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('showMemos()'))
|
2011-01-27 04:46:47 -05:00
|
|
|
self.menu = QtGui.QMenuBar(self)
|
2011-02-03 01:20:37 -05:00
|
|
|
|
2011-02-01 06:14:56 -05:00
|
|
|
filemenu = self.menu.addMenu(self.theme["main/menus/client/_name"])
|
|
|
|
self.filemenu = filemenu
|
2011-01-27 04:46:47 -05:00
|
|
|
filemenu.addAction(opts)
|
2011-02-04 16:17:27 -05:00
|
|
|
filemenu.addAction(memoaction)
|
2011-02-03 01:20:37 -05:00
|
|
|
filemenu.addAction(userlistaction)
|
2011-01-27 04:46:47 -05:00
|
|
|
filemenu.addAction(exitaction)
|
2011-01-28 01:41:01 -05:00
|
|
|
|
2011-02-01 06:14:56 -05:00
|
|
|
changetheme = QtGui.QAction(self.theme["main/menus/profile/theme"], self)
|
|
|
|
self.changetheme = changetheme
|
2011-01-28 06:17:42 -05:00
|
|
|
self.connect(changetheme, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('pickTheme()'))
|
2011-02-01 06:14:56 -05:00
|
|
|
changequirks = QtGui.QAction(self.theme["main/menus/profile/quirks"], self)
|
|
|
|
self.changequirks = changequirks
|
2011-01-29 16:55:35 -05:00
|
|
|
self.connect(changequirks, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('openQuirks()'))
|
2011-02-02 19:06:03 -05:00
|
|
|
loadslum = QtGui.QAction(self.theme["main/menus/profile/block"], self)
|
|
|
|
self.loadslum = loadslum
|
|
|
|
self.connect(loadslum, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('showTrollSlum()'))
|
2011-01-29 16:55:35 -05:00
|
|
|
|
2011-02-02 07:26:17 -05:00
|
|
|
changecoloraction = QtGui.QAction(self.theme["main/menus/profile/color"], self)
|
|
|
|
self.changecoloraction = changecoloraction
|
|
|
|
self.connect(changecoloraction, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('changeMyColor()'))
|
|
|
|
|
2011-02-01 06:14:56 -05:00
|
|
|
switch = QtGui.QAction(self.theme["main/menus/profile/switch"], self)
|
|
|
|
self.switch = switch
|
|
|
|
self.connect(switch, QtCore.SIGNAL('triggered()'),
|
|
|
|
self, QtCore.SLOT('switchProfile()'))
|
|
|
|
|
|
|
|
profilemenu = self.menu.addMenu(self.theme["main/menus/profile/_name"])
|
|
|
|
self.profilemenu = profilemenu
|
2011-01-28 06:17:42 -05:00
|
|
|
profilemenu.addAction(changetheme)
|
2011-01-29 16:55:35 -05:00
|
|
|
profilemenu.addAction(changequirks)
|
2011-02-02 19:06:03 -05:00
|
|
|
profilemenu.addAction(loadslum)
|
2011-02-02 07:26:17 -05:00
|
|
|
profilemenu.addAction(changecoloraction)
|
2011-01-29 16:55:35 -05:00
|
|
|
profilemenu.addAction(switch)
|
2011-01-28 01:41:01 -05:00
|
|
|
|
2011-02-02 03:20:48 -05:00
|
|
|
self.closeButton = WMButton(PesterIcon(self.theme["main/close/image"]), self)
|
2011-01-22 04:36:24 -05:00
|
|
|
self.connect(self.closeButton, QtCore.SIGNAL('clicked()'),
|
|
|
|
self, QtCore.SLOT('close()'))
|
2011-02-02 03:20:48 -05:00
|
|
|
self.miniButton = WMButton(PesterIcon(self.theme["main/minimize/image"]), self)
|
2011-01-27 04:46:47 -05:00
|
|
|
self.connect(self.miniButton, QtCore.SIGNAL('clicked()'),
|
|
|
|
self, QtCore.SLOT('showMinimized()'))
|
|
|
|
|
2011-02-03 01:20:37 -05:00
|
|
|
self.namesdb = {}
|
2011-01-31 18:43:49 -05:00
|
|
|
self.chumdb = PesterProfileDB()
|
|
|
|
|
2011-02-01 06:14:56 -05:00
|
|
|
chums = [PesterProfile(c, chumdb=self.chumdb) for c in set(self.config.chums())]
|
2011-01-28 01:08:56 -05:00
|
|
|
self.chumList = chumArea(chums, self)
|
2011-01-29 06:31:41 -05:00
|
|
|
self.connect(self.chumList,
|
|
|
|
QtCore.SIGNAL('itemActivated(QListWidgetItem *)'),
|
|
|
|
self,
|
|
|
|
QtCore.SLOT('newConversationWindow(QListWidgetItem *)'))
|
|
|
|
self.connect(self.chumList,
|
|
|
|
QtCore.SIGNAL('removeChumSignal(QListWidgetItem *)'),
|
|
|
|
self,
|
|
|
|
QtCore.SLOT('removeChum(QListWidgetItem *)'))
|
2011-02-02 07:26:17 -05:00
|
|
|
self.connect(self.chumList,
|
|
|
|
QtCore.SIGNAL('blockChumSignal(QString)'),
|
|
|
|
self,
|
|
|
|
QtCore.SLOT('blockChum(QString)'))
|
2011-01-29 06:31:41 -05:00
|
|
|
|
|
|
|
self.addChumButton = QtGui.QPushButton(self.theme["main/addchum/text"], self)
|
|
|
|
self.connect(self.addChumButton, QtCore.SIGNAL('clicked()'),
|
|
|
|
self, QtCore.SLOT('addChumWindow()'))
|
2011-01-29 07:33:35 -05:00
|
|
|
self.pesterButton = QtGui.QPushButton(self.theme["main/pester/text"], self)
|
|
|
|
self.connect(self.pesterButton, QtCore.SIGNAL('clicked()'),
|
|
|
|
self, QtCore.SLOT('pesterSelectedChum()'))
|
2011-02-02 07:26:17 -05:00
|
|
|
self.blockButton = QtGui.QPushButton(self.theme["main/block/text"], self)
|
|
|
|
self.connect(self.blockButton, QtCore.SIGNAL('clicked()'),
|
|
|
|
self, QtCore.SLOT('blockSelectedChum()'))
|
2011-01-29 07:33:35 -05:00
|
|
|
|
2011-01-31 18:43:49 -05:00
|
|
|
self.moodsLabel = QtGui.QLabel(self.theme["main/moodlabel/text"], self)
|
|
|
|
|
2011-01-29 07:33:35 -05:00
|
|
|
self.mychumhandleLabel = QtGui.QLabel(self.theme["main/mychumhandle/label/text"], self)
|
|
|
|
self.mychumhandle = QtGui.QPushButton(self.profile().handle, self)
|
|
|
|
self.mychumhandle.setFlat(True)
|
|
|
|
self.connect(self.mychumhandle, QtCore.SIGNAL('clicked()'),
|
|
|
|
self, QtCore.SLOT('switchProfile()'))
|
|
|
|
|
|
|
|
self.mychumcolor = QtGui.QPushButton(self)
|
|
|
|
self.connect(self.mychumcolor, QtCore.SIGNAL('clicked()'),
|
|
|
|
self, QtCore.SLOT('changeMyColor()'))
|
2011-01-29 06:31:41 -05:00
|
|
|
|
2011-01-31 06:04:03 -05:00
|
|
|
self.initTheme(self.theme)
|
|
|
|
|
2011-01-29 06:31:41 -05:00
|
|
|
self.waitingMessages = waitingMessageHolder(self)
|
2011-01-31 06:04:03 -05:00
|
|
|
|
|
|
|
if not self.config.defaultprofile():
|
|
|
|
self.changeProfile()
|
2011-02-04 19:50:56 -05:00
|
|
|
self.loadingscreen = LoadingScreen(self)
|
2011-02-05 12:17:33 -05:00
|
|
|
self.connect(self.loadingscreen, QtCore.SIGNAL('rejected()'),
|
|
|
|
self, QtCore.SLOT('close()'))
|
2011-01-29 06:31:41 -05:00
|
|
|
|
2011-01-28 21:36:12 -05:00
|
|
|
def profile(self):
|
|
|
|
return self.userprofile.chat
|
2011-01-28 01:41:01 -05:00
|
|
|
def closeConversations(self):
|
2011-01-31 06:04:03 -05:00
|
|
|
if not hasattr(self, 'tabconvo'):
|
|
|
|
self.tabconvo = None
|
2011-01-26 05:32:35 -05:00
|
|
|
if self.tabconvo:
|
|
|
|
self.tabconvo.close()
|
2011-01-27 17:16:14 -05:00
|
|
|
else:
|
|
|
|
for c in self.convos.values():
|
|
|
|
c.close()
|
2011-02-04 19:50:56 -05:00
|
|
|
if self.tabmemo:
|
|
|
|
self.tabmemo.close()
|
|
|
|
else:
|
|
|
|
for m in self.memos.values():
|
|
|
|
m.close()
|
|
|
|
|
2011-01-28 01:41:01 -05:00
|
|
|
def closeEvent(self, event):
|
|
|
|
self.closeConversations()
|
2011-02-02 19:06:03 -05:00
|
|
|
if hasattr(self, 'trollslum') and self.trollslum:
|
|
|
|
self.trollslum.close()
|
2011-01-24 02:34:07 -05:00
|
|
|
event.accept()
|
|
|
|
def newMessage(self, handle, msg):
|
2011-02-02 19:06:03 -05:00
|
|
|
if handle in self.config.getBlocklist():
|
2011-02-02 07:26:17 -05:00
|
|
|
#yeah suck on this
|
|
|
|
return
|
2011-01-24 04:10:44 -05:00
|
|
|
if not self.convos.has_key(handle):
|
2011-01-28 03:59:03 -05:00
|
|
|
if msg == "PESTERCHUM:CEASE": # ignore cease after we hang up
|
|
|
|
return
|
2011-01-28 03:10:00 -05:00
|
|
|
matchingChums = [c for c in self.chumList.chums if c.handle == handle]
|
|
|
|
if len(matchingChums) > 0:
|
|
|
|
mood = matchingChums[0].mood
|
|
|
|
else:
|
|
|
|
mood = Mood(0)
|
2011-02-01 06:14:56 -05:00
|
|
|
chum = PesterProfile(handle, mood=mood, chumdb=self.chumdb)
|
2011-01-24 04:10:44 -05:00
|
|
|
self.newConversation(chum, False)
|
2011-01-28 03:10:00 -05:00
|
|
|
if len(matchingChums) == 0:
|
|
|
|
self.moodRequest.emit(chum)
|
2011-01-24 04:10:44 -05:00
|
|
|
convo = self.convos[handle]
|
|
|
|
convo.addMessage(msg, False)
|
|
|
|
# play sound here
|
2011-01-29 06:31:41 -05:00
|
|
|
self.alarm.play()
|
2011-02-04 19:50:56 -05:00
|
|
|
def newMemoMsg(self, chan, handle, msg):
|
|
|
|
if not self.memos.has_key(chan):
|
|
|
|
# silently ignore in case we forgot to /part
|
|
|
|
return
|
|
|
|
memo = self.memos[chan]
|
|
|
|
memo.addMessage(msg, handle)
|
2011-02-05 12:17:33 -05:00
|
|
|
self.alarm.play()
|
2011-01-24 04:10:44 -05:00
|
|
|
|
|
|
|
def changeColor(self, handle, color):
|
2011-01-28 04:07:20 -05:00
|
|
|
# pesterconvo and chumlist
|
|
|
|
self.chumList.updateColor(handle, color)
|
|
|
|
if self.convos.has_key(handle):
|
|
|
|
self.convos[handle].updateColor(color)
|
2011-01-31 18:43:49 -05:00
|
|
|
self.chumdb.setColor(handle, color)
|
2011-01-24 02:34:07 -05:00
|
|
|
|
|
|
|
def updateMood(self, handle, mood):
|
|
|
|
self.chumList.updateMood(handle, mood)
|
|
|
|
if self.convos.has_key(handle):
|
|
|
|
self.convos[handle].updateMood(mood)
|
2011-02-02 19:06:03 -05:00
|
|
|
if hasattr(self, 'trollslum') and self.trollslum:
|
|
|
|
self.trollslum.updateMood(handle, mood)
|
2011-01-24 02:34:07 -05:00
|
|
|
def newConversation(self, chum, initiated=True):
|
2011-01-24 13:02:00 -05:00
|
|
|
if self.convos.has_key(chum.handle):
|
|
|
|
self.convos[chum.handle].showChat()
|
|
|
|
return
|
2011-01-26 05:50:00 -05:00
|
|
|
if self.config.tabs():
|
2011-01-26 05:32:35 -05:00
|
|
|
if not self.tabconvo:
|
2011-01-27 17:16:14 -05:00
|
|
|
self.createTabWindow()
|
2011-01-26 05:32:35 -05:00
|
|
|
convoWindow = PesterConvo(chum, initiated, self, self.tabconvo)
|
|
|
|
self.tabconvo.show()
|
|
|
|
else:
|
|
|
|
convoWindow = PesterConvo(chum, initiated, self)
|
2011-02-04 19:50:56 -05:00
|
|
|
self.connect(convoWindow, QtCore.SIGNAL('messageSent(QString, QString)'),
|
|
|
|
self, QtCore.SIGNAL('sendMessage(QString, QString)'))
|
2011-01-27 04:46:47 -05:00
|
|
|
self.connect(convoWindow, QtCore.SIGNAL('windowClosed(QString)'),
|
|
|
|
self, QtCore.SLOT('closeConvo(QString)'))
|
2011-01-24 02:34:07 -05:00
|
|
|
self.convos[chum.handle] = convoWindow
|
2011-01-24 04:10:44 -05:00
|
|
|
self.newConvoStarted.emit(QtCore.QString(chum.handle), initiated)
|
2011-01-24 02:34:07 -05:00
|
|
|
convoWindow.show()
|
2011-02-04 19:50:56 -05:00
|
|
|
|
2011-01-27 17:16:14 -05:00
|
|
|
def createTabWindow(self):
|
|
|
|
self.tabconvo = PesterTabWindow(self)
|
|
|
|
self.connect(self.tabconvo, QtCore.SIGNAL('windowClosed()'),
|
|
|
|
self, QtCore.SLOT('tabsClosed()'))
|
2011-02-04 19:50:56 -05:00
|
|
|
def createMemoTabWindow(self):
|
|
|
|
self.tabmemo = MemoTabWindow(self)
|
|
|
|
self.connect(self.tabmemo, QtCore.SIGNAL('windowClosed()'),
|
|
|
|
self, QtCore.SLOT('memoTabsClosed()'))
|
2011-02-04 16:17:27 -05:00
|
|
|
|
2011-02-05 12:17:33 -05:00
|
|
|
def newMemo(self, channel, timestr):
|
2011-02-04 19:50:56 -05:00
|
|
|
if channel == "#pesterchum":
|
|
|
|
return
|
2011-02-04 16:17:27 -05:00
|
|
|
if self.memos.has_key(channel):
|
2011-02-05 12:17:33 -05:00
|
|
|
self.memos[channel].showChat()
|
2011-02-04 16:17:27 -05:00
|
|
|
return
|
2011-02-04 19:50:56 -05:00
|
|
|
# do slider dialog then set
|
|
|
|
if self.config.tabs():
|
|
|
|
if not self.tabmemo:
|
|
|
|
self.createMemoTabWindow()
|
2011-02-05 12:17:33 -05:00
|
|
|
memoWindow = PesterMemo(channel, timestr, self, self.tabmemo)
|
2011-02-04 19:50:56 -05:00
|
|
|
self.tabmemo.show()
|
2011-02-04 16:17:27 -05:00
|
|
|
else:
|
2011-02-05 12:17:33 -05:00
|
|
|
memoWindow = PesterMemo(channel, timestr, self, None)
|
2011-02-04 16:17:27 -05:00
|
|
|
# connect signals
|
2011-02-04 19:50:56 -05:00
|
|
|
self.connect(memoWindow, QtCore.SIGNAL('messageSent(QString, QString)'),
|
|
|
|
self, QtCore.SIGNAL('sendMessage(QString, QString)'))
|
2011-02-05 12:17:33 -05:00
|
|
|
self.connect(memoWindow, QtCore.SIGNAL('windowClosed(QString)'),
|
|
|
|
self, QtCore.SLOT('closeMemo(QString)'))
|
|
|
|
self.connect(self, QtCore.SIGNAL('namesUpdated()'),
|
|
|
|
memoWindow, QtCore.SLOT('namesUpdated()'))
|
|
|
|
self.connect(self,
|
|
|
|
QtCore.SIGNAL('userPresentSignal(QString, QString, QString)'),
|
|
|
|
memoWindow, QtCore.SLOT('userPresentChange(QString, QString, QString)'))
|
2011-02-04 16:17:27 -05:00
|
|
|
# chat client send memo open
|
2011-02-04 19:50:56 -05:00
|
|
|
self.memos[channel] = memoWindow
|
2011-02-05 12:17:33 -05:00
|
|
|
self.joinChannel.emit(channel) # race condition?
|
|
|
|
memoWindow.sendTimeInfo()
|
2011-02-04 19:50:56 -05:00
|
|
|
memoWindow.show()
|
2011-02-04 16:17:27 -05:00
|
|
|
|
|
|
|
def addChum(self, chum):
|
|
|
|
self.chumList.addChum(chum)
|
|
|
|
self.config.addChum(chum)
|
|
|
|
self.moodRequest.emit(chum)
|
|
|
|
|
2011-01-28 01:08:56 -05:00
|
|
|
def changeProfile(self, collision=None):
|
2011-01-31 06:04:03 -05:00
|
|
|
if not hasattr(self, 'chooseprofile'):
|
|
|
|
self.chooseprofile = None
|
2011-01-29 06:31:41 -05:00
|
|
|
if not self.chooseprofile:
|
|
|
|
self.chooseprofile = PesterChooseProfile(self.userprofile, self.config, self.theme, self, collision=collision)
|
|
|
|
self.chooseprofile.exec_()
|
2011-01-28 01:08:56 -05:00
|
|
|
|
2011-01-28 06:17:42 -05:00
|
|
|
def themePicker(self):
|
2011-01-31 06:04:03 -05:00
|
|
|
if not hasattr(self, 'choosetheme'):
|
|
|
|
self.choosetheme = None
|
2011-01-29 06:31:41 -05:00
|
|
|
if not self.choosetheme:
|
|
|
|
self.choosetheme = PesterChooseTheme(self.config, self.theme, self)
|
|
|
|
self.choosetheme.exec_()
|
2011-01-31 06:04:03 -05:00
|
|
|
def initTheme(self, theme):
|
|
|
|
self.resize(*theme["main/size"])
|
2011-02-02 03:20:48 -05:00
|
|
|
self.setWindowIcon(PesterIcon(theme["main/icon"]))
|
2011-01-31 06:04:03 -05:00
|
|
|
self.setWindowTitle(theme["main/windowtitle"])
|
|
|
|
self.setStyleSheet("QFrame#main { "+theme["main/style"]+" }")
|
2011-02-01 06:14:56 -05:00
|
|
|
self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " % (theme["main/menubar/style"], theme["main/menu/menuitem"]) + "QMenu { background: transparent; %s } QMenu::item::selected { %s }" % (theme["main/menu/style"], theme["main/menu/selected"]))
|
2011-02-02 03:20:48 -05:00
|
|
|
newcloseicon = PesterIcon(theme["main/close/image"])
|
|
|
|
self.closeButton.setIcon(newcloseicon)
|
|
|
|
self.closeButton.setIconSize(newcloseicon.realsize())
|
2011-01-31 06:04:03 -05:00
|
|
|
self.closeButton.move(*theme["main/close/loc"])
|
2011-02-02 03:20:48 -05:00
|
|
|
newminiicon = PesterIcon(theme["main/minimize/image"])
|
|
|
|
self.miniButton.setIcon(newminiicon)
|
|
|
|
self.miniButton.setIconSize(newminiicon.realsize())
|
2011-01-31 06:04:03 -05:00
|
|
|
self.miniButton.move(*theme["main/minimize/loc"])
|
2011-02-01 06:14:56 -05:00
|
|
|
# menus
|
|
|
|
self.menu.move(*theme["main/menu/loc"])
|
|
|
|
self.opts.setText(theme["main/menus/client/options"])
|
|
|
|
self.exitaction.setText(theme["main/menus/client/exit"])
|
2011-02-03 01:20:37 -05:00
|
|
|
self.userlistaction.setText(theme["main/menus/client/userlist"])
|
2011-02-05 12:17:33 -05:00
|
|
|
self.memoaction.setText(theme["main/menus/client/memos"])
|
2011-02-01 06:14:56 -05:00
|
|
|
self.filemenu.setTitle(theme["main/menus/client/_name"])
|
|
|
|
self.changetheme.setText(theme["main/menus/profile/theme"])
|
|
|
|
self.changequirks.setText(theme["main/menus/profile/quirks"])
|
2011-02-03 01:20:37 -05:00
|
|
|
self.loadslum.setText(theme["main/menus/profile/block"])
|
2011-02-02 07:26:17 -05:00
|
|
|
self.changecoloraction.setText(theme["main/menus/profile/color"])
|
2011-02-01 06:14:56 -05:00
|
|
|
self.switch.setText(theme["main/menus/profile/switch"])
|
|
|
|
self.profilemenu.setTitle(theme["main/menus/profile/_name"])
|
|
|
|
|
2011-01-28 21:36:12 -05:00
|
|
|
# moods
|
2011-01-31 18:43:49 -05:00
|
|
|
self.moodsLabel.setText(theme["main/moodlabel/text"])
|
|
|
|
self.moodsLabel.move(*theme["main/moodlabel/loc"])
|
|
|
|
self.moodsLabel.setStyleSheet(theme["main/moodlabel/style"])
|
|
|
|
|
2011-01-31 06:04:03 -05:00
|
|
|
if hasattr(self, 'moods'):
|
|
|
|
self.moods.removeButtons()
|
|
|
|
self.moods = PesterMoodHandler(self, *[PesterMoodButton(self, **d) for d in theme["main/moods"]])
|
2011-01-28 21:36:12 -05:00
|
|
|
self.moods.showButtons()
|
2011-01-29 06:31:41 -05:00
|
|
|
# chum
|
2011-01-31 06:04:03 -05:00
|
|
|
self.addChumButton.setText(theme["main/addchum/text"])
|
|
|
|
self.addChumButton.resize(*theme["main/addchum/size"])
|
|
|
|
self.addChumButton.move(*theme["main/addchum/loc"])
|
|
|
|
self.addChumButton.setStyleSheet(theme["main/addchum/style"])
|
|
|
|
self.pesterButton.setText(theme["main/pester/text"])
|
|
|
|
self.pesterButton.resize(*theme["main/pester/size"])
|
|
|
|
self.pesterButton.move(*theme["main/pester/loc"])
|
|
|
|
self.pesterButton.setStyleSheet(theme["main/pester/style"])
|
2011-02-02 07:26:17 -05:00
|
|
|
self.blockButton.setText(theme["main/block/text"])
|
|
|
|
self.blockButton.resize(*theme["main/block/size"])
|
|
|
|
self.blockButton.move(*theme["main/block/loc"])
|
|
|
|
self.blockButton.setStyleSheet(theme["main/block/style"])
|
2011-01-29 07:33:35 -05:00
|
|
|
# buttons
|
2011-01-31 06:04:03 -05:00
|
|
|
self.mychumhandleLabel.setText(theme["main/mychumhandle/label/text"])
|
|
|
|
self.mychumhandleLabel.move(*theme["main/mychumhandle/label/loc"])
|
|
|
|
self.mychumhandleLabel.setStyleSheet(theme["main/mychumhandle/label/style"])
|
2011-01-29 07:33:35 -05:00
|
|
|
self.mychumhandle.setText(self.profile().handle)
|
2011-01-31 06:04:03 -05:00
|
|
|
self.mychumhandle.move(*theme["main/mychumhandle/handle/loc"])
|
|
|
|
self.mychumhandle.resize(*theme["main/mychumhandle/handle/size"])
|
|
|
|
self.mychumhandle.setStyleSheet(theme["main/mychumhandle/handle/style"])
|
|
|
|
self.mychumcolor.resize(*theme["main/mychumhandle/colorswatch/size"])
|
|
|
|
self.mychumcolor.move(*theme["main/mychumhandle/colorswatch/loc"])
|
2011-01-29 07:33:35 -05:00
|
|
|
self.mychumcolor.setStyleSheet("background: %s" % (self.profile().colorhtml()))
|
2011-01-31 06:04:03 -05:00
|
|
|
if theme["main/mychumhandle/colorswatch/text"]:
|
|
|
|
self.mychumcolor.setText(theme["main/mychumhandle/colorswatch/text"])
|
2011-01-29 07:33:35 -05:00
|
|
|
|
2011-01-29 06:31:41 -05:00
|
|
|
# sounds
|
|
|
|
if not pygame.mixer:
|
|
|
|
self.alarm = NoneSound()
|
|
|
|
else:
|
2011-02-04 16:17:27 -05:00
|
|
|
self.alarm = pygame.mixer.Sound(theme["main/sounds/alertsound"])
|
2011-02-03 01:20:37 -05:00
|
|
|
|
2011-01-31 06:04:03 -05:00
|
|
|
def changeTheme(self, theme):
|
|
|
|
self.theme = theme
|
|
|
|
# do self
|
|
|
|
self.initTheme(theme)
|
|
|
|
# chum area
|
|
|
|
self.chumList.changeTheme(theme)
|
|
|
|
# do open windows
|
|
|
|
if self.tabconvo:
|
|
|
|
self.tabconvo.changeTheme(theme)
|
2011-02-05 22:24:27 -05:00
|
|
|
if self.tabmemo:
|
|
|
|
self.tabmemo.changeTheme(theme)
|
2011-01-31 06:04:03 -05:00
|
|
|
for c in self.convos.values():
|
|
|
|
c.changeTheme(theme)
|
2011-02-02 19:06:03 -05:00
|
|
|
if hasattr(self, 'trollslum') and self.trollslum:
|
|
|
|
self.trollslum.changeTheme(theme)
|
2011-02-03 01:20:37 -05:00
|
|
|
if hasattr(self, 'allusers') and self.allusers:
|
|
|
|
self.allusers.changeTheme(theme)
|
2011-01-29 06:31:41 -05:00
|
|
|
# system tray icon
|
|
|
|
self.updateSystemTray()
|
2011-01-31 06:04:03 -05:00
|
|
|
|
2011-01-29 06:31:41 -05:00
|
|
|
def updateSystemTray(self):
|
|
|
|
if len(self.waitingMessages) == 0:
|
|
|
|
self.trayIconSignal.emit(0)
|
|
|
|
else:
|
|
|
|
self.trayIconSignal.emit(1)
|
|
|
|
|
|
|
|
def systemTrayFunction(self):
|
|
|
|
if len(self.waitingMessages) == 0:
|
|
|
|
if self.isMinimized():
|
|
|
|
self.showNormal()
|
|
|
|
else:
|
|
|
|
if self.isActiveWindow():
|
|
|
|
self.showMinimized()
|
|
|
|
else:
|
|
|
|
self.raise_()
|
|
|
|
self.activateWindow()
|
|
|
|
else:
|
|
|
|
self.waitingMessages.answerMessage()
|
2011-01-28 06:17:42 -05:00
|
|
|
|
2011-02-04 19:50:56 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def connected(self):
|
|
|
|
if self.loadingscreen:
|
2011-02-05 12:17:33 -05:00
|
|
|
self.loadingscreen.accept()
|
2011-02-04 19:50:56 -05:00
|
|
|
self.loadingscreen = None
|
2011-01-29 07:33:35 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-02-02 07:26:17 -05:00
|
|
|
def blockSelectedChum(self):
|
|
|
|
curChumListing = self.chumList.currentItem()
|
|
|
|
if curChumListing:
|
|
|
|
curChum = curChumListing.chum
|
2011-02-02 19:06:03 -05:00
|
|
|
self.blockChum(curChum.handle)
|
2011-02-02 07:26:17 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-01-29 07:33:35 -05:00
|
|
|
def pesterSelectedChum(self):
|
|
|
|
curChum = self.chumList.currentItem()
|
|
|
|
if curChum:
|
|
|
|
self.newConversationWindow(curChum)
|
2011-01-24 04:10:44 -05:00
|
|
|
@QtCore.pyqtSlot(QtGui.QListWidgetItem)
|
|
|
|
def newConversationWindow(self, chumlisting):
|
2011-02-01 06:14:56 -05:00
|
|
|
# check chumdb
|
2011-01-24 04:10:44 -05:00
|
|
|
chum = chumlisting.chum
|
2011-02-01 06:14:56 -05:00
|
|
|
color = self.chumdb.getColor(chum)
|
|
|
|
if color:
|
|
|
|
chum.color = color
|
2011-01-24 04:10:44 -05:00
|
|
|
self.newConversation(chum)
|
2011-01-26 05:32:35 -05:00
|
|
|
@QtCore.pyqtSlot(QtCore.QString)
|
|
|
|
def closeConvo(self, handle):
|
2011-01-31 18:43:49 -05:00
|
|
|
h = unicode(handle)
|
2011-02-02 03:20:48 -05:00
|
|
|
chum = self.convos[h].chum
|
2011-01-31 18:43:49 -05:00
|
|
|
chumopen = self.convos[h].chumopen
|
|
|
|
if chumopen:
|
2011-02-03 03:51:22 -05:00
|
|
|
self.chatlog.log(chum.handle, convertTags(self.profile().pestermsg(chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/ceasepester"]), "bbcode"))
|
2011-01-31 18:43:49 -05:00
|
|
|
self.convoClosed.emit(handle)
|
2011-02-05 12:17:33 -05:00
|
|
|
self.chatlog.finish(h)
|
2011-02-02 03:20:48 -05:00
|
|
|
del self.convos[h]
|
2011-02-05 12:17:33 -05:00
|
|
|
@QtCore.pyqtSlot(QtCore.QString)
|
|
|
|
def closeMemo(self, channel):
|
|
|
|
c = unicode(channel)
|
|
|
|
self.chatlog.finish(c)
|
|
|
|
self.leftChannel.emit(channel)
|
|
|
|
del self.memos[c]
|
2011-01-27 06:05:36 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-01-27 05:41:53 -05:00
|
|
|
def tabsClosed(self):
|
|
|
|
del self.tabconvo
|
|
|
|
self.tabconvo = None
|
2011-02-04 19:50:56 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def memoTabsClosed(self):
|
|
|
|
del self.tabmemo
|
|
|
|
self.tabmemo = None
|
2011-01-28 21:36:12 -05:00
|
|
|
|
2011-01-24 07:17:12 -05:00
|
|
|
@QtCore.pyqtSlot(QtCore.QString, Mood)
|
|
|
|
def updateMoodSlot(self, handle, mood):
|
2011-01-31 18:43:49 -05:00
|
|
|
h = unicode(handle)
|
2011-01-24 07:17:12 -05:00
|
|
|
self.updateMood(h, mood)
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot(QtCore.QString, QtGui.QColor)
|
|
|
|
def updateColorSlot(self, handle, color):
|
2011-01-31 18:43:49 -05:00
|
|
|
h = unicode(handle)
|
2011-01-24 07:17:12 -05:00
|
|
|
self.changeColor(h, color)
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
|
|
|
|
def deliverMessage(self, handle, msg):
|
2011-01-31 18:43:49 -05:00
|
|
|
h = unicode(handle)
|
|
|
|
m = unicode(msg)
|
2011-01-24 07:17:12 -05:00
|
|
|
self.newMessage(h, m)
|
2011-02-04 19:50:56 -05:00
|
|
|
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString)
|
|
|
|
def deliverMemo(self, chan, handle, msg):
|
|
|
|
(c, h, m) = (unicode(chan), unicode(handle), unicode(msg))
|
|
|
|
self.newMemoMsg(c,h,m)
|
2011-02-05 12:17:33 -05:00
|
|
|
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString)
|
|
|
|
def timeCommand(self, chan, handle, command):
|
|
|
|
(c, h, cmd) = (unicode(chan), unicode(handle), unicode(command))
|
|
|
|
if self.memos[c]:
|
|
|
|
self.memos[c].timeUpdate(h, cmd)
|
2011-01-24 07:17:12 -05:00
|
|
|
|
2011-02-03 01:20:37 -05:00
|
|
|
@QtCore.pyqtSlot(QtCore.QString, PesterList)
|
|
|
|
def updateNames(self, channel, names):
|
|
|
|
c = unicode(channel)
|
|
|
|
# update name DB
|
|
|
|
self.namesdb[c] = names
|
|
|
|
# warn interested party of names
|
|
|
|
self.namesUpdated.emit()
|
|
|
|
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString)
|
|
|
|
def userPresentUpdate(self, handle, channel, update):
|
|
|
|
c = unicode(channel)
|
|
|
|
n = unicode(handle)
|
2011-02-05 22:24:10 -05:00
|
|
|
if update == "quit" or update == "oldnick":
|
2011-02-03 01:20:37 -05:00
|
|
|
for c in self.namesdb.keys():
|
|
|
|
try:
|
|
|
|
i = self.namesdb[c].index(n)
|
|
|
|
self.namesdb[c].pop(i)
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
except KeyError:
|
|
|
|
self.namesdb[c] = []
|
|
|
|
elif update == "left":
|
|
|
|
try:
|
|
|
|
i = self.namesdb[c].index(n)
|
|
|
|
self.namesdb[c].pop(i)
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
except KeyError:
|
|
|
|
self.namesdb[c] = []
|
2011-02-05 22:24:10 -05:00
|
|
|
elif update == "newnick":
|
|
|
|
for c in self.namesdb.keys():
|
|
|
|
try:
|
|
|
|
i = self.namesdb[c].index(n)
|
|
|
|
except ValueError:
|
|
|
|
self.namesdb[c].append(n)
|
|
|
|
except KeyError:
|
|
|
|
self.namesdb[c] = [n]
|
2011-02-03 01:20:37 -05:00
|
|
|
elif update == "join":
|
|
|
|
try:
|
|
|
|
i = self.namesdb[c].index(n)
|
|
|
|
except ValueError:
|
|
|
|
self.namesdb[c].append(n)
|
|
|
|
except KeyError:
|
|
|
|
self.namesdb[c] = [n]
|
|
|
|
|
|
|
|
self.userPresentSignal.emit(handle, channel, update)
|
|
|
|
|
2011-01-27 04:46:47 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-01-29 06:31:41 -05:00
|
|
|
def addChumWindow(self):
|
2011-01-31 06:04:03 -05:00
|
|
|
if not hasattr(self, 'addchumdialog'):
|
|
|
|
self.addchumdialog = None
|
2011-01-29 06:31:41 -05:00
|
|
|
if not self.addchumdialog:
|
|
|
|
self.addchumdialog = QtGui.QInputDialog(self)
|
|
|
|
(handle, ok) = self.addchumdialog.getText(self, "New Chum", "Enter Chum Handle:")
|
|
|
|
if ok:
|
|
|
|
handle = unicode(handle)
|
|
|
|
if not (PesterProfile.checkLength(handle) and
|
|
|
|
PesterProfile.checkValid(handle)):
|
|
|
|
errormsg = QtGui.QErrorMessage(self)
|
|
|
|
errormsg.showMessage("THIS IS NOT A VALID CHUMTAG!")
|
|
|
|
self.addchumdialog = None
|
|
|
|
return
|
2011-02-01 06:14:56 -05:00
|
|
|
chum = PesterProfile(handle, chumdb=self.chumdb)
|
2011-02-03 01:20:37 -05:00
|
|
|
self.addChum(chum)
|
2011-01-29 06:31:41 -05:00
|
|
|
self.addchumdialog = None
|
|
|
|
@QtCore.pyqtSlot(QtGui.QListWidgetItem)
|
|
|
|
def removeChum(self, chumlisting):
|
|
|
|
self.config.removeChum(chumlisting.chum)
|
2011-02-02 07:26:17 -05:00
|
|
|
@QtCore.pyqtSlot(QtCore.QString)
|
|
|
|
def blockChum(self, handle):
|
|
|
|
h = unicode(handle)
|
2011-02-02 19:06:03 -05:00
|
|
|
self.config.addBlocklist(h)
|
|
|
|
self.config.removeChum(h)
|
2011-02-02 07:26:17 -05:00
|
|
|
if self.convos.has_key(h):
|
|
|
|
convo = self.convos[h]
|
|
|
|
msg = self.profile().pestermsg(convo.chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/blocked"])
|
2011-02-03 03:51:22 -05:00
|
|
|
convo.textArea.append(convertTags(msg))
|
|
|
|
self.chatlog.log(convo.chum.handle, convertTags(msg, "bbcode"))
|
2011-02-02 07:26:17 -05:00
|
|
|
convo.updateBlocked()
|
2011-02-02 19:06:03 -05:00
|
|
|
self.chumList.removeChum(h)
|
|
|
|
if hasattr(self, 'trollslum') and self.trollslum:
|
|
|
|
newtroll = PesterProfile(h)
|
|
|
|
self.trollslum.addTroll(newtroll)
|
|
|
|
self.moodRequest.emit(newtroll)
|
2011-02-02 07:26:17 -05:00
|
|
|
self.blockedChum.emit(handle)
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot(QtCore.QString)
|
|
|
|
def unblockChum(self, handle):
|
|
|
|
h = unicode(handle)
|
2011-02-02 19:06:03 -05:00
|
|
|
self.config.delBlocklist(h)
|
2011-02-02 07:26:17 -05:00
|
|
|
if self.convos.has_key(h):
|
|
|
|
convo = self.convos[h]
|
|
|
|
msg = self.profile().pestermsg(convo.chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/unblocked"])
|
2011-02-03 03:51:22 -05:00
|
|
|
convo.textArea.append(convertTags(msg))
|
|
|
|
self.chatlog.log(convo.chum.handle, convertTags(msg, "bbcode"))
|
2011-02-02 07:26:17 -05:00
|
|
|
convo.updateMood(convo.chum.mood, unblocked=True)
|
2011-02-02 19:06:03 -05:00
|
|
|
chum = PesterProfile(h, chumdb=self.chumdb)
|
|
|
|
if hasattr(self, 'trollslum') and self.trollslum:
|
|
|
|
self.trollslum.removeTroll(handle)
|
|
|
|
self.config.addChum(chum)
|
|
|
|
self.chumList.addChum(chum)
|
|
|
|
self.moodRequest.emit(chum)
|
2011-02-02 07:26:17 -05:00
|
|
|
self.unblockedChum.emit(handle)
|
2011-02-02 19:06:03 -05:00
|
|
|
|
2011-01-29 06:31:41 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-02-04 16:17:27 -05:00
|
|
|
def showMemos(self):
|
|
|
|
if not hasattr(self, 'memochooser'):
|
|
|
|
self.memochooser = None
|
|
|
|
if self.memochooser:
|
|
|
|
return
|
|
|
|
self.memochooser = PesterMemoList(self)
|
|
|
|
self.connect(self.memochooser, QtCore.SIGNAL('accepted()'),
|
|
|
|
self, QtCore.SLOT('joinSelectedMemo()'))
|
|
|
|
self.connect(self.memochooser, QtCore.SIGNAL('rejected()'),
|
|
|
|
self, QtCore.SLOT('memoChooserClose()'))
|
|
|
|
self.requestChannelList.emit()
|
|
|
|
self.memochooser.show()
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def joinSelectedMemo(self):
|
|
|
|
newmemo = self.memochooser.newmemoname()
|
|
|
|
selectedmemo = self.memochooser.selectedmemo()
|
2011-02-05 12:17:33 -05:00
|
|
|
time = unicode(self.memochooser.timeinput.text())
|
2011-02-04 16:17:27 -05:00
|
|
|
if newmemo:
|
2011-02-05 13:56:25 -05:00
|
|
|
channel = "#"+unicode(newmemo).replace(" ", "_")
|
2011-02-05 12:17:33 -05:00
|
|
|
self.newMemo(channel, time)
|
2011-02-04 19:50:56 -05:00
|
|
|
elif selectedmemo:
|
|
|
|
channel = "#"+unicode(selectedmemo.text())
|
2011-02-05 12:17:33 -05:00
|
|
|
self.newMemo(channel, time)
|
2011-02-04 16:17:27 -05:00
|
|
|
self.memochooser = None
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def memoChooserClose(self):
|
|
|
|
self.memochooser = None
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def memoChooserClose(self):
|
|
|
|
self.memochooser = None
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot(PesterList)
|
|
|
|
def updateChannelList(self, channels):
|
|
|
|
if hasattr(self, 'memochooser') and self.memochooser:
|
|
|
|
self.memochooser.updateChannels(channels)
|
|
|
|
@QtCore.pyqtSlot()
|
2011-02-03 01:20:37 -05:00
|
|
|
def showAllUsers(self):
|
|
|
|
if not hasattr(self, 'allusers'):
|
|
|
|
self.allusers = None
|
|
|
|
if not self.allusers:
|
|
|
|
self.allusers = PesterUserlist(self.config, self.theme, self)
|
|
|
|
self.connect(self.allusers, QtCore.SIGNAL('accepted()'),
|
|
|
|
self, QtCore.SLOT('userListClose()'))
|
|
|
|
self.connect(self.allusers, QtCore.SIGNAL('rejected()'),
|
|
|
|
self, QtCore.SLOT('userListClose()'))
|
|
|
|
self.connect(self.allusers, QtCore.SIGNAL('addChum(QString)'),
|
|
|
|
self, QtCore.SLOT('userListAdd(QString)'))
|
|
|
|
self.requestNames.emit("#pesterchum")
|
|
|
|
self.allusers.show()
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot(QtCore.QString)
|
|
|
|
def userListAdd(self, handle):
|
|
|
|
h = unicode(handle)
|
|
|
|
chum = PesterProfile(h, chumdb=self.chumdb)
|
|
|
|
self.addChum(chum)
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def userListClose(self):
|
|
|
|
self.allusers = None
|
2011-02-04 16:17:27 -05:00
|
|
|
|
2011-02-03 01:20:37 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-01-29 16:55:35 -05:00
|
|
|
def openQuirks(self):
|
2011-01-31 06:04:03 -05:00
|
|
|
if not hasattr(self, 'quirkmenu'):
|
|
|
|
self.quirkmenu = None
|
2011-01-29 16:55:35 -05:00
|
|
|
if not self.quirkmenu:
|
|
|
|
self.quirkmenu = PesterChooseQuirks(self.config, self.theme, self)
|
|
|
|
self.connect(self.quirkmenu, QtCore.SIGNAL('accepted()'),
|
|
|
|
self, QtCore.SLOT('updateQuirks()'))
|
|
|
|
self.connect(self.quirkmenu, QtCore.SIGNAL('rejected()'),
|
|
|
|
self, QtCore.SLOT('closeQuirks()'))
|
|
|
|
self.quirkmenu.show()
|
|
|
|
self.quirkmenu.raise_()
|
|
|
|
self.quirkmenu.activateWindow()
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def updateQuirks(self):
|
|
|
|
quirks = pesterQuirks(self.quirkmenu.quirks())
|
|
|
|
self.userprofile.setQuirks(quirks)
|
|
|
|
self.quirkmenu = None
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def closeQuirks(self):
|
|
|
|
self.quirkmenu = None
|
|
|
|
@QtCore.pyqtSlot()
|
2011-01-27 04:46:47 -05:00
|
|
|
def openOpts(self):
|
2011-01-31 06:04:03 -05:00
|
|
|
if not hasattr(self, 'optionmenu'):
|
|
|
|
self.optionmenu = None
|
2011-01-27 04:46:47 -05:00
|
|
|
if not self.optionmenu:
|
|
|
|
self.optionmenu = PesterOptions(self.config, self.theme, self)
|
|
|
|
self.connect(self.optionmenu, QtCore.SIGNAL('accepted()'),
|
|
|
|
self, QtCore.SLOT('updateOptions()'))
|
2011-01-27 21:21:02 -05:00
|
|
|
self.connect(self.optionmenu, QtCore.SIGNAL('rejected()'),
|
|
|
|
self, QtCore.SLOT('closeOptions()'))
|
2011-01-27 04:46:47 -05:00
|
|
|
self.optionmenu.show()
|
|
|
|
self.optionmenu.raise_()
|
|
|
|
self.optionmenu.activateWindow()
|
|
|
|
@QtCore.pyqtSlot()
|
2011-01-27 21:21:02 -05:00
|
|
|
def closeOptions(self):
|
|
|
|
self.optionmenu.close()
|
|
|
|
self.optionmenu = None
|
|
|
|
@QtCore.pyqtSlot()
|
2011-01-27 04:46:47 -05:00
|
|
|
def updateOptions(self):
|
|
|
|
# tabs
|
|
|
|
curtab = self.config.tabs()
|
|
|
|
tabsetting = self.optionmenu.tabcheck.isChecked()
|
|
|
|
if curtab and not tabsetting:
|
|
|
|
# split tabs into windows
|
2011-02-05 12:17:33 -05:00
|
|
|
windows = []
|
2011-01-27 06:05:36 -05:00
|
|
|
if self.tabconvo:
|
|
|
|
windows = list(self.tabconvo.convos.values())
|
2011-02-05 12:17:33 -05:00
|
|
|
if self.tabmemo:
|
|
|
|
windows += list(self.tabmemo.convos.values())
|
|
|
|
|
|
|
|
for w in windows:
|
|
|
|
w.setParent(None)
|
|
|
|
w.show()
|
|
|
|
w.raiseChat()
|
|
|
|
if self.tabconvo:
|
2011-01-27 06:05:36 -05:00
|
|
|
self.tabconvo.closeSoft()
|
2011-02-05 12:17:33 -05:00
|
|
|
if self.tabmemo:
|
|
|
|
self.tabmemo.closeSoft()
|
2011-01-27 04:46:47 -05:00
|
|
|
# save options
|
|
|
|
self.config.set("tabs", tabsetting)
|
|
|
|
elif tabsetting and not curtab:
|
|
|
|
# combine
|
2011-01-27 17:16:14 -05:00
|
|
|
self.createTabWindow()
|
|
|
|
newconvos = {}
|
|
|
|
for (h,c) in self.convos.iteritems():
|
|
|
|
c.setParent(self.tabconvo)
|
|
|
|
self.tabconvo.addChat(c)
|
|
|
|
self.tabconvo.show()
|
|
|
|
newconvos[h] = c
|
|
|
|
self.convos = newconvos
|
2011-02-05 12:17:33 -05:00
|
|
|
newmemos = {}
|
|
|
|
self.createMemoTabWindow()
|
|
|
|
for (h,m) in self.memos.iteritems():
|
|
|
|
m.setParent(self.tabmemo)
|
|
|
|
self.tabmemo.addChat(m)
|
|
|
|
self.tabmemo.show()
|
|
|
|
newmemos[h] = m
|
|
|
|
self.memos = newmemos
|
2011-01-27 04:46:47 -05:00
|
|
|
# save options
|
|
|
|
self.config.set("tabs", tabsetting)
|
|
|
|
self.optionmenu = None
|
2011-01-27 21:21:02 -05:00
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
2011-01-28 06:17:42 -05:00
|
|
|
def themeSelected(self):
|
2011-01-28 06:26:13 -05:00
|
|
|
themename = unicode(self.choosetheme.themeBox.currentText())
|
2011-01-28 06:17:42 -05:00
|
|
|
if themename != self.theme.name:
|
2011-01-31 18:43:49 -05:00
|
|
|
try:
|
|
|
|
self.changeTheme(pesterTheme(themename))
|
|
|
|
except ValueError, e:
|
2011-02-01 06:14:56 -05:00
|
|
|
themeWarning = QtGui.QMessageBox(self)
|
|
|
|
themeWarning.setText("Theme Error: %s" % (e))
|
|
|
|
themeWarning.exec_()
|
|
|
|
self.choosetheme = None
|
2011-01-31 18:43:49 -05:00
|
|
|
return
|
2011-01-28 06:26:13 -05:00
|
|
|
# update profile
|
|
|
|
self.userprofile.setTheme(self.theme)
|
2011-01-28 06:17:42 -05:00
|
|
|
self.choosetheme = None
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def closeTheme(self):
|
|
|
|
self.choosetheme = None
|
|
|
|
@QtCore.pyqtSlot()
|
2011-01-27 21:21:02 -05:00
|
|
|
def profileSelected(self):
|
|
|
|
if self.chooseprofile.profileBox and \
|
2011-01-28 01:41:01 -05:00
|
|
|
self.chooseprofile.profileBox.currentIndex() > 0:
|
2011-01-27 21:21:02 -05:00
|
|
|
handle = unicode(self.chooseprofile.profileBox.currentText())
|
2011-01-28 21:36:12 -05:00
|
|
|
if handle == self.profile().handle:
|
2011-02-01 06:14:56 -05:00
|
|
|
self.chooseprofile = None
|
2011-01-28 21:36:12 -05:00
|
|
|
return
|
2011-01-27 21:21:02 -05:00
|
|
|
self.userprofile = userProfile(handle)
|
2011-01-28 06:26:13 -05:00
|
|
|
self.changeTheme(self.userprofile.getTheme())
|
2011-01-27 21:21:02 -05:00
|
|
|
else:
|
2011-01-28 21:36:12 -05:00
|
|
|
handle = unicode(self.chooseprofile.chumHandle.text())
|
|
|
|
if handle == self.profile().handle:
|
2011-02-01 06:14:56 -05:00
|
|
|
self.chooseprofile = None
|
2011-01-28 21:36:12 -05:00
|
|
|
return
|
|
|
|
profile = PesterProfile(handle,
|
|
|
|
self.chooseprofile.chumcolor)
|
2011-01-27 21:21:02 -05:00
|
|
|
self.userprofile = userProfile.newUserProfile(profile)
|
2011-01-31 06:04:03 -05:00
|
|
|
self.changeTheme(self.userprofile.getTheme())
|
2011-01-27 21:21:02 -05:00
|
|
|
|
2011-02-02 03:20:48 -05:00
|
|
|
self.chatlog.close()
|
|
|
|
self.chatlog = PesterLog(handle)
|
|
|
|
|
2011-01-28 21:36:12 -05:00
|
|
|
# is default?
|
|
|
|
if self.chooseprofile.defaultcheck.isChecked():
|
|
|
|
self.config.set("defaultprofile", self.userprofile.chat.handle)
|
2011-01-28 01:41:01 -05:00
|
|
|
# this may have to be fixed
|
|
|
|
self.closeConversations()
|
2011-02-02 19:06:03 -05:00
|
|
|
if hasattr(self, 'trollslum') and self.trollslum:
|
|
|
|
self.trollslum.close()
|
2011-02-01 06:14:56 -05:00
|
|
|
self.chooseprofile = None
|
2011-01-28 01:41:01 -05:00
|
|
|
self.profileChanged.emit()
|
2011-02-02 19:06:03 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def showTrollSlum(self):
|
|
|
|
if not hasattr(self, 'trollslum'):
|
|
|
|
self.trollslum = None
|
|
|
|
if self.trollslum:
|
|
|
|
return
|
|
|
|
trolls = [PesterProfile(h) for h in self.config.getBlocklist()]
|
|
|
|
self.trollslum = TrollSlumWindow(trolls, self)
|
|
|
|
self.connect(self.trollslum, QtCore.SIGNAL('blockChumSignal(QString)'),
|
|
|
|
self, QtCore.SLOT('blockChum(QString)'))
|
|
|
|
self.connect(self.trollslum,
|
|
|
|
QtCore.SIGNAL('unblockChumSignal(QString)'),
|
|
|
|
self, QtCore.SLOT('unblockChum(QString)'))
|
2011-02-03 01:20:37 -05:00
|
|
|
self.moodsRequest.emit(PesterList(trolls))
|
2011-02-02 19:06:03 -05:00
|
|
|
self.trollslum.show()
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def closeTrollSlum(self):
|
|
|
|
self.trollslum = None
|
2011-01-27 21:21:02 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-01-29 07:33:35 -05:00
|
|
|
def changeMyColor(self):
|
2011-01-31 06:04:03 -05:00
|
|
|
if not hasattr(self, 'colorDialog'):
|
|
|
|
self.colorDialog = None
|
2011-01-29 07:33:35 -05:00
|
|
|
if self.colorDialog:
|
|
|
|
return
|
|
|
|
self.colorDialog = QtGui.QColorDialog(self)
|
|
|
|
color = self.colorDialog.getColor(initial=self.profile().color)
|
2011-02-04 16:17:27 -05:00
|
|
|
if not color.isValid():
|
|
|
|
color = self.profile().color
|
2011-01-29 07:33:35 -05:00
|
|
|
self.mychumcolor.setStyleSheet("background: %s" % color.name())
|
|
|
|
self.userprofile.setColor(color)
|
2011-01-31 18:43:49 -05:00
|
|
|
self.mycolorUpdated.emit()
|
2011-01-29 07:33:35 -05:00
|
|
|
self.colorDialog = None
|
|
|
|
@QtCore.pyqtSlot()
|
2011-01-27 21:21:02 -05:00
|
|
|
def closeProfile(self):
|
|
|
|
self.chooseprofile = None
|
2011-01-28 01:41:01 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def switchProfile(self):
|
2011-01-28 04:20:32 -05:00
|
|
|
if self.convos:
|
|
|
|
closeWarning = QtGui.QMessageBox()
|
2011-01-29 07:33:35 -05:00
|
|
|
closeWarning.setText("WARNING: CHANGING PROFILES WILL CLOSE ALL CONVERSATION WINDOWS!")
|
|
|
|
closeWarning.setInformativeText("i warned you about windows bro!!!! i told you dog!")
|
2011-01-28 04:20:32 -05:00
|
|
|
closeWarning.setStandardButtons(QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok)
|
|
|
|
closeWarning.setDefaultButton(QtGui.QMessageBox.Ok)
|
|
|
|
ret = closeWarning.exec_()
|
|
|
|
if ret == QtGui.QMessageBox.Cancel:
|
|
|
|
return
|
|
|
|
self.changeProfile()
|
2011-01-27 21:21:02 -05:00
|
|
|
|
2011-02-01 06:14:56 -05:00
|
|
|
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
|
|
|
|
def nickCollision(self, handle, tmphandle):
|
|
|
|
self.mychumhandle.setText(tmphandle)
|
|
|
|
if not hasattr(self, 'chooseprofile'):
|
|
|
|
self.chooseprofile = None
|
2011-01-28 01:08:56 -05:00
|
|
|
if not self.chooseprofile:
|
|
|
|
h = unicode(handle)
|
|
|
|
self.changeProfile(collision=h)
|
2011-01-27 04:46:47 -05:00
|
|
|
|
2011-01-28 06:17:42 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def pickTheme(self):
|
|
|
|
self.themePicker()
|
|
|
|
|
2011-01-29 06:31:41 -05:00
|
|
|
@QtCore.pyqtSlot(QtGui.QSystemTrayIcon.ActivationReason)
|
|
|
|
def systemTrayActivated(self, reason):
|
|
|
|
if reason == QtGui.QSystemTrayIcon.Trigger:
|
|
|
|
self.systemTrayFunction()
|
|
|
|
elif reason == QtGui.QSystemTrayIcon.Context:
|
|
|
|
# show context menu i guess
|
|
|
|
pass
|
|
|
|
|
2011-01-24 04:10:44 -05:00
|
|
|
newConvoStarted = QtCore.pyqtSignal(QtCore.QString, bool, name="newConvoStarted")
|
2011-02-04 19:50:56 -05:00
|
|
|
sendMessage = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
|
2011-01-27 04:46:47 -05:00
|
|
|
convoClosed = QtCore.pyqtSignal(QtCore.QString)
|
2011-01-28 01:41:01 -05:00
|
|
|
profileChanged = QtCore.pyqtSignal()
|
2011-01-28 03:10:00 -05:00
|
|
|
moodRequest = QtCore.pyqtSignal(PesterProfile)
|
2011-02-03 01:20:37 -05:00
|
|
|
moodsRequest = QtCore.pyqtSignal(PesterList)
|
2011-01-28 21:36:12 -05:00
|
|
|
moodUpdated = QtCore.pyqtSignal()
|
2011-02-04 16:17:27 -05:00
|
|
|
requestChannelList = QtCore.pyqtSignal()
|
2011-02-03 01:20:37 -05:00
|
|
|
requestNames = QtCore.pyqtSignal(QtCore.QString)
|
|
|
|
namesUpdated = QtCore.pyqtSignal()
|
|
|
|
userPresentSignal = QtCore.pyqtSignal(QtCore.QString,QtCore.QString,QtCore.QString)
|
2011-01-31 18:43:49 -05:00
|
|
|
mycolorUpdated = QtCore.pyqtSignal()
|
2011-01-29 06:31:41 -05:00
|
|
|
trayIconSignal = QtCore.pyqtSignal(int)
|
2011-02-02 07:26:17 -05:00
|
|
|
blockedChum = QtCore.pyqtSignal(QtCore.QString)
|
|
|
|
unblockedChum = QtCore.pyqtSignal(QtCore.QString)
|
2011-02-04 19:50:56 -05:00
|
|
|
joinChannel = QtCore.pyqtSignal(QtCore.QString)
|
2011-02-05 12:17:33 -05:00
|
|
|
leftChannel = QtCore.pyqtSignal(QtCore.QString)
|
2011-01-21 05:18:22 -05:00
|
|
|
|
2011-01-24 07:17:12 -05:00
|
|
|
class IRCThread(QtCore.QThread):
|
|
|
|
def __init__(self, ircobj):
|
|
|
|
QtCore.QThread.__init__(self)
|
|
|
|
self.irc = ircobj
|
|
|
|
def run(self):
|
|
|
|
irc = self.irc
|
|
|
|
while 1:
|
|
|
|
irc.updateIRC()
|
2011-01-21 05:18:22 -05:00
|
|
|
|
2011-01-29 06:31:41 -05:00
|
|
|
class PesterTray(QtGui.QSystemTrayIcon):
|
|
|
|
def __init__(self, icon, mainwindow, parent):
|
|
|
|
QtGui.QSystemTrayIcon.__init__(self, icon, parent)
|
|
|
|
self.mainwindow = mainwindow
|
|
|
|
traymenu = QtGui.QMenu()
|
|
|
|
traymenu.addAction("Hi!! HI!!")
|
|
|
|
self.setContextMenu(traymenu)
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot(int)
|
|
|
|
def changeTrayIcon(self, i):
|
|
|
|
if i == 0:
|
2011-02-02 03:20:48 -05:00
|
|
|
self.setIcon(PesterIcon(self.mainwindow.theme["main/icon"]))
|
2011-01-29 06:31:41 -05:00
|
|
|
else:
|
2011-02-02 03:20:48 -05:00
|
|
|
self.setIcon(PesterIcon(self.mainwindow.theme["main/newmsgicon"]))
|
2011-01-29 06:31:41 -05:00
|
|
|
|
2011-01-21 05:18:22 -05:00
|
|
|
def main():
|
|
|
|
|
|
|
|
app = QtGui.QApplication(sys.argv)
|
2011-01-29 06:31:41 -05:00
|
|
|
if pygame.mixer:
|
|
|
|
# we could set the frequency higher but i love how cheesy it sounds
|
|
|
|
pygame.mixer.init()
|
|
|
|
else:
|
|
|
|
print "Warning: No sound!"
|
2011-01-21 05:18:22 -05:00
|
|
|
widget = PesterWindow()
|
|
|
|
widget.show()
|
|
|
|
|
2011-02-02 03:20:48 -05:00
|
|
|
trayicon = PesterTray(PesterIcon(widget.theme["main/icon"]), widget, app)
|
2011-01-29 06:31:41 -05:00
|
|
|
trayicon.show()
|
|
|
|
|
|
|
|
trayicon.connect(trayicon,
|
|
|
|
QtCore.SIGNAL('activated(QSystemTrayIcon::ActivationReason)'),
|
|
|
|
widget,
|
|
|
|
QtCore.SLOT('systemTrayActivated(QSystemTrayIcon::ActivationReason)'))
|
|
|
|
trayicon.connect(widget,
|
|
|
|
QtCore.SIGNAL('trayIconSignal(int)'),
|
|
|
|
trayicon,
|
|
|
|
QtCore.SLOT('changeTrayIcon(int)'))
|
|
|
|
|
|
|
|
|
2011-01-28 01:08:56 -05:00
|
|
|
irc = PesterIRC(widget)
|
2011-01-22 04:36:24 -05:00
|
|
|
irc.IRCConnect()
|
2011-02-04 19:50:56 -05:00
|
|
|
irc.connect(widget, QtCore.SIGNAL('sendMessage(QString, QString)'),
|
|
|
|
irc, QtCore.SLOT('sendMessage(QString, QString)'))
|
2011-01-24 04:10:44 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('newConvoStarted(QString, bool)'),
|
|
|
|
irc, QtCore.SLOT('startConvo(QString, bool)'))
|
2011-01-27 04:46:47 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('convoClosed(QString)'),
|
|
|
|
irc, QtCore.SLOT('endConvo(QString)'))
|
2011-01-28 01:41:01 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('profileChanged()'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('updateProfile()'))
|
2011-01-28 03:10:00 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('moodRequest(PyQt_PyObject)'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('getMood(PyQt_PyObject)'))
|
2011-02-02 19:06:03 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('moodsRequest(PyQt_PyObject)'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('getMoods(PyQt_PyObject)'))
|
2011-01-28 21:36:12 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('moodUpdated()'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('updateMood()'))
|
2011-01-31 18:43:49 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('mycolorUpdated()'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('updateColor()'))
|
2011-02-02 07:26:17 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('blockedChum(QString)'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('blockedChum(QString)'))
|
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('unblockedChum(QString)'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('unblockedChum(QString)'))
|
2011-02-03 01:20:37 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('requestNames(QString)'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('requestNames(QString)'))
|
2011-02-04 16:17:27 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('requestChannelList()'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('requestChannelList()'))
|
2011-02-04 19:50:56 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('joinChannel(QString)'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('joinChannel(QString)'))
|
2011-02-05 12:17:33 -05:00
|
|
|
irc.connect(widget,
|
|
|
|
QtCore.SIGNAL('leftChannel(QString)'),
|
|
|
|
irc,
|
|
|
|
QtCore.SLOT('leftChannel(QString)'))
|
|
|
|
|
2011-02-03 01:20:37 -05:00
|
|
|
|
|
|
|
# IRC --> Main window
|
2011-02-04 19:50:56 -05:00
|
|
|
irc.connect(irc, QtCore.SIGNAL('connected()'),
|
|
|
|
widget, QtCore.SLOT('connected()'))
|
2011-01-24 07:17:12 -05:00
|
|
|
irc.connect(irc,
|
|
|
|
QtCore.SIGNAL('moodUpdated(QString, PyQt_PyObject)'),
|
|
|
|
widget,
|
|
|
|
QtCore.SLOT('updateMoodSlot(QString, PyQt_PyObject)'))
|
|
|
|
irc.connect(irc,
|
|
|
|
QtCore.SIGNAL('colorUpdated(QString, QColor)'),
|
|
|
|
widget,
|
|
|
|
QtCore.SLOT('updateColorSlot(QString, QColor)'))
|
|
|
|
irc.connect(irc,
|
|
|
|
QtCore.SIGNAL('messageReceived(QString, QString)'),
|
|
|
|
widget,
|
|
|
|
QtCore.SLOT('deliverMessage(QString, QString)'))
|
2011-02-04 19:50:56 -05:00
|
|
|
irc.connect(irc,
|
|
|
|
QtCore.SIGNAL('memoReceived(QString, QString, QString)'),
|
|
|
|
widget,
|
|
|
|
QtCore.SLOT('deliverMemo(QString, QString, QString)'))
|
2011-01-27 21:21:02 -05:00
|
|
|
irc.connect(irc,
|
2011-02-01 06:14:56 -05:00
|
|
|
QtCore.SIGNAL('nickCollision(QString, QString)'),
|
2011-01-27 21:21:02 -05:00
|
|
|
widget,
|
2011-02-01 06:14:56 -05:00
|
|
|
QtCore.SLOT('nickCollision(QString, QString)'))
|
2011-02-03 01:20:37 -05:00
|
|
|
irc.connect(irc,
|
|
|
|
QtCore.SIGNAL('namesReceived(QString, PyQt_PyObject)'),
|
|
|
|
widget,
|
|
|
|
QtCore.SLOT('updateNames(QString, PyQt_PyObject)'))
|
|
|
|
irc.connect(irc,
|
|
|
|
QtCore.SIGNAL('userPresentUpdate(QString, QString, QString)'),
|
|
|
|
widget,
|
|
|
|
QtCore.SLOT('userPresentUpdate(QString, QString, QString)'))
|
2011-02-04 16:17:27 -05:00
|
|
|
irc.connect(irc,
|
|
|
|
QtCore.SIGNAL('channelListReceived(PyQt_PyObject)'),
|
|
|
|
widget,
|
|
|
|
QtCore.SLOT('updateChannelList(PyQt_PyObject)'))
|
2011-02-05 12:17:33 -05:00
|
|
|
irc.connect(irc,
|
|
|
|
QtCore.SIGNAL('timeCommand(QString, QString, QString)'),
|
|
|
|
widget,
|
|
|
|
QtCore.SLOT('timeCommand(QString, QString, QString)'))
|
2011-01-24 07:17:12 -05:00
|
|
|
|
|
|
|
ircapp = IRCThread(irc)
|
|
|
|
ircapp.start()
|
2011-02-05 12:17:33 -05:00
|
|
|
status = widget.loadingscreen.exec_()
|
|
|
|
if status == QtGui.QDialog.Rejected:
|
|
|
|
sys.exit(0)
|
2011-01-21 05:18:22 -05:00
|
|
|
sys.exit(app.exec_())
|
|
|
|
|
|
|
|
main()
|