further pyqt6 changes, version, linux/macos color fix

This commit is contained in:
Dpeta 2022-06-29 01:50:08 +02:00
parent 2576be41aa
commit b18d4c9aee
10 changed files with 65 additions and 48 deletions

View file

@ -1,7 +1,10 @@
# Changelog
(This document uses YYYY-MM-DD)
## [v2.4] - 2022-06-27
## [v2.4] - 2022-06-28
### Fixed
- Some text using the system's default color instead of black in the 'pesterchum' theme. (white text on white background)
### Changed
- Transitioned from PyQt5 to PyQt6 🌈

View file

@ -420,7 +420,7 @@ class ConsoleText(QtWidgets.QTextEdit):
# Save the old cursor
oldcur = self.textCursor()
# Move the cursor to the end of the document for insertion
self.moveCursor(QtGui.QTextCursor.End)
self.moveCursor(QtGui.QTextCursor.MoveOperation.End)
# Insert the text
self.insertPlainText(text)
# Return the cursor to wherever it was prior
@ -440,7 +440,7 @@ class ConsoleText(QtWidgets.QTextEdit):
# should.
# karxi: Test for tab changing?
if self.window().text.input:
if event.key() not in (QtCore.Key.Qt.Key_PageUp, QtCore.Qt.Key.Key_PageDown,
if event.key() not in (QtCore.Qt.Key.Key_PageUp, QtCore.Qt.Key.Key_PageDown,
QtCore.Qt.Key.Key_Up, QtCore.Qt.Key.Key_Down):
self.window().text.input.keyPressEvent(event)

View file

@ -187,10 +187,12 @@ class PesterLogViewer(QtWidgets.QDialog):
child_1 = None
last = ["",""]
#blackbrush = QtGui.QBrush(QtCore.Qt.GlobalColor.black)
for (i,l) in enumerate(self.logList):
my = self.fileToMonthYear(l)
if my[0] != last[0]:
child_1 = QtWidgets.QTreeWidgetItem(["%s %s" % (my[0], my[1])])
#child_1.setForeground(0, blackbrush)
self.tree.addTopLevelItem(child_1)
if i == 0:
child_1.setExpanded(True)

View file

@ -1100,7 +1100,7 @@ class PesterMemo(PesterConvo):
msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}")
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.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec()
def quirkDisable(self, op, msg):
@ -1281,10 +1281,10 @@ class PesterMemo(PesterConvo):
# This shouldn't happen
PchumLog.warning("kickmsg IndexError: %s" % e)
msgbox.setInformativeText(kick_msg)
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel)
# Find the OK button and make it default
for b in msgbox.buttons():
if msgbox.buttonRole(b) == QtWidgets.QMessageBox.AcceptRole:
if msgbox.buttonRole(b) == QtWidgets.QMessageBox.ButtonRole.AcceptRole:
# We found the 'OK' button, set it as the default
b.setDefault(True)
b.setAutoDefault(True)
@ -1293,7 +1293,7 @@ class PesterMemo(PesterConvo):
b.setFocus()
break
ret = msgbox.exec()
if ret == QtWidgets.QMessageBox.Ok:
if ret == QtWidgets.QMessageBox.StandardButton.Ok:
self.userlist.clear()
self.time = TimeTracker(curtime)
self.resetSlider(curtime)
@ -1303,7 +1303,7 @@ class PesterMemo(PesterConvo):
msg = me.memoopenmsg(systemColor, self.time.getTime(), self.time.getGrammar(), self.mainwindow.theme["convo/text/openmemo"], self.channel)
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg)
elif ret == QtWidgets.QMessageBox.Cancel:
elif ret == QtWidgets.QMessageBox.StandardButton.Cancel:
if self.parent():
i = self.parent().tabIndices[self.channel]
self.parent().tabClose(i)

View file

