This commit is contained in:
Dpeta 2022-08-07 17:38:45 +02:00
parent 1419c4985e
commit f78a9f97ac
6 changed files with 439 additions and 141 deletions

View file

@ -1,21 +1,23 @@
import logging import logging
import logging.config import logging.config
import ostools
_datadir = ostools.getDataDir()
logging.config.fileConfig(_datadir + "logging.ini")
PchumLog = logging.getLogger('pchumLogger')
from string import Template from string import Template
from time import strftime from time import strftime
from datetime import datetime, timedelta from datetime import datetime, timedelta
from PyQt6 import QtCore, QtGui, QtWidgets from PyQt6 import QtCore, QtGui, QtWidgets
import ostools
from dataobjs import PesterHistory from dataobjs import PesterHistory
from parsetools import convertTags, lexMessage, mecmd, colorBegin, colorEnd, \ from parsetools import (convertTags, lexMessage, mecmd, colorBegin, colorEnd,
smiledict#, img2smiley smiledict)
import parsetools import parsetools
from pnc.dep.attrdict import AttrDict from pnc.dep.attrdict import AttrDict
_datadir = ostools.getDataDir()
logging.config.fileConfig(_datadir + "logging.ini")
PchumLog = logging.getLogger('pchumLogger')
class PesterTabWindow(QtWidgets.QFrame): class PesterTabWindow(QtWidgets.QFrame):
def __init__(self, mainwindow, parent=None, convo="convo"): def __init__(self, mainwindow, parent=None, convo="convo"):
super(PesterTabWindow, self).__init__(parent) super(PesterTabWindow, self).__init__(parent)
@ -206,7 +208,9 @@ class PesterTabWindow(QtWidgets.QFrame):
return False return False
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["%s/tabs/newmsgcolor" % (self.type)])) self.tabs.setTabTextColor(i,
QtGui.QColor(self.mainwindow.theme["%s/tabs/newmsgcolor"
% (self.type)]))
convo = self.convos[handle] convo = self.convos[handle]
# Create a function for the icon to use # Create a function for the icon to use
# TODO: Let us disable this. # TODO: Let us disable this.
@ -225,7 +229,9 @@ class PesterTabWindow(QtWidgets.QFrame):
self.resize(*theme["convo/size"]) self.resize(*theme["convo/size"])
self.setStyleSheet(theme["convo/tabwindow/style"]) self.setStyleSheet(theme["convo/tabwindow/style"])
self.tabs.setShape(QtWidgets.QTabBar.Shape(theme["convo/tabs/tabstyle"])) self.tabs.setShape(QtWidgets.QTabBar.Shape(theme["convo/tabs/tabstyle"]))
self.tabs.setStyleSheet("QTabBar::tab{ %s } QTabBar::tab:selected { %s }" % (theme["convo/tabs/style"], theme["convo/tabs/selectedstyle"])) self.tabs.setStyleSheet("QTabBar::tab{ %s } QTabBar::tab:selected { %s }"
% (theme["convo/tabs/style"],
theme["convo/tabs/selectedstyle"]))
def changeTheme(self, theme): def changeTheme(self, theme):
self.initTheme(theme) self.initTheme(theme)
@ -382,7 +388,20 @@ class PesterText(QtWidgets.QTextEdit):
self.textSelected = ready self.textSelected = ready
def initTheme(self, theme): def initTheme(self, theme):
if "convo/scrollbar" in theme: if "convo/scrollbar" in theme:
self.setStyleSheet("QTextEdit { %s } QScrollBar:vertical { %s } QScrollBar::handle:vertical { %s } QScrollBar::add-line:vertical { %s } QScrollBar::sub-line:vertical { %s } QScrollBar:up-arrow:vertical { %s } QScrollBar:down-arrow:vertical { %s }" % (theme["convo/textarea/style"], theme["convo/scrollbar/style"], theme["convo/scrollbar/handle"], theme["convo/scrollbar/downarrow"], theme["convo/scrollbar/uparrow"], theme["convo/scrollbar/uarrowstyle"], theme["convo/scrollbar/darrowstyle"] )) self.setStyleSheet("QTextEdit { %s }"
"QScrollBar:vertical { %s }"
"QScrollBar::handle:vertical { %s }"
"QScrollBar::add-line:vertical { %s }"
"QScrollBar::sub-line:vertical { %s }"
"QScrollBar:up-arrow:vertical { %s }"
"QScrollBar:down-arrow:vertical { %s }"
% (theme["convo/textarea/style"],
theme["convo/scrollbar/style"],
theme["convo/scrollbar/handle"],
theme["convo/scrollbar/downarrow"],
theme["convo/scrollbar/uparrow"],
theme["convo/scrollbar/uarrowstyle"],
theme["convo/scrollbar/darrowstyle"]))
else: else:
self.setStyleSheet("QTextEdit { %s }" % (theme["convo/textarea/style"])) self.setStyleSheet("QTextEdit { %s }" % (theme["convo/textarea/style"]))
def addMessage(self, lexmsg, chum): def addMessage(self, lexmsg, chum):
@ -453,7 +472,10 @@ class PesterText(QtWidgets.QTextEdit):
lexmsg[0:0] = [colorBegin("<c=%s>" % (color), color), lexmsg[0:0] = [colorBegin("<c=%s>" % (color), color),
"%s: " % (initials)] "%s: " % (initials)]
lexmsg.append(colorEnd("</c>")) lexmsg.append(colorEnd("</c>"))
self.append("<span style=\"color:#000000\">" + time + convertTags(lexmsg) + "</span>") self.append("<span style=\"color:#000000\">"
+ time
+ convertTags(lexmsg)
+ "</span>")
#self.append('<img src="/Users/lexi/pesterchum-lex/smilies/tab.gif" />' #self.append('<img src="/Users/lexi/pesterchum-lex/smilies/tab.gif" />'
# + '<img src="/Users/lexi/pesterchum/smilies/tab.gif" />' # + '<img src="/Users/lexi/pesterchum/smilies/tab.gif" />'
# + '<img src="/Applications/Pesterchum.app/Contents/Resources/smilies/tab.gif" />' # + '<img src="/Applications/Pesterchum.app/Contents/Resources/smilies/tab.gif" />'
@ -512,7 +534,8 @@ class PesterText(QtWidgets.QTextEdit):
if event.modifiers() == QtCore.Qt.KeyboardModifier.ControlModifier: if event.modifiers() == QtCore.Qt.KeyboardModifier.ControlModifier:
QtWidgets.QApplication.clipboard().setText(url) QtWidgets.QApplication.clipboard().setText(url)
else: else:
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.ParsingMode.TolerantMode)) QtGui.QDesktopServices.openUrl(QtCore.QUrl(url,
QtCore.QUrl.ParsingMode.TolerantMode))
QtWidgets.QTextEdit.mousePressEvent(self, event) QtWidgets.QTextEdit.mousePressEvent(self, event)
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
QtWidgets.QTextEdit.mouseMoveEvent(self, event) QtWidgets.QTextEdit.mouseMoveEvent(self, event)
@ -569,7 +592,9 @@ class PesterConvo(QtWidgets.QFrame):
self.mainwindow = mainwindow self.mainwindow = mainwindow
theme = self.mainwindow.theme theme = self.mainwindow.theme
self.resize(*theme["convo/size"]) self.resize(*theme["convo/size"])
self.setStyleSheet("QtWidgets.QFrame#%s { %s }" % (chum.handle, theme["convo/style"])) self.setStyleSheet("QtWidgets.QFrame#%s { %s }"
% (chum.handle,
theme["convo/style"]))
self.setWindowIcon(self.icon()) self.setWindowIcon(self.icon())
self.setWindowTitle(self.title()) self.setWindowTitle(self.title())
@ -577,10 +602,12 @@ class PesterConvo(QtWidgets.QFrame):
self.chumLabel = QtWidgets.QLabel(t.safe_substitute(handle=chum.handle), self) self.chumLabel = QtWidgets.QLabel(t.safe_substitute(handle=chum.handle), self)
self.chumLabel.setStyleSheet(self.mainwindow.theme["convo/chumlabel/style"]) self.chumLabel.setStyleSheet(self.mainwindow.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"])
self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"]) self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"])
self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.MinimumExpanding)) self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding,
QtWidgets.QSizePolicy.Policy.MinimumExpanding))
self.textArea = PesterText(self.mainwindow.theme, self) self.textArea = PesterText(self.mainwindow.theme, self)
self.textInput = PesterInput(self.mainwindow.theme, self) self.textInput = PesterInput(self.mainwindow.theme, self)
self.textInput.setFocus() self.textInput.setFocus()
@ -909,7 +936,10 @@ class PesterConvo(QtWidgets.QFrame):
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def openChumLogs(self): def openChumLogs(self):
currentChum = self.chum.handle currentChum = self.chum.handle
self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum,
self.mainwindow.config,
self.mainwindow.theme,
self.mainwindow)
self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog) self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog)
self.mainwindow.chumList.pesterlogviewer.show() self.mainwindow.chumList.pesterlogviewer.show()
self.mainwindow.chumList.pesterlogviewer.raise_() self.mainwindow.chumList.pesterlogviewer.raise_()

View file

@ -202,9 +202,9 @@ class pesterQuirks(object):
recvparts.append(q.apply(part)) recvparts.append(q.apply(part))
# Reconstruct and update string. # Reconstruct and update string.
string = '' string = ''
print("excludes: " + str(excludes)) #print("excludes: " + str(excludes))
print("sendparts: " + str(sendparts)) #print("sendparts: " + str(sendparts))
print("recvparts: " + str(recvparts)) #print("recvparts: " + str(recvparts))
for part in range(0, len(excludes)): for part in range(0, len(excludes)):
string += recvparts[part] string += recvparts[part]
string += excludes[part].group() string += excludes[part].group()
@ -235,10 +235,6 @@ class pesterQuirks(object):
string = q.apply(string) string = q.apply(string)
elif q.type == 'suffix' and lastStr: elif q.type == 'suffix' and lastStr:
string = q.apply(string) string = q.apply(string)
newlist.append(string) newlist.append(string)
final = [] final = []
for n in newlist: for n in newlist:

270
memos.py
View file

@ -11,8 +11,8 @@ import parsetools
from dataobjs import PesterProfile, PesterHistory from dataobjs import PesterProfile, PesterHistory
from generic import PesterIcon, RightClickList, mysteryTime from generic import PesterIcon, RightClickList, mysteryTime
from convo import PesterConvo, PesterInput, PesterText, PesterTabWindow from convo import PesterConvo, PesterInput, PesterText, PesterTabWindow
from parsetools import convertTags, timeProtocol, \ from parsetools import (convertTags, timeProtocol, lexMessage, colorBegin,
lexMessage, colorBegin, mecmd, smiledict mecmd, smiledict)
from logviewer import PesterLogViewer from logviewer import PesterLogViewer
_datadir = ostools.getDataDir() _datadir = ostools.getDataDir()
@ -248,7 +248,8 @@ class MemoTabWindow(PesterTabWindow):
newindex = self.tabs.addTab(convo.channel) newindex = self.tabs.addTab(convo.channel)
self.tabIndices[convo.channel] = newindex self.tabIndices[convo.channel] = newindex
self.tabs.setCurrentIndex(newindex) self.tabs.setCurrentIndex(newindex)
self.tabs.setTabIcon(newindex, PesterIcon(self.mainwindow.theme["memos/memoicon"])) self.tabs.setTabIcon(newindex,
PesterIcon(self.mainwindow.theme["memos/memoicon"]))
def updateBlocked(self): def updateBlocked(self):
pass pass
def updateMood(self): def updateMood(self):
@ -275,19 +276,35 @@ class MemoText(PesterText):
self.copyAvailable[bool].connect(self.textReady) self.copyAvailable[bool].connect(self.textReady)
self.urls = {} self.urls = {}
for k in smiledict: for k in smiledict:
self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k])) self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])),
"smilies/%s" % (smiledict[k]))
#self.mainwindow.animationSetting[bool].connect(self.animateChanged) #self.mainwindow.animationSetting[bool].connect(self.animateChanged)
def initTheme(self, theme): def initTheme(self, theme):
if "memos/scrollbar" in theme: if "memos/scrollbar" in theme:
self.setStyleSheet("QTextEdit { %s } QScrollBar:vertical { %s } QScrollBar::handle:vertical { %s } QScrollBar::add-line:vertical { %s } QScrollBar::sub-line:vertical { %s } QScrollBar:up-arrow:vertical { %s } QScrollBar:down-arrow:vertical { %s }" % (theme["memos/textarea/style"], theme["memos/scrollbar/style"], theme["memos/scrollbar/handle"], theme["memos/scrollbar/downarrow"], theme["memos/scrollbar/uparrow"], theme["memos/scrollbar/uarrowstyle"], theme["memos/scrollbar/darrowstyle"] )) self.setStyleSheet("QTextEdit { %s }"
"QScrollBar:vertical { %s }"
"QScrollBar::handle:vertical { %s }"
"QScrollBar::add-line:vertical { %s }"
"QScrollBar::sub-line:vertical { %s }"
"QScrollBar:up-arrow:vertical { %s }"
"QScrollBar:down-arrow:vertical { %s }"
% (theme["memos/textarea/style"],
theme["memos/scrollbar/style"],
theme["memos/scrollbar/handle"],
theme["memos/scrollbar/downarrow"],
theme["memos/scrollbar/uparrow"],
theme["memos/scrollbar/uarrowstyle"],
theme["memos/scrollbar/darrowstyle"] ))
else: else:
self.setStyleSheet("QTextEdit { %s }" % theme["memos/textarea/style"]) self.setStyleSheet("QTextEdit { %s }" % theme["memos/textarea/style"])
# So it doesn't inherit the memo's background image. # So it doesn't inherit the memo's background image.
# Fixes floating "PESTERLOG:" # Fixes floating "PESTERLOG:"
try: try:
self.setStyleSheet(self.styleSheet() + " QMenu{" + theme["main/defaultwindow/style"] + "}") self.setStyleSheet(self.styleSheet()
+ ("QMenu{ %s }"
% theme["main/defaultwindow/style"]))
except: except:
pass pass
@ -343,7 +360,10 @@ class MemoText(PesterText):
if time.isFirstTime(): if time.isFirstTime():
grammar = time.getGrammar() grammar = time.getGrammar()
joinmsg = chum.memojoinmsg(systemColor, time.getTime(), grammar, window.theme["convo/text/joinmemo"]) joinmsg = chum.memojoinmsg(systemColor,
time.getTime(),
grammar,
window.theme["convo/text/joinmemo"])
self.append(convertTags(joinmsg)) self.append(convertTags(joinmsg))
parent.mainwindow.chatlog.log(parent.channel, joinmsg) parent.mainwindow.chatlog.log(parent.channel, joinmsg)
time.openCurrentTime() time.openCurrentTime()
@ -369,7 +389,6 @@ class MemoInput(PesterInput):
# karxi: Because of the use of stylesheet_path, we don't have to rewrite # karxi: Because of the use of stylesheet_path, we don't have to rewrite
# this code. # this code.
# Neat, huh? # Neat, huh?
pass # So vim recognizes the end of this class
class PesterMemo(PesterConvo): class PesterMemo(PesterConvo):
# TODO: Clean up inheritance between these!! The inits are ugly. # TODO: Clean up inheritance between these!! The inits are ugly.
@ -382,7 +401,8 @@ class PesterMemo(PesterConvo):
self.time = TimeTracker(txt2delta(timestr)) self.time = TimeTracker(txt2delta(timestr))
self.setWindowTitle(channel) self.setWindowTitle(channel)
self.channelLabel = QtWidgets.QLabel(self) self.channelLabel = QtWidgets.QLabel(self)
self.channelLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Expanding)) self.channelLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding,
QtWidgets.QSizePolicy.Policy.Expanding))
self.textArea = MemoText(self.mainwindow.theme, self) self.textArea = MemoText(self.mainwindow.theme, self)
self.textInput = MemoInput(self.mainwindow.theme, self) self.textInput = MemoInput(self.mainwindow.theme, self)
@ -395,7 +415,8 @@ class PesterMemo(PesterConvo):
self.userlist = RightClickList(self) self.userlist = RightClickList(self)
self.userlist.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Expanding)) self.userlist.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed,
QtWidgets.QSizePolicy.Policy.Expanding))
self.userlist.optionsMenu = QtWidgets.QMenu(self) self.userlist.optionsMenu = QtWidgets.QMenu(self)
self.pesterChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self) self.pesterChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self)
self.pesterChumAction.triggered.connect(self.newPesterSlot) self.pesterChumAction.triggered.connect(self.newPesterSlot)
@ -538,7 +559,11 @@ class PesterMemo(PesterConvo):
p = self.mainwindow.profile() p = self.mainwindow.profile()
timeGrammar = self.time.getGrammar() timeGrammar = self.time.getGrammar()
systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"]) systemColor = QtGui.QColor(self.mainwindow.theme["memos/systemMsgColor"])
msg = p.memoopenmsg(systemColor, self.time.getTime(), timeGrammar, self.mainwindow.theme["convo/text/openmemo"], self.channel) msg = p.memoopenmsg(systemColor,
self.time.getTime(),
timeGrammar,
self.mainwindow.theme["convo/text/openmemo"],
self.channel)
self.time.openCurrentTime() self.time.openCurrentTime()
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg) self.mainwindow.chatlog.log(self.channel, msg)
@ -558,11 +583,13 @@ class PesterMemo(PesterConvo):
if self.userlist.isHidden(): if self.userlist.isHidden():
self.userlist.show() self.userlist.show()
self.miniUserlist.setText(">\n>") self.miniUserlist.setText(">\n>")
self.miniUserlist.setStyleSheet("%s border-width: 2px 0px 2px 2px;" % self.miniUserlist.styleSheet()) self.miniUserlist.setStyleSheet("%s border-width: 2px 0px 2px 2px;"
% self.miniUserlist.styleSheet())
else: else:
self.userlist.hide() self.userlist.hide()
self.miniUserlist.setText("<\n<") self.miniUserlist.setText("<\n<")
self.miniUserlist.setStyleSheet("%s border-width: 2px;" % self.miniUserlist.styleSheet()) self.miniUserlist.setStyleSheet("%s border-width: 2px;"
% self.miniUserlist.styleSheet())
def title(self): def title(self):
return self.channel return self.channel
@ -603,25 +630,63 @@ class PesterMemo(PesterConvo):
else: else:
self.channelLabel.setText(t.safe_substitute(channel=self.channel)) self.channelLabel.setText(t.safe_substitute(channel=self.channel))
self.channelLabel.setStyleSheet(theme["memos/label/style"]) self.channelLabel.setStyleSheet(theme["memos/label/style"])
self.channelLabel.setAlignment(self.aligndict["h"][theme["memos/label/align/h"]] | self.aligndict["v"][theme["memos/label/align/v"]]) self.channelLabel.setAlignment(self.aligndict["h"][theme["memos/label/align/h"]]
| self.aligndict["v"][theme["memos/label/align/v"]])
self.channelLabel.setMaximumHeight(theme["memos/label/maxheight"]) self.channelLabel.setMaximumHeight(theme["memos/label/maxheight"])
self.channelLabel.setMinimumHeight(theme["memos/label/minheight"]) self.channelLabel.setMinimumHeight(theme["memos/label/minheight"])
self.userlist.optionsMenu.setStyleSheet(theme["main/defaultwindow/style"]) self.userlist.optionsMenu.setStyleSheet(theme["main/defaultwindow/style"])
scrolls = "width: 12px; height: 12px; border: 0; padding: 0;" scrolls = "width: 12px; height: 12px; border: 0; padding: 0;"
if "main/chums/scrollbar" in theme: if "main/chums/scrollbar" in theme:
self.userlist.setStyleSheet("QListWidget { %s } QScrollBar { %s } QScrollBar::handle { %s } QScrollBar::add-line { %s } QScrollBar::sub-line { %s } QScrollBar:up-arrow { %s } QScrollBar:down-arrow { %s }" % (theme["memos/userlist/style"], theme["main/chums/scrollbar/style"] + scrolls, theme["main/chums/scrollbar/handle"], theme["main/chums/scrollbar/downarrow"], theme["main/chums/scrollbar/uparrow"], theme["main/chums/scrollbar/uarrowstyle"], theme["main/chums/scrollbar/darrowstyle"] )) self.userlist.setStyleSheet("QListWidget { %s }"
"QScrollBar { %s }"
"QScrollBar::handle { %s }"
"QScrollBar::add-line { %s }"
"QScrollBar::sub-line { %s }"
"QScrollBar:up-arrow { %s }"
"QScrollBar:down-arrow { %s }"
% (theme["memos/userlist/style"],
theme["main/chums/scrollbar/style"] + scrolls,
theme["main/chums/scrollbar/handle"],
theme["main/chums/scrollbar/downarrow"],
theme["main/chums/scrollbar/uparrow"],
theme["main/chums/scrollbar/uarrowstyle"],
theme["main/chums/scrollbar/darrowstyle"]))
elif "convo/scrollbar" in theme: elif "convo/scrollbar" in theme:
self.userlist.setStyleSheet("QListWidget { %s } QScrollBar { %s } QScrollBar::handle { %s } QScrollBar::add-line { %s } QScrollBar::sub-line { %s } QScrollBar:up-arrow { %s } QScrollBar:down-arrow { %s }" % (theme["memos/userlist/style"], theme["convo/scrollbar/style"] + scrolls, theme["convo/scrollbar/handle"], "display:none;", "display:none;", "display:none;", "display:none;" )) self.userlist.setStyleSheet("QListWidget { %s }"
"QScrollBar { %s }"
"QScrollBar::handle { %s }"
"QScrollBar::add-line { %s }"
"QScrollBar::sub-line { %s }"
"QScrollBar:up-arrow { %s }"
"QScrollBar:down-arrow { %s }"
% (theme["memos/userlist/style"],
theme["convo/scrollbar/style"] + scrolls,
theme["convo/scrollbar/handle"],
"display: none;",
"display: none;",
"display: none;",
"display: none;"))
else: else:
self.userlist.setStyleSheet("QListWidget { %s } QScrollBar { %s } QScrollBar::handle { %s }" % (theme["memos/userlist/style"], scrolls, "background-color: black;")) self.userlist.setStyleSheet("QListWidget { %s }"
"QScrollBar { %s }"
"QScrollBar::handle { %s }"
% (theme["memos/userlist/style"],
scrolls,
"background-color: black;"))
self.userlist.setFixedWidth(theme["memos/userlist/width"]) self.userlist.setFixedWidth(theme["memos/userlist/width"])
if self.userlist.isHidden(): if self.userlist.isHidden():
borders = "border-width: 2px;" borders = "border-width: 2px;"
else: else:
borders = "border-width: 2px 0px 2px 2px;" borders = "border-width: 2px 0px 2px 2px;"
self.miniUserlist.setStyleSheet("%s padding: 0px; margin: 0px; margin-left: 5px; width: 10px; height: 90px; %s" % (theme["memos/userlist/style"], borders)) self.miniUserlist.setStyleSheet("padding: 0px;"
"margin: 0px;"
"margin-left: 5px;"
"width: 10px;"
"height: 90px;"
+ borders
+ theme["memos/userlist/style"])
self.addchumAction.setText(theme["main/menus/rclickchumlist/addchum"]) self.addchumAction.setText(theme["main/menus/rclickchumlist/addchum"])
self.banuserAction.setText(theme["main/menus/rclickchumlist/banuser"]) self.banuserAction.setText(theme["main/menus/rclickchumlist/banuser"])
@ -639,7 +704,12 @@ class PesterMemo(PesterConvo):
self.timeinput.setFixedWidth(theme["memos/time/text/width"]) self.timeinput.setFixedWidth(theme["memos/time/text/width"])
self.timeinput.setStyleSheet(theme["memos/time/text/style"]) self.timeinput.setStyleSheet(theme["memos/time/text/style"])
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 }"
"Slider::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)
larrow = PesterIcon(self.mainwindow.theme["memos/time/arrows/left"]) larrow = PesterIcon(self.mainwindow.theme["memos/time/arrows/left"])
@ -1012,7 +1082,8 @@ class PesterMemo(PesterConvo):
self.modes = "+" + "".join(chanmodes) self.modes = "+" + "".join(chanmodes)
if self.mainwindow.advanced: if self.mainwindow.advanced:
t = Template(self.mainwindow.theme["memos/label/text"]) t = Template(self.mainwindow.theme["memos/label/text"])
self.channelLabel.setText(t.safe_substitute(channel=self.channel) + "(%s)" % (self.modes)) self.channelLabel.setText(t.safe_substitute(channel=self.channel)
+ "(%s)" % (self.modes))
def timeUpdate(self, handle, cmd): def timeUpdate(self, handle, cmd):
window = self.mainwindow window = self.mainwindow
@ -1051,7 +1122,9 @@ class PesterMemo(PesterConvo):
self.times[handle].setCurrent(close) self.times[handle].setCurrent(close)
grammar = self.times[handle].getGrammar() grammar = self.times[handle].getGrammar()
self.times[handle].removeTime(close) self.times[handle].removeTime(close)
msg = chum.memoclosemsg(systemColor, grammar, window.theme["convo/text/closememo"]) msg = chum.memoclosemsg(systemColor,
grammar,
window.theme["convo/text/closememo"])
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg) self.mainwindow.chatlog.log(self.channel, msg)
elif timed not in self.times[handle]: elif timed not in self.times[handle]:
@ -1097,9 +1170,11 @@ class PesterMemo(PesterConvo):
else: else:
self.close() self.close()
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}") msgbox.setStyleSheet("QMessageBox{ %s }"
% self.mainwindow.theme["main/defaultwindow/style"])
msgbox.setText("%s: Invites only!" % (c)) msgbox.setText("%s: Invites only!" % (c))
msgbox.setInformativeText("This channel is invite-only. You must get an invitation from someone on the inside before entering.") msgbox.setInformativeText("This channel is invite-only. "
"You must get an invitation from someone on the inside before entering.")
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec() msgbox.exec()
@ -1115,7 +1190,8 @@ class PesterMemo(PesterConvo):
else: else:
self.close() self.close()
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}") msgbox.setStyleSheet("QMessageBox{ %s }"
% self.mainwindow.theme["main/defaultwindow/style"])
msgbox.setText("%s: D: CANT JOIN MEMO!!!" % (c)) msgbox.setText("%s: D: CANT JOIN MEMO!!!" % (c))
msgbox.setInformativeText(reason) msgbox.setInformativeText(reason)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
@ -1216,7 +1292,9 @@ class PesterMemo(PesterConvo):
if update == "netsplit": if update == "netsplit":
if not hasattr(self, "netsplit"): if not hasattr(self, "netsplit"):
self.netsplit = [] self.netsplit = []
QtCore.QTimer.singleShot(1500, self, QtCore.SLOT('dumpNetsplit()')) QtCore.QTimer.singleShot(1500,
self,
QtCore.SLOT('dumpNetsplit()'))
for c in chums: for c in chums:
chum = PesterProfile(h) chum = PesterProfile(h)
self.userlist.takeItem(self.userlist.row(c)) self.userlist.takeItem(self.userlist.row(c))
@ -1226,17 +1304,22 @@ class PesterMemo(PesterConvo):
while self.times[h].getTime() is not None: while self.times[h].getTime() is not None:
t = self.times[h] t = self.times[h]
grammar = t.getGrammar() grammar = t.getGrammar()
allinitials.append("%s%s%s" % (grammar.pcf, chum.initials(), grammar.number)) allinitials.append("%s%s%s" % (grammar.pcf,
chum.initials(),
grammar.number))
self.times[h].removeTime(t.getTime()) self.times[h].removeTime(t.getTime())
if update == "netsplit": if update == "netsplit":
self.netsplit.extend(allinitials) self.netsplit.extend(allinitials)
else: else:
msg = chum.memoclosemsg(systemColor, allinitials, self.mainwindow.theme["convo/text/closememo"]) msg = chum.memoclosemsg(systemColor,
allinitials,
self.mainwindow.theme["convo/text/closememo"])
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg) self.mainwindow.chatlog.log(self.channel, msg)
if update == "nick": if update == "nick":
self.addUser(newnick) self.addUser(newnick)
newchums = self.userlist.findItems(newnick, QtCore.Qt.MatchFlag.MatchExactly) newchums = self.userlist.findItems(newnick,
QtCore.Qt.MatchFlag.MatchExactly)
for nc in newchums: for nc in newchums:
for c in chums: for c in chums:
nc.founder = c.founder nc.founder = c.founder
@ -1277,7 +1360,8 @@ class PesterMemo(PesterConvo):
if chum is self.mainwindow.profile(): if chum is self.mainwindow.profile():
# are you next? # are you next?
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}") msgbox.setStyleSheet("QMessageBox{ %s }"
% self.mainwindow.theme["main/defaultwindow/style"])
msgbox.setText(self.mainwindow.theme["convo/text/kickedmemo"]) msgbox.setText(self.mainwindow.theme["convo/text/kickedmemo"])
# Add ban(kick) reason # Add ban(kick) reason
@ -1319,7 +1403,11 @@ class PesterMemo(PesterConvo):
self.mainwindow.joinChannel.emit(self.channel) self.mainwindow.joinChannel.emit(self.channel)
me = self.mainwindow.profile() me = self.mainwindow.profile()
self.time.openCurrentTime() self.time.openCurrentTime()
msg = me.memoopenmsg(systemColor, self.time.getTime(), self.time.getGrammar(), self.mainwindow.theme["convo/text/openmemo"], self.channel) msg = me.memoopenmsg(systemColor,
self.time.getTime(),
self.time.getGrammar(),
self.mainwindow.theme["convo/text/openmemo"],
self.channel)
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg) self.mainwindow.chatlog.log(self.channel, msg)
elif ret == QtWidgets.QMessageBox.StandardButton.Cancel: elif ret == QtWidgets.QMessageBox.StandardButton.Cancel:
@ -1349,9 +1437,10 @@ class PesterMemo(PesterConvo):
elif update == "+o": elif update == "+o":
if self.mainwindow.config.opvoiceMessages(): if self.mainwindow.config.opvoiceMessages():
(chum, opchum, opgrammar) = self.chumOPstuff(h, op) (chum, opchum, opgrammar) = self.chumOPstuff(h, op)
PchumLog.debug("chum.handle = %s\nopchum.handle = %s\nopgrammar = %s\n systemColor = %s\n" % (chum.handle, opchum.handle, opgrammar, systemColor)) #PchumLog.debug("chum.handle = %s\nopchum.handle = %s\nopgrammar = %s\n systemColor = %s\n"
# % (chum.handle, opchum.handle, opgrammar, systemColor))
msg = chum.memoopmsg(opchum, opgrammar, systemColor) msg = chum.memoopmsg(opchum, opgrammar, systemColor)
PchumLog.debug("post memoopmsg") #PchumLog.debug("post memoopmsg")
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg) self.mainwindow.chatlog.log(self.channel, msg)
for c in chums: for c in chums:
@ -1469,7 +1558,9 @@ class PesterMemo(PesterConvo):
if not self.userlist.currentItem(): if not self.userlist.currentItem():
return return
currentHandle = str(self.userlist.currentItem().text()) currentHandle = str(self.userlist.currentItem().text())
(reason, ok) = QtWidgets.QInputDialog.getText(self, "Ban User", "Enter the reason you are banning this user (optional):") (reason, ok) = QtWidgets.QInputDialog.getText(self,
"Ban User",
"Enter the reason you are banning this user (optional):")
if ok: if ok:
self.mainwindow.kickUser.emit("%s:%s" % (currentHandle, reason), self.channel) self.mainwindow.kickUser.emit("%s:%s" % (currentHandle, reason), self.channel)
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
@ -1500,7 +1591,10 @@ class PesterMemo(PesterConvo):
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def openChumLogs(self): def openChumLogs(self):
currentChum = self.channel currentChum = self.channel
self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum,
self.mainwindow.config,
self.mainwindow.theme,
self.mainwindow)
self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog) self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog)
self.mainwindow.chumList.pesterlogviewer.show() self.mainwindow.chumList.pesterlogviewer.show()
self.mainwindow.chumList.pesterlogviewer.raise_() self.mainwindow.chumList.pesterlogviewer.raise_()
@ -1511,7 +1605,9 @@ class PesterMemo(PesterConvo):
if not hasattr(self, 'invitechums'): if not hasattr(self, 'invitechums'):
self.invitechums = None self.invitechums = None
if not self.invitechums: if not self.invitechums:
(chum, ok) = QtWidgets.QInputDialog.getText(self, "Invite to Chat", "Enter the chumhandle of the user you'd like to invite:") (chum, ok) = QtWidgets.QInputDialog.getText(self,
"Invite to Chat",
"Enter the chumhandle of the user you'd like to invite:")
if ok: if ok:
chum = str(chum) chum = str(chum)
self.mainwindow.inviteChum.emit(chum, self.channel) self.mainwindow.inviteChum.emit(chum, self.channel)
@ -1581,7 +1677,107 @@ class PesterMemo(PesterConvo):
windowClosed = QtCore.pyqtSignal('QString') windowClosed = QtCore.pyqtSignal('QString')
timelist = ["0:00", "0:01", "0:02", "0:04", "0:06", "0:10", "0:14", "0:22", "0:30", "0:41", "1:00", "1:34", "2:16", "3:14", "4:13", "4:20", "5:25", "6:12", "7:30", "8:44", "10:25", "11:34", "14:13", "16:12", "17:44", "22:22", "25:10", "33:33", "42:00", "43:14", "50:00", "62:12", "75:00", "88:44", "100", "133", "143", "188", "200", "222", "250", "314", "333", "413", "420", "500", "600", "612", "888", "1000", "1025"] timelist = ["0:00",
"0:01",
"0:02",
"0:04",
"0:06",
"0:10",
"0:14",
"0:22",
"0:30",
"0:41",
"1:00",
"1:34",
"2:16",
"3:14",
"4:13",
"4:20",
"5:25",
"6:12",
"7:30",
"8:44",
"10:25",
"11:34",
"14:13",
"16:12",
"17:44",
"22:22",
"25:10",
"33:33",
"42:00",
"43:14",
"50:00",
"62:12",
"75:00",
"88:44",
"100",
"133",
"143",
"188",
"200",
"222",
"250",
"314",
"333",
"413",
"420",
"500",
"600",
"612",
"888",
"1000",
"1025"]
timedlist = [timedelta(0), timedelta(0, 60), timedelta(0, 120), timedelta(0, 240), timedelta(0, 360), timedelta(0, 600), timedelta(0, 840), timedelta(0, 1320), timedelta(0, 1800), timedelta(0, 2460), timedelta(0, 3600), timedelta(0, 5640), timedelta(0, 8160), timedelta(0, 11640), timedelta(0, 15180), timedelta(0, 15600), timedelta(0, 19500), timedelta(0, 22320), timedelta(0, 27000), timedelta(0, 31440), timedelta(0, 37500), timedelta(0, 41640), timedelta(0, 51180), timedelta(0, 58320), timedelta(0, 63840), timedelta(0, 80520), timedelta(1, 4200), timedelta(1, 34380), timedelta(1, 64800), timedelta(1, 69240), timedelta(2, 7200), timedelta(2, 51120), timedelta(3, 10800), timedelta(3, 60240), timedelta(4, 14400), timedelta(5, 46800), timedelta(5, 82800), timedelta(7, 72000), timedelta(8, 28800), timedelta(9, 21600), timedelta(10, 36000), timedelta(13, 7200), timedelta(13, 75600), timedelta(17, 18000), timedelta(17, 43200), timedelta(20, 72000), timedelta(25), timedelta(25, 43200), timedelta(37), timedelta(41, 57600), timedelta(42, 61200)] timedlist = [timedelta(0),
timedelta(0, 60),
timedelta(0, 120),
timedelta(0, 240),
timedelta(0, 360),
timedelta(0, 600),
timedelta(0, 840),
timedelta(0, 1320),
timedelta(0, 1800),
timedelta(0, 2460),
timedelta(0, 3600),
timedelta(0, 5640),
timedelta(0, 8160),
timedelta(0, 11640),
timedelta(0, 15180),
timedelta(0, 15600),
timedelta(0, 19500),
timedelta(0, 22320),
timedelta(0, 27000),
timedelta(0, 31440),
timedelta(0, 37500),
timedelta(0, 41640),
timedelta(0, 51180),
timedelta(0, 58320),
timedelta(0, 63840),
timedelta(0, 80520),
timedelta(1, 4200),
timedelta(1, 34380),
timedelta(1, 64800),
timedelta(1, 69240),
timedelta(2, 7200),
timedelta(2, 51120),
timedelta(3, 10800),
timedelta(3, 60240),
timedelta(4, 14400),
timedelta(5, 46800),
timedelta(5, 82800),
timedelta(7, 72000),
timedelta(8, 28800),
timedelta(9, 21600),
timedelta(10, 36000),
timedelta(13, 7200),
timedelta(13, 75600),
timedelta(17, 18000),
timedelta(17, 43200),
timedelta(20, 72000),
timedelta(25),
timedelta(25, 43200),
timedelta(37),
timedelta(41, 57600),
timedelta(42, 61200)]

View file

@ -1585,7 +1585,11 @@ class PesterUserlist(QtWidgets.QDialog):
self.searchbox.setFocus() self.searchbox.setFocus()
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def updateUsers(self): def updateUsers(self):
try:
names = self.mainwindow.namesdb["#pesterchum"] names = self.mainwindow.namesdb["#pesterchum"]
except KeyError:
# Not in #pesterchum?
return
self.userarea.clear() self.userarea.clear()
for n in names: for n in names:
if str(self.searchbox.text()) == "" or n.lower().find(str(self.searchbox.text()).lower()) != -1: if str(self.searchbox.text()) == "" or n.lower().find(str(self.searchbox.text()).lower()) != -1:

View file

@ -107,9 +107,9 @@ class CommandHandler(object):
try: try:
f(*args) f(*args)
except TypeError as e: except TypeError as e:
logging.warning("Failed to pass command, did the server pass an unsupported paramater? " + str(e)) logging.info("Failed to pass command, did the server pass an unsupported paramater? " + str(e))
except Exception as e: except Exception as e:
logging.warning("Failed to pass command, %s" % str(e)) logging.info("Failed to pass command, %s" % str(e))
@protected @protected
def __unhandled__(self, cmd, *args): def __unhandled__(self, cmd, *args):

View file

@ -12,18 +12,19 @@ QString = str
if os.path.dirname(sys.argv[0]): if os.path.dirname(sys.argv[0]):
os.chdir(os.path.dirname(sys.argv[0])) os.chdir(os.path.dirname(sys.argv[0]))
print("Usage: pesterchum.py [OPTIONS]") print("Usage: pesterchum.py [OPTIONS]")
print("Use -h/--help to see the available options.\nLogging is configured in logging.ini") print("Use -h/--help to see the available options."
"\nLogging is configured in logging.ini")
# Help # Help
if ('--help' in sys.argv[1:]) or ('-h' in sys.argv[1:]): if ('--help' in sys.argv[1:]) or ('-h' in sys.argv[1:]):
print("Possible arguments:") print("Possible arguments:")
help_arguments = (" -l, --logging\n Specify level of logging, possible values are:\n" help_arguments = (" -l, --logging\n Specify level of logging, possible values are:\n"
+ " CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET.\n" " CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET.\n"
+ " The default value is WARNING.\n" " The default value is WARNING.\n"
+ " (See https://docs.python.org/3/library/logging.html)\n\n" " (See https://docs.python.org/3/library/logging.html)\n\n"
+ " -s, --server\n Specify server override. (legacy)\n\n" " -s, --server\n Specify server override. (legacy)\n\n"
+ " -p, --port\n Specify port override. (legacy)\n\n" " -p, --port\n Specify port override. (legacy)\n\n"
+ " --advanced\n Enable advanced.\n\n" " --advanced\n Enable advanced.\n\n"
+ " --no-honk\n Disable honking.\n") " --no-honk\n Disable honking.\n")
print(help_arguments) print(help_arguments)
sys.exit() sys.exit()
@ -605,13 +606,16 @@ class chumArea(RightClickTree):
#self.topLevelItem(0).sortChildren(0, QtCore.Qt.SortOrder.AscendingOrder) #self.topLevelItem(0).sortChildren(0, QtCore.Qt.SortOrder.AscendingOrder)
def getChums(self, handle): def getChums(self, handle):
chums = self.findItems(handle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive) chums = self.findItems(handle, QtCore.Qt.MatchFlag.MatchExactly
| QtCore.Qt.MatchFlag.MatchRecursive)
return chums return chums
def showAllChums(self): def showAllChums(self):
for c in self.chums: for c in self.chums:
chandle = c.handle chandle = c.handle
if not len(self.findItems(chandle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)): if not len(self.findItems(chandle,
QtCore.Qt.MatchFlag.MatchExactly
| QtCore.Qt.MatchFlag.MatchRecursive)):
#if True:# For if it doesn't work at all :/ #if True:# For if it doesn't work at all :/
chumLabel = chumListing(c, self.mainwindow) chumLabel = chumListing(c, self.mainwindow)
self.addItem(chumLabel) self.addItem(chumLabel)
@ -720,7 +724,9 @@ class chumArea(RightClickTree):
if text.rfind(" (") != -1: if text.rfind(" (") != -1:
text = text[0:text.rfind(" (")] text = text[0:text.rfind(" (")]
curgroups.append(text) curgroups.append(text)
if not self.findItems(chumLabel.handle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive): if not self.findItems(chumLabel.handle,
QtCore.Qt.MatchFlag.MatchExactly
| QtCore.Qt.MatchFlag.MatchRecursive):
#if True:# For if it doesn't work at all :/ #if True:# For if it doesn't work at all :/
if chumLabel.chum.group not in curgroups: if chumLabel.chum.group not in curgroups:
child_1 = QtWidgets.QTreeWidgetItem(["%s" % (chumLabel.chum.group)]) child_1 = QtWidgets.QTreeWidgetItem(["%s" % (chumLabel.chum.group)])
@ -773,7 +779,9 @@ class chumArea(RightClickTree):
if self.mainwindow.config.showOnlineNumbers(): if self.mainwindow.config.showOnlineNumbers():
self.showOnlineNumbers() self.showOnlineNumbers()
else: # usually means this is now the trollslum else: # usually means this is now the trollslum
if not self.findItems(chumLabel.handle, QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive): if not self.findItems(chumLabel.handle,
QtCore.Qt.MatchFlag.MatchExactly
| QtCore.Qt.MatchFlag.MatchRecursive):
#if True:# For if it doesn't work at all :/ #if True:# For if it doesn't work at all :/
self.topLevelItem(0).addChild(chumLabel) self.topLevelItem(0).addChild(chumLabel)
self.topLevelItem(0).sortChildren(0, QtCore.Qt.SortOrder.AscendingOrder) self.topLevelItem(0).sortChildren(0, QtCore.Qt.SortOrder.AscendingOrder)
@ -933,7 +941,10 @@ class chumArea(RightClickTree):
if not currentChum: if not currentChum:
return return
currentChum = currentChum.text(0) currentChum = currentChum.text(0)
self.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) self.pesterlogviewer = PesterLogViewer(currentChum,
self.mainwindow.config,
self.mainwindow.theme,
self.mainwindow)
self.pesterlogviewer.rejected.connect(self.closeActiveLog) self.pesterlogviewer.rejected.connect(self.closeActiveLog)
self.pesterlogviewer.show() self.pesterlogviewer.show()
self.pesterlogviewer.raise_() self.pesterlogviewer.raise_()
@ -947,7 +958,9 @@ class chumArea(RightClickTree):
currentChum = self.currentItem() currentChum = self.currentItem()
if not currentChum: if not currentChum:
return return
(notes, ok) = QtWidgets.QInputDialog.getText(self, "Notes", "Enter your notes...") (notes, ok) = QtWidgets.QInputDialog.getText(self,
"Notes",
"Enter your notes...")
if ok: if ok:
notes = str(notes) notes = str(notes)
self.mainwindow.chumdb.setNotes(currentChum.handle, notes) self.mainwindow.chumdb.setNotes(currentChum.handle, notes)
@ -957,12 +970,15 @@ class chumArea(RightClickTree):
if not hasattr(self, 'renamegroupdialog'): if not hasattr(self, 'renamegroupdialog'):
self.renamegroupdialog = None self.renamegroupdialog = None
if not self.renamegroupdialog: if not self.renamegroupdialog:
(gname, ok) = QtWidgets.QInputDialog.getText(self, "Rename Group", "Enter a new name for the group:") (gname, ok) = QtWidgets.QInputDialog.getText(self,
"Rename Group",
"Enter a new name for the group:")
if ok: if ok:
gname = str(gname) gname = str(gname)
if re.search("[^A-Za-z0-9_\s]", gname) is not None: if re.search("[^A-Za-z0-9_\s]", gname) is not None:
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}") msgbox.setStyleSheet("QMessageBox{ %s }"
% self.mainwindow.theme["main/defaultwindow/style"])
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME") msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec() msgbox.exec()
@ -1140,7 +1156,9 @@ class TrollSlumWindow(QtWidgets.QFrame):
if self.addtrolldialog: if self.addtrolldialog:
return return
self.addtrolldialog = QtWidgets.QInputDialog(self) self.addtrolldialog = QtWidgets.QInputDialog(self)
(handle, ok) = self.addtrolldialog.getText(self, "Add Troll", "Enter Troll Handle:") (handle, ok) = self.addtrolldialog.getText(self,
"Add Troll",
"Enter Troll Handle:")
if ok: if ok:
handle = str(handle) handle = str(handle)
if not (PesterProfile.checkLength(handle) and if not (PesterProfile.checkLength(handle) and
@ -1162,8 +1180,8 @@ class PesterWindow(MovingWindow):
def __init__(self, options, parent=None, app=None): def __init__(self, options, parent=None, app=None):
super(PesterWindow, self).__init__(None, super(PesterWindow, self).__init__(None,
(QtCore.Qt.WindowType.CustomizeWindowHint | (QtCore.Qt.WindowType.CustomizeWindowHint
QtCore.Qt.WindowType.FramelessWindowHint)) | QtCore.Qt.WindowType.FramelessWindowHint))
# For debugging # For debugging
_CONSOLE_ENV.PAPP = self _CONSOLE_ENV.PAPP = self
@ -1200,7 +1218,10 @@ class PesterWindow(MovingWindow):
self.userprofile = userProfile(self.config.defaultprofile()) self.userprofile = userProfile(self.config.defaultprofile())
self.theme = self.userprofile.getTheme() self.theme = self.userprofile.getTheme()
else: else:
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0))) self.userprofile = userProfile(PesterProfile("pesterClient%d"
% (random.randint(100,999)),
QtGui.QColor("black"),
Mood(0)))
self.theme = self.userprofile.getTheme() self.theme = self.userprofile.getTheme()
except Exception as e: except Exception as e:
msgBox = QtWidgets.QMessageBox() msgBox = QtWidgets.QMessageBox()
@ -1208,14 +1229,15 @@ class PesterWindow(MovingWindow):
msgBox.setWindowTitle(":(") msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js" self.filename = _datadir+"pesterchum.js"
msgBox.setText("<html><h3>A profile error occured, trying to switch to default pesterClient profile." + \ msgBox.setText("<html><h3>A profile error occured,"
"<br><br>" + str(e) + "<\h3><\html>") "trying to switch to default pesterClient profile."
#"\" if pesterchum acts oddly you might want to try backing up and then deleting \"" + \ "<br><br>%s<\h3><\html>" % e)
#_datadir+"pesterchum.js" + \
#"\"")
PchumLog.critical(e) PchumLog.critical(e)
msgBox.exec() msgBox.exec()
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0))) self.userprofile = userProfile(PesterProfile("pesterClient%d"
% (random.randint(100,999)),
QtGui.QColor("black"),
Mood(0)))
self.theme = self.userprofile.getTheme() self.theme = self.userprofile.getTheme()
# karxi: For the record, these are set via commandline arguments. By # karxi: For the record, these are set via commandline arguments. By
@ -1563,8 +1585,8 @@ class PesterWindow(MovingWindow):
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def closeToTray(self): def closeToTray(self):
# I'm just gonna include a toast here to make sure people don't get confused. :'3 # I'm just gonna include a toast here to make sure people don't get confused. :'3
t = self.tm.Toast("Notice:", "Pesterchum has been minimized to your tray. \ t = self.tm.Toast("Notice:",
\n(This behavior is configurable in settings.)") "Pesterchum has been minimized to your tray.")
t.show() t.show()
self.hide() self.hide()
self.closeToTraySignal.emit() self.closeToTraySignal.emit()
@ -1597,7 +1619,10 @@ class PesterWindow(MovingWindow):
elif not self.config.notifyOptions() & self.config.NEWCONVO: elif not self.config.notifyOptions() & self.config.NEWCONVO:
if msg[:11] != "PESTERCHUM:": if msg[:11] != "PESTERCHUM:":
if handle.upper() not in BOTNAMES: if handle.upper() not in BOTNAMES:
t = self.tm.Toast("From: %s" % handle, re.sub("</?c(=.*?)?>", "", msg)) t = self.tm.Toast("From: %s" % handle,
re.sub("</?c(=.*?)?>",
"",
msg))
t.show() t.show()
else: else:
if msg == "PESTERCHUM:CEASE": if msg == "PESTERCHUM:CEASE":
@ -1668,7 +1693,9 @@ class PesterWindow(MovingWindow):
self.namesound.play() self.namesound.play()
return return
if not memo.notifications_muted: if not memo.notifications_muted:
if self.honk and re.search(r"\bhonk\b", convertTags(msg, "text"), re.I): if self.honk and re.search(r"\bhonk\b",
convertTags(msg, "text"),
re.I):
# TODO: I've got my eye on you, Gamzee. # TODO: I've got my eye on you, Gamzee.
self.honksound.play() self.honksound.play()
elif self.config.memoPing() or memo.always_beep: elif self.config.memoPing() or memo.always_beep:
@ -1874,10 +1901,13 @@ class PesterWindow(MovingWindow):
self.backgroundImage = QtGui.QPixmap(theme["main/background-image"]) self.backgroundImage = QtGui.QPixmap(theme["main/background-image"])
self.setMask(self.backgroundImage.mask()) self.setMask(self.backgroundImage.mask())
self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " self.menu.setStyleSheet(("QMenuBar { background: transparent; %s }"
"QMenuBar::item { background: transparent; %s }")
% (theme["main/menubar/style"], % (theme["main/menubar/style"],
theme["main/menu/menuitem"]) theme["main/menu/menuitem"])
+ "QMenu { background: transparent; %s } QMenu::item::selected { %s } QMenu::item::disabled { %s }" + ("QMenu { background: transparent; %s }"
"QMenu::item::selected { %s }"
"QMenu::item::disabled { %s }")
% (theme["main/menu/style"], % (theme["main/menu/style"],
theme["main/menu/selected"], theme["main/menu/selected"],
theme["main/menu/disabled"])) theme["main/menu/disabled"]))
@ -2004,7 +2034,9 @@ class PesterWindow(MovingWindow):
# This is a better spot to put this :) # This is a better spot to put this :)
# Setting QMessageBox's style usually doesn't do anything. # Setting QMessageBox's style usually doesn't do anything.
self.setStyleSheet("QInputDialog { %s } QMessageBox { %s }" % (self.theme["main/defaultwindow/style"], self.theme["main/defaultwindow/style"])) self.setStyleSheet("QInputDialog { %s } QMessageBox { %s }"
% (self.theme["main/defaultwindow/style"],
self.theme["main/defaultwindow/style"]))
if theme["main/mychumhandle/colorswatch/text"]: if theme["main/mychumhandle/colorswatch/text"]:
self.mychumcolor.setText(theme["main/mychumhandle/colorswatch/text"]) self.mychumcolor.setText(theme["main/mychumhandle/colorswatch/text"])
@ -2168,7 +2200,9 @@ class PesterWindow(MovingWindow):
def doAutoIdentify(self): def doAutoIdentify(self):
if self.userprofile.getAutoIdentify(): if self.userprofile.getAutoIdentify():
self.sendMessage.emit("identify " + self.userprofile.getNickServPass(), "NickServ") self.sendMessage.emit("identify "
+ self.userprofile.getNickServPass(),
"NickServ")
def doAutoJoins(self): def doAutoJoins(self):
if not self.autoJoinDone: if not self.autoJoinDone:
@ -2221,7 +2255,10 @@ class PesterWindow(MovingWindow):
except KeyError: except KeyError:
chumopen = self.convos[h.lower()].chumopen chumopen = self.convos[h.lower()].chumopen
if chumopen: if chumopen:
self.chatlog.log(chum.handle, self.profile().pestermsg(chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/ceasepester"])) self.chatlog.log(chum.handle,
self.profile().pestermsg(chum,
QtGui.QColor(self.theme["convo/systemMsgColor"]),
self.theme["convo/text/ceasepester"]))
self.convoClosed.emit(handle) self.convoClosed.emit(handle)
self.chatlog.finish(h) self.chatlog.finish(h)
del self.convos[h] del self.convos[h]
@ -2273,9 +2310,12 @@ class PesterWindow(MovingWindow):
if h.upper() == "NICKSERV" and m.startswith("Your nickname is now being changed to"): if h.upper() == "NICKSERV" and m.startswith("Your nickname is now being changed to"):
changedto = m[39:-1] changedto = m[39:-1]
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") msgbox.setStyleSheet("QMessageBox{ %s }"
msgbox.setText("This chumhandle has been registered; you may not use it.") % self.theme["main/defaultwindow/style"])
msgbox.setInformativeText("Your handle is now being changed to %s." % (changedto)) msgbox.setText("This chumhandle has been registered; "
"you may not use it.")
msgbox.setInformativeText("Your handle is now being changed to %s."
% (changedto))
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec() msgbox.exec()
elif h == self.randhandler.randNick: elif h == self.randhandler.randNick:
@ -2298,8 +2338,11 @@ class PesterWindow(MovingWindow):
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setText("You're invited!") msgbox.setText("You're invited!")
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")
msgbox.setInformativeText("%s has invited you to the memo: %s\nWould you like to join them?" % (handle, channel)) msgbox.setInformativeText(("%s has invited you to the memo: %s"
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel) "\nWould you like to join them?")
% (handle, channel))
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok
| QtWidgets.QMessageBox.StandardButton.Cancel)
# Find the Cancel button and make it default # Find the Cancel button and make it default
for b in msgbox.buttons(): for b in msgbox.buttons():
if msgbox.buttonRole(b) == QtWidgets.QMessageBox.ButtonRole.RejectRole: if msgbox.buttonRole(b) == QtWidgets.QMessageBox.ButtonRole.RejectRole:
@ -2433,9 +2476,13 @@ class PesterWindow(MovingWindow):
def removeChum(self, chumlisting): def removeChum(self, chumlisting):
self.config.removeChum(chumlisting) self.config.removeChum(chumlisting)
def reportChum(self, handle): def reportChum(self, handle):
(reason, ok) = QtWidgets.QInputDialog.getText(self, "Report User", "Enter the reason you are reporting this user (optional):") (reason, ok) = QtWidgets.QInputDialog.getText(self,
"Report User",
"Enter the reason you are reporting this user (optional):")
if ok: if ok:
self.sendMessage.emit("REPORT %s %s" % (handle, reason) , "calSprite") self.sendMessage.emit("REPORT %s %s"
% (handle, reason),
"calSprite")
@QtCore.pyqtSlot(QString) @QtCore.pyqtSlot(QString)
def blockChum(self, handle): def blockChum(self, handle):
@ -2444,7 +2491,9 @@ class PesterWindow(MovingWindow):
self.config.removeChum(h) self.config.removeChum(h)
if h in self.convos: if h in self.convos:
convo = self.convos[h] convo = self.convos[h]
msg = self.profile().pestermsg(convo.chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/blocked"]) msg = self.profile().pestermsg(convo.chum,
QtGui.QColor(self.theme["convo/systemMsgColor"]),
self.theme["convo/text/blocked"])
convo.textArea.append(convertTags(msg)) convo.textArea.append(convertTags(msg))
self.chatlog.log(convo.chum.handle, msg) self.chatlog.log(convo.chum.handle, msg)
convo.updateBlocked() convo.updateBlocked()
@ -2461,7 +2510,9 @@ class PesterWindow(MovingWindow):
self.config.delBlocklist(h) self.config.delBlocklist(h)
if h in self.convos: if h in self.convos:
convo = self.convos[h] convo = self.convos[h]
msg = self.profile().pestermsg(convo.chum, QtGui.QColor(self.theme["convo/systemMsgColor"]), self.theme["convo/text/unblocked"]) msg = self.profile().pestermsg(convo.chum,
QtGui.QColor(self.theme["convo/systemMsgColor"]),
self.theme["convo/text/unblocked"])
convo.textArea.append(convertTags(msg)) convo.textArea.append(convertTags(msg))
self.chatlog.log(convo.chum.handle, msg) self.chatlog.log(convo.chum.handle, msg)
convo.updateMood(convo.chum.mood, unblocked=True) convo.updateMood(convo.chum.mood, unblocked=True)
@ -2735,7 +2786,9 @@ class PesterWindow(MovingWindow):
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME") msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")#Style :) (memos/style or convo/style works :3 ) #Style :) (memos/style or convo/style works :3 )
msgbox.setStyleSheet("QMessageBox{ %s }"
% self.theme["main/defaultwindow/style"])
msgbox.exec() msgbox.exec()
self.addgroupdialog = None self.addgroupdialog = None
return return
@ -3063,28 +3116,33 @@ class PesterWindow(MovingWindow):
try: try:
self.userprofile = userProfile(handle) self.userprofile = userProfile(handle)
self.changeTheme(self.userprofile.getTheme()) self.changeTheme(self.userprofile.getTheme())
except (json.JSONDecodeError, FileNotFoundError) as e: except (json.JSONDecodeError, FileNotFoundError, ValueError) as e:
msgBox = QtWidgets.QMessageBox() msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.StandardButton.Warning) msgBox.setIcon(QtWidgets.QMessageBox.Icon.Warning)
msgBox.setWindowTitle(":(") msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js" self.filename = _datadir+"pesterchum.js"
try: try:
msgBox.setText("<html><h3>Failed to load: " + ("<a href='%s'>%s/%s.js</a>" % (self.profiledir, self.profiledir, user)) + \ msg = ("<html><h3>Failed to load: "
"<br><br> Try to check for syntax errors if the file exists." + \ "<a href='%s'>%s/%s.js</a>"
"<br><br>If you got this message at launch you may want to change your default profile." + \ "<br><br>"
"<br><br>" + str(e) + "<\h3><\html>") "Try to check for syntax errors if the file exists."
#"\" if pesterchum acts oddly you might want to try backing up and then deleting \"" + \ "<br><br>"
#_datadir+"pesterchum.js" + \ "If you got this message at launch you may want to "
#"\"") "change your default profile."
"<br><br>%s<\h3><\html>"
% (self.profiledir, self.profiledir, user, e))
except: except:
# More generic error for if not all variables are available. # More generic error for if not all variables are available.
msgBox.setText("Unspecified profile error." + \ msg = ("Unspecified profile error."
"<br><br> Try to check for syntax errors if the file exists." + \ "<br><br> Try to check for syntax errors if the "
"<br><br>If you got this message at launch you may want to change your default profile." + \ "file exists."
"<br><br>" + str(e) + "<\h3><\html>") "<br><br>If you got this message at launch you may "
"want to change your default profile."
"<br><br>%s<\h3><\html>" % e)
PchumLog.critical(e) PchumLog.critical(e)
msgBox.setText(msg)
msgBox.exec() msgBox.exec()
return return
else: else:
@ -3145,7 +3203,8 @@ class PesterWindow(MovingWindow):
closeWarning = QtWidgets.QMessageBox() closeWarning = QtWidgets.QMessageBox()
closeWarning.setText("WARNING: CHANGING PROFILES WILL CLOSE ALL CONVERSATION WINDOWS!") closeWarning.setText("WARNING: CHANGING PROFILES WILL CLOSE ALL CONVERSATION WINDOWS!")
closeWarning.setInformativeText("i warned you about windows bro!!!! i told you dog!") closeWarning.setInformativeText("i warned you about windows bro!!!! i told you dog!")
closeWarning.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Cancel | QtWidgets.QMessageBox.StandardButton.Ok) closeWarning.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Cancel
| QtWidgets.QMessageBox.StandardButton.Ok)
closeWarning.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok) closeWarning.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok)
ret = closeWarning.exec() ret = closeWarning.exec()
if ret == QtWidgets.QMessageBox.StandardButton.Cancel: if ret == QtWidgets.QMessageBox.StandardButton.Cancel:
@ -3178,15 +3237,19 @@ class PesterWindow(MovingWindow):
self.newConversation("nickServ") self.newConversation("nickServ")
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def launchHelp(self): def launchHelp(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", QtCore.QUrl.ParsingMode.TolerantMode)) QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues",
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://forum.homestuck.xyz/viewtopic.php?f=7&t=467", QtCore.QUrl.ParsingMode.TolerantMode)) QtCore.QUrl.ParsingMode.TolerantMode))
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://forum.homestuck.xyz/viewtopic.php?f=7&t=467",
QtCore.QUrl.ParsingMode.TolerantMode))
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def reportBug(self): def reportBug(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues", QtCore.QUrl.ParsingMode.TolerantMode)) QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/Dpeta/pesterchum-alt-servers/issues",
QtCore.QUrl.ParsingMode.TolerantMode))
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def xyzRules(self): def xyzRules(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://www.pesterchum.xyz/pesterchum-rules", QtCore.QUrl.ParsingMode.TolerantMode)) QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://www.pesterchum.xyz/pesterchum-rules",
QtCore.QUrl.ParsingMode.TolerantMode))
@QtCore.pyqtSlot(QString, QString) @QtCore.pyqtSlot(QString, QString)
def nickCollision(self, handle, tmphandle): def nickCollision(self, handle, tmphandle):
@ -3196,7 +3259,10 @@ class PesterWindow(MovingWindow):
self.loadingscreen = None self.loadingscreen = None
self.mychumhandle.setText(tmphandle) self.mychumhandle.setText(tmphandle)
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0))) self.userprofile = userProfile(PesterProfile("pesterClient%d"
% (random.randint(100,999)),
QtGui.QColor("black"),
Mood(0)))
self.changeTheme(self.userprofile.getTheme()) self.changeTheme(self.userprofile.getTheme())
if not hasattr(self, 'chooseprofile'): if not hasattr(self, 'chooseprofile'):
@ -3247,7 +3313,8 @@ class PesterWindow(MovingWindow):
def tooManyPeeps(self): def tooManyPeeps(self):
msg = QtWidgets.QMessageBox(self) msg = QtWidgets.QMessageBox(self)
msg.setText("D: TOO MANY PEOPLE!!!") msg.setText("D: TOO MANY PEOPLE!!!")
msg.setInformativeText("The server has hit max capacity. Please try again later.") msg.setInformativeText("The server has hit max capacity."
"Please try again later.")
#msg.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") #msg.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")
msg.exec() msg.exec()
@ -3276,7 +3343,8 @@ class PesterWindow(MovingWindow):
PchumLog.info("server: "+str(server)) PchumLog.info("server: "+str(server))
except: except:
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") msgbox.setStyleSheet("QMessageBox{ %s }"
% self.theme["main/defaultwindow/style"])
msgbox.setWindowIcon(PesterIcon(self.theme["main/icon"])) msgbox.setWindowIcon(PesterIcon(self.theme["main/icon"]))
msgbox.setInformativeText("Incorrect format :(") msgbox.setInformativeText("Incorrect format :(")
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok) msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
@ -3308,11 +3376,12 @@ class PesterWindow(MovingWindow):
if os.path.isfile(_datadir + "serverlist.json"): if os.path.isfile(_datadir + "serverlist.json"):
PchumLog.error("Failed to load server list from serverlist.json.") PchumLog.error("Failed to load server list from serverlist.json.")
msgbox = QtWidgets.QMessageBox() msgbox = QtWidgets.QMessageBox()
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}") msgbox.setStyleSheet("QMessageBox{ %s }"
% self.theme["main/defaultwindow/style"])
msgbox.setWindowIcon(PesterIcon(self.theme["main/icon"])) msgbox.setWindowIcon(PesterIcon(self.theme["main/icon"]))
msgbox.setInformativeText("Failed to load server list, do you want to revert to defaults?\n" \ msgbox.setInformativeText("Failed to load server list, do you want to revert to defaults?\n"
+ "If you choose no, Pesterchum will most likely crash unless you manually fix serverlist.json\n" \ "If you choose no, Pesterchum will most likely crash unless you manually fix serverlist.json\n"
+ "Please tell me if this error occurs :'3") "Please tell me if this error occurs :'3")
msgbox.addButton(QtWidgets.QPushButton("Yes"), QtWidgets.QMessageBox.ButtonRole.YesRole) msgbox.addButton(QtWidgets.QPushButton("Yes"), QtWidgets.QMessageBox.ButtonRole.YesRole)
msgbox.addButton(QtWidgets.QPushButton("No"), QtWidgets.QMessageBox.ButtonRole.NoRole) msgbox.addButton(QtWidgets.QPushButton("No"), QtWidgets.QMessageBox.ButtonRole.NoRole)
msgbox.exec() msgbox.exec()
@ -3323,8 +3392,8 @@ class PesterWindow(MovingWindow):
server_file.close() server_file.close()
else: else:
PchumLog.warning("Failed to load server list because serverlist.json doesn't exist, " \ PchumLog.warning("Failed to load server list because serverlist.json doesn't exist, "
+ "this isn't an issue if this is the first time Pesterchum has been started.") "this isn't an issue if this is the first time Pesterchum has been started.")
with open(_datadir + "serverlist.json", "w") as server_file: with open(_datadir + "serverlist.json", "w") as server_file:
server_file.write(json.dumps(default_server_list, indent = 4) ) server_file.write(json.dumps(default_server_list, indent = 4) )
server_file.close() server_file.close()
@ -3561,7 +3630,8 @@ class PesterWindow(MovingWindow):
# Connect # Connect
self.chooseServerWidged.accepted.connect(self.setServer) self.chooseServerWidged.accepted.connect(self.setServer)
self.chooseServerWidged.rejected.connect(self.killApp, QtCore.Qt.ConnectionType.QueuedConnection) self.chooseServerWidged.rejected.connect(self.killApp,
QtCore.Qt.ConnectionType.QueuedConnection)
# Show # Show
self.chooseServerWidged.show() self.chooseServerWidged.show()
@ -3664,7 +3734,9 @@ class MainProgram(QtCore.QObject):
self.widget = PesterWindow(options, parent=self, app=self.app) self.widget = PesterWindow(options, parent=self, app=self.app)
#self.widget.show() <== Already called in showLoading() #self.widget.show() <== Already called in showLoading()
self.trayicon = PesterTray(PesterIcon(self.widget.theme["main/icon"]), self.widget, self.app) self.trayicon = PesterTray(PesterIcon(self.widget.theme["main/icon"]),
self.widget,
self.app)
self.traymenu = QtWidgets.QMenu() self.traymenu = QtWidgets.QMenu()
moodMenu = self.traymenu.addMenu("SET MOOD") moodMenu = self.traymenu.addMenu("SET MOOD")
@ -3725,7 +3797,8 @@ class MainProgram(QtCore.QObject):
self.trayicon.show() self.trayicon.show()
if self.widget.config.trayMessage(): if self.widget.config.trayMessage():
self.trayicon.showMessage("Pesterchum", ("Pesterchum is still running in the system tray." self.trayicon.showMessage("Pesterchum", ("Pesterchum is still running in the system tray."
+ '\n' + "Right click to close it.")) "\n"
"Right click to close it."))
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def trayMessageClick(self): def trayMessageClick(self):
@ -3967,7 +4040,7 @@ class MainProgram(QtCore.QObject):
# Show error to end user and log. # Show error to end user and log.
try: try:
# Log to log file # Log to log file
PchumLog.error(exc, value, tb) PchumLog.error("%s, %s" % (exc, value))
# Try to write to separate logfile # Try to write to separate logfile
try: try:
@ -3997,7 +4070,6 @@ class MainProgram(QtCore.QObject):
PchumLog.exception("app error") PchumLog.exception("app error")
def run(self): def run(self):
#PchumLog.critical("mreowww") <--- debug thingy :3
sys.exit(self.app.exec()) sys.exit(self.app.exec())
def _retrieveGlobals(): def _retrieveGlobals():