fsda
This commit is contained in:
parent
2c48fe24c0
commit
e0e80d17ee
7 changed files with 69 additions and 22 deletions
2
TODO
2
TODO
|
@ -1,6 +1,4 @@
|
||||||
Bugs:
|
Bugs:
|
||||||
* client exits if PC is in tray and convo windows are closed
|
|
||||||
* save last mood of user
|
|
||||||
* "it's only a few sele¢t letters" <-- unicode error!
|
* "it's only a few sele¢t letters" <-- unicode error!
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
2
convo.py
2
convo.py
|
@ -13,6 +13,7 @@ from parsetools import convertTags, lexMessage, mecmd, colorBegin, colorEnd, img
|
||||||
class PesterTabWindow(QtGui.QFrame):
|
class PesterTabWindow(QtGui.QFrame):
|
||||||
def __init__(self, mainwindow, parent=None, convo="convo"):
|
def __init__(self, mainwindow, parent=None, convo="convo"):
|
||||||
QtGui.QFrame.__init__(self, parent)
|
QtGui.QFrame.__init__(self, parent)
|
||||||
|
self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
|
||||||
self.setFocusPolicy(QtCore.Qt.ClickFocus)
|
self.setFocusPolicy(QtCore.Qt.ClickFocus)
|
||||||
self.mainwindow = mainwindow
|
self.mainwindow = mainwindow
|
||||||
|
|
||||||
|
@ -378,6 +379,7 @@ class PesterInput(QtGui.QLineEdit):
|
||||||
class PesterConvo(QtGui.QFrame):
|
class PesterConvo(QtGui.QFrame):
|
||||||
def __init__(self, chum, initiated, mainwindow, parent=None):
|
def __init__(self, chum, initiated, mainwindow, parent=None):
|
||||||
QtGui.QFrame.__init__(self, parent)
|
QtGui.QFrame.__init__(self, parent)
|
||||||
|
self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
|
||||||
self.setObjectName(chum.handle)
|
self.setObjectName(chum.handle)
|
||||||
self.setFocusPolicy(QtCore.Qt.ClickFocus)
|
self.setFocusPolicy(QtCore.Qt.ClickFocus)
|
||||||
self.chum = chum
|
self.chum = chum
|
||||||
|
|
File diff suppressed because one or more lines are too long
1
memos.py
1
memos.py
|
@ -317,6 +317,7 @@ class MemoInput(PesterInput):
|
||||||
class PesterMemo(PesterConvo):
|
class PesterMemo(PesterConvo):
|
||||||
def __init__(self, channel, timestr, mainwindow, parent=None):
|
def __init__(self, channel, timestr, mainwindow, parent=None):
|
||||||
QtGui.QFrame.__init__(self, parent)
|
QtGui.QFrame.__init__(self, parent)
|
||||||
|
self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
|
||||||
self.channel = channel
|
self.channel = channel
|
||||||
self.mainwindow = mainwindow
|
self.mainwindow = mainwindow
|
||||||
self.time = TimeTracker(txt2delta(timestr))
|
self.time = TimeTracker(txt2delta(timestr))
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"hideOfflineChums": true, "tabs": true, "soundon": true, "server": "irc.tymoon.eu", "chums": ["unknownTraveler", "tentacleTherapist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "anguillaNuntia", "oilslickOrchid", "confusedTransient", "pretentiousFantasia", "aquaticMarinist", "lyricalKeraunoscopic", "counterRealist", "ectoBiologist", "percipientPedestrian", "asceticClinician", "doctectiveMiracles", "noSense", "obliviousCrafter", "ircMonster", "twinArmageddons", "cannabisHero", "jetRocket", "adiosToreador", "turntechGodhead", "magmaExploiter", "hannaSongstress", "endlessVoid", "sporadicAgent", "grayscaleVisionary", "corruptedInsanity", "riskRepeats", "stupidlyBrilliant", "artsyGyarados"], "defaultprofile": "ghostDunk", "block": []}
|
{"hideOfflineChums": true, "tabs": true, "soundon": true, "server": "irc.tymoon.eu", "chums": ["unknownTraveler", "tentacleTherapist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "anguillaNuntia", "oilslickOrchid", "confusedTransient", "pretentiousFantasia", "aquaticMarinist", "lyricalKeraunoscopic", "counterRealist", "ectoBiologist", "percipientPedestrian", "asceticClinician", "doctectiveMiracles", "noSense", "obliviousCrafter", "ircMonster", "twinArmageddons", "cannabisHero", "jetRocket", "adiosToreador", "turntechGodhead", "magmaExploiter", "hannaSongstress", "endlessVoid", "sporadicAgent", "grayscaleVisionary", "corruptedInsanity", "riskRepeats", "stupidlyBrilliant", "artsyGyarados", "subtleChaotician"], "defaultprofile": "ghostDunk", "block": []}
|
|
@ -23,6 +23,17 @@ from parsetools import convertTags, addTimeInitial
|
||||||
from memos import PesterMemo, MemoTabWindow, TimeTracker
|
from memos import PesterMemo, MemoTabWindow, TimeTracker
|
||||||
from irc import PesterIRC
|
from irc import PesterIRC
|
||||||
|
|
||||||
|
_datadir = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.DataLocation)+"Pesterchum/"
|
||||||
|
|
||||||
|
if sys.platform == "darwin":
|
||||||
|
if not os.path.exists(_datadir):
|
||||||
|
os.mkdir(_datadir)
|
||||||
|
if not os.path.exists(_datadir+"profiles"):
|
||||||
|
os.mkdir(_datadir+"profiles")
|
||||||
|
if not os.path.exists(_datadir+"pesterchum.js"):
|
||||||
|
f = open(_datadir+"pesterchum.js", 'w')
|
||||||
|
f.close()
|
||||||
|
|
||||||
class waitingMessageHolder(object):
|
class waitingMessageHolder(object):
|
||||||
def __init__(self, mainwindow, **msgfuncs):
|
def __init__(self, mainwindow, **msgfuncs):
|
||||||
self.mainwindow = mainwindow
|
self.mainwindow = mainwindow
|
||||||
|
@ -56,8 +67,14 @@ class NoneSound(object):
|
||||||
|
|
||||||
class PesterLog(object):
|
class PesterLog(object):
|
||||||
def __init__(self, handle):
|
def __init__(self, handle):
|
||||||
|
global _datadir
|
||||||
self.handle = handle
|
self.handle = handle
|
||||||
self.convos = {}
|
self.convos = {}
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
self.logpath = "logs"
|
||||||
|
else:
|
||||||
|
self.logpath = _datadir+"logs"
|
||||||
|
|
||||||
def log(self, handle, msg):
|
def log(self, handle, msg):
|
||||||
bbcodemsg = convertTags(msg, "bbcode")
|
bbcodemsg = convertTags(msg, "bbcode")
|
||||||
html = convertTags(msg, "html")+"<br />"
|
html = convertTags(msg, "html")+"<br />"
|
||||||
|
@ -67,9 +84,9 @@ class PesterLog(object):
|
||||||
time = datetime.now().strftime("%Y-%m-%d.%H.%M")
|
time = datetime.now().strftime("%Y-%m-%d.%H.%M")
|
||||||
self.convos[handle] = {}
|
self.convos[handle] = {}
|
||||||
for (format, t) in modes.iteritems():
|
for (format, t) in modes.iteritems():
|
||||||
if not os.path.exists("logs/%s/%s/%s" % (self.handle, handle, format)):
|
if not os.path.exists("%s/%s/%s/%s" % (self.logpath, self.handle, handle, format)):
|
||||||
os.makedirs("logs/%s/%s/%s" % (self.handle, handle, format))
|
os.makedirs("%s/%s/%s/%s" % (self.logpath, self.handle, handle, format))
|
||||||
fp = codecs.open("logs/%s/%s/%s/%s.%s.txt" % (self.handle, handle, format, handle, time), encoding='utf-8', mode='a')
|
fp = codecs.open("%s/%s/%s/%s/%s.%s.txt" % (self.logpath, self.handle, handle, format, handle, time), encoding='utf-8', mode='a')
|
||||||
self.convos[handle][format] = fp
|
self.convos[handle][format] = fp
|
||||||
for (format, t) in modes.iteritems():
|
for (format, t) in modes.iteritems():
|
||||||
f = self.convos[handle][format]
|
f = self.convos[handle][format]
|
||||||
|
@ -91,20 +108,25 @@ class PesterLog(object):
|
||||||
|
|
||||||
class PesterProfileDB(dict):
|
class PesterProfileDB(dict):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
self.logpath = "logs"
|
||||||
|
else:
|
||||||
|
self.logpath = _datadir+"logs"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fp = open("logs/chums.js", 'r')
|
fp = open("%s/chums.js" % (self.logpath), 'r')
|
||||||
chumdict = json.load(fp)
|
chumdict = json.load(fp)
|
||||||
fp.close()
|
fp.close()
|
||||||
except IOError:
|
except IOError:
|
||||||
chumdict = {}
|
chumdict = {}
|
||||||
fp = open("logs/chums.js", 'w')
|
fp = open("%s/chums.js" % (self.logpath), 'w')
|
||||||
json.dump(chumdict, fp)
|
json.dump(chumdict, fp)
|
||||||
fp.close()
|
fp.close()
|
||||||
converted = dict([(handle, PesterProfile(handle, color=QtGui.QColor(c['color']), mood=Mood(c['mood']))) for (handle, c) in chumdict.iteritems()])
|
converted = dict([(handle, PesterProfile(handle, color=QtGui.QColor(c['color']), mood=Mood(c['mood']))) for (handle, c) in chumdict.iteritems()])
|
||||||
self.update(converted)
|
self.update(converted)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
fp = open("logs/chums.js", 'w')
|
fp = open("%s/chums.js" % (self.logpath), 'w')
|
||||||
chumdict = dict([p.plaindict() for p in self.itervalues()])
|
chumdict = dict([p.plaindict() for p in self.itervalues()])
|
||||||
json.dump(chumdict, fp)
|
json.dump(chumdict, fp)
|
||||||
fp.close()
|
fp.close()
|
||||||
|
@ -124,7 +146,11 @@ class PesterProfileDB(dict):
|
||||||
|
|
||||||
class pesterTheme(dict):
|
class pesterTheme(dict):
|
||||||
def __init__(self, name, default=False):
|
def __init__(self, name, default=False):
|
||||||
|
if sys.platform != "darwin":
|
||||||
self.path = "themes/%s" % (name)
|
self.path = "themes/%s" % (name)
|
||||||
|
else:
|
||||||
|
self.path = _datadir+"themes/%s" % (name)
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
fp = open(self.path+"/style.js")
|
fp = open(self.path+"/style.js")
|
||||||
theme = json.load(fp, object_hook=self.pathHook)
|
theme = json.load(fp, object_hook=self.pathHook)
|
||||||
|
@ -190,7 +216,11 @@ class pesterTheme(dict):
|
||||||
|
|
||||||
class userConfig(object):
|
class userConfig(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
fp = open("pesterchum.js")
|
if sys.platform != "darwin":
|
||||||
|
self.filename = "pesterchum.js"
|
||||||
|
else:
|
||||||
|
self.filename = _datadir+"pesterchum.js"
|
||||||
|
fp = open(self.filename)
|
||||||
self.config = json.load(fp)
|
self.config = json.load(fp)
|
||||||
fp.close()
|
fp.close()
|
||||||
if self.config.has_key("defaultprofile"):
|
if self.config.has_key("defaultprofile"):
|
||||||
|
@ -198,7 +228,9 @@ class userConfig(object):
|
||||||
else:
|
else:
|
||||||
self.userprofile = None
|
self.userprofile = None
|
||||||
def chums(self):
|
def chums(self):
|
||||||
return self.config['chums']
|
if not self.config.has_key('chums'):
|
||||||
|
self.set("chums", [])
|
||||||
|
return self.config.get('chums', [])
|
||||||
def hideOfflineChums(self):
|
def hideOfflineChums(self):
|
||||||
return self.config.get('hideOfflineChums', False)
|
return self.config.get('hideOfflineChums', False)
|
||||||
def defaultprofile(self):
|
def defaultprofile(self):
|
||||||
|
@ -207,10 +239,10 @@ class userConfig(object):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
def tabs(self):
|
def tabs(self):
|
||||||
return self.config["tabs"]
|
return self.config.get("tabs", True)
|
||||||
def addChum(self, chum):
|
def addChum(self, chum):
|
||||||
if chum.handle not in self.config['chums']:
|
if chum.handle not in self.chums():
|
||||||
fp = open("pesterchum.js") # what if we have two clients open??
|
fp = open(self.filename) # what if we have two clients open??
|
||||||
newconfig = json.load(fp)
|
newconfig = json.load(fp)
|
||||||
fp.close()
|
fp.close()
|
||||||
newchums = newconfig['chums'] + [chum.handle]
|
newchums = newconfig['chums'] + [chum.handle]
|
||||||
|
@ -249,7 +281,7 @@ class userConfig(object):
|
||||||
jsonoutput = json.dumps(self.config)
|
jsonoutput = json.dumps(self.config)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
raise e
|
raise e
|
||||||
fp = open("pesterchum.js", 'w')
|
fp = open(self.filename, 'w')
|
||||||
fp.write(jsonoutput)
|
fp.write(jsonoutput)
|
||||||
fp.close()
|
fp.close()
|
||||||
def availableThemes(self):
|
def availableThemes(self):
|
||||||
|
@ -270,6 +302,11 @@ class userConfig(object):
|
||||||
return [userProfile(p) for p in profs]
|
return [userProfile(p) for p in profs]
|
||||||
class userProfile(object):
|
class userProfile(object):
|
||||||
def __init__(self, user):
|
def __init__(self, user):
|
||||||
|
if sys.platform != "darwin":
|
||||||
|
self.profiledir = "profiles"
|
||||||
|
else:
|
||||||
|
self.profiledir = _datadir+"profiles"
|
||||||
|
|
||||||
if type(user) is PesterProfile:
|
if type(user) is PesterProfile:
|
||||||
self.chat = user
|
self.chat = user
|
||||||
self.userprofile = {"handle":user.handle,
|
self.userprofile = {"handle":user.handle,
|
||||||
|
@ -278,20 +315,22 @@ class userProfile(object):
|
||||||
"theme": "pesterchum"}
|
"theme": "pesterchum"}
|
||||||
self.theme = pesterTheme("pesterchum")
|
self.theme = pesterTheme("pesterchum")
|
||||||
self.chat.mood = Mood(self.theme["main/defaultmood"])
|
self.chat.mood = Mood(self.theme["main/defaultmood"])
|
||||||
|
self.lastmood = self.chat.mood.value()
|
||||||
self.quirks = pesterQuirks([])
|
self.quirks = pesterQuirks([])
|
||||||
else:
|
else:
|
||||||
fp = open("profiles/%s.js" % (user))
|
fp = open("%s/%s.js" % (self.profiledir, user))
|
||||||
self.userprofile = json.load(fp)
|
self.userprofile = json.load(fp)
|
||||||
fp.close()
|
fp.close()
|
||||||
try:
|
try:
|
||||||
self.theme = pesterTheme(self.userprofile["theme"])
|
self.theme = pesterTheme(self.userprofile["theme"])
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
self.theme = pesterTheme("pesterchum")
|
self.theme = pesterTheme("pesterchum")
|
||||||
|
self.lastmood = self.userprofile.get('lastmood', self.theme["main/defaultmood"])
|
||||||
self.chat = PesterProfile(self.userprofile["handle"],
|
self.chat = PesterProfile(self.userprofile["handle"],
|
||||||
QtGui.QColor(self.userprofile["color"]),
|
QtGui.QColor(self.userprofile["color"]),
|
||||||
Mood(self.theme["main/defaultmood"]))
|
Mood(self.lastmood))
|
||||||
self.quirks = pesterQuirks(self.userprofile["quirks"])
|
self.quirks = pesterQuirks(self.userprofile["quirks"])
|
||||||
|
|
||||||
def setMood(self, mood):
|
def setMood(self, mood):
|
||||||
self.chat.mood = mood
|
self.chat.mood = mood
|
||||||
def setTheme(self, theme):
|
def setTheme(self, theme):
|
||||||
|
@ -306,6 +345,12 @@ class userProfile(object):
|
||||||
self.quirks = quirks
|
self.quirks = quirks
|
||||||
self.userprofile["quirks"] = self.quirks.plainList()
|
self.userprofile["quirks"] = self.quirks.plainList()
|
||||||
self.save()
|
self.save()
|
||||||
|
def getLastMood(self):
|
||||||
|
return self.lastmood
|
||||||
|
def setLastMood(self, mood):
|
||||||
|
self.lastmood = mood.value()
|
||||||
|
self.userprofile["lastmood"] = self.lastmood
|
||||||
|
self.save()
|
||||||
def getTheme(self):
|
def getTheme(self):
|
||||||
return self.theme
|
return self.theme
|
||||||
def save(self):
|
def save(self):
|
||||||
|
@ -314,7 +359,7 @@ class userProfile(object):
|
||||||
jsonoutput = json.dumps(self.userprofile)
|
jsonoutput = json.dumps(self.userprofile)
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
raise e
|
raise e
|
||||||
fp = open("profiles/%s.js" % (handle), 'w')
|
fp = open("%s/%s.js" % (self.profiledir, handle), 'w')
|
||||||
fp.write(jsonoutput)
|
fp.write(jsonoutput)
|
||||||
fp.close()
|
fp.close()
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -640,6 +685,7 @@ class PesterMoodHandler(QtCore.QObject):
|
||||||
pass
|
pass
|
||||||
newmood = Mood(m)
|
newmood = Mood(m)
|
||||||
self.mainwindow.userprofile.chat.mood = newmood
|
self.mainwindow.userprofile.chat.mood = newmood
|
||||||
|
self.mainwindow.userprofile.setLastMood(newmood)
|
||||||
if self.mainwindow.currentMoodIcon:
|
if self.mainwindow.currentMoodIcon:
|
||||||
moodicon = newmood.icon(self.mainwindow.theme)
|
moodicon = newmood.icon(self.mainwindow.theme)
|
||||||
self.mainwindow.currentMoodIcon.setPixmap(moodicon.pixmap(moodicon.realsize()))
|
self.mainwindow.currentMoodIcon.setPixmap(moodicon.pixmap(moodicon.realsize()))
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"color": "#ff00ff", "theme": "gold xl", "quirks": [], "handle": "ghostDunk"}
|
{"color": "#ff00ff", "lastmood": 21, "theme": "gold xl", "quirks": [], "handle": "ghostDunk"}
|
Loading…
Reference in a new issue