@ -88,7 +88,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
@QtCore.pyqtSlot()
def upShiftQuirk(self):
found = self.findItems(self.currentItem().text(0), QtCore.MatchFlag.Qt.MatchExactly)
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchFlag.MatchExactly)
if len(found): # group
i = self.indexOfTopLevelItem(found[0])
if i > 0:
@ -158,10 +158,10 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
msgbox.setObjectName("delquirkwarning")
msgbox.setWindowTitle("WARNING!")
msgbox.setInformativeText("Are you sure you want to delete the quirk group: %s" % (f.text(0)))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel)
# Find the Cancel button and make it default
for b in msgbox.buttons():
if msgbox.buttonRole(b) == QtWidgets.QMessageBox.RejectRole:
if msgbox.buttonRole(b) == QtWidgets.QMessageBox.ButtonRole.RejectRole:
# We found the 'OK' button, set it as the default
b.setDefault(True)
b.setAutoDefault(True)
@ -170,7 +170,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
b.setFocus()
break
ret = msgbox.exec()
if ret == QtWidgets.QMessageBox.Ok:
if ret == QtWidgets.QMessageBox.StandardButton.Ok:
self.takeTopLevelItem(self.indexOfTopLevelItem(f))
else:
f.parent().takeChild(f.parent().indexOfChild(f))
@ -187,7 +187,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
if re.search("[^A-Za-z0-9_\s]", gname) is not None:
msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec()
self.addgroupdialog = None
return
@ -195,7 +195,7 @@ class PesterQuirkList(QtWidgets.QTreeWidget):
if found:
msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText("THIS QUIRK GROUP ALREADY EXISTS")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec()
return
child_1 = QtWidgets.QTreeWidgetItem([gname])
@ -899,7 +899,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
problem.setStyleSheet(self.theme["main/defaultwindow/style"])
problem.setWindowTitle("Problem!")
problem.setInformativeText("You can't delete the profile you're currently using!")
problem.setStandardButtons(QtWidgets.QMessageBox.Ok)
problem.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
problem.exec()
return
# TODO: Make this select 'no' as the default, as usual.
@ -907,9 +907,9 @@ class PesterChooseProfile(QtWidgets.QDialog):
msgbox.setStyleSheet(self.theme["main/defaultwindow/style"])
msgbox.setWindowTitle("WARNING!")
msgbox.setInformativeText("Are you sure you want to delete the profile: %s" % (handle))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel)
ret = msgbox.exec()
if ret == QtWidgets.QMessageBox.Ok:
if ret == QtWidgets.QMessageBox.StandardButton.Ok:
try:
remove(_datadir+"profiles/%s.js" % (handle))
except OSError:
@ -918,7 +918,7 @@ class PesterChooseProfile(QtWidgets.QDialog):
problem.setStyleSheet(self.theme["main/defaultwindow/style"])
problem.setWindowTitle("Problem!")
problem.setInformativeText("There was a problem deleting the profile: %s" % (handle))
problem.setStandardButtons(QtWidgets.QMessageBox.Ok)
problem.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
problem.exec()
class PesterMentions(QtWidgets.QDialog):

View file

@ -109,6 +109,8 @@ class IRCClient:
str they will be converted to bytes with the encoding specified by the
'encoding' keyword argument (default 'utf8').
"""
if self._end == True:
return
# Convert all args to bytes if not already
encoding = kwargs.get('encoding') or 'utf8'
bargs = []
@ -167,10 +169,15 @@ class IRCClient:
PchumLog.debug("ready_to_write (len %s): " % str(len(ready_to_write)) + str(ready_to_write))
except Exception as se:
PchumLog.warning("socket.error %s" % str(se))
try:
if not self.blocking and se.errno == 11:
pass
else:
raise se
#raise se
_end = True # This ok?
except AttributeError:
#raise se
_end = True # This ok?
def connect(self):
""" initiates the connection to the server set in self.host:self.port

View file

@ -535,7 +535,12 @@ class chumArea(RightClickTree):
self.mainwindow.config.saveGroups(gTemp)
# Drop item is a chum
else:
item = self.itemAt(event.pos())
eventpos = event.position()
if type(eventpos) == QtCore.QPointF:
# Round if float, which it should be in PyQt6
item = self.itemAt(eventpos.toPoint())
else:
item = self.itemAt(eventpos)
if item:
text = str(item.text(0))
# Figure out which group to drop into
@ -968,7 +973,7 @@ class chumArea(RightClickTree):
msgbox = QtWidgets.QMessageBox()
msgbox.setStyleSheet("QMessageBox{" + self.mainwindow.theme["main/defaultwindow/style"] + "}")
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec()
self.addgroupdialog = None
return
@ -1208,7 +1213,7 @@ class PesterWindow(MovingWindow):
self.theme = self.userprofile.getTheme()
except Exception as e:
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Information)
msgBox.setIcon(QtWidgets.QMessageBox.Icon.Information)
msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js"
@ -2252,7 +2257,7 @@ class PesterWindow(MovingWindow):
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")
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.Ok)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec()
elif h == self.randhandler.randNick:
self.randhandler.incoming(msg)
@ -2269,10 +2274,10 @@ class PesterWindow(MovingWindow):
msgbox.setText("You're invited!")
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.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel)
# Find the Cancel button and make it default
for b in msgbox.buttons():
if msgbox.buttonRole(b) == QtWidgets.QMessageBox.RejectRole:
if msgbox.buttonRole(b) == QtWidgets.QMessageBox.ButtonRole.RejectRole:
# We found the 'OK' button, set it as the default
b.setDefault(True)
b.setAutoDefault(True)
@ -2281,7 +2286,7 @@ class PesterWindow(MovingWindow):
b.setFocus()
break
ret = msgbox.exec()
if ret == QtWidgets.QMessageBox.Ok:
if ret == QtWidgets.QMessageBox.StandardButton.Ok:
self.newMemo(str(channel), "+0:00")
@QtCore.pyqtSlot(QString)
def chanInviteOnly(self, channel):
@ -2701,7 +2706,7 @@ class PesterWindow(MovingWindow):
if re.search("[^A-Za-z0-9_\s]", gname) is not None:
msgbox = QtWidgets.QMessageBox()
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")#Style :) (memos/style or convo/style works :3 )
msgbox.exec()
self.addgroupdialog = None
@ -3032,7 +3037,7 @@ class PesterWindow(MovingWindow):
self.changeTheme(self.userprofile.getTheme())
except (json.JSONDecodeError, FileNotFoundError) as e:
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Warning)
msgBox.setIcon(QtWidgets.QMessageBox.StandardButton.Warning)
msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js"
@ -3112,10 +3117,10 @@ class PesterWindow(MovingWindow):
closeWarning = QtWidgets.QMessageBox()
closeWarning.setText("WARNING: CHANGING PROFILES WILL CLOSE ALL CONVERSATION WINDOWS!")
closeWarning.setInformativeText("i warned you about windows bro!!!! i told you dog!")
closeWarning.setStandardButtons(QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Ok)
closeWarning.setDefaultButton(QtWidgets.QMessageBox.Ok)
closeWarning.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Cancel | QtWidgets.QMessageBox.StandardButton.Ok)
closeWarning.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok)
ret = closeWarning.exec()
if ret == QtWidgets.QMessageBox.Cancel:
if ret == QtWidgets.QMessageBox.StandardButton.Cancel:
return
self.changeProfile()
# Update RE bot
@ -3229,7 +3234,7 @@ class PesterWindow(MovingWindow):
msgbox.setStyleSheet("QMessageBox{" + self.theme["main/defaultwindow/style"] + "}")
msgbox.setWindowIcon(PesterIcon(self.theme["main/icon"]))
msgbox.setInformativeText("Incorrect format :(")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
msgbox.exec()
self.chooseServer()
return 1
@ -3263,12 +3268,12 @@ class PesterWindow(MovingWindow):
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" \
+ "Please tell me if this error occurs :'3")
msgbox.addButton(QtWidgets.QPushButton("Yes"), QtWidgets.QMessageBox.YesRole)
msgbox.addButton(QtWidgets.QPushButton("No"), QtWidgets.QMessageBox.NoRole)
msgbox.addButton(QtWidgets.QPushButton("Yes"), QtWidgets.QMessageBox.ButtonRole.YesRole)
msgbox.addButton(QtWidgets.QPushButton("No"), QtWidgets.QMessageBox.ButtonRole.NoRole)
msgbox.exec()
reply = msgbox.buttonRole(msgbox.clickedButton())
if (reply==QtWidgets.QMessageBox.YesRole):
if (reply==QtWidgets.QMessageBox.ButtonRole.YesRole):
with open(_datadir + "serverlist.json", "w") as server_file:
server_file.write(json.dumps(default_server_list, indent = 4) )
server_file.close()

View file

@ -67,7 +67,7 @@ class PesterLog(object):
# Catching this exception does not stop pchum from dying if we run out of file handles </3
PchumLog.critical(e)
errmsg = QtWidgets.QMessageBox()
errmsg.setIcon(QtWidgets.QMessageBox.Warning)
errmsg.setIcon(QtWidgets.QMessageBox.Icon.Warning)
errmsg.setText("Warning: Pesterchum could not open the log file for %s!" % (handle))
errmsg.setInformativeText("Your log for %s will not be saved because something went wrong. We suggest restarting Pesterchum. Sorry :(" % (handle))
errmsg.setWindowTitle(":(")
@ -126,7 +126,7 @@ class userConfig(object):
PchumLog.critical("failed to load pesterchum.js")
PchumLog.critical(e)
msgbox = QtWidgets.QMessageBox()
msgbox.setIcon(QtWidgets.QMessageBox.Warning)
msgbox.setIcon(QtWidgets.QMessageBox.Icon.Warning)
msgbox.setWindowTitle(":(")
msgbox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
msgbox.setInformativeText("<html><h3>Failed to load pesterchum.js, this might require manual intervention.<br><br>\
@ -470,7 +470,7 @@ with a backup from: <a href='%s'>%s</a></h3></html>" % (_datadir, self.filename,
PchumLog.warning(x + " removed from profile list.")
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Warning)
msgBox.setIcon(QtWidgets.QMessageBox.Icon.Warning)
msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js"
@ -519,7 +519,7 @@ class userProfile(object):
self.userprofile = json.load(fp)
except (json.JSONDecodeError, FileNotFoundError) as e:
msgBox = QtWidgets.QMessageBox()
msgBox.setIcon(QtWidgets.QMessageBox.Warning)
msgBox.setIcon(QtWidgets.QMessageBox.Icon.Warning)
msgBox.setWindowTitle(":(")
msgBox.setTextFormat(QtCore.Qt.TextFormat.RichText) # Clickable html links
self.filename = _datadir+"pesterchum.js"

View file

@ -150,7 +150,7 @@
"text": "" },
"currentMood": [18, 249]
},
"defaultwindow": { "style": "background: #fdb302; font-family:'Courier';font:bold;selection-background-color:#919191; "
"defaultwindow": { "style": "color: black;background: #fdb302; font-family:'Courier';font:bold;selection-background-color:#919191; "
},
"addchum": { "style": "background: rgba(255, 255, 0, 0%); border:2px solid #c48a00; font: bold; color: rgba(0, 0, 0, 0%); font-family:'Courier';",
"pressed" : "background: rgb(255, 255, 255, 30%);",
@ -304,7 +304,7 @@
"maxheight": 47
},
"input": { "style": "color: black; background: white; border:2px solid #c48a00;margin-top:5px; margin-right:10px; margin-left:10px; font-size: 12px;" },
"textarea": { "style": "background: white; font-size: 14px;font:bold; border:2px solid #c48a00;text-align:center; margin-right:10px; margin-left:10px;" },
"textarea": { "style": "color: black; background: white; font-size: 14px;font:bold; border:2px solid #c48a00;text-align:center; margin-right:10px; margin-left:10px;" },
"margins": {"top": 0, "bottom": 6, "left": 0, "right": 0 },
"userlist": { "width": 150,
"style": "border:2px solid #c48a00; background: white;font: bold;font-family: 'Courier';selection-background-color:#646464; font-size: 12px; margin-left:0px; margin-right:10px;"

View file

@ -1,2 +1,2 @@
_pcVersion = "Alt. v2.3.1"
buildVersion = "v2.3.1"
_pcVersion = "Alt. v2.4"
buildVersion = "v2.4"