diff --git a/TODO b/TODO index 711f2c0..3081ddf 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,5 @@ Features: -* Hyperlinks +* chat window margins * /me ghostDunk's [GD'S] * Transparent background * tab recombining gives wrong window icon @@ -17,6 +17,7 @@ Features: * ctrl-tab should prefer new convos * More complex quirks: random, spelling, by-sound * Implement TC options +* chumList not scaling -- QListView + delegate? * spell check? * Help menu * more robust IRC error handling diff --git a/generic.pyc b/generic.pyc index 11d6583..0f85a66 100644 Binary files a/generic.pyc and b/generic.pyc differ diff --git a/logs/chums.js b/logs/chums.js index 7cc3baf..1a11cb1 100644 --- a/logs/chums.js +++ b/logs/chums.js @@ -1 +1 @@ -{"macruralAlchemist": {"color": "#700000", "handle": "macruralAlchemist", "mood": "offline"}, "agogPorphyry": {"color": "#522d80", "handle": "agogPorphyry", "mood": "offline"}, "fireSwallow": {"color": "#80bb9a", "handle": "fireSwallow", "mood": "offline"}, "aquaMarinist": {"color": "#00caca", "handle": "aquaMarinist", "mood": "offline"}, "nitroZealist": {"color": "#ff3737", "handle": "nitroZealist", "mood": "offline"}, "superGhost": {"color": "#800564", "handle": "superGhost", "mood": "offline"}, "tentacleTherapist": {"color": "#cc66ff", "handle": "tentacleTherapist", "mood": "offline"}, "captainCaveman": {"color": "#7c414e", "handle": "captainCaveman", "mood": "offline"}, "mechanicalSpectacle": {"color": "#0000ff", "handle": "mechanicalSpectacle", "mood": "offline"}, "gamblingGenocider": {"color": "#00ff00", "handle": "gamblingGenocider", "mood": "offline"}, "centaursTesticle": {"color": "#000056", "handle": "centaursTesticle", "mood": "offline"}, "schlagzeugGator": {"color": "#61821f", "handle": "schlagzeugGator", "mood": "offline"}, "unknownTraveler": {"color": "#006666", "handle": "unknownTraveler", "mood": "offline"}, "marineAquist": {"color": "#00caca", "handle": "marineAquist", "mood": "offline"}} \ No newline at end of file +{"macruralAlchemist": {"color": "#700000", "handle": "macruralAlchemist", "mood": "offline"}, "agogPorphyry": {"color": "#522d80", "handle": "agogPorphyry", "mood": "offline"}, "fireSwallow": {"color": "#80bb9a", "handle": "fireSwallow", "mood": "offline"}, "aquaMarinist": {"color": "#00caca", "handle": "aquaMarinist", "mood": "offline"}, "nitroZealist": {"color": "#ff3737", "handle": "nitroZealist", "mood": "offline"}, "superGhost": {"color": "#800564", "handle": "superGhost", "mood": "offline"}, "tentacleTherapist": {"color": "#cc66ff", "handle": "tentacleTherapist", "mood": "offline"}, "aquaticMarinist": {"color": "#00caca", "handle": "aquaticMarinist", "mood": "offline"}, "captainCaveman": {"color": "#7c414e", "handle": "captainCaveman", "mood": "offline"}, "mechanicalSpectacle": {"color": "#0000ff", "handle": "mechanicalSpectacle", "mood": "offline"}, "gamblingGenocider": {"color": "#00ff00", "handle": "gamblingGenocider", "mood": "offline"}, "centaursTesticle": {"color": "#000056", "handle": "centaursTesticle", "mood": "offline"}, "schlagzeugGator": {"color": "#61821f", "handle": "schlagzeugGator", "mood": "offline"}, "unknownTraveler": {"color": "#006666", "handle": "unknownTraveler", "mood": "offline"}, "marineAquist": {"color": "#00caca", "handle": "marineAquist", "mood": "offline"}} \ No newline at end of file diff --git a/pesterchum.py b/pesterchum.py index f8de3be..6a36873 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -22,11 +22,12 @@ logging.basicConfig(level=logging.INFO) _ctag_begin = re.compile(r'') _ctag_rgb = re.compile(r'\d+,\d+,\d+') +_urlre = re.compile(r"(?i)(http://[^\s<]+)") -def convertColorTags(string, format="html"): +def convertTags(string, format="html"): if format not in ["html", "bbcode", "ctag"]: raise ValueError("Color format not recognized") - def repfunc(matchobj): + def colorrepfunc(matchobj): color = matchobj.group(1) if _ctag_rgb.match(color) is not None: if format=='ctag': @@ -46,9 +47,13 @@ def convertColorTags(string, format="html"): elif format == "ctag": (r,g,b,a) = qc.getRgb() return '' % (r,g,b) - string = _ctag_begin.sub(repfunc, string) + string = _ctag_begin.sub(colorrepfunc, string) endtag = {"html": "", "bbcode": "[/color]", "ctag": ""} string = string.replace("", endtag[format]) + urlrep = {"html": r"\1", + "bbcode": r"[url]\1[/url]", + "ctag": r"\1" } + string = _urlre.sub(urlrep[format], string) return string def escapeBrackets(string): @@ -98,10 +103,6 @@ def escapeBrackets(string): retval += "" return retval -#_urlre = re.compile() -#def findURLs(string): - - class waitingMessageHolder(object): def __init__(self, mainwindow, **msgfuncs): self.mainwindow = mainwindow @@ -362,13 +363,15 @@ class chumListing(QtGui.QListWidgetItem): def updateMood(self, unblock=False): mood = self.chum.mood self.mood = mood - self.setIcon(self.mood.icon(self.mainwindow.theme)) + icon = self.mood.icon(self.mainwindow.theme) + self.setIcon(icon) 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"])) def changeTheme(self, theme): - self.setIcon(self.mood.icon(theme)) + icon = self.mood.icon(theme) + self.setIcon(icon) try: self.setTextColor(QtGui.QColor(self.mainwindow.theme["main/chums/moods"][self.mood.name()]["color"])) except KeyError: @@ -841,36 +844,35 @@ class PesterText(QtGui.QTextEdit): if msg == "PESTERCHUM:BEGIN": parent.setChumOpen(True) msg = chum.pestermsg(me, systemColor, window.theme["convo/text/beganpester"]) - window.chatlog.log(chum.handle, convertColorTags(msg, "bbcode")) - self.append(convertColorTags(msg)) + window.chatlog.log(chum.handle, convertTags(msg, "bbcode")) + self.append(convertTags(msg)) elif msg == "PESTERCHUM:CEASE": parent.setChumOpen(False) msg = chum.pestermsg(me, systemColor, window.theme["convo/text/ceasepester"]) - window.chatlog.log(chum.handle, convertColorTags(msg, "bbcode")) - self.append(convertColorTags(msg)) + window.chatlog.log(chum.handle, convertTags(msg, "bbcode")) + self.append(convertTags(msg)) elif msg == "PESTERCHUM:BLOCK": msg = chum.pestermsg(me, systemColor, window.theme['convo/text/blocked']) - window.chatlog.log(chum.handle, convertColorTags(msg, "bbcode")) - self.append(convertColorTags(msg)) + window.chatlog.log(chum.handle, convertTags(msg, "bbcode")) + self.append(convertTags(msg)) elif msg == "PESTERCHUM:UNBLOCK": msg = chum.pestermsg(me, systemColor, window.theme['convo/text/unblocked']) - window.chatlog.log(chum.handle, convertColorTags(msg, "bbcode")) - self.append(convertColorTags(msg)) + window.chatlog.log(chum.handle, convertTags(msg, "bbcode")) + self.append(convertTags(msg)) else: if not parent.chumopen and chum is not me: beginmsg = chum.pestermsg(me, systemColor, window.theme["convo/text/beganpester"]) parent.setChumOpen(True) - window.chatlog.log(chum.handle, convertColorTags(beginmsg, "bbcode")) - self.append(convertColorTags(beginmsg)) + window.chatlog.log(chum.handle, convertTags(beginmsg, "bbcode")) + self.append(convertTags(beginmsg)) msg = "%s: %s" % (color, initials, msg) msg = escapeBrackets(msg) - #msg = findURLs(msg) - self.append(convertColorTags(msg)) + self.append(convertTags(msg)) if chum is me: - window.chatlog.log(parent.chum.handle, convertColorTags(msg, "bbcode")) + window.chatlog.log(parent.chum.handle, convertTags(msg, "bbcode")) else: - window.chatlog.log(chum.handle, convertColorTags(msg, "bbcode")) + window.chatlog.log(chum.handle, convertTags(msg, "bbcode")) def changeTheme(self, theme): self.setStyleSheet(theme["convo/textarea/style"]) sb = self.verticalScrollBar() @@ -880,6 +882,13 @@ class PesterText(QtGui.QTextEdit): self.parent().clearNewMessage() QtGui.QTextEdit.focusInEvent(self, event) + def mousePressEvent(self, event): + url = self.anchorAt(event.pos()) + if url == "": + return + else: + QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode)) + class PesterInput(QtGui.QLineEdit): def __init__(self, theme, parent=None): QtGui.QLineEdit.__init__(self, parent) @@ -932,15 +941,15 @@ class PesterConvo(QtGui.QFrame): if initiated: msg = self.mainwindow.profile().pestermsg(self.chum, QtGui.QColor(self.mainwindow.theme["convo/systemMsgColor"]), self.mainwindow.theme["convo/text/beganpester"]) self.setChumOpen(True) - self.textArea.append(convertColorTags(msg)) - self.mainwindow.chatlog.log(self.chum.handle, convertColorTags(msg, "bbcode")) + self.textArea.append(convertTags(msg)) + self.mainwindow.chatlog.log(self.chum.handle, convertTags(msg, "bbcode")) self.newmessage = False def updateMood(self, mood, unblocked=False): if mood.name() == "offline" and self.chumopen == True and not unblocked: msg = self.chum.pestermsg(self.mainwindow.profile(), QtGui.QColor(self.mainwindow.theme["convo/systemMsgColor"]), self.mainwindow.theme["convo/text/ceasepester"]) - self.textArea.append(convertColorTags(msg)) - self.mainwindow.chatlog.log(self.chum.handle, convertColorTags(msg, "bbcode")) + self.textArea.append(convertTags(msg)) + self.mainwindow.chatlog.log(self.chum.handle, convertTags(msg, "bbcode")) self.chumopen = False if self.parent(): self.parent().updateMood(self.chum.handle, mood, unblocked) @@ -1034,6 +1043,8 @@ class PesterConvo(QtGui.QFrame): # if ceased, rebegin if not self.chumopen: self.mainwindow.newConvoStarted.emit(QtCore.QString(self.chum.handle), True) + # convert color tags + text = convertTags(unicode(text), "ctag") self.messageSent.emit(text, self.chum) messageSent = QtCore.pyqtSignal(QtCore.QString, PesterProfile) @@ -1395,7 +1406,7 @@ class PesterWindow(MovingWindow): chum = self.convos[h].chum chumopen = self.convos[h].chumopen if chumopen: - self.chatlog.log(chum.handle, convertColorTags(self.profile().pestermsg(chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/ceasepester"]), "bbcode")) + self.chatlog.log(chum.handle, convertTags(self.profile().pestermsg(chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/ceasepester"]), "bbcode")) self.chatlog.finish(h) self.convoClosed.emit(handle) del self.convos[h] @@ -1487,8 +1498,8 @@ class PesterWindow(MovingWindow): 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"]) - convo.textArea.append(convertColorTags(msg)) - self.chatlog.log(convo.chum.handle, convertColorTags(msg, "bbcode")) + convo.textArea.append(convertTags(msg)) + self.chatlog.log(convo.chum.handle, convertTags(msg, "bbcode")) convo.updateBlocked() self.chumList.removeChum(h) if hasattr(self, 'trollslum') and self.trollslum: @@ -1504,8 +1515,8 @@ class PesterWindow(MovingWindow): 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"]) - convo.textArea.append(convertColorTags(msg)) - self.chatlog.log(convo.chum.handle, convertColorTags(msg, "bbcode")) + convo.textArea.append(convertTags(msg)) + self.chatlog.log(convo.chum.handle, convertTags(msg, "bbcode")) convo.updateMood(convo.chum.mood, unblocked=True) chum = PesterProfile(h, chumdb=self.chumdb) if hasattr(self, 'trollslum') and self.trollslum: diff --git a/pestermenus.py b/pestermenus.py index c9441b5..557d577 100644 --- a/pestermenus.py +++ b/pestermenus.py @@ -347,7 +347,7 @@ class PesterUserlist(QtGui.QDialog): self.userarea.clear() for n in names: item = QtGui.QListWidgetItem(n) - item.setTextColor(QtGui.QColor(self.theme["main/chums/moods/chummy/color"])) + item.setTextColor(QtGui.QColor(self.theme["main/chums/userlistcolor"])) self.userarea.addItem(item) self.userarea.sortItems() @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) @@ -362,7 +362,7 @@ class PesterUserlist(QtGui.QDialog): self.addUser(h) def addUser(self, name): item = QtGui.QListWidgetItem(name) - item.setTextColor(QtGui.QColor(self.theme["main/chums/moods/chummy/color"])) + item.setTextColor(QtGui.QColor(self.theme["main/chums/userlistcolor"])) self.userarea.addItem(item) self.userarea.sortItems() def delUser(self, name): @@ -377,7 +377,7 @@ class PesterUserlist(QtGui.QDialog): self.addChumAction.setText(theme["main/menus/rclickchumlist/addchum"]) for item in [self.userarea.item(i) for i in range(0, self.userarea.count())]: print item.text() - item.setTextColor(QtGui.QColor(theme["main/chums/moods/chummy/color"])) + item.setTextColor(QtGui.QColor(theme["main/chums/userlistcolor"])) @QtCore.pyqtSlot() def addChumSlot(self): diff --git a/pestermenus.pyc b/pestermenus.pyc index 90b58ce..fcaec88 100644 Binary files a/pestermenus.pyc and b/pestermenus.pyc differ diff --git a/themes/pesterchum/style.js b/themes/pesterchum/style.js index 4ab5825..965b2d3 100644 --- a/themes/pesterchum/style.js +++ b/themes/pesterchum/style.js @@ -35,6 +35,7 @@ "chums": { "style": "border:2px solid yellow; background-color: black;color: white;font: bold;font-family: 'Courier';selection-background-color:#646464; ", "loc": [12, 117], "size": [209, 82], + "userlistcolor": "black", "moods": { "chummy": { "icon": "$path/chummy.gif", "color": "white" }, diff --git a/themes/trollian/style.js b/themes/trollian/style.js index 97c0ac4..75307ce 100644 --- a/themes/trollian/style.js +++ b/themes/trollian/style.js @@ -34,7 +34,7 @@ "chums": { "style": "border: 0px; background-color: white; padding: 5px; font-family: 'Arial';selection-background-color:rgb(200,200,200); ", "loc": [476, 90], "size": [175, 361], - + "userlistcolor": "black", "moods": { "chummy": { "icon": "$path/chummy.png", "color": "#63ea00" },