This commit is contained in:
Stephen Dranger 2011-02-09 00:26:23 -06:00
parent 3c16004844
commit 547fdb71b4
24 changed files with 92 additions and 39 deletions

2
TODO
View file

@ -1,7 +1,5 @@
Features:
* Tray doesn't disappear on windows after close
* comment history (up button)
* page up/down scrolling
* System tray menu
* troll colors
* ctrl-tab should prefer new convos

View file

@ -2,7 +2,7 @@ from string import Template
import re
from PyQt4 import QtGui, QtCore
from dataobjs import PesterProfile, Mood
from dataobjs import PesterProfile, Mood, PesterHistory
from generic import PesterIcon, RightClickList
from parsetools import escapeBrackets, convertTags
@ -277,6 +277,20 @@ class PesterInput(QtGui.QLineEdit):
def focusInEvent(self, event):
self.parent().clearNewMessage()
QtGui.QLineEdit.focusInEvent(self, event)
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Up:
text = unicode(self.text())
next = self.parent().history.next(text)
if next is not None:
self.setText(next)
elif event.key() == QtCore.Qt.Key_Down:
prev = self.parent().history.prev()
if prev is not None:
self.setText(prev)
elif event.key() in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]:
self.parent().textArea.keyPressEvent(event)
QtGui.QLineEdit.keyPressEvent(self, event)
class PesterConvo(QtGui.QFrame):
def __init__(self, chum, initiated, mainwindow, parent=None):
@ -343,7 +357,7 @@ class PesterConvo(QtGui.QFrame):
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.title(), convertTags(msg, "bbcode"))
self.newmessage = False
self.history = []
self.history = PesterHistory()
def title(self):
return self.chum.handle
@ -411,6 +425,7 @@ class PesterConvo(QtGui.QFrame):
def focusInEvent(self, event):
self.clearNewMessage()
self.textInput.setFocus()
def raiseChat(self):
self.activateWindow()
self.raise_()
@ -457,6 +472,7 @@ class PesterConvo(QtGui.QFrame):
text = unicode(self.textInput.text())
if text == "":
return
self.history.add(text)
# deal with quirks here
if self.applyquirks:
qtext = self.mainwindow.userprofile.quirks.apply(text)

BIN
convo.pyc

Binary file not shown.

View file

@ -176,21 +176,30 @@ class PesterProfile(object):
class PesterHistory(object):
def __init__(self):
self.history = []
self.current = -1
def next(self):
if self.current == -1:
return ""
text = self.history[self.current]
if self.current > 0:
self.current = 0
self.saved = None
def next(self, text):
if self.current == 0:
return None
if self.current == len(self.history):
self.save(text)
self.current -= 1
text = self.history[self.current]
return text
def prev(self):
if self.current == -1 or self.current == len(self.history) - 1:
return ""
self.current += 1
if self.current >= len(self.history):
self.current = len(self.history)
return self.retrieve()
return self.history[self.current]
def reset(self):
self.current = len(self.history) - 1
self.current = len(self.history)
self.saved = None
def save(self, text):
self.saved = text
def retrieve(self):
return self.saved
def add(self, text):
if len(self.history) == 0 or text != self.history[len(self.history)-1]:
self.history.append(text)
self.current = len(self.history) - 1
self.reset()

Binary file not shown.

Binary file not shown.

BIN
irc.pyc

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -543,6 +543,7 @@ class PesterMemo(PesterConvo):
text = unicode(self.textInput.text())
if text == "":
return
self.history.add(text)
if self.time.getTime() == None:
self.sendtime()
grammar = self.time.getGrammar()

BIN
memos.pyc

Binary file not shown.

View file

@ -487,3 +487,10 @@ class LoadingScreen(QtGui.QDialog):
self.layout.addWidget(self.loadinglabel)
self.layout.addWidget(self.cancel)
self.setLayout(self.layout)
class AboutPesterchum(QtGui.QMessageBox):
def __init__(self, parent=None):
QtGui.QMessageBox.__init__(self, parent)
self.setText("P3ST3RCHUM V. 0.1.2")
self.setInformativeText("Programming by illuminatedwax (ghostDunk), art by Grimlive (aquaMarinist)")
self.mainwindow = parent

BIN
menus.pyc

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"tabs": true, "soundon": true, "chums": ["marineAquist", "unknownTraveler", "tentacleTherapist", "macruralAlchemist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "superGhost", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "adiosToreador", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "maxiumumFatness", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "acapellaWaterfall", "anguillaNuntia", "oilslickOrchid", "confusedTransient"], "defaultprofile": "ghostDunk", "block": []}
{"tabs": true, "soundon": true, "chums": ["marineAquist", "unknownTraveler", "tentacleTherapist", "macruralAlchemist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "superGhost", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "adiosToreador", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "maxiumumFatness", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "acapellaWaterfall", "anguillaNuntia", "oilslickOrchid", "confusedTransient", "pretentiousFantasia"], "defaultprofile": "ghostDunk", "block": []}

View file

@ -14,7 +14,7 @@ import pygame
from menus import PesterChooseQuirks, PesterChooseTheme, \
PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList, \
LoadingScreen
LoadingScreen, AboutPesterchum
from dataobjs import PesterProfile, Mood, pesterQuirk, pesterQuirks
from generic import PesterIcon, RightClickList, MultiTextDialog, PesterList
from convo import PesterTabWindow, PesterText, PesterInput, PesterConvo
@ -109,25 +109,26 @@ class PesterProfileDB(dict):
self.save()
class pesterTheme(dict):
def __init__(self, name):
def __init__(self, name, default=False):
self.path = "themes/%s" % (name)
self.name = name
fp = open(self.path+"/style.js")
theme = json.load(fp, object_hook=self.pathHook)
self.update(theme)
fp.close()
defaultfp = open("themes/pesterchum/style.js") # set default
defaultTheme = json.load(defaultfp, object_hook=self.pathHook)
self.defaultTheme = defaultTheme
defaultfp.close()
if not default:
self.defaultTheme = pesterTheme("pesterchum", default=True)
def __getitem__(self, key):
keys = key.split("/")
v = dict.__getitem__(self, keys.pop(0))
for k in keys:
try:
v = v[k]
except KeyError:
v = self.defaultTheme[k]
except KeyError, e:
if hasattr(self, 'defaultTheme'):
return self.defaultTheme[key]
else:
raise e
return v
def pathHook(self, d):
for (k, v) in d.iteritems():
@ -136,18 +137,22 @@ class pesterTheme(dict):
d[k] = s.safe_substitute(path=self.path)
return d
def get(self, key, default):
keys = key.split("/")
v = dict.__getitem__(self, keys.pop(0))
for k in keys:
try:
ret = self[key]
v = v[k]
except KeyError:
return default
else:
return ret
return v
def has_key(self, key):
keys = key.split("/")
v = dict.__getitem__(self, keys.pop(0))
for k in keys:
try:
self[key]
v = v[k]
except KeyError:
return False
else:
return True
class userConfig(object):
@ -684,6 +689,14 @@ class PesterWindow(MovingWindow):
profilemenu.addAction(changecoloraction)
profilemenu.addAction(switch)
self.aboutAction = QtGui.QAction(self.theme["main/menus/help/about"], self)
self.connect(self.aboutAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('aboutPesterchum()'))
helpmenu = self.menu.addMenu(self.theme["main/menus/help/_name"])
self.helpmenu = helpmenu
self.helpmenu.addAction(self.aboutAction)
self.closeButton = WMButton(PesterIcon(self.theme["main/close/image"]), self)
self.connect(self.closeButton, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('closeToTray()'))
@ -923,6 +936,8 @@ class PesterWindow(MovingWindow):
self.changecoloraction.setText(theme["main/menus/profile/color"])
self.switch.setText(theme["main/menus/profile/switch"])
self.profilemenu.setTitle(theme["main/menus/profile/_name"])
self.aboutAction.setText(self.theme["main/menus/help/about"])
self.helpmenu.setTitle(self.theme["main/menus/help/_name"])
# moods
self.moodsLabel.setText(theme["main/moodlabel/text"])
@ -976,9 +991,7 @@ class PesterWindow(MovingWindow):
self.currentMoodIcon.move(*theme["main/mychumhandle/currentMood"])
self.currentMoodIcon.show()
else:
print "no mood :("
if hasattr(self, 'currentMoodIcon') and self.currentMoodIcon:
print "hiding..."
self.currentMoodIcon.hide()
self.currentMoodIcon = None
@ -1475,6 +1488,13 @@ class PesterWindow(MovingWindow):
if ret == QtGui.QMessageBox.Cancel:
return
self.changeProfile()
@QtCore.pyqtSlot()
def aboutPesterchum(self):
if hasattr(self, 'aboutwindow') and self.aboutwindow:
return
self.aboutwindow = AboutPesterchum(self)
self.aboutwindow.exec_()
self.aboutwindow = None
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
def nickCollision(self, handle, tmphandle):

View file

@ -28,6 +28,8 @@
"theme": "THEME",
"block": "TROLLSLUM",
"quirks": "QUIRKS"},
"help": { "_name": "HELP",
"about": "ABOUT" },
"rclickchumlist": {"pester": "PESTER",
"removechum": "REMOVE CHUM",
"blockchum": "BLOCK",

BIN
trayicon32.icns Normal file

Binary file not shown.

BIN
trayicon32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB