more memo work

This commit is contained in:
Stephen Dranger 2011-02-04 18:50:56 -06:00
parent 79e4de5710
commit 3bafa1e48a
21 changed files with 219 additions and 83 deletions

View file

@ -7,12 +7,10 @@ from generic import PesterIcon
from parsetools import escapeBrackets, convertTags from parsetools import escapeBrackets, convertTags
class PesterTabWindow(QtGui.QFrame): class PesterTabWindow(QtGui.QFrame):
def __init__(self, mainwindow, parent=None): def __init__(self, mainwindow, parent=None, convo="convo"):
QtGui.QFrame.__init__(self, parent) QtGui.QFrame.__init__(self, parent)
self.setFocusPolicy(QtCore.Qt.ClickFocus) self.setFocusPolicy(QtCore.Qt.ClickFocus)
self.mainwindow = mainwindow self.mainwindow = mainwindow
self.resize(*self.mainwindow.theme["convo/size"])
self.setStyleSheet(self.mainwindow.theme["convo/style"])
self.tabs = QtGui.QTabBar(self) self.tabs = QtGui.QTabBar(self)
self.tabs.setTabsClosable(True) self.tabs.setTabsClosable(True)
@ -20,9 +18,8 @@ class PesterTabWindow(QtGui.QFrame):
self, QtCore.SLOT('changeTab(int)')) self, QtCore.SLOT('changeTab(int)'))
self.connect(self.tabs, QtCore.SIGNAL('tabCloseRequested(int)'), self.connect(self.tabs, QtCore.SIGNAL('tabCloseRequested(int)'),
self, QtCore.SLOT('tabClose(int)')) self, QtCore.SLOT('tabClose(int)'))
self.tabs.setShape(self.mainwindow.theme["convo/tabs/tabstyle"])
self.tabs.setStyleSheet("QTabBar::tab{ %s } QTabBar::tab:selected { %s }" % (self.mainwindow.theme["convo/tabs/style"], self.mainwindow.theme["convo/tabs/selectedstyle"]))
self.initTheme(self.mainwindow.theme[convo])
self.layout = QtGui.QVBoxLayout() self.layout = QtGui.QVBoxLayout()
self.layout.setContentsMargins(0,0,0,0) self.layout.setContentsMargins(0,0,0,0)
self.layout.addWidget(self.tabs) self.layout.addWidget(self.tabs)
@ -33,8 +30,11 @@ class PesterTabWindow(QtGui.QFrame):
self.changedTab = False self.changedTab = False
self.softclose = False self.softclose = False
self.type = convo
# get default tab color i guess # get default tab color i guess
self.defaultTabTextColor = self.getTabTextColor() self.defaultTabTextColor = self.getTabTextColor()
def getTabTextColor(self): def getTabTextColor(self):
# ugly, ugly hack # ugly, ugly hack
self.changedTab = True self.changedTab = True
@ -44,12 +44,12 @@ class PesterTabWindow(QtGui.QFrame):
self.changedTab = False self.changedTab = False
return c return c
def addChat(self, convo): def addChat(self, convo):
self.convos[convo.chum.handle] = convo self.convos[convo.title()] = convo
# either addTab or setCurrentIndex will trigger changed() # either addTab or setCurrentIndex will trigger changed()
newindex = self.tabs.addTab(convo.chum.handle) newindex = self.tabs.addTab(convo.title())
self.tabIndices[convo.chum.handle] = newindex self.tabIndices[convo.title()] = newindex
self.tabs.setCurrentIndex(newindex) self.tabs.setCurrentIndex(newindex)
self.tabs.setTabIcon(newindex, convo.chum.mood.icon(self.mainwindow.theme)) self.tabs.setTabIcon(newindex, convo.icon())
def showChat(self, handle): def showChat(self, handle):
tabi = self.tabIndices[handle] tabi = self.tabIndices[handle]
if self.tabs.currentIndex() == tabi: if self.tabs.currentIndex() == tabi:
@ -61,7 +61,7 @@ class PesterTabWindow(QtGui.QFrame):
def convoHasFocus(self, convo): def convoHasFocus(self, convo):
if ((self.hasFocus() or self.tabs.hasFocus()) and if ((self.hasFocus() or self.tabs.hasFocus()) and
self.tabs.tabText(self.tabs.currentIndex()) == convo.chum.handle): self.tabs.tabText(self.tabs.currentIndex()) == convo.title()):
return True return True
def keyPressEvent(self, event): def keyPressEvent(self, event):
@ -69,7 +69,7 @@ class PesterTabWindow(QtGui.QFrame):
mods = event.modifiers() mods = event.modifiers()
if ((mods & QtCore.Qt.ControlModifier) and if ((mods & QtCore.Qt.ControlModifier) and
keypress == QtCore.Qt.Key_Tab): keypress == QtCore.Qt.Key_Tab):
nexti = (self.tabIndices[self.currentConvo.chum.handle] + 1) % self.tabs.count() nexti = (self.tabIndices[self.currentConvo.title()] + 1) % self.tabs.count()
self.tabs.setCurrentIndex(nexti) self.tabs.setCurrentIndex(nexti)
def closeSoft(self): def closeSoft(self):
@ -112,7 +112,7 @@ class PesterTabWindow(QtGui.QFrame):
def notifyNewMessage(self, handle): def notifyNewMessage(self, handle):
i = self.tabIndices[handle] i = self.tabIndices[handle]
self.tabs.setTabTextColor(i, QtGui.QColor(self.mainwindow.theme["convo/tabs/newmsgcolor"])) self.tabs.setTabTextColor(i, QtGui.QColor(self.mainwindow.theme["%s/tabs/newmsgcolor" % (self.type)]))
convo = self.convos[handle] convo = self.convos[handle]
def func(): def func():
convo.showChat() convo.showChat()
@ -125,11 +125,14 @@ class PesterTabWindow(QtGui.QFrame):
except KeyError: except KeyError:
pass pass
self.mainwindow.waitingMessages.messageAnswered(handle) self.mainwindow.waitingMessages.messageAnswered(handle)
def initTheme(self, convo):
self.resize(*convo["size"])
self.setStyleSheet(convo["style"])
self.tabs.setShape(convo["tabs"]["tabstyle"])
self.tabs.setStyleSheet("QTabBar::tab{ %s } QTabBar::tab:selected { %s }" % (convo["tabs"]["style"], convo["tabs"]["selectedstyle"]))
def changeTheme(self, theme): def changeTheme(self, theme):
self.resize(*theme["convo/size"]) self.initTheme(theme["convo"])
self.setStyleSheet(theme["convo/style"])
self.tabs.setShape(theme["convo/tabs/tabstyle"])
self.tabs.setStyleSheet("QTabBar::tabs{ %s }" % (theme["convo/tabs/style"]))
for c in self.convos.values(): for c in self.convos.values():
tabi = self.tabIndices[c.chum.handle] tabi = self.tabIndices[c.chum.handle]
self.tabs.setTabIcon(tabi, c.chum.mood.icon(theme)) self.tabs.setTabIcon(tabi, c.chum.mood.icon(theme))
@ -174,8 +177,8 @@ class PesterTabWindow(QtGui.QFrame):
self.layout.removeWidget(self.currentConvo) self.layout.removeWidget(self.currentConvo)
self.currentConvo = convo self.currentConvo = convo
self.layout.addWidget(convo) self.layout.addWidget(convo)
self.setWindowIcon(convo.chum.mood.icon(self.mainwindow.theme)) self.setWindowIcon(convo.icon())
self.setWindowTitle(convo.chum.handle) self.setWindowTitle(convo.title())
self.activateWindow() self.activateWindow()
self.raise_() self.raise_()
convo.raiseChat() convo.raiseChat()
@ -281,8 +284,8 @@ class PesterConvo(QtGui.QFrame):
convo = self.mainwindow.theme["convo"] convo = self.mainwindow.theme["convo"]
self.resize(*convo["size"]) self.resize(*convo["size"])
self.setStyleSheet(convo["style"]) self.setStyleSheet(convo["style"])
self.setWindowIcon(chum.mood.icon(self.mainwindow.theme)) self.setWindowIcon(self.icon())
self.setWindowTitle(chum.handle) self.setWindowTitle(self.title())
t = Template(self.mainwindow.theme["convo/chumlabel/text"]) t = Template(self.mainwindow.theme["convo/chumlabel/text"])
@ -318,17 +321,22 @@ class PesterConvo(QtGui.QFrame):
msg = self.mainwindow.profile().pestermsg(self.chum, QtGui.QColor(self.mainwindow.theme["convo/systemMsgColor"]), self.mainwindow.theme["convo/text/beganpester"]) msg = self.mainwindow.profile().pestermsg(self.chum, QtGui.QColor(self.mainwindow.theme["convo/systemMsgColor"]), self.mainwindow.theme["convo/text/beganpester"])
self.setChumOpen(True) self.setChumOpen(True)
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.chum.handle, convertTags(msg, "bbcode")) self.mainwindow.chatlog.log(self.title(), convertTags(msg, "bbcode"))
self.newmessage = False self.newmessage = False
def title(self):
return self.chum.handle
def icon(self):
return self.chum.mood.icon(self.mainwindow.theme)
def updateMood(self, mood, unblocked=False): def updateMood(self, mood, unblocked=False):
if mood.name() == "offline" and self.chumopen == True and not unblocked: 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"]) msg = self.chum.pestermsg(self.mainwindow.profile(), QtGui.QColor(self.mainwindow.theme["convo/systemMsgColor"]), self.mainwindow.theme["convo/text/ceasepester"])
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.chum.handle, convertTags(msg, "bbcode")) self.mainwindow.chatlog.log(self.title(), convertTags(msg, "bbcode"))
self.chumopen = False self.chumopen = False
if self.parent(): if self.parent():
self.parent().updateMood(self.chum.handle, mood, unblocked) self.parent().updateMood(self.title(), mood, unblocked)
else: else:
if self.chum.blocked(self.mainwindow.config) and not unblocked: if self.chum.blocked(self.mainwindow.config) and not unblocked:
self.setWindowIcon(QtGui.QIcon(self.mainwindow.theme["main/chums/moods/blocked/icon"])) self.setWindowIcon(QtGui.QIcon(self.mainwindow.theme["main/chums/moods/blocked/icon"]))
@ -337,7 +345,7 @@ class PesterConvo(QtGui.QFrame):
# print mood update? # print mood update?
def updateBlocked(self): def updateBlocked(self):
if self.parent(): if self.parent():
self.parent().updateBlocked(self.chum.handle) self.parent().updateBlocked(self.title())
else: else:
self.setWindowIcon(QtGui.QIcon(self.mainwindow.theme["main/chums/moods/blocked/icon"])) self.setWindowIcon(QtGui.QIcon(self.mainwindow.theme["main/chums/moods/blocked/icon"]))
def updateColor(self, color): def updateColor(self, color):
@ -354,25 +362,25 @@ class PesterConvo(QtGui.QFrame):
# first see if this conversation HASS the focus # first see if this conversation HASS the focus
if not (self.hasFocus() or self.textArea.hasFocus() or if not (self.hasFocus() or self.textArea.hasFocus() or
self.textInput.hasFocus() or self.textInput.hasFocus() or
(self.parent() and self.parent().convoHasFocus(self.chum.handle))): (self.parent() and self.parent().convoHasFocus(self.title()))):
# ok if it has a tabconvo parent, send that the notify. # ok if it has a tabconvo parent, send that the notify.
if self.parent(): if self.parent():
self.parent().notifyNewMessage(self.chum.handle) self.parent().notifyNewMessage(self.title())
# if not change the window title and update system tray # if not change the window title and update system tray
else: else:
self.newmessage = True self.newmessage = True
self.setWindowTitle(self.chum.handle+"*") self.setWindowTitle(self.title()+"*")
def func(): def func():
self.showChat() self.showChat()
self.mainwindow.waitingMessages.addMessage(self.chum.handle, func) self.mainwindow.waitingMessages.addMessage(self.title(), func)
def clearNewMessage(self): def clearNewMessage(self):
if self.parent(): if self.parent():
self.parent().clearNewMessage(self.chum.handle) self.parent().clearNewMessage(self.title())
elif self.newmessage: elif self.newmessage:
self.newmessage = False self.newmessage = False
self.setWindowTitle(self.chum.handle) self.setWindowTitle(self.title())
self.mainwindow.waitingMessages.messageAnswered(self.chum.handle) self.mainwindow.waitingMessages.messageAnswered(self.title())
# reset system tray # reset system tray
def focusInEvent(self, event): def focusInEvent(self, event):
self.clearNewMessage() self.clearNewMessage()
@ -384,12 +392,12 @@ class PesterConvo(QtGui.QFrame):
def showChat(self): def showChat(self):
if self.parent(): if self.parent():
self.parent().showChat(self.chum.handle) self.parent().showChat(self.title())
self.raiseChat() self.raiseChat()
def closeEvent(self, event): def closeEvent(self, event):
self.mainwindow.waitingMessages.messageAnswered(self.chum.handle) self.mainwindow.waitingMessages.messageAnswered(self.title())
self.windowClosed.emit(self.chum.handle) self.windowClosed.emit(self.title())
def setChumOpen(self, o): def setChumOpen(self, o):
self.chumopen = o self.chumopen = o
def changeTheme(self, theme): def changeTheme(self, theme):
@ -399,9 +407,9 @@ class PesterConvo(QtGui.QFrame):
self.layout.setContentsMargins(margins["left"], margins["top"], self.layout.setContentsMargins(margins["left"], margins["top"],
margins["right"], margins["bottom"]) margins["right"], margins["bottom"])
self.setWindowIcon(self.chum.mood.icon(theme)) self.setWindowIcon(self.icon())
t = Template(self.mainwindow.theme["convo/chumlabel/text"]) t = Template(self.mainwindow.theme["convo/chumlabel/text"])
self.chumLabel.setText(t.safe_substitute(handle=self.chum.handle)) self.chumLabel.setText(t.safe_substitute(handle=self.title()))
self.chumLabel.setStyleSheet(theme["convo/chumlabel/style"]) self.chumLabel.setStyleSheet(theme["convo/chumlabel/style"])
self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]]) self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]])
self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"]) self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"])
@ -421,13 +429,13 @@ class PesterConvo(QtGui.QFrame):
self.textInput.setText("") self.textInput.setText("")
self.addMessage(text, True) self.addMessage(text, True)
# if ceased, rebegin # if ceased, rebegin
if not self.chumopen: if hasattr(self, 'chumopen') and not self.chumopen:
self.mainwindow.newConvoStarted.emit(QtCore.QString(self.chum.handle), True) self.mainwindow.newConvoStarted.emit(QtCore.QString(self.title()), True)
# convert color tags # convert color tags
text = convertTags(unicode(text), "ctag") text = convertTags(unicode(text), "ctag")
self.messageSent.emit(text, self.chum) self.messageSent.emit(text, self.title())
messageSent = QtCore.pyqtSignal(QtCore.QString, PesterProfile) messageSent = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
windowClosed = QtCore.pyqtSignal(QtCore.QString) windowClosed = QtCore.pyqtSignal(QtCore.QString)
aligndict = {"h": {"center": QtCore.Qt.AlignHCenter, aligndict = {"h": {"center": QtCore.Qt.AlignHCenter,

BIN
convo.pyc

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -4,7 +4,24 @@ from PyQt4 import QtGui, QtCore
from dataobjs import PesterProfile, Mood from dataobjs import PesterProfile, Mood
from generic import PesterIcon from generic import PesterIcon
from convo import PesterConvo, PesterInput, PesterText from convo import PesterConvo, PesterInput, PesterText, PesterTabWindow
class MemoTabWindow(PesterTabWindow):
def __init__(self, mainwindow, parent=None):
PesterTabWindow.__init__(self, mainwindow, parent, "memos")
def addChat(self, convo):
self.convos[convo.channel] = convo
# either addTab or setCurrentIndex will trigger changed()
newindex = self.tabs.addTab(convo.channel)
self.tabIndices[convo.channel] = newindex
self.tabs.setCurrentIndex(newindex)
self.tabs.setTabIcon(newindex, PesterIcon(self.mainwindow.theme["memos/memoicon"]))
def updateBlocked(self):
pass
def updateMood(self):
pass
_ctag_begin = re.compile(r'<c=(.*?)>')
class MemoText(PesterText): class MemoText(PesterText):
def __init__(self, theme, parent=None): def __init__(self, theme, parent=None):
@ -13,7 +30,11 @@ class MemoText(PesterText):
self.setReadOnly(True) self.setReadOnly(True)
self.setMouseTracking(True) self.setMouseTracking(True)
def addMessage(self, text, chum): def addMessage(self, text, chum):
pass # get chum color from c tag
mobj = _ctag_begin.match(text)
# tinychum sends straight /me with no color. go to chumdb!
systemColor = QtGui.QColor(self.parent().mainwindow.theme["memo/systemMsgColor"])
def changeTheme(self): def changeTheme(self):
pass pass
@ -46,6 +67,9 @@ class PesterMemo(PesterConvo):
self.initTheme(self.mainwindow.theme) self.initTheme(self.mainwindow.theme)
# connect # connect
self.connect(self.textInput, QtCore.SIGNAL('returnPressed()'),
self, QtCore.SLOT('sentMessage()'))
layout_0 = QtGui.QVBoxLayout() layout_0 = QtGui.QVBoxLayout()
layout_0.addWidget(self.channelLabel) layout_0.addWidget(self.channelLabel)
layout_0.addWidget(self.textArea) layout_0.addWidget(self.textArea)
@ -66,22 +90,27 @@ class PesterMemo(PesterConvo):
self.layout.setContentsMargins(margins["left"], margins["top"], self.layout.setContentsMargins(margins["left"], margins["top"],
margins["right"], margins["bottom"]) margins["right"], margins["bottom"])
#if parent: if parent:
# parent.addChat(self) parent.addChat(self)
self.newmessage = False self.newmessage = False
def title(self):
return self.channel
def icon(self):
return PesterIcon(self.mainwindow.theme["memos/memoicon"])
def updateMood(self): def updateMood(self):
pass pass
def updateBlocked(self): def updateBlocked(self):
pass pass
def updateColor(self): def updateColor(self):
pass pass
def addMessage(self): def addMessage(self, text, handle):
pass if type(handle) is bool:
def notifyNewMessage(self): chum = self.mainwindow.profile()
pass else:
def clearNewMessage(self): chum = PesterProfile(handle)
pass self.textArea.addMessage(text, chum)
def initTheme(self, theme): def initTheme(self, theme):
memo = theme["memos"] memo = theme["memos"]
@ -104,14 +133,19 @@ class PesterMemo(PesterConvo):
slidercss = "QSlider { %s } QSlider::groove { %s } QSlider::handle { %s }" % (theme["memos/time/slider/style"], theme["memos/time/slider/groove"], theme["memos/time/slider/handle"]) slidercss = "QSlider { %s } QSlider::groove { %s } QSlider::handle { %s }" % (theme["memos/time/slider/style"], theme["memos/time/slider/groove"], theme["memos/time/slider/handle"])
self.timeslider.setStyleSheet(slidercss) self.timeslider.setStyleSheet(slidercss)
def changeTheme(self, theme): def changeTheme(self, theme):
self.initTheme(theme) self.initTheme(theme)
self.textArea.changeTheme(theme) self.textArea.changeTheme(theme)
self.textInput.changeTheme(theme) self.textInput.changeTheme(theme)
@QtCore.pyqtSlot()
def sentMessage(self): def sentMessage(self):
pass text = self.textInput.text()
if text == "":
return
text = "<c=%s>%s</c>" % (self.mainwindow.profile().colorcmd(), text)
self.textInput.setText(text)
PesterConvo.sentMessage(self)
def closeEvent(self, event): def closeEvent(self, event):
self.mainwindow.waitingMessages.messageAnswered(self.channel) self.mainwindow.waitingMessages.messageAnswered(self.channel)

BIN
memos.pyc

Binary file not shown.

View file

@ -2,7 +2,7 @@ from PyQt4 import QtGui, QtCore
import re import re
from generic import RightClickList, MultiTextDialog from generic import RightClickList, MultiTextDialog
from pesterdata import pesterQuirk, PesterProfile from dataobjs import pesterQuirk, PesterProfile
class PesterQuirkItem(QtGui.QListWidgetItem): class PesterQuirkItem(QtGui.QListWidgetItem):
def __init__(self, quirk, parent): def __init__(self, quirk, parent):
@ -450,3 +450,26 @@ class PesterMemoList(QtGui.QDialog):
def joinActivatedMemo(self, item): def joinActivatedMemo(self, item):
self.channelarea.setCurrentItem(item) self.channelarea.setCurrentItem(item)
self.accept() self.accept()
class LoadingScreen(QtGui.QDialog):
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent, flags=(QtCore.Qt.CustomizeWindowHint |
QtCore.Qt.FramelessWindowHint))
self.mainwindow = parent
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
self.loadinglabel = QtGui.QLabel("LO4D1NG")
self.layout = QtGui.QVBoxLayout()
self.layout.addWidget(self.loadinglabel)
self.setLayout(self.layout)
QtCore.QTimer.singleShot(25000, self, QtCore.SLOT('connectTimeout()'))
@QtCore.pyqtSlot()
def connectTimeout(self):
if hasattr(self, 'failed'):
self.accept()
else:
self.failed = True
self.loadinglabel.setText("F41L3D")
QtCore.QTimer.singleShot(1000, self, QtCore.SLOT('connectTimeout()'))

BIN
menus.pyc

Binary file not shown.

Binary file not shown.

View file

@ -170,7 +170,7 @@ class IRCClient:
try: try:
self.command_handler.run(command, prefix, *args) self.command_handler.run(command, prefix, *args)
except CommandError: except CommandError:
# error will of already been loggingged by the handler # error will have already been loggingged by the handler
pass pass
yield True yield True

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -12,7 +12,7 @@ def convertTags(string, format="html"):
color = matchobj.group(1) color = matchobj.group(1)
if _ctag_rgb.match(color) is not None: if _ctag_rgb.match(color) is not None:
if format=='ctag': if format=='ctag':
return "<c=%s,%s,%s>" return "<c=%s>" % (color)
try: try:
qc = QtGui.QColor(*[int(c) for c in color.split(",")]) qc = QtGui.QColor(*[int(c) for c in color.split(",")])
except ValueError: except ValueError:

Binary file not shown.

View file

@ -1 +1 @@
{"tabs": false, "chums": ["aquaMarinist", "marineAquist", "unknownTraveler", "tentacleTherapist", "macruralAlchemist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "superGhost", "centaursTesticle", "arachnidsGrip", "fireSwallow", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr"], "defaultprofile": "testProfile", "block": []} {"tabs": false, "chums": ["aquaMarinist", "marineAquist", "unknownTraveler", "tentacleTherapist", "macruralAlchemist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "superGhost", "centaursTesticle", "arachnidsGrip", "fireSwallow", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "adiosToreador"], "defaultprofile": "testProfile", "block": []}

View file

@ -14,16 +14,16 @@ from PyQt4 import QtGui, QtCore
import pygame import pygame
from menus import PesterChooseQuirks, PesterChooseTheme, \ from menus import PesterChooseQuirks, PesterChooseTheme, \
PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList, \
LoadingScreen
from dataobjs import PesterProfile, Mood, pesterQuirk, pesterQuirks from dataobjs import PesterProfile, Mood, pesterQuirk, pesterQuirks
from generic import PesterIcon, RightClickList, MultiTextDialog from generic import PesterIcon, RightClickList, MultiTextDialog
from convo import PesterTabWindow, PesterText, PesterInput, PesterConvo from convo import PesterTabWindow, PesterText, PesterInput, PesterConvo
from parsetools import convertTags from parsetools import convertTags
from memos import PesterMemo from memos import PesterMemo, MemoTabWindow
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
class waitingMessageHolder(object): class waitingMessageHolder(object):
def __init__(self, mainwindow, **msgfuncs): def __init__(self, mainwindow, **msgfuncs):
self.mainwindow = mainwindow self.mainwindow = mainwindow
@ -583,6 +583,7 @@ class PesterWindow(MovingWindow):
self.convos = {} self.convos = {}
self.memos = {} self.memos = {}
self.tabconvo = None self.tabconvo = None
self.tabmemo = None
self.setObjectName("main") self.setObjectName("main")
self.config = userConfig() self.config = userConfig()
@ -706,6 +707,7 @@ class PesterWindow(MovingWindow):
if not self.config.defaultprofile(): if not self.config.defaultprofile():
self.changeProfile() self.changeProfile()
self.loadingscreen = LoadingScreen(self)
def profile(self): def profile(self):
return self.userprofile.chat return self.userprofile.chat
@ -717,6 +719,12 @@ class PesterWindow(MovingWindow):
else: else:
for c in self.convos.values(): for c in self.convos.values():
c.close() c.close()
if self.tabmemo:
self.tabmemo.close()
else:
for m in self.memos.values():
m.close()
def closeEvent(self, event): def closeEvent(self, event):
self.closeConversations() self.closeConversations()
if hasattr(self, 'trollslum') and self.trollslum: if hasattr(self, 'trollslum') and self.trollslum:
@ -742,6 +750,12 @@ class PesterWindow(MovingWindow):
convo.addMessage(msg, False) convo.addMessage(msg, False)
# play sound here # play sound here
self.alarm.play() self.alarm.play()
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)
def changeColor(self, handle, color): def changeColor(self, handle, color):
# pesterconvo and chumlist # pesterconvo and chumlist
@ -767,33 +781,46 @@ class PesterWindow(MovingWindow):
self.tabconvo.show() self.tabconvo.show()
else: else:
convoWindow = PesterConvo(chum, initiated, self) convoWindow = PesterConvo(chum, initiated, self)
self.connect(convoWindow, QtCore.SIGNAL('messageSent(QString, PyQt_PyObject)'), self.connect(convoWindow, QtCore.SIGNAL('messageSent(QString, QString)'),
self, QtCore.SIGNAL('sendMessage(QString, PyQt_PyObject)')) self, QtCore.SIGNAL('sendMessage(QString, QString)'))
self.connect(convoWindow, QtCore.SIGNAL('windowClosed(QString)'), self.connect(convoWindow, QtCore.SIGNAL('windowClosed(QString)'),
self, QtCore.SLOT('closeConvo(QString)')) self, QtCore.SLOT('closeConvo(QString)'))
self.convos[chum.handle] = convoWindow self.convos[chum.handle] = convoWindow
self.newConvoStarted.emit(QtCore.QString(chum.handle), initiated) self.newConvoStarted.emit(QtCore.QString(chum.handle), initiated)
convoWindow.show() convoWindow.show()
def createTabWindow(self): def createTabWindow(self):
self.tabconvo = PesterTabWindow(self) self.tabconvo = PesterTabWindow(self)
self.connect(self.tabconvo, QtCore.SIGNAL('windowClosed()'), self.connect(self.tabconvo, QtCore.SIGNAL('windowClosed()'),
self, QtCore.SLOT('tabsClosed()')) self, QtCore.SLOT('tabsClosed()'))
def createMemoTabWindow(self):
self.tabmemo = MemoTabWindow(self)
self.connect(self.tabmemo, QtCore.SIGNAL('windowClosed()'),
self, QtCore.SLOT('memoTabsClosed()'))
def newMemo(self, channel): def newMemo(self, channel):
if channel == "#pesterchum":
return
if self.memos.has_key(channel): if self.memos.has_key(channel):
# load memo # load memo
return return
# do slider dialog then set
if self.config.tabs():
if not self.tabmemo:
self.createMemoTabWindow()
memoWindow = PesterMemo(channel, self, self.tabmemo)
self.tabmemo.show()
else: else:
# do slider dialog then set memoWindow = PesterMemo(channel, self, None)
if self.config.tabs():
# create new tabbed memo window
pass
else:
self.memoWindow = PesterMemo(channel, self, None)
# connect signals # connect signals
self.connect(memoWindow, QtCore.SIGNAL('messageSent(QString, QString)'),
self, QtCore.SIGNAL('sendMessage(QString, QString)'))
# self.connect(memoWindow, QtCore.SIGNAL('windowClosed(QString)'),
# self, QtCore.SLOT('closeConvo(QString)'))
# chat client send memo open # chat client send memo open
self.memoWindow.show() self.memos[channel] = memoWindow
self.joinChannel.emit(channel)
memoWindow.show()
def addChum(self, chum): def addChum(self, chum):
self.chumList.addChum(chum) self.chumList.addChum(chum)
@ -919,7 +946,11 @@ class PesterWindow(MovingWindow):
else: else:
self.waitingMessages.answerMessage() self.waitingMessages.answerMessage()
@QtCore.pyqtSlot()
def connected(self):
if self.loadingscreen:
self.loadingscreen.close()
self.loadingscreen = None
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def blockSelectedChum(self): def blockSelectedChum(self):
curChumListing = self.chumList.currentItem() curChumListing = self.chumList.currentItem()
@ -953,6 +984,10 @@ class PesterWindow(MovingWindow):
def tabsClosed(self): def tabsClosed(self):
del self.tabconvo del self.tabconvo
self.tabconvo = None self.tabconvo = None
@QtCore.pyqtSlot()
def memoTabsClosed(self):
del self.tabmemo
self.tabmemo = None
@QtCore.pyqtSlot(QtCore.QString, Mood) @QtCore.pyqtSlot(QtCore.QString, Mood)
def updateMoodSlot(self, handle, mood): def updateMoodSlot(self, handle, mood):
@ -969,6 +1004,10 @@ class PesterWindow(MovingWindow):
h = unicode(handle) h = unicode(handle)
m = unicode(msg) m = unicode(msg)
self.newMessage(h, m) self.newMessage(h, m)
@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)
@QtCore.pyqtSlot(QtCore.QString, PesterList) @QtCore.pyqtSlot(QtCore.QString, PesterList)
def updateNames(self, channel, names): def updateNames(self, channel, names):
@ -1083,9 +1122,11 @@ class PesterWindow(MovingWindow):
newmemo = self.memochooser.newmemoname() newmemo = self.memochooser.newmemoname()
selectedmemo = self.memochooser.selectedmemo() selectedmemo = self.memochooser.selectedmemo()
if newmemo: if newmemo:
self.newMemo('#'+newmemo) channel = "#"+unicode(newmemo)
else: self.newMemo(channel)
self.newMemo('#'+selectedmemo.text()) elif selectedmemo:
channel = "#"+unicode(selectedmemo.text())
self.newMemo(channel)
self.memochooser = None self.memochooser = None
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def memoChooserClose(self): def memoChooserClose(self):
@ -1310,7 +1351,7 @@ class PesterWindow(MovingWindow):
pass pass
newConvoStarted = QtCore.pyqtSignal(QtCore.QString, bool, name="newConvoStarted") newConvoStarted = QtCore.pyqtSignal(QtCore.QString, bool, name="newConvoStarted")
sendMessage = QtCore.pyqtSignal(QtCore.QString, PesterProfile) sendMessage = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
convoClosed = QtCore.pyqtSignal(QtCore.QString) convoClosed = QtCore.pyqtSignal(QtCore.QString)
profileChanged = QtCore.pyqtSignal() profileChanged = QtCore.pyqtSignal()
moodRequest = QtCore.pyqtSignal(PesterProfile) moodRequest = QtCore.pyqtSignal(PesterProfile)
@ -1324,6 +1365,7 @@ class PesterWindow(MovingWindow):
trayIconSignal = QtCore.pyqtSignal(int) trayIconSignal = QtCore.pyqtSignal(int)
blockedChum = QtCore.pyqtSignal(QtCore.QString) blockedChum = QtCore.pyqtSignal(QtCore.QString)
unblockedChum = QtCore.pyqtSignal(QtCore.QString) unblockedChum = QtCore.pyqtSignal(QtCore.QString)
joinChannel = QtCore.pyqtSignal(QtCore.QString)
class PesterIRC(QtCore.QObject): class PesterIRC(QtCore.QObject):
def __init__(self, window): def __init__(self, window):
@ -1342,10 +1384,10 @@ class PesterIRC(QtCore.QObject):
def getMoods(self, chums): def getMoods(self, chums):
self.cli.command_handler.getMood(*chums) self.cli.command_handler.getMood(*chums)
@QtCore.pyqtSlot(QtCore.QString, PesterProfile) @QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
def sendMessage(self, text, chum): def sendMessage(self, text, handle):
handle = chum.handle h = unicode(handle)
helpers.msg(self.cli, handle, text) helpers.msg(self.cli, h, text)
@QtCore.pyqtSlot(QtCore.QString, bool) @QtCore.pyqtSlot(QtCore.QString, bool)
def startConvo(self, handle, initiated): def startConvo(self, handle, initiated):
@ -1387,16 +1429,21 @@ class PesterIRC(QtCore.QObject):
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def requestChannelList(self): def requestChannelList(self):
helpers.channel_list(self.cli) helpers.channel_list(self.cli)
@QtCore.pyqtSlot(QtCore.QString)
def joinChannel(self, channel):
c = unicode(channel)
helpers.join(self.cli, c)
def updateIRC(self): def updateIRC(self):
self.conn.next() self.conn.next()
moodUpdated = QtCore.pyqtSignal(QtCore.QString, Mood) moodUpdated = QtCore.pyqtSignal(QtCore.QString, Mood)
colorUpdated = QtCore.pyqtSignal(QtCore.QString, QtGui.QColor) colorUpdated = QtCore.pyqtSignal(QtCore.QString, QtGui.QColor)
messageReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) messageReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
memoReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, QtCore.QString)
namesReceived = QtCore.pyqtSignal(QtCore.QString, PesterList) namesReceived = QtCore.pyqtSignal(QtCore.QString, PesterList)
channelListReceived = QtCore.pyqtSignal(PesterList) channelListReceived = QtCore.pyqtSignal(PesterList)
nickCollision = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) nickCollision = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
connected = QtCore.pyqtSignal()
userPresentUpdate = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, userPresentUpdate = QtCore.pyqtSignal(QtCore.QString, QtCore.QString,
QtCore.QString) QtCore.QString)
@ -1422,7 +1469,12 @@ class PesterHandler(DefaultCommandHandler):
if msg.find(mychumhandle, 8) != -1: if msg.find(mychumhandle, 8) != -1:
helpers.msg(self.client, "#pesterchum", helpers.msg(self.client, "#pesterchum",
"MOOD >%d" % (mymood)) "MOOD >%d" % (mymood))
elif chan[0] == '#':
if msg[0:16] == "PESTERCHUM:TIME>":
# send time msg
pass
else:
self.parent.memoReceived.emit(chan, handle, msg)
else: else:
# private message # private message
# silently ignore messages to yourself. # silently ignore messages to yourself.
@ -1441,6 +1493,7 @@ class PesterHandler(DefaultCommandHandler):
def welcome(self, server, nick, msg): def welcome(self, server, nick, msg):
self.parent.connected.emit()
helpers.join(self.client, "#pesterchum") helpers.join(self.client, "#pesterchum")
mychumhandle = self.mainwindow.profile().handle mychumhandle = self.mainwindow.profile().handle
mymood = self.mainwindow.profile().mood.value() mymood = self.mainwindow.profile().mood.value()
@ -1561,8 +1614,8 @@ def main():
irc = PesterIRC(widget) irc = PesterIRC(widget)
irc.IRCConnect() irc.IRCConnect()
irc.connect(widget, QtCore.SIGNAL('sendMessage(QString, PyQt_PyObject)'), irc.connect(widget, QtCore.SIGNAL('sendMessage(QString, QString)'),
irc, QtCore.SLOT('sendMessage(QString, PyQt_PyObject)')) irc, QtCore.SLOT('sendMessage(QString, QString)'))
irc.connect(widget, irc.connect(widget,
QtCore.SIGNAL('newConvoStarted(QString, bool)'), QtCore.SIGNAL('newConvoStarted(QString, bool)'),
irc, QtCore.SLOT('startConvo(QString, bool)')) irc, QtCore.SLOT('startConvo(QString, bool)'))
@ -1605,8 +1658,14 @@ def main():
QtCore.SIGNAL('requestChannelList()'), QtCore.SIGNAL('requestChannelList()'),
irc, irc,
QtCore.SLOT('requestChannelList()')) QtCore.SLOT('requestChannelList()'))
irc.connect(widget,
QtCore.SIGNAL('joinChannel(QString)'),
irc,
QtCore.SLOT('joinChannel(QString)'))
# IRC --> Main window # IRC --> Main window
irc.connect(irc, QtCore.SIGNAL('connected()'),
widget, QtCore.SLOT('connected()'))
irc.connect(irc, irc.connect(irc,
QtCore.SIGNAL('moodUpdated(QString, PyQt_PyObject)'), QtCore.SIGNAL('moodUpdated(QString, PyQt_PyObject)'),
widget, widget,
@ -1619,6 +1678,10 @@ def main():
QtCore.SIGNAL('messageReceived(QString, QString)'), QtCore.SIGNAL('messageReceived(QString, QString)'),
widget, widget,
QtCore.SLOT('deliverMessage(QString, QString)')) QtCore.SLOT('deliverMessage(QString, QString)'))
irc.connect(irc,
QtCore.SIGNAL('memoReceived(QString, QString, QString)'),
widget,
QtCore.SLOT('deliverMemo(QString, QString, QString)'))
irc.connect(irc, irc.connect(irc,
QtCore.SIGNAL('nickCollision(QString, QString)'), QtCore.SIGNAL('nickCollision(QString, QString)'),
widget, widget,
@ -1638,6 +1701,7 @@ def main():
ircapp = IRCThread(irc) ircapp = IRCThread(irc)
ircapp.start() ircapp.start()
widget.loadingscreen.exec_()
sys.exit(app.exec_()) sys.exit(app.exec_())
main() main()

View file

@ -216,6 +216,12 @@
{"memoicon": "$path/memo.png", {"memoicon": "$path/memo.png",
"style": "background: #fdb302; font-family:'Courier';font:bold;selection-background-color:#919191; ", "style": "background: #fdb302; font-family:'Courier';font:bold;selection-background-color:#919191; ",
"size": [600,300], "size": [600,300],
"tabs": {
"style": "",
"selectedstyle": "",
"newmsgcolor": "#fdb302",
"tabstyle": 0
},
"label": { "text": "$channel", "label": { "text": "$channel",
"style": "background: rgb(196, 138, 0); color: white; border:0px;", "style": "background: rgb(196, 138, 0); color: white; border:0px;",
"align": { "h": "center", "v": "center" }, "align": { "h": "center", "v": "center" },
@ -230,6 +236,7 @@
"slider": { "style": "", "slider": { "style": "",
"groove": "", "groove": "",
"handle": "" } "handle": "" }
} },
"systemMsgColor": "#646464"
} }
} }

Binary file not shown.