Theme checking
This commit is contained in:
parent
a7f6ee4b38
commit
5400112c85
8 changed files with 115 additions and 13 deletions
|
@ -8,7 +8,6 @@ Features
|
|||
* random pesters
|
||||
* copy quirks between profiles?
|
||||
* More complex quirks: by-sound
|
||||
* Theme checking
|
||||
* Spy mode
|
||||
* Turn @ and # links on/off?
|
||||
|
||||
|
|
|
@ -247,8 +247,8 @@ def splitMessage(msg, format="ctag"):
|
|||
if len(okmsg) > 0:
|
||||
output.append(okmsg)
|
||||
return output
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def addTimeInitial(string, grammar):
|
||||
endofi = string.find(":")
|
||||
|
@ -364,7 +364,7 @@ def parseRegexpFunctions(to):
|
|||
current.append(to[curi:])
|
||||
curi = len(to)
|
||||
return parsed
|
||||
|
||||
|
||||
|
||||
def img2smiley(string):
|
||||
string = unicode(string)
|
||||
|
@ -429,3 +429,73 @@ smiledict = {
|
|||
|
||||
reverse_smiley = dict((v,k) for k, v in smiledict.iteritems())
|
||||
_smilere = re.compile("|".join(smiledict.keys()))
|
||||
|
||||
class ThemeException(Exception):
|
||||
def __init__(self, value):
|
||||
self.parameter = value
|
||||
def __str__(self):
|
||||
return repr(self.parameter)
|
||||
|
||||
def themeChecker(theme):
|
||||
needs = ["main/size", "main/icon", "main/windowtitle", "main/style", \
|
||||
"main/background-image", "main/menubar/style", "main/menu/menuitem", \
|
||||
"main/menu/style", "main/menu/selected", "main/close/image", \
|
||||
"main/close/loc", "main/minimize/image", "main/minimize/loc", \
|
||||
"main/menu/loc", "main/menus/client/logviewer", \
|
||||
"main/menus/client/addgroup", "main/menus/client/options", \
|
||||
"main/menus/client/exit", "main/menus/client/userlist", \
|
||||
"main/menus/client/memos", "main/menus/client/import", \
|
||||
"main/menus/client/idle", "main/menus/client/reconnect", \
|
||||
"main/menus/client/_name", "main/menus/profile/quirks", \
|
||||
"main/menus/profile/block", "main/menus/profile/color", \
|
||||
"main/menus/profile/switch", "main/menus/profile/_name", \
|
||||
"main/menus/help/about", "main/menus/help/_name", "main/moodlabel/text", \
|
||||
"main/moodlabel/loc", "main/moodlabel/style", "main/moods", \
|
||||
"main/addchum/style", "main/addchum/text", "main/addchum/size", \
|
||||
"main/addchum/loc", "main/pester/text", "main/pester/size", \
|
||||
"main/pester/loc", "main/block/text", "main/block/size", "main/block/loc", \
|
||||
"main/mychumhandle/label/text", "main/mychumhandle/label/loc", \
|
||||
"main/mychumhandle/label/style", "main/mychumhandle/handle/loc", \
|
||||
"main/mychumhandle/handle/size", "main/mychumhandle/handle/style", \
|
||||
"main/mychumhandle/colorswatch/size", "main/mychumhandle/colorswatch/loc", \
|
||||
"main/defaultmood", "main/chums/size", "main/chums/loc", \
|
||||
"main/chums/style", "main/menus/rclickchumlist/pester", \
|
||||
"main/menus/rclickchumlist/removechum", \
|
||||
"main/menus/rclickchumlist/blockchum", "main/menus/rclickchumlist/viewlog", \
|
||||
"main/menus/rclickchumlist/removegroup", \
|
||||
"main/menus/rclickchumlist/renamegroup", \
|
||||
"main/menus/rclickchumlist/movechum", "convo/size", \
|
||||
"convo/tabwindow/style", "convo/tabs/tabstyle", "convo/tabs/style", \
|
||||
"convo/tabs/selectedstyle", "convo/style", "convo/margins", \
|
||||
"convo/chumlabel/text", "convo/chumlabel/style", "convo/chumlabel/align/h", \
|
||||
"convo/chumlabel/align/v", "convo/chumlabel/maxheight", \
|
||||
"convo/chumlabel/minheight", "main/menus/rclickchumlist/quirksoff", \
|
||||
"main/menus/rclickchumlist/addchum", "main/menus/rclickchumlist/blockchum", \
|
||||
"main/menus/rclickchumlist/unblockchum", \
|
||||
"main/menus/rclickchumlist/viewlog", "main/trollslum/size", \
|
||||
"main/trollslum/style", "main/trollslum/label/text", \
|
||||
"main/trollslum/label/style", "main/menus/profile/block", \
|
||||
"main/chums/moods/blocked/icon", "convo/systemMsgColor", \
|
||||
"convo/textarea/style", "convo/text/beganpester", "convo/text/ceasepester", \
|
||||
"convo/text/blocked", "convo/text/unblocked", "convo/text/blockedmsg", \
|
||||
"convo/text/idle", "convo/input/style", "memos/memoicon", \
|
||||
"memos/textarea/style", "memos/systemMsgColor", "convo/text/joinmemo", \
|
||||
"memos/input/style", "main/menus/rclickchumlist/banuser", \
|
||||
"main/menus/rclickchumlist/opuser", "main/menus/rclickchumlist/voiceuser", \
|
||||
"memos/margins", "convo/text/openmemo", "memos/size", "memos/style", \
|
||||
"memos/label/text", "memos/label/style", "memos/label/align/h", \
|
||||
"memos/label/align/v", "memos/label/maxheight", "memos/label/minheight", \
|
||||
"memos/userlist/style", "memos/userlist/width", "memos/time/text/width", \
|
||||
"memos/time/text/style", "memos/time/arrows/left", \
|
||||
"memos/time/arrows/style", "memos/time/buttons/style", \
|
||||
"memos/time/arrows/right", "memos/op/icon", "memos/voice/icon", \
|
||||
"convo/text/closememo", "convo/text/kickedmemo", \
|
||||
"main/chums/userlistcolor", "main/defaultwindow/style", \
|
||||
"main/chums/moods", "main/chums/moods/chummy/icon", "main/menus/help/help", \
|
||||
"main/menus/help/calsprite", "main/menus/help/nickserv"]
|
||||
|
||||
for n in needs:
|
||||
try:
|
||||
theme[n]
|
||||
except KeyError:
|
||||
raise ThemeException("Missing theme requirement: %s" % (n))
|
||||
|
|
|
@ -20,7 +20,7 @@ from menus import PesterChooseQuirks, PesterChooseTheme, \
|
|||
from dataobjs import PesterProfile, Mood, pesterQuirk, pesterQuirks
|
||||
from generic import PesterIcon, RightClickList, RightClickTree, MultiTextDialog, PesterList, CaseInsensitiveDict
|
||||
from convo import PesterTabWindow, PesterText, PesterInput, PesterConvo
|
||||
from parsetools import convertTags, addTimeInitial
|
||||
from parsetools import convertTags, addTimeInitial, themeChecker, ThemeException
|
||||
from memos import PesterMemo, MemoTabWindow, TimeTracker
|
||||
from irc import PesterIRC
|
||||
from logviewer import PesterLogUserSelect, PesterLogViewer
|
||||
|
@ -1334,6 +1334,15 @@ class PesterWindow(MovingWindow):
|
|||
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0)))
|
||||
self.theme = self.userprofile.getTheme()
|
||||
|
||||
try:
|
||||
themeChecker(self.theme)
|
||||
except ThemeException, (inst):
|
||||
print "Caught: "+inst.parameter
|
||||
themeWarning = QtGui.QMessageBox(self)
|
||||
themeWarning.setText("Theme Error: %s\nFalling back..." % (inst))
|
||||
themeWarning.exec_()
|
||||
self.theme = pesterTheme("pesterchum")
|
||||
|
||||
self.chatlog = PesterLog(self.profile().handle, self)
|
||||
|
||||
self.move(100, 100)
|
||||
|
@ -1413,13 +1422,13 @@ class PesterWindow(MovingWindow):
|
|||
profilemenu.addAction(changecoloraction)
|
||||
profilemenu.addAction(switch)
|
||||
|
||||
self.helpAction = QtGui.QAction("HELP", self)
|
||||
self.helpAction = QtGui.QAction(self.theme["main/menus/help/help"], self)
|
||||
self.connect(self.helpAction, QtCore.SIGNAL('triggered()'),
|
||||
self, QtCore.SLOT('launchHelp()'))
|
||||
self.botAction = QtGui.QAction("CALSPRITE", self)
|
||||
self.botAction = QtGui.QAction(self.theme["main/menus/help/calsprite"], self)
|
||||
self.connect(self.botAction, QtCore.SIGNAL('triggered()'),
|
||||
self, QtCore.SLOT('loadCalsprite()'))
|
||||
self.nickServAction = QtGui.QAction("NICKSERV", self)
|
||||
self.nickServAction = QtGui.QAction(self.theme["main/menus/help/nickserv"], self)
|
||||
self.connect(self.nickServAction, QtCore.SIGNAL('triggered()'),
|
||||
self, QtCore.SLOT('loadNickServ()'))
|
||||
self.aboutAction = QtGui.QAction(self.theme["main/menus/help/about"], self)
|
||||
|
@ -1808,6 +1817,15 @@ class PesterWindow(MovingWindow):
|
|||
self.ceasesound = NoneSound()
|
||||
|
||||
def changeTheme(self, theme):
|
||||
# check theme
|
||||
try:
|
||||
themeChecker(theme)
|
||||
except ThemeException, (inst):
|
||||
themeWarning = QtGui.QMessageBox(self)
|
||||
themeWarning.setText("Theme Error: %s\nFalling back..." % (inst))
|
||||
themeWarning.exec_()
|
||||
theme = pesterTheme("pesterchum")
|
||||
return
|
||||
self.theme = theme
|
||||
# do self
|
||||
self.initTheme(theme)
|
||||
|
|
|
@ -32,7 +32,10 @@
|
|||
"block": "Trollslum",
|
||||
"quirks": "Quirks"},
|
||||
"help": { "_name": "Help",
|
||||
"about": "About" },
|
||||
"about": "About",
|
||||
"help": "Help",
|
||||
"calsprite": "CalSprite",
|
||||
"nickserv": "NickServ" },
|
||||
"rclickchumlist": {"pester": "Pester",
|
||||
"removechum": "Remove Chum",
|
||||
"blockchum": "Block",
|
||||
|
|
|
@ -35,7 +35,10 @@
|
|||
"block": "Trollslum",
|
||||
"quirks": "Quirks"},
|
||||
"help": { "_name": "Help",
|
||||
"about": "About" },
|
||||
"about": "About",
|
||||
"help": "Help",
|
||||
"calsprite": "CalSprite",
|
||||
"nickserv": "NickServ" },
|
||||
"rclickchumlist": {"pester": "Pester",
|
||||
"removechum": "Remove Chum",
|
||||
"report": "Report",
|
||||
|
|
|
@ -35,7 +35,10 @@
|
|||
"block": "TROLLSLUM",
|
||||
"quirks": "QUIRKS"},
|
||||
"help": { "_name": "HELP",
|
||||
"about": "ABOUT" },
|
||||
"about": "ABOUT",
|
||||
"help": "HELP",
|
||||
"calsprite": "CALSPRITE",
|
||||
"nickserv": "NICKSERV" },
|
||||
"rclickchumlist": {"pester": "PESTER",
|
||||
"removechum": "REMOVE CHUM",
|
||||
"report": "REPORT",
|
||||
|
|
|
@ -34,7 +34,10 @@
|
|||
"block": "Chumpdump",
|
||||
"quirks": "Annoying" },
|
||||
"help": { "_name": "Help",
|
||||
"about": "About" },
|
||||
"about": "About",
|
||||
"help": "Help",
|
||||
"calsprite": "CalSprite",
|
||||
"nickserv": "NickServ" },
|
||||
"rclickchumlist": {"pester": "Troll",
|
||||
"removechum": "Trash",
|
||||
"report": "Remove",
|
||||
|
|
|
@ -35,7 +35,10 @@
|
|||
"block": "Ruffians",
|
||||
"quirks": "Quirks"},
|
||||
"help": { "_name": "Assistance",
|
||||
"about": "About" },
|
||||
"about": "About",
|
||||
"help": "Assistance",
|
||||
"calsprite": "CalSprite",
|
||||
"nickserv": "NickServ" },
|
||||
"rclickchumlist": {"pester": "Converse",
|
||||
"removechum": "Erase User",
|
||||
"report": "Report User",
|
||||
|
|
Loading…
Reference in a new issue