diff --git a/bugreport.py b/bugreport.py index 0dbf75a..04f7cff 100644 --- a/bugreport.py +++ b/bugreport.py @@ -1,51 +1,47 @@ -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets import urllib import ostools import version -class BugReporter(QtGui.QDialog): +class BugReporter(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.mainwindow = parent self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) self.setWindowTitle("Report a Bug") self.setModal(False) - self.title = QtGui.QLabel("Bug Report:") + self.title = QtWidgets.QLabel("Bug Report:") - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.title) - layout_0.addWidget(QtGui.QLabel("Chumhandle:")) - handleLabel = QtGui.QLabel("The best chumhandle to contact you at for further information.") + layout_0.addWidget(QtWidgets.QLabel("Chumhandle:")) + handleLabel = QtWidgets.QLabel("The best chumhandle to contact you at for further information.") font = handleLabel.font() font.setPointSize(8) handleLabel.setFont(font) layout_0.addWidget(handleLabel) - self.name = QtGui.QLineEdit(self) + self.name = QtWidgets.QLineEdit(self) self.name.setStyleSheet("background:white; font-weight:bold; color:black; font-size: 10pt;") layout_0.addWidget(self.name) - layout_0.addWidget(QtGui.QLabel("Description of bug:")) - descLabel = QtGui.QLabel("Include as much information as possible\n(theme, related options, what you were doing at the time, etc.)") + layout_0.addWidget(QtWidgets.QLabel("Description of bug:")) + descLabel = QtWidgets.QLabel("Include as much information as possible\n(theme, related options, what you were doing at the time, etc.)") font = descLabel.font() font.setPointSize(8) descLabel.setFont(font) layout_0.addWidget(descLabel) - self.textarea = QtGui.QTextEdit(self) + self.textarea = QtWidgets.QTextEdit(self) self.textarea.setStyleSheet("background:white; font-weight:normal; color:black; font-size: 10pt;") layout_0.addWidget(self.textarea) - self.ok = QtGui.QPushButton("SEND", self) + self.ok = QtWidgets.QPushButton("SEND", self, clicked=self.sendReport) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('sendReport()')) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_2 = QtGui.QHBoxLayout() + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self.cancel) layout_2.addWidget(self.ok) @@ -64,14 +60,14 @@ class BugReporter(QtGui.QDialog): msg = unicode(self.textarea.toPlainText()) if len(bestname) <= 0 or len(msg) <= 0: - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) msgbox.setText("You must fill out all fields first!") - msgbox.setStandardButtons(QtGui.QMessageBox.Ok) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) ret = msgbox.exec_() return - QtGui.QDialog.accept(self) + QtWidgets.QDialog.accept(self) data = urllib.urlencode({"name":name, "version": version._pcVersion, "bestname":bestname, "os":os, "platform":full, "python":python, "qt":qt, "msg":msg}) print "Sending..." f = urllib.urlopen("http://distantsphere.com/pc/reporter.php", data) diff --git a/convo.py b/convo.py index a74c9a5..b9a1c93 100644 --- a/convo.py +++ b/convo.py @@ -5,7 +5,7 @@ import httplib, urllib from time import strftime from copy import copy from datetime import datetime, timedelta -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets from mood import Mood from dataobjs import PesterProfile, PesterHistory @@ -13,25 +13,22 @@ from generic import PesterIcon from parsetools import convertTags, lexMessage, splitMessage, mecmd, colorBegin, colorEnd, \ img2smiley, smiledict, oocre -class PesterTabWindow(QtGui.QFrame): +class PesterTabWindow(QtWidgets.QFrame): def __init__(self, mainwindow, parent=None, convo="convo"): - QtGui.QFrame.__init__(self, parent) + QtWidgets.QFrame.__init__(self, parent) self.setAttribute(QtCore.Qt.WA_QuitOnClose, False) self.setFocusPolicy(QtCore.Qt.ClickFocus) self.mainwindow = mainwindow - self.tabs = QtGui.QTabBar(self) + self.tabs = QtWidgets.QTabBar(self) self.tabs.setMovable(True) self.tabs.setTabsClosable(True) - self.connect(self.tabs, QtCore.SIGNAL('currentChanged(int)'), - self, QtCore.SLOT('changeTab(int)')) - self.connect(self.tabs, QtCore.SIGNAL('tabCloseRequested(int)'), - self, QtCore.SLOT('tabClose(int)')) - self.connect(self.tabs, QtCore.SIGNAL('tabMoved(int, int)'), - self, QtCore.SLOT('tabMoved(int, int)')) + self.tabs.currentChanged.connect(self.changeTab) + self.tabs.tabCloseRequested.connect(self.tabClose) + self.tabs.tabMoved.connect(self.tabMoved) self.initTheme(self.mainwindow.theme) - self.layout = QtGui.QVBoxLayout() + self.layout = QtWidgets.QVBoxLayout() self.layout.setContentsMargins(0,0,0,0) self.layout.addWidget(self.tabs) self.setLayout(self.layout) @@ -235,9 +232,9 @@ class PesterMovie(QtGui.QMovie): text.urls[movie], movie.currentPixmap()) text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth()) -class PesterText(QtGui.QTextEdit): +class PesterText(QtWidgets.QTextEdit): def __init__(self, theme, parent=None): - QtGui.QTextEdit.__init__(self, parent) + QtWidgets.QTextEdit.__init__(self, parent) if hasattr(self.parent(), 'mainwindow'): self.mainwindow = self.parent().mainwindow else: @@ -251,21 +248,18 @@ class PesterText(QtGui.QTextEdit): self.setReadOnly(True) self.setMouseTracking(True) self.textSelected = False - self.connect(self, QtCore.SIGNAL('copyAvailable(bool)'), - self, QtCore.SLOT('textReady(bool)')) + self.copyAvailable.connect(self.textReady) self.urls = {} for k in smiledict: self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k])) - self.connect(self.mainwindow, QtCore.SIGNAL('animationSetting(bool)'), - self, QtCore.SLOT('animateChanged(bool)')) + self.mainwindow.animationSetting.connect(self.animateChanged) def addAnimation(self, url, fileName): movie = PesterMovie(self) movie.setFileName(fileName) movie.setCacheMode(QtGui.QMovie.CacheAll) if movie.frameCount() > 1: self.urls[movie] = url - movie.connect(movie, QtCore.SIGNAL('frameChanged(int)'), - movie, QtCore.SLOT('animate(int)')) + movie.frameChanged.connect(movie.animate) #movie.start() @QtCore.pyqtSlot(bool) def animateChanged(self, animate): @@ -383,14 +377,14 @@ class PesterText(QtGui.QTextEdit): sb.setValue(sb.maximum()) def focusInEvent(self, event): self.parent().clearNewMessage() - QtGui.QTextEdit.focusInEvent(self, event) + QtWidgets.QTextEdit.focusInEvent(self, event) def keyPressEvent(self, event): if hasattr(self.parent(), 'textInput'): if event.key() not in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown, \ QtCore.Qt.Key_Up, QtCore.Qt.Key_Down]: self.parent().textInput.keyPressEvent(event) - QtGui.QTextEdit.keyPressEvent(self, event) + QtWidgets.QTextEdit.keyPressEvent(self, event) def mousePressEvent(self, event): if event.button() == QtCore.Qt.LeftButton: @@ -403,12 +397,12 @@ class PesterText(QtGui.QTextEdit): self.parent().mainwindow.newConversation(handle) else: if event.modifiers() == QtCore.Qt.ControlModifier: - QtGui.QApplication.clipboard().setText(url) + QtWidgets.QApplication.clipboard().setText(url) else: QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode)) - QtGui.QTextEdit.mousePressEvent(self, event) + QtWidgets.QTextEdit.mousePressEvent(self, event) def mouseMoveEvent(self, event): - QtGui.QTextEdit.mouseMoveEvent(self, event) + QtWidgets.QTextEdit.mouseMoveEvent(self, event) if self.anchorAt(event.pos()): if self.viewport().cursor().shape != QtCore.Qt.PointingHandCursor: self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) @@ -418,9 +412,7 @@ class PesterText(QtGui.QTextEdit): def contextMenuEvent(self, event): textMenu = self.createStandardContextMenu() if self.textSelected: - self.submitLogAction = QtGui.QAction("Submit to Pesterchum QDB", self) - self.connect(self.submitLogAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('submitLog()')) + self.submitLogAction = QtWidgets.QAction("Submit to Pesterchum QDB", self, triggered=self.submitLog) textMenu.addAction(self.submitLogAction) textMenu.exec_(event.globalPos()) @@ -435,12 +427,10 @@ class PesterText(QtGui.QTextEdit): textdoc = QtGui.QTextDocument() textdoc.setHtml(htmldata) logdata = "%s\n%s" % (self.submitLogTitle(), textdoc.toPlainText()) - self.sending = QtGui.QDialog(self) - layout = QtGui.QVBoxLayout() - self.sending.sendinglabel = QtGui.QLabel("S3ND1NG...", self.sending) - cancelbutton = QtGui.QPushButton("OK", self.sending) - self.sending.connect(cancelbutton, QtCore.SIGNAL('clicked()'), - self.sending, QtCore.SLOT('close()')) + self.sending = QtWidgets.QDialog(self) + layout = QtWidgets.QVBoxLayout() + self.sending.sendinglabel = QtWidgets.QLabel("S3ND1NG...", self.sending) + cancelbutton = QtWidgets.QPushButton("OK", self.sending, clicked=self.sending.close) layout.addWidget(self.sending.sendinglabel) layout.addWidget(cancelbutton) self.sending.setLayout(layout) @@ -463,16 +453,16 @@ class PesterText(QtGui.QTextEdit): self.sending.sendinglabel.setText("F41L3D: %s" % (e)) del self.sending -class PesterInput(QtGui.QLineEdit): +class PesterInput(QtWidgets.QLineEdit): def __init__(self, theme, parent=None): - QtGui.QLineEdit.__init__(self, parent) + QtWidgets.QLineEdit.__init__(self, parent) self.setStyleSheet(theme["convo/input/style"]) def changeTheme(self, theme): self.setStyleSheet(theme["convo/input/style"]) def focusInEvent(self, event): self.parent().clearNewMessage() self.parent().textArea.textCursor().clearSelection() - QtGui.QLineEdit.focusInEvent(self, event) + QtWidgets.QLineEdit.focusInEvent(self, event) def keyPressEvent(self, event): if event.key() == QtCore.Qt.Key_Up: text = unicode(self.text()) @@ -486,11 +476,11 @@ class PesterInput(QtGui.QLineEdit): elif event.key() in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]: self.parent().textArea.keyPressEvent(event) self.parent().mainwindow.idletime = 0 - QtGui.QLineEdit.keyPressEvent(self, event) + QtWidgets.QLineEdit.keyPressEvent(self, event) -class PesterConvo(QtGui.QFrame): +class PesterConvo(QtWidgets.QFrame): def __init__(self, chum, initiated, mainwindow, parent=None): - QtGui.QFrame.__init__(self, parent) + QtWidgets.QFrame.__init__(self, parent) self.setAttribute(QtCore.Qt.WA_QuitOnClose, False) self.setObjectName(chum.handle) self.setFocusPolicy(QtCore.Qt.ClickFocus) @@ -504,20 +494,19 @@ class PesterConvo(QtGui.QFrame): t = Template(self.mainwindow.theme["convo/chumlabel/text"]) - self.chumLabel = QtGui.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.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.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"]) - self.chumLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding)) + self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)) self.textArea = PesterText(self.mainwindow.theme, self) self.textInput = PesterInput(self.mainwindow.theme, self) self.textInput.setFocus() - self.connect(self.textInput, QtCore.SIGNAL('returnPressed()'), - self, QtCore.SLOT('sentMessage()')) + self.textInput.returnPressed.connect(self.sentMessage) - self.layout = QtGui.QVBoxLayout() + self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.chumLabel) self.layout.addWidget(self.textArea) self.layout.addWidget(self.textInput) @@ -528,31 +517,17 @@ class PesterConvo(QtGui.QFrame): self.setLayout(self.layout) - self.optionsMenu = QtGui.QMenu(self) + self.optionsMenu = QtWidgets.QMenu(self) self.optionsMenu.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) - self.addChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self) - self.connect(self.addChumAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('addThisChum()')) - self.blockAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self) - self.connect(self.blockAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('blockThisChum()')) - self.quirksOff = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self) + self.addChumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self, triggered=self.addThisChum) + self.blockAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self, triggered=self.blockThisChum) + self.quirksOff = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self, toggled=self.toggleQuirks) self.quirksOff.setCheckable(True) - self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'), - self, QtCore.SLOT('toggleQuirks(bool)')) - self.oocToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self) + self.oocToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self, toggled=self.toggleOOC) self.oocToggle.setCheckable(True) - self.connect(self.oocToggle, QtCore.SIGNAL('toggled(bool)'), - self, QtCore.SLOT('toggleOOC(bool)')) - self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self) - self.connect(self.unblockchum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('unblockChumSlot()')) - self.reportchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self) - self.connect(self.reportchum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('reportThisChum()')) - self.logchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self) - self.connect(self.logchum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('openChumLogs()')) + self.unblockchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self, triggered=self.unblockChumSlot) + self.reportchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self, triggered=self.reportThisChum) + self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self, triggered=self.openChumLogs) self.optionsMenu.addAction(self.quirksOff) self.optionsMenu.addAction(self.oocToggle) @@ -708,7 +683,7 @@ class PesterConvo(QtGui.QFrame): 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.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"]) - self.chumLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding)) + self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding)) self.quirksOff.setText(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"]) self.addChumAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/addchum"]) self.blockAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"]) @@ -734,7 +709,7 @@ class PesterConvo(QtGui.QFrame): try: lexmsg = quirks.apply(lexmsg) except: - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setText("Whoa there! There seems to be a problem.") msgbox.setInformativeText("A quirk seems to be having a problem. (Possibly you're trying to capture a non-existant group?)") msgbox.exec_() @@ -746,7 +721,7 @@ class PesterConvo(QtGui.QFrame): self.addMessage(lm, True) # if ceased, rebegin if hasattr(self, 'chumopen') and not self.chumopen: - self.mainwindow.newConvoStarted.emit(QtCore.QString(self.title()), True) + self.mainwindow.newConvoStarted.emit(self.title(), True) self.setChumOpen(True) text = convertTags(serverMsg, "ctag") self.messageSent.emit(text, self.title()) @@ -774,14 +749,13 @@ class PesterConvo(QtGui.QFrame): def openChumLogs(self): currentChum = self.chum.handle self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) - self.connect(self.mainwindow.chumList.pesterlogviewer, QtCore.SIGNAL('rejected()'), - self.mainwindow.chumList, QtCore.SLOT('closeActiveLog()')) + self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog) self.mainwindow.chumList.pesterlogviewer.show() self.mainwindow.chumList.pesterlogviewer.raise_() self.mainwindow.chumList.pesterlogviewer.activateWindow() - messageSent = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - windowClosed = QtCore.pyqtSignal(QtCore.QString) + messageSent = QtCore.pyqtSignal('QString', 'QString') + windowClosed = QtCore.pyqtSignal('QString') aligndict = {"h": {"center": QtCore.Qt.AlignHCenter, "left": QtCore.Qt.AlignLeft, diff --git a/dataobjs.py b/dataobjs.py index 0ea6c58..2f86f8f 100644 --- a/dataobjs.py +++ b/dataobjs.py @@ -1,4 +1,4 @@ -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore from datetime import * import re import random diff --git a/generic.py b/generic.py index 8ff08be..35fdb2a 100644 --- a/generic.py +++ b/generic.py @@ -1,4 +1,4 @@ -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets from datetime import timedelta class mysteryTime(timedelta): @@ -41,7 +41,7 @@ class PesterIcon(QtGui.QIcon): except IndexError: return None -class RightClickList(QtGui.QListWidget): +class RightClickList(QtWidgets.QListWidget): def contextMenuEvent(self, event): #fuckin Qt if event.reason() == QtGui.QContextMenuEvent.Mouse: @@ -53,7 +53,7 @@ class RightClickList(QtGui.QListWidget): def getOptionsMenu(self): return self.optionsMenu -class RightClickTree(QtGui.QTreeWidget): +class RightClickTree(QtWidgets.QTreeWidget): def contextMenuEvent(self, event): if event.reason() == QtGui.QContextMenuEvent.Mouse: listing = self.itemAt(event.pos()) @@ -64,41 +64,37 @@ class RightClickTree(QtGui.QTreeWidget): def getOptionsMenu(self): return self.optionsMenu -class MultiTextDialog(QtGui.QDialog): +class MultiTextDialog(QtWidgets.QDialog): def __init__(self, title, parent, *queries): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle(title) if len(queries) == 0: return self.inputs = {} - layout_1 = QtGui.QHBoxLayout() + layout_1 = QtWidgets.QHBoxLayout() for d in queries: label = d["label"] inputname = d["inputname"] value = d.get("value", "") - l = QtGui.QLabel(label, self) + l = QtWidgets.QLabel(label, self) layout_1.addWidget(l) - self.inputs[inputname] = QtGui.QLineEdit(value, self) + self.inputs[inputname] = QtWidgets.QLineEdit(value, self) layout_1.addWidget(self.inputs[inputname]) - self.ok = QtGui.QPushButton("OK", self) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.accept) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('accept()')) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_ok = QtGui.QHBoxLayout() + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + layout_ok = QtWidgets.QHBoxLayout() layout_ok.addWidget(self.cancel) layout_ok.addWidget(self.ok) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addLayout(layout_1) layout_0.addLayout(layout_ok) self.setLayout(layout_0) def getText(self): r = self.exec_() - if r == QtGui.QDialog.Accepted: + if r == QtWidgets.QDialog.Accepted: retval = {} for (name, widget) in self.inputs.iteritems(): retval[name] = unicode(widget.text()) @@ -106,9 +102,9 @@ class MultiTextDialog(QtGui.QDialog): else: return None -class MovingWindow(QtGui.QFrame): +class MovingWindow(QtWidgets.QFrame): def __init__(self, *x, **y): - QtGui.QFrame.__init__(self, *x, **y) + QtWidgets.QFrame.__init__(self, *x, **y) self.moving = None self.moveupdate = 0 def mouseMoveEvent(self, event): @@ -131,9 +127,9 @@ class NoneSound(object): def play(self): pass def set_volume(self, v): pass -class WMButton(QtGui.QPushButton): +class WMButton(QtWidgets.QPushButton): def __init__(self, icon, parent=None): - QtGui.QPushButton.__init__(self, icon, "", parent) + QtWidgets.QPushButton.__init__(self, icon, "", parent) self.setIconSize(icon.realsize()) self.resize(icon.realsize()) self.setFlat(True) diff --git a/irc.py b/irc.py index 5d794c6..a4e8a2c 100644 --- a/irc.py +++ b/irc.py @@ -1,4 +1,4 @@ -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore from oyoyo.client import IRCClient from oyoyo.cmdhandler import DefaultCommandHandler from oyoyo import helpers, services @@ -97,7 +97,7 @@ class PesterIRC(QtCore.QThread): @QtCore.pyqtSlot(PesterList) def getMoods(self, chums): self.cli.command_handler.getMood(*chums) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def sendNotice(self, text, handle): h = unicode(handle) t = unicode(text) @@ -105,7 +105,7 @@ class PesterIRC(QtCore.QThread): helpers.notice(self.cli, h, t) except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def sendMessage(self, text, handle): h = unicode(handle) textl = [unicode(text)] @@ -151,7 +151,7 @@ class PesterIRC(QtCore.QThread): helpers.msg(self.cli, h, t) except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString, bool) + @QtCore.pyqtSlot('QString', bool) def startConvo(self, handle, initiated): h = unicode(handle) try: @@ -160,7 +160,7 @@ class PesterIRC(QtCore.QThread): helpers.msg(self.cli, h, "COLOR >%s" % (self.mainwindow.profile().colorcmd())) except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def endConvo(self, handle): h = unicode(handle) try: @@ -195,21 +195,21 @@ class PesterIRC(QtCore.QThread): helpers.msg(self.cli, h, "COLOR >%s" % (self.mainwindow.profile().colorcmd())) except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def blockedChum(self, handle): h = unicode(handle) try: helpers.msg(self.cli, h, "PESTERCHUM:BLOCK") except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def unblockedChum(self, handle): h = unicode(handle) try: helpers.msg(self.cli, h, "PESTERCHUM:UNBLOCK") except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def requestNames(self, channel): c = unicode(channel) try: @@ -222,7 +222,7 @@ class PesterIRC(QtCore.QThread): helpers.channel_list(self.cli) except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def joinChannel(self, channel): c = unicode(channel) try: @@ -230,7 +230,7 @@ class PesterIRC(QtCore.QThread): helpers.mode(self.cli, c, "", None) except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def leftChannel(self, channel): c = unicode(channel) try: @@ -238,7 +238,7 @@ class PesterIRC(QtCore.QThread): self.cli.command_handler.joined = False except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def kickUser(self, handle, channel): l = handle.split(":") c = unicode(channel) @@ -254,7 +254,7 @@ class PesterIRC(QtCore.QThread): helpers.kick(self.cli, h, c, reason) except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString', 'QString') def setChannelMode(self, channel, mode, command): c = unicode(channel) m = unicode(mode) @@ -265,14 +265,14 @@ class PesterIRC(QtCore.QThread): helpers.mode(self.cli, c, m, cmd) except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def channelNames(self, channel): c = unicode(channel) try: helpers.names(self.cli, c) except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def inviteChum(self, handle, channel): h = unicode(handle) c = unicode(channel) @@ -298,7 +298,7 @@ class PesterIRC(QtCore.QThread): except socket.error: self.setConnectionBroken() - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def killSomeQuirks(self, channel, handle): c = unicode(channel) h = unicode(handle) @@ -307,25 +307,25 @@ class PesterIRC(QtCore.QThread): except socket.error: self.setConnectionBroken() - moodUpdated = QtCore.pyqtSignal(QtCore.QString, Mood) - colorUpdated = QtCore.pyqtSignal(QtCore.QString, QtGui.QColor) - messageReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - memoReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, QtCore.QString) - noticeReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - inviteReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - timeCommand = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, QtCore.QString) - namesReceived = QtCore.pyqtSignal(QtCore.QString, PesterList) + moodUpdated = QtCore.pyqtSignal('QString', Mood) + colorUpdated = QtCore.pyqtSignal('QString', QtGui.QColor) + messageReceived = QtCore.pyqtSignal('QString', 'QString') + memoReceived = QtCore.pyqtSignal('QString', 'QString', 'QString') + noticeReceived = QtCore.pyqtSignal('QString', 'QString') + inviteReceived = QtCore.pyqtSignal('QString', 'QString') + timeCommand = QtCore.pyqtSignal('QString', 'QString', 'QString') + namesReceived = QtCore.pyqtSignal('QString', PesterList) channelListReceived = QtCore.pyqtSignal(PesterList) - nickCollision = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - myHandleChanged = QtCore.pyqtSignal(QtCore.QString) - chanInviteOnly = QtCore.pyqtSignal(QtCore.QString) - modesUpdated = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) + nickCollision = QtCore.pyqtSignal('QString', 'QString') + myHandleChanged = QtCore.pyqtSignal('QString') + chanInviteOnly = QtCore.pyqtSignal('QString') + modesUpdated = QtCore.pyqtSignal('QString', 'QString') connected = QtCore.pyqtSignal() - userPresentUpdate = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, - QtCore.QString) - cannotSendToChan = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) + userPresentUpdate = QtCore.pyqtSignal('QString', 'QString', + 'QString') + cannotSendToChan = QtCore.pyqtSignal('QString', 'QString') tooManyPeeps = QtCore.pyqtSignal() - quirkDisable = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, QtCore.QString) + quirkDisable = QtCore.pyqtSignal('QString', 'QString', 'QString') class PesterHandler(DefaultCommandHandler): def notice(self, nick, chan, msg): diff --git a/logviewer.py b/logviewer.py index 4ee809a..5aef272 100644 --- a/logviewer.py +++ b/logviewer.py @@ -3,19 +3,19 @@ import codecs import re import ostools from time import strftime, strptime -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets from generic import RightClickList, RightClickTree from parsetools import convertTags from convo import PesterText _datadir = ostools.getDataDir() -class PesterLogSearchInput(QtGui.QLineEdit): +class PesterLogSearchInput(QtWidgets.QLineEdit): def __init__(self, theme, parent=None): - QtGui.QLineEdit.__init__(self, parent) + QtWidgets.QLineEdit.__init__(self, parent) self.setStyleSheet(theme["convo/input/style"] + "margin-right:0px;") def keyPressEvent(self, event): - QtGui.QLineEdit.keyPressEvent(self, event) + QtWidgets.QLineEdit.keyPressEvent(self, event) if hasattr(self.parent(), 'textArea'): if event.key() == QtCore.Qt.Key_Return: self.parent().logSearch(self.text()) @@ -36,9 +36,9 @@ class PesterLogHighlighter(QtGui.QSyntaxHighlighter): if unicode(text[i:i+len(self.searchTerm)]).lower() == unicode(self.searchTerm).lower(): self.setFormat(i, len(self.searchTerm), self.hilightstyle) -class PesterLogUserSelect(QtGui.QDialog): +class PesterLogUserSelect(QtWidgets.QDialog): def __init__(self, config, theme, parent): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setModal(False) self.config = config self.theme = theme @@ -49,7 +49,7 @@ class PesterLogUserSelect(QtGui.QDialog): self.setStyleSheet(self.theme["main/defaultwindow/style"]) self.setWindowTitle("Pesterlogs") - instructions = QtGui.QLabel("Pick a memo or chumhandle:") + instructions = QtWidgets.QLabel("Pick a memo or chumhandle:") if os.path.exists("%s/%s" % (self.logpath, self.handle)): chumMemoList = os.listdir("%s/%s/" % (self.logpath, self.handle)) @@ -63,31 +63,25 @@ class PesterLogUserSelect(QtGui.QDialog): self.chumsBox = RightClickList(self) self.chumsBox.setStyleSheet(self.theme["main/chums/style"]) - self.chumsBox.optionsMenu = QtGui.QMenu(self) + self.chumsBox.optionsMenu = QtWidgets.QMenu(self) for (i, t) in enumerate(chumMemoList): - item = QtGui.QListWidgetItem(t) - item.setTextColor(QtGui.QColor(self.theme["main/chums/userlistcolor"])) + item = QtWidgets.QListWidgetItem(t) + item.setForeground(QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"]))) self.chumsBox.addItem(item) self.search = PesterLogSearchInput(theme, self) self.search.setFocus() - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - self.ok = QtGui.QPushButton("OK", self) + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.viewActivatedLog) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('viewActivatedLog()')) - layout_ok = QtGui.QHBoxLayout() + layout_ok = QtWidgets.QHBoxLayout() layout_ok.addWidget(self.cancel) layout_ok.addWidget(self.ok) - self.directory = QtGui.QPushButton("LOG DIRECTORY", self) - self.connect(self.directory, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('openDir()')) + self.directory = QtWidgets.QPushButton("LOG DIRECTORY", self, clicked=self.openDir) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(instructions) layout_0.addWidget(self.chumsBox) layout_0.addWidget(self.search) @@ -111,8 +105,7 @@ class PesterLogUserSelect(QtGui.QDialog): self.pesterlogviewer = None if not self.pesterlogviewer: self.pesterlogviewer = PesterLogViewer(selectedchum, self.config, self.theme, self.parent) - self.connect(self.pesterlogviewer, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('closeActiveLog()')) + self.pesterlogviewer.rejected.connect(self.closeActiveLog) self.pesterlogviewer.show() self.pesterlogviewer.raise_() self.pesterlogviewer.activateWindow() @@ -127,9 +120,9 @@ class PesterLogUserSelect(QtGui.QDialog): def openDir(self): QtGui.QDesktopServices.openUrl(QtCore.QUrl("file:///" + os.path.join(_datadir, "logs"), QtCore.QUrl.TolerantMode)) -class PesterLogViewer(QtGui.QDialog): +class PesterLogViewer(QtWidgets.QDialog): def __init__(self, chum, config, theme, parent): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setModal(False) self.config = config self.theme = theme @@ -151,22 +144,20 @@ class PesterLogViewer(QtGui.QDialog): self.logList = [] if not os.path.exists("%s/%s/%s/%s" % (self.logpath, self.handle, chum, self.format)) or len(self.logList) == 0: - instructions = QtGui.QLabel("No Pesterlogs were found") + instructions = QtWidgets.QLabel("No Pesterlogs were found") - self.ok = QtGui.QPushButton("CLOSE", self) + self.ok = QtWidgets.QPushButton("CLOSE", self, clicked=self.reject) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_ok = QtGui.QHBoxLayout() + layout_ok = QtWidgets.QHBoxLayout() layout_ok.addWidget(self.ok) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(instructions) layout_0.addLayout(layout_ok) self.setLayout(layout_0) else: - self.instructions = QtGui.QLabel("Pesterlog with " +self.chum+ " on") + self.instructions = QtWidgets.QLabel("Pesterlog with " +self.chum+ " on") self.textArea = PesterLogText(theme, self.parent) self.textArea.setReadOnly(True) @@ -180,15 +171,14 @@ class PesterLogViewer(QtGui.QDialog): self.logList.reverse() self.tree = RightClickTree() - self.tree.optionsMenu = QtGui.QMenu(self) + self.tree.optionsMenu = QtWidgets.QMenu(self) self.tree.setFixedSize(260, 300) self.tree.header().hide() if theme.has_key("convo/scrollbar"): self.tree.setStyleSheet("QTreeWidget { %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: self.tree.setStyleSheet("%s" % (theme["convo/textarea/style"])) - self.connect(self.tree, QtCore.SIGNAL('itemSelectionChanged()'), - self, QtCore.SLOT('loadSelectedLog()')) + self.tree.itemSelectionChanged.connect(self.loadSelectedLog) self.tree.setSortingEnabled(False) child_1 = None @@ -196,11 +186,11 @@ class PesterLogViewer(QtGui.QDialog): for (i,l) in enumerate(self.logList): my = self.fileToMonthYear(l) if my[0] != last[0]: - child_1 = QtGui.QTreeWidgetItem(["%s %s" % (my[0], my[1])]) + child_1 = QtWidgets.QTreeWidgetItem(["%s %s" % (my[0], my[1])]) self.tree.addTopLevelItem(child_1) if i == 0: child_1.setExpanded(True) - child_1.addChild(QtGui.QTreeWidgetItem([self.fileToTime(l)])) + child_1.addChild(QtWidgets.QTreeWidgetItem([self.fileToTime(l)])) last = self.fileToMonthYear(l) self.hilight = PesterLogHighlighter(self.textArea) @@ -208,37 +198,33 @@ class PesterLogViewer(QtGui.QDialog): self.search = PesterLogSearchInput(theme, self) self.search.setFocus() - self.find = QtGui.QPushButton("Find", self) + self.find = QtWidgets.QPushButton("Find", self) font = self.find.font() font.setPointSize(8) self.find.setFont(font) self.find.setDefault(True) self.find.setFixedSize(40, 20) - layout_search = QtGui.QHBoxLayout() + layout_search = QtWidgets.QHBoxLayout() layout_search.addWidget(self.search) layout_search.addWidget(self.find) - self.qdb = QtGui.QPushButton("Pesterchum QDB", self) + self.qdb = QtWidgets.QPushButton("Pesterchum QDB", self, clicked=self.openQDB) self.qdb.setFixedWidth(260) - self.connect(self.qdb, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('openQDB()')) - self.ok = QtGui.QPushButton("CLOSE", self) + self.ok = QtWidgets.QPushButton("CLOSE", self, clicked=self.reject) self.ok.setFixedWidth(80) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_ok = QtGui.QHBoxLayout() + layout_ok = QtWidgets.QHBoxLayout() layout_ok.addWidget(self.qdb) layout_ok.addWidget(self.ok) layout_ok.setAlignment(self.ok, QtCore.Qt.AlignRight) - layout_logs = QtGui.QHBoxLayout() + layout_logs = QtWidgets.QHBoxLayout() layout_logs.addWidget(self.tree) - layout_right = QtGui.QVBoxLayout() + layout_right = QtWidgets.QVBoxLayout() layout_right.addWidget(self.textArea) layout_right.addLayout(layout_search) layout_logs.addLayout(layout_right) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.instructions) layout_0.addLayout(layout_logs) layout_0.addLayout(layout_ok) @@ -284,7 +270,7 @@ class PesterLogText(PesterText): PesterText.__init__(self, theme, parent) def focusInEvent(self, event): - QtGui.QTextEdit.focusInEvent(self, event) + QtWidgets.QTextEdit.focusInEvent(self, event) def mousePressEvent(self, event): url = self.anchorAt(event.pos()) if url != "": @@ -295,9 +281,9 @@ class PesterLogText(PesterText): self.parent().parent.newConversation(handle) else: QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode)) - QtGui.QTextEdit.mousePressEvent(self, event) + QtWidgets.QTextEdit.mousePressEvent(self, event) def mouseMoveEvent(self, event): - QtGui.QTextEdit.mouseMoveEvent(self, event) + QtWidgets.QTextEdit.mouseMoveEvent(self, event) if self.anchorAt(event.pos()): if self.viewport().cursor().shape != QtCore.Qt.PointingHandCursor: self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) @@ -307,9 +293,7 @@ class PesterLogText(PesterText): def contextMenuEvent(self, event): textMenu = self.createStandardContextMenu() if self.textSelected: - self.submitLogAction = QtGui.QAction("Submit to Pesterchum QDB", self) - self.connect(self.submitLogAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('submitLog()')) + self.submitLogAction = QtWidgets.QAction("Submit to Pesterchum QDB", self, triggered=self.submitLog) textMenu.addAction(self.submitLogAction) a = textMenu.actions() a[0].setText("Copy Plain Text") diff --git a/luaquirks.py b/luaquirks.py index b81e386..72cd58f 100644 --- a/luaquirks.py +++ b/luaquirks.py @@ -4,7 +4,7 @@ try: except ImportError: lua = None from quirks import ScriptQuirks -from PyQt4 import QtGui, QtCore +from PyQt5 import QtWidgets class LuaQuirks(ScriptQuirks): def loadModule(self, name, filename): @@ -52,7 +52,7 @@ class LuaQuirks(ScriptQuirks): raise Exception except: print "Quirk malformed: %s" % (name) - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setWindowTitle("Error!") msgbox.setText("Quirk malformed: %s" % (name)) msgbox.exec_() diff --git a/memos.py b/memos.py index 8aa2350..b286c5c 100644 --- a/memos.py +++ b/memos.py @@ -1,7 +1,7 @@ from string import Template import re from copy import copy -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets from datetime import time, timedelta, datetime from mood import Mood @@ -178,15 +178,13 @@ class TimeTracker(list): return TimeGrammar(temporal, pcf, when, 0) return TimeGrammar(temporal, pcf, when, self.getRecord(timed)) -class TimeInput(QtGui.QLineEdit): +class TimeInput(QtWidgets.QLineEdit): def __init__(self, timeslider, parent): - QtGui.QLineEdit.__init__(self, parent) + QtWidgets.QLineEdit.__init__(self, parent) self.timeslider = timeslider self.setText("+0:00") - self.connect(self.timeslider, QtCore.SIGNAL('valueChanged(int)'), - self, QtCore.SLOT('setTime(int)')) - self.connect(self, QtCore.SIGNAL('editingFinished()'), - self, QtCore.SLOT('setSlider()')) + self.timeslider.valueChanged.connect(self.setTime) + self.editingFinished.connect(self.setSlider) @QtCore.pyqtSlot(int) def setTime(self, sliderval): self.setText(self.timeslider.getTime()) @@ -209,9 +207,9 @@ class TimeInput(QtGui.QLineEdit): text = delta2txt(timed) self.setText(text) -class TimeSlider(QtGui.QSlider): +class TimeSlider(QtWidgets.QSlider): def __init__(self, orientation, parent): - QtGui.QSlider.__init__(self, orientation, parent) + QtWidgets.QSlider.__init__(self, orientation, parent) self.setTracking(True) self.setMinimum(-50) self.setMaximum(50) @@ -243,7 +241,7 @@ _ctag_begin = re.compile(r'') class MemoText(PesterText): def __init__(self, theme, parent=None): - QtGui.QTextEdit.__init__(self, parent) + QtWidgets.QTextEdit.__init__(self, parent) if hasattr(self.parent(), 'mainwindow'): self.mainwindow = self.parent().mainwindow else: @@ -257,13 +255,11 @@ class MemoText(PesterText): self.setReadOnly(True) self.setMouseTracking(True) self.textSelected = False - self.connect(self, QtCore.SIGNAL('copyAvailable(bool)'), - self, QtCore.SLOT('textReady(bool)')) + self.copyAvailable.connect(self.textReady) self.urls = {} for k in smiledict: self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k])) - self.connect(self.mainwindow, QtCore.SIGNAL('animationSetting(bool)'), - self, QtCore.SLOT('animateChanged(bool)')) + self.mainwindow.animationSetting.connect(self.animateChanged) def initTheme(self, theme): if theme.has_key("memos/scrollbar"): @@ -343,91 +339,62 @@ class MemoText(PesterText): class MemoInput(PesterInput): def __init__(self, theme, parent=None): - QtGui.QLineEdit.__init__(self, parent) + QtWidgets.QLineEdit.__init__(self, parent) self.setStyleSheet(theme["memos/input/style"]) def changeTheme(self, theme): self.setStyleSheet(theme["memos/input/style"]) class PesterMemo(PesterConvo): def __init__(self, channel, timestr, mainwindow, parent=None): - QtGui.QFrame.__init__(self, parent) + QtWidgets.QFrame.__init__(self, parent) self.setAttribute(QtCore.Qt.WA_QuitOnClose, False) self.channel = channel self.setObjectName(self.channel) self.mainwindow = mainwindow self.time = TimeTracker(txt2delta(timestr)) self.setWindowTitle(channel) - self.channelLabel = QtGui.QLabel(self) - self.channelLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding)) + self.channelLabel = QtWidgets.QLabel(self) + self.channelLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding)) self.textArea = MemoText(self.mainwindow.theme, self) self.textInput = MemoInput(self.mainwindow.theme, self) self.textInput.setFocus() - self.miniUserlist = QtGui.QPushButton(">\n>", self) + self.miniUserlist = QtWidgets.QPushButton(">\n>", self, clicked=self.toggleUserlist) #self.miniUserlist.setStyleSheet("border:1px solid #a68168; border-width: 2px 0px 2px 2px; height: 90px; width: 10px; color: #cd8f9d; font-family: 'Arial'; background: white; margin-left: 2px;") - self.connect(self.miniUserlist, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('toggleUserlist()')) - self.userlist = RightClickList(self) - self.userlist.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)) - self.userlist.optionsMenu = QtGui.QMenu(self) - self.addchumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self) - self.connect(self.addchumAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('addChumSlot()')) - self.banuserAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self) - self.connect(self.banuserAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('banSelectedUser()')) - self.opAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/opuser"], self) - self.connect(self.opAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('opSelectedUser()')) - self.voiceAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/voiceuser"], self) - self.connect(self.voiceAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('voiceSelectedUser()')) - self.quirkDisableAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirkkill"], self) - self.connect(self.quirkDisableAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('killQuirkUser()')) + self.userlist.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)) + self.userlist.optionsMenu = QtWidgets.QMenu(self) + self.addchumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self, triggered=self.addChumSlot) + self.banuserAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self, triggered=self.banSelectedUser) + self.opAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/opuser"], self, triggered=self.opSelectedUser) + self.voiceAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/voiceuser"], self, triggered=self.voiceSelectedUser) + self.quirkDisableAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirkkill"], self, triggered=self.killQuirkUser) self.userlist.optionsMenu.addAction(self.addchumAction) # ban & op list added if we are op - self.optionsMenu = QtGui.QMenu(self) - self.oocToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self) + self.optionsMenu = QtWidgets.QMenu(self) + self.oocToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self, toggled=self.toggleOOC) self.oocToggle.setCheckable(True) - self.connect(self.oocToggle, QtCore.SIGNAL('toggled(bool)'), - self, QtCore.SLOT('toggleOOC(bool)')) - self.quirksOff = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self) + self.quirksOff = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self, toggled=self.toggleQuirks) self.quirksOff.setCheckable(True) - self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'), - self, QtCore.SLOT('toggleQuirks(bool)')) - self.logchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self) - self.connect(self.logchum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('openChumLogs()')) - self.invitechum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/invitechum"], self) - self.connect(self.invitechum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('inviteChums()')) + self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self, triggered=self.openChumLogs) + self.invitechum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/invitechum"], self, triggered=self.inviteChums) self.optionsMenu.addAction(self.quirksOff) self.optionsMenu.addAction(self.oocToggle) self.optionsMenu.addAction(self.logchum) self.optionsMenu.addAction(self.invitechum) - self.chanModeMenu = QtGui.QMenu(self.mainwindow.theme["main/menus/rclickchumlist/memosetting"], self) - self.chanNoquirks = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memonoquirk"], self) + self.chanModeMenu = QtWidgets.QMenu(self.mainwindow.theme["main/menus/rclickchumlist/memosetting"], self) + self.chanNoquirks = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memonoquirk"], self, toggled=self.noquirksChan) self.chanNoquirks.setCheckable(True) - self.connect(self.chanNoquirks, QtCore.SIGNAL('toggled(bool)'), - self, QtCore.SLOT('noquirksChan(bool)')) - self.chanHide = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memohidden"], self) + self.chanHide = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memohidden"], self, toggled=self.hideChan) self.chanHide.setCheckable(True) - self.connect(self.chanHide, QtCore.SIGNAL('toggled(bool)'), - self, QtCore.SLOT('hideChan(bool)')) - self.chanInvite = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memoinvite"], self) + self.chanInvite = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memoinvite"], self, toggled=self.inviteChan) self.chanInvite.setCheckable(True) - self.connect(self.chanInvite, QtCore.SIGNAL('toggled(bool)'), - self, QtCore.SLOT('inviteChan(bool)')) - self.chanMod = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memomute"], self) + self.chanMod = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memomute"], self, toggled=self.modChan) self.chanMod.setCheckable(True) - self.connect(self.chanMod, QtCore.SIGNAL('toggled(bool)'), - self, QtCore.SLOT('modChan(bool)')) self.chanModeMenu.addAction(self.chanNoquirks) self.chanModeMenu.addAction(self.chanHide) self.chanModeMenu.addAction(self.chanInvite) @@ -437,48 +404,38 @@ class PesterMemo(PesterConvo): self.timeinput = TimeInput(self.timeslider, self) self.timeinput.setText(timestr) self.timeinput.setSlider() - self.timetravel = QtGui.QPushButton("GO", self) - self.timeclose = QtGui.QPushButton("CLOSE", self) - self.timeswitchl = QtGui.QPushButton(self) - self.timeswitchr = QtGui.QPushButton(self) - - self.connect(self.timetravel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('sendtime()')) - self.connect(self.timeclose, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('smashclock()')) - self.connect(self.timeswitchl, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('prevtime()')) - self.connect(self.timeswitchr, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('nexttime()')) + self.timetravel = QtWidgets.QPushButton("GO", self, clicked=self.sendtime) + self.timeclose = QtWidgets.QPushButton("CLOSE", self, clicked=self.smashclock) + self.timeswitchl = QtWidgets.QPushButton(self, clicked=self.prevtime) + self.timeswitchr = QtWidgets.QPushButton(self, clicked=self.nexttime) self.times = {} self.initTheme(self.mainwindow.theme) # connect - self.connect(self.textInput, QtCore.SIGNAL('returnPressed()'), - self, QtCore.SLOT('sentMessage()')) + self.textInput.returnPressed.connect(self.sentMessage) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.textArea) layout_0.addWidget(self.textInput) - layout_1 = QtGui.QHBoxLayout() + layout_1 = QtWidgets.QHBoxLayout() layout_1.addLayout(layout_0) layout_1.addWidget(self.miniUserlist) layout_1.addWidget(self.userlist) -# layout_1 = QtGui.QGridLayout() +# layout_1 = QtWidgets.QGridLayout() # layout_1.addWidget(self.timeslider, 0, 1, QtCore.Qt.AlignHCenter) # layout_1.addWidget(self.timeinput, 1, 0, 1, 3) - layout_2 = QtGui.QHBoxLayout() + layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self.timeslider) layout_2.addWidget(self.timeinput) layout_2.addWidget(self.timetravel) layout_2.addWidget(self.timeclose) layout_2.addWidget(self.timeswitchl) layout_2.addWidget(self.timeswitchr) - self.layout = QtGui.QVBoxLayout() + self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.channelLabel) self.layout.addLayout(layout_1) @@ -538,7 +495,7 @@ class PesterMemo(PesterConvo): def updateColor(self, handle, color): chums = self.userlist.findItems(handle, QtCore.Qt.MatchFlags(0)) for c in chums: - c.setTextColor(color) + c.setForeground(QtGui.QBrush(color)) def addMessage(self, text, handle): if type(handle) is bool: chum = self.mainwindow.profile() @@ -653,13 +610,13 @@ class PesterMemo(PesterConvo): elif handle[0] == '&': admin = True handle = handle[1:] - item = QtGui.QListWidgetItem(handle) + item = QtWidgets.QListWidgetItem(handle) if handle == self.mainwindow.profile().handle: color = self.mainwindow.profile().color else: color = chumdb.getColor(handle, defaultcolor) item.box = (handle == "evacipatedBox") - item.setTextColor(color) + item.setForeground(QtGui.QBrush(color)) item.founder = founder item.op = op item.halfop = halfop @@ -835,7 +792,7 @@ class PesterMemo(PesterConvo): self.messageSent.emit(serverText, self.title()) self.textInput.setText("") - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def namesUpdated(self, channel): c = unicode(channel) if c.lower() != self.channel.lower(): return @@ -845,28 +802,27 @@ class PesterMemo(PesterConvo): self.userlist.clear() for n in self.mainwindow.namesdb[self.channel]: self.addUser(n) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def modesUpdated(self, channel, modes): c = unicode(channel) if c.lower() == self.channel.lower(): self.updateChanModes(modes, None) - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def closeInviteOnly(self, channel): c = unicode(channel) if c.lower() == self.channel.lower(): - self.disconnect(self.mainwindow, QtCore.SIGNAL('inviteOnlyChan(QString)'), - self, QtCore.SLOT('closeInviteOnly(QString)')) + self.mainwindow.inviteOnlyChan.disconnect(self.closeInviteOnly) if self.parent(): print self.channel i = self.parent().tabIndices[self.channel] self.parent().tabClose(i) else: self.close() - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() 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(QtGui.QMessageBox.Ok) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) ret = msgbox.exec_() def quirkDisable(self, op, msg): @@ -929,7 +885,7 @@ class PesterMemo(PesterConvo): self.mainwindow.chatlog.log(self.channel, msg) del self.netsplit - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString', 'QString') def userPresentChange(self, handle, channel, update): h = unicode(handle) c = unicode(channel) @@ -960,7 +916,7 @@ class PesterMemo(PesterConvo): if update == "netsplit": if not hasattr(self, "netsplit"): self.netsplit = [] - QtCore.QTimer.singleShot(1500, self, QtCore.SLOT('dumpNetsplit()')) + QtCore.QTimer.singleShot(1500, self.dumpNetsplit) for c in chums: chum = PesterProfile(h) self.userlist.takeItem(self.userlist.row(c)) @@ -1020,12 +976,12 @@ class PesterMemo(PesterConvo): if chum is self.mainwindow.profile(): # are you next? - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setText(self.mainwindow.theme["convo/text/kickedmemo"]) msgbox.setInformativeText("press 0k to rec0nnect or cancel to absc0nd") - msgbox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) ret = msgbox.exec_() - if ret == QtGui.QMessageBox.Ok: + if ret == QtWidgets.QMessageBox.Ok: self.userlist.clear() self.time = TimeTracker(curtime) self.resetSlider(curtime) @@ -1035,7 +991,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 == QtGui.QMessageBox.Cancel: + elif ret == QtWidgets.QMessageBox.Cancel: if self.parent(): i = self.parent().tabIndices[self.channel] self.parent().tabClose(i) @@ -1171,7 +1127,7 @@ class PesterMemo(PesterConvo): if not self.userlist.currentItem(): return currentHandle = unicode(self.userlist.currentItem().text()) - (reason, ok) = QtGui.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: self.mainwindow.kickUser.emit("%s:%s" % (currentHandle, reason), self.channel) @QtCore.pyqtSlot() @@ -1203,8 +1159,7 @@ class PesterMemo(PesterConvo): def openChumLogs(self): currentChum = self.channel self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) - self.connect(self.mainwindow.chumList.pesterlogviewer, QtCore.SIGNAL('rejected()'), - self.mainwindow.chumList, QtCore.SLOT('closeActiveLog()')) + self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog) self.mainwindow.chumList.pesterlogviewer.show() self.mainwindow.chumList.pesterlogviewer.raise_() self.mainwindow.chumList.pesterlogviewer.activateWindow() @@ -1214,7 +1169,7 @@ class PesterMemo(PesterConvo): if not hasattr(self, 'invitechums'): self.invitechums = None if not self.invitechums: - (chum, ok) = QtGui.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: chum = unicode(chum) self.mainwindow.inviteChum.emit(chum, self.channel) @@ -1280,7 +1235,7 @@ class PesterMemo(PesterConvo): self.mainwindow.waitingMessages.messageAnswered(self.channel) self.windowClosed.emit(self.title()) - windowClosed = QtCore.pyqtSignal(QtCore.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"] diff --git a/menus.py b/menus.py index 8e542e1..1ff01d6 100644 --- a/menus.py +++ b/menus.py @@ -1,4 +1,4 @@ -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets import re, ostools from os import remove @@ -9,10 +9,10 @@ from version import _pcVersion _datadir = ostools.getDataDir() -class PesterQuirkItem(QtGui.QTreeWidgetItem): +class PesterQuirkItem(QtWidgets.QTreeWidgetItem): def __init__(self, quirk): parent = None - QtGui.QTreeWidgetItem.__init__(self, parent) + QtWidgets.QTreeWidgetItem.__init__(self, parent) self.quirk = quirk self.setText(0, unicode(quirk)) def update(self, quirk): @@ -27,16 +27,15 @@ class PesterQuirkItem(QtGui.QTreeWidgetItem): return True else: return False -class PesterQuirkList(QtGui.QTreeWidget): +class PesterQuirkList(QtWidgets.QTreeWidget): def __init__(self, mainwindow, parent): - QtGui.QTreeWidget.__init__(self, parent) + QtWidgets.QTreeWidget.__init__(self, parent) self.resize(400, 200) # make sure we have access to mainwindow info like profiles self.mainwindow = mainwindow self.setStyleSheet("background:black; color:white;") - self.connect(self, QtCore.SIGNAL('itemChanged(QTreeWidgetItem *, int)'), - self, QtCore.SLOT('changeCheckState()')) + self.itemChanged.connect(self.changeCheckState) for q in mainwindow.userprofile.quirks: item = PesterQuirkItem(q) @@ -64,10 +63,10 @@ class PesterQuirkList(QtGui.QTreeWidget): if len(found) > 0: found[0].addChild(item) else: - child_1 = QtGui.QTreeWidgetItem([item.quirk.group]) + child_1 = QtWidgets.QTreeWidgetItem([item.quirk.group]) self.addTopLevelItem(child_1) child_1.setFlags(child_1.flags() | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) - child_1.setChildIndicatorPolicy(QtGui.QTreeWidgetItem.DontShowIndicatorWhenChildless) + child_1.setChildIndicatorPolicy(QtWidgets.QTreeWidgetItem.DontShowIndicatorWhenChildless) child_1.setCheckState(0,0) child_1.setExpanded(True) child_1.addChild(item) @@ -145,13 +144,13 @@ class PesterQuirkList(QtGui.QTreeWidget): for f in found: if not f.isSelected(): continue if not f.parent(): # group - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) msgbox.setWindowTitle("WARNING!") msgbox.setInformativeText("Are you sure you want to delete the quirk group: %s" % (f.text(0))) - msgbox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) ret = msgbox.exec_() - if ret == QtGui.QMessageBox.Ok: + if ret == QtWidgets.QMessageBox.Ok: self.takeTopLevelItem(self.indexOfTopLevelItem(f)) else: f.parent().takeChild(f.parent().indexOfChild(f)) @@ -162,27 +161,27 @@ class PesterQuirkList(QtGui.QTreeWidget): if not hasattr(self, 'addgroupdialog'): self.addgroupdialog = None if not self.addgroupdialog: - (gname, ok) = QtGui.QInputDialog.getText(self, "Add Group", "Enter a name for the new quirk group:") + (gname, ok) = QtWidgets.QInputDialog.getText(self, "Add Group", "Enter a name for the new quirk group:") if ok: gname = unicode(gname) if re.search("[^A-Za-z0-9_\s]", gname) is not None: - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME") - msgbox.setStandardButtons(QtGui.QMessageBox.Ok) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) ret = msgbox.exec_() self.addgroupdialog = None return found = self.findItems(gname, QtCore.Qt.MatchExactly) if found: - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setInformativeText("THIS QUIRK GROUP ALREADY EXISTS") - msgbox.setStandardButtons(QtGui.QMessageBox.Ok) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) ret = msgbox.exec_() return - child_1 = QtGui.QTreeWidgetItem([gname]) + child_1 = QtWidgets.QTreeWidgetItem([gname]) self.addTopLevelItem(child_1) child_1.setFlags(child_1.flags() | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) - child_1.setChildIndicatorPolicy(QtGui.QTreeWidgetItem.DontShowIndicatorWhenChildless) + child_1.setChildIndicatorPolicy(QtWidgets.QTreeWidgetItem.DontShowIndicatorWhenChildless) child_1.setCheckState(0,0) child_1.setExpanded(True) @@ -212,9 +211,9 @@ from copy import copy from convo import PesterInput, PesterText from parsetools import convertTags, lexMessage, splitMessage, mecmd, colorBegin, colorEnd, img2smiley, smiledict from dataobjs import pesterQuirks, PesterHistory -class QuirkTesterWindow(QtGui.QDialog): +class QuirkTesterWindow(QtWidgets.QDialog): def __init__(self, parent): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.prnt = parent self.mainwindow = parent.mainwindow self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) @@ -225,14 +224,13 @@ class QuirkTesterWindow(QtGui.QDialog): self.textInput = PesterInput(self.mainwindow.theme, self) self.textInput.setFocus() - self.connect(self.textInput, QtCore.SIGNAL('returnPressed()'), - self, QtCore.SLOT('sentMessage()')) + self.textInput.returnPressed.connect(self.sentMessage) self.chumopen = True self.chum = self.mainwindow.profile() self.history = PesterHistory() - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.textArea) layout_0.addWidget(self.textInput) self.setLayout(layout_0) @@ -254,7 +252,7 @@ class QuirkTesterWindow(QtGui.QDialog): try: lexmsg = quirks.apply(lexmsg) except Exception, e: - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setText("Whoa there! There seems to be a problem.") msgbox.setInformativeText("A quirk seems to be having a problem. (Possibly you're trying to capture a non-existant group?)\n\ %s" % e) @@ -281,45 +279,39 @@ class QuirkTesterWindow(QtGui.QDialog): def closeEvent(self, event): self.parent().quirktester = None -class PesterQuirkTypes(QtGui.QDialog): +class PesterQuirkTypes(QtWidgets.QDialog): def __init__(self, parent, quirk=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.mainwindow = parent.mainwindow self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) self.setWindowTitle("Quirk Wizard") self.resize(500,310) self.quirk = quirk - self.pages = QtGui.QStackedWidget(self) + self.pages = QtWidgets.QStackedWidget(self) - self.next = QtGui.QPushButton("Next", self) + self.next = QtWidgets.QPushButton("Next", self, clicked=self.nextPage) self.next.setDefault(True) - self.connect(self.next, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('nextPage()')) - self.back = QtGui.QPushButton("Back", self) + self.back = QtWidgets.QPushButton("Back", self, clicked=self.backPage) self.back.setEnabled(False) - self.connect(self.back, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('backPage()')) - self.cancel = QtGui.QPushButton("Cancel", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_2 = QtGui.QHBoxLayout() + self.cancel = QtWidgets.QPushButton("Cancel", self, clicked=self.reject) + layout_2 = QtWidgets.QHBoxLayout() layout_2.setAlignment(QtCore.Qt.AlignRight) layout_2.addWidget(self.back) layout_2.addWidget(self.next) layout_2.addSpacing(5) layout_2.addWidget(self.cancel) - vr = QtGui.QFrame() - vr.setFrameShape(QtGui.QFrame.VLine) - vr.setFrameShadow(QtGui.QFrame.Sunken) - vr2 = QtGui.QFrame() - vr2.setFrameShape(QtGui.QFrame.VLine) - vr2.setFrameShadow(QtGui.QFrame.Sunken) + vr = QtWidgets.QFrame() + vr.setFrameShape(QtWidgets.QFrame.VLine) + vr.setFrameShadow(QtWidgets.QFrame.Sunken) + vr2 = QtWidgets.QFrame() + vr2.setFrameShape(QtWidgets.QFrame.VLine) + vr2.setFrameShadow(QtWidgets.QFrame.Sunken) - self.funclist = QtGui.QListWidget(self) + self.funclist = QtWidgets.QListWidget(self) self.funclist.setStyleSheet("color: #000000; background-color: #FFFFFF;") - self.funclist2 = QtGui.QListWidget(self) + self.funclist2 = QtWidgets.QListWidget(self) self.funclist2.setStyleSheet("color: #000000; background-color: #FFFFFF;") from parsetools import quirkloader @@ -328,127 +320,119 @@ class PesterQuirkTypes(QtGui.QDialog): self.funclist.addItems(funcs) self.funclist2.addItems(funcs) - self.reloadQuirkFuncButton = QtGui.QPushButton("RELOAD FUNCTIONS", self) - self.connect(self.reloadQuirkFuncButton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reloadQuirkFuncSlot()')) - self.reloadQuirkFuncButton2 = QtGui.QPushButton("RELOAD FUNCTIONS", self) - self.connect(self.reloadQuirkFuncButton2, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reloadQuirkFuncSlot()')) + self.reloadQuirkFuncButton = QtWidgets.QPushButton("RELOAD FUNCTIONS", self, clicked=self.reloadQuirkFuncSlot) + self.reloadQuirkFuncButton2 = QtWidgets.QPushButton("RELOAD FUNCTIONS", self, clicked=self.reloadQuirkFuncSlot) self.funclist.setMaximumWidth(160) self.funclist.resize(160,50) self.funclist2.setMaximumWidth(160) self.funclist2.resize(160,50) - layout_f = QtGui.QVBoxLayout() - layout_f.addWidget(QtGui.QLabel("Available Regexp\nFunctions")) + layout_f = QtWidgets.QVBoxLayout() + layout_f.addWidget(QtWidgets.QLabel("Available Regexp\nFunctions")) layout_f.addWidget(self.funclist) layout_f.addWidget(self.reloadQuirkFuncButton) - layout_g = QtGui.QVBoxLayout() - layout_g.addWidget(QtGui.QLabel("Available Regexp\nFunctions")) + layout_g = QtWidgets.QVBoxLayout() + layout_g.addWidget(QtWidgets.QLabel("Available Regexp\nFunctions")) layout_g.addWidget(self.funclist2) layout_g.addWidget(self.reloadQuirkFuncButton2) # Pages # Type select - widget = QtGui.QWidget() + widget = QtWidgets.QWidget() self.pages.addWidget(widget) - layout_select = QtGui.QVBoxLayout(widget) + layout_select = QtWidgets.QVBoxLayout(widget) layout_select.setAlignment(QtCore.Qt.AlignTop) self.radios = [] - self.radios.append(QtGui.QRadioButton("Prefix", self)) - self.radios.append(QtGui.QRadioButton("Suffix", self)) - self.radios.append(QtGui.QRadioButton("Simple Replace", self)) - self.radios.append(QtGui.QRadioButton("Regexp Replace", self)) - self.radios.append(QtGui.QRadioButton("Random Replace", self)) - self.radios.append(QtGui.QRadioButton("Mispeller", self)) + self.radios.append(QtWidgets.QRadioButton("Prefix", self)) + self.radios.append(QtWidgets.QRadioButton("Suffix", self)) + self.radios.append(QtWidgets.QRadioButton("Simple Replace", self)) + self.radios.append(QtWidgets.QRadioButton("Regexp Replace", self)) + self.radios.append(QtWidgets.QRadioButton("Random Replace", self)) + self.radios.append(QtWidgets.QRadioButton("Mispeller", self)) - layout_select.addWidget(QtGui.QLabel("Select Quirk Type:")) + layout_select.addWidget(QtWidgets.QLabel("Select Quirk Type:")) for r in self.radios: layout_select.addWidget(r) # Prefix - widget = QtGui.QWidget() + widget = QtWidgets.QWidget() self.pages.addWidget(widget) - layout_prefix = QtGui.QVBoxLayout(widget) + layout_prefix = QtWidgets.QVBoxLayout(widget) layout_prefix.setAlignment(QtCore.Qt.AlignTop) - layout_prefix.addWidget(QtGui.QLabel("Prefix")) - layout_3 = QtGui.QHBoxLayout() - layout_3.addWidget(QtGui.QLabel("Value:")) - layout_3.addWidget(QtGui.QLineEdit()) + layout_prefix.addWidget(QtWidgets.QLabel("Prefix")) + layout_3 = QtWidgets.QHBoxLayout() + layout_3.addWidget(QtWidgets.QLabel("Value:")) + layout_3.addWidget(QtWidgets.QLineEdit()) layout_prefix.addLayout(layout_3) # Suffix - widget = QtGui.QWidget() + widget = QtWidgets.QWidget() self.pages.addWidget(widget) - layout_suffix = QtGui.QVBoxLayout(widget) + layout_suffix = QtWidgets.QVBoxLayout(widget) layout_suffix.setAlignment(QtCore.Qt.AlignTop) - layout_suffix.addWidget(QtGui.QLabel("Suffix")) - layout_3 = QtGui.QHBoxLayout() - layout_3.addWidget(QtGui.QLabel("Value:")) - layout_3.addWidget(QtGui.QLineEdit()) + layout_suffix.addWidget(QtWidgets.QLabel("Suffix")) + layout_3 = QtWidgets.QHBoxLayout() + layout_3.addWidget(QtWidgets.QLabel("Value:")) + layout_3.addWidget(QtWidgets.QLineEdit()) layout_suffix.addLayout(layout_3) # Simple Replace - widget = QtGui.QWidget() + widget = QtWidgets.QWidget() self.pages.addWidget(widget) - layout_replace = QtGui.QVBoxLayout(widget) + layout_replace = QtWidgets.QVBoxLayout(widget) layout_replace.setAlignment(QtCore.Qt.AlignTop) - layout_replace.addWidget(QtGui.QLabel("Simple Replace")) - layout_3 = QtGui.QHBoxLayout() - layout_3.addWidget(QtGui.QLabel("Replace:")) - layout_3.addWidget(QtGui.QLineEdit()) + layout_replace.addWidget(QtWidgets.QLabel("Simple Replace")) + layout_3 = QtWidgets.QHBoxLayout() + layout_3.addWidget(QtWidgets.QLabel("Replace:")) + layout_3.addWidget(QtWidgets.QLineEdit()) layout_replace.addLayout(layout_3) - layout_3 = QtGui.QHBoxLayout() - layout_3.addWidget(QtGui.QLabel("With:")) - layout_3.addWidget(QtGui.QLineEdit()) + layout_3 = QtWidgets.QHBoxLayout() + layout_3.addWidget(QtWidgets.QLabel("With:")) + layout_3.addWidget(QtWidgets.QLineEdit()) layout_replace.addLayout(layout_3) # Regexp Replace - widget = QtGui.QWidget() + widget = QtWidgets.QWidget() self.pages.addWidget(widget) - layout_all = QtGui.QHBoxLayout(widget) - layout_regexp = QtGui.QVBoxLayout() + layout_all = QtWidgets.QHBoxLayout(widget) + layout_regexp = QtWidgets.QVBoxLayout() layout_regexp.setAlignment(QtCore.Qt.AlignTop) - layout_regexp.addWidget(QtGui.QLabel("Regexp Replace")) - layout_3 = QtGui.QHBoxLayout() - layout_3.addWidget(QtGui.QLabel("Regexp:")) - layout_3.addWidget(QtGui.QLineEdit()) + layout_regexp.addWidget(QtWidgets.QLabel("Regexp Replace")) + layout_3 = QtWidgets.QHBoxLayout() + layout_3.addWidget(QtWidgets.QLabel("Regexp:")) + layout_3.addWidget(QtWidgets.QLineEdit()) layout_regexp.addLayout(layout_3) - layout_3 = QtGui.QHBoxLayout() - layout_3.addWidget(QtGui.QLabel("Replace With:")) - layout_3.addWidget(QtGui.QLineEdit()) + layout_3 = QtWidgets.QHBoxLayout() + layout_3.addWidget(QtWidgets.QLabel("Replace With:")) + layout_3.addWidget(QtWidgets.QLineEdit()) layout_regexp.addLayout(layout_3) layout_all.addLayout(layout_f) layout_all.addWidget(vr) layout_all.addLayout(layout_regexp) # Random Replace - widget = QtGui.QWidget() + widget = QtWidgets.QWidget() self.pages.addWidget(widget) - layout_all = QtGui.QHBoxLayout(widget) - layout_random = QtGui.QVBoxLayout() + layout_all = QtWidgets.QHBoxLayout(widget) + layout_random = QtWidgets.QVBoxLayout() layout_random.setAlignment(QtCore.Qt.AlignTop) - layout_random.addWidget(QtGui.QLabel("Random Replace")) - layout_5 = QtGui.QHBoxLayout() - regexpl = QtGui.QLabel("Regexp:", self) - self.regexp = QtGui.QLineEdit("", self) + layout_random.addWidget(QtWidgets.QLabel("Random Replace")) + layout_5 = QtWidgets.QHBoxLayout() + regexpl = QtWidgets.QLabel("Regexp:", self) + self.regexp = QtWidgets.QLineEdit("", self) layout_5.addWidget(regexpl) layout_5.addWidget(self.regexp) - replacewithl = QtGui.QLabel("Replace With:", self) + replacewithl = QtWidgets.QLabel("Replace With:", self) layout_all.addLayout(layout_g) layout_all.addWidget(vr2) layout_all.addLayout(layout_random) - layout_6 = QtGui.QVBoxLayout() - layout_7 = QtGui.QHBoxLayout() - self.replacelist = QtGui.QListWidget(self) - self.replaceinput = QtGui.QLineEdit(self) - addbutton = QtGui.QPushButton("ADD", self) - self.connect(addbutton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('addRandomString()')) - removebutton = QtGui.QPushButton("REMOVE", self) - self.connect(removebutton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('removeRandomString()')) + layout_6 = QtWidgets.QVBoxLayout() + layout_7 = QtWidgets.QHBoxLayout() + self.replacelist = QtWidgets.QListWidget(self) + self.replaceinput = QtWidgets.QLineEdit(self) + addbutton = QtWidgets.QPushButton("ADD", self, clicked=self.addRandomString) + removebutton = QtWidgets.QPushButton("REMOVE", self, clicked=self.removeRandomString) layout_7.addWidget(addbutton) layout_7.addWidget(removebutton) layout_6.addLayout(layout_5) @@ -459,29 +443,27 @@ class PesterQuirkTypes(QtGui.QDialog): layout_random.addLayout(layout_6) # Misspeller - widget = QtGui.QWidget() + widget = QtWidgets.QWidget() self.pages.addWidget(widget) - layout_mispeller = QtGui.QVBoxLayout(widget) + layout_mispeller = QtWidgets.QVBoxLayout(widget) layout_mispeller.setAlignment(QtCore.Qt.AlignTop) - layout_mispeller.addWidget(QtGui.QLabel("Mispeller")) - layout_1 = QtGui.QHBoxLayout() - zero = QtGui.QLabel("1%", self) - hund = QtGui.QLabel("100%", self) - self.current = QtGui.QLabel("50%", self) + layout_mispeller.addWidget(QtWidgets.QLabel("Mispeller")) + layout_1 = QtWidgets.QHBoxLayout() + zero = QtWidgets.QLabel("1%", self) + hund = QtWidgets.QLabel("100%", self) + self.current = QtWidgets.QLabel("50%", self) self.current.setAlignment(QtCore.Qt.AlignHCenter) - self.slider = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self, valueChanged=self.printValue) self.slider.setMinimum(1) self.slider.setMaximum(100) self.slider.setValue(50) - self.connect(self.slider, QtCore.SIGNAL('valueChanged(int)'), - self, QtCore.SLOT('printValue(int)')) layout_1.addWidget(zero) layout_1.addWidget(self.slider) layout_1.addWidget(hund) layout_mispeller.addLayout(layout_1) layout_mispeller.addWidget(self.current) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.pages) layout_0.addLayout(layout_2) @@ -504,7 +486,7 @@ class PesterQuirkTypes(QtGui.QDialog): elif q["type"] == "random": self.regexp.setText(q["from"]) for v in q["randomlist"]: - item = QtGui.QListWidgetItem(v, self.replacelist) + item = QtWidgets.QListWidgetItem(v, self.replacelist) elif q["type"] == "spelling": self.slider.setValue(q["percentage"]) @@ -546,7 +528,7 @@ class PesterQuirkTypes(QtGui.QDialog): @QtCore.pyqtSlot() def addRandomString(self): text = unicode(self.replaceinput.text()) - item = QtGui.QListWidgetItem(text, self.replacelist) + item = QtWidgets.QListWidgetItem(text, self.replacelist) self.replaceinput.setText("") self.replaceinput.setFocus() @QtCore.pyqtSlot() @@ -568,9 +550,9 @@ class PesterQuirkTypes(QtGui.QDialog): self.funclist2.clear() self.funclist2.addItems(funcs) -class PesterChooseQuirks(QtGui.QDialog): +class PesterChooseQuirks(QtWidgets.QDialog): def __init__(self, config, theme, parent): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setModal(False) self.config = config self.theme = theme @@ -580,61 +562,43 @@ class PesterChooseQuirks(QtGui.QDialog): self.quirkList = PesterQuirkList(self.mainwindow, self) - self.addQuirkButton = QtGui.QPushButton("ADD QUIRK", self) - self.connect(self.addQuirkButton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('addQuirkDialog()')) + self.addQuirkButton = QtWidgets.QPushButton("ADD QUIRK", self, clicked=self.addQuirkDialog) - self.upShiftButton = QtGui.QPushButton("^", self) - self.downShiftButton = QtGui.QPushButton("v", self) + self.upShiftButton = QtWidgets.QPushButton("^", self, clicked=self.quirkList.upShiftQuirk) + self.downShiftButton = QtWidgets.QPushButton("v", self, clicked=self.quirkList.downShiftQuirk) self.upShiftButton.setToolTip("Move quirk up one") self.downShiftButton.setToolTip("Move quirk down one") - self.connect(self.upShiftButton, QtCore.SIGNAL('clicked()'), - self.quirkList, QtCore.SLOT('upShiftQuirk()')) - self.connect(self.downShiftButton, QtCore.SIGNAL('clicked()'), - self.quirkList, QtCore.SLOT('downShiftQuirk()')) - self.newGroupButton = QtGui.QPushButton("*", self) + self.newGroupButton = QtWidgets.QPushButton("*", self, clicked=self.quirkList.addQuirkGroup) self.newGroupButton.setToolTip("New Quirk Group") - self.connect(self.newGroupButton, QtCore.SIGNAL('clicked()'), - self.quirkList, QtCore.SLOT('addQuirkGroup()')) - layout_quirklist = QtGui.QHBoxLayout() #the nude layout quirklist - layout_shiftbuttons = QtGui.QVBoxLayout() #the shift button layout + layout_quirklist = QtWidgets.QHBoxLayout() #the nude layout quirklist + layout_shiftbuttons = QtWidgets.QVBoxLayout() #the shift button layout layout_shiftbuttons.addWidget(self.upShiftButton) layout_shiftbuttons.addWidget(self.newGroupButton) layout_shiftbuttons.addWidget(self.downShiftButton) layout_quirklist.addWidget(self.quirkList) layout_quirklist.addLayout(layout_shiftbuttons) - layout_1 = QtGui.QHBoxLayout() + layout_1 = QtWidgets.QHBoxLayout() layout_1.addWidget(self.addQuirkButton) - self.editSelectedButton = QtGui.QPushButton("EDIT", self) - self.connect(self.editSelectedButton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('editSelected()')) - self.removeSelectedButton = QtGui.QPushButton("REMOVE", self) - self.connect(self.removeSelectedButton, QtCore.SIGNAL('clicked()'), - self.quirkList, QtCore.SLOT('removeCurrent()')) - layout_3 = QtGui.QHBoxLayout() + self.editSelectedButton = QtWidgets.QPushButton("EDIT", self, clicked=self.editSelected) + self.removeSelectedButton = QtWidgets.QPushButton("REMOVE", self, clicked=self.quirkList.removeCurrent) + layout_3 = QtWidgets.QHBoxLayout() layout_3.addWidget(self.editSelectedButton) layout_3.addWidget(self.removeSelectedButton) - self.ok = QtGui.QPushButton("OK", self) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.accept) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('accept()')) - self.test = QtGui.QPushButton("TEST QUIRKS", self) - self.connect(self.test, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('testQuirks()')) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_ok = QtGui.QHBoxLayout() + self.test = QtWidgets.QPushButton("TEST QUIRKS", self, clicked=self.testQuirks) + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + layout_ok = QtWidgets.QHBoxLayout() layout_ok.addWidget(self.cancel) layout_ok.addWidget(self.test) layout_ok.addWidget(self.ok) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addLayout(layout_quirklist) layout_0.addLayout(layout_1) #layout_0.addLayout(layout_2) @@ -682,10 +646,8 @@ class PesterChooseQuirks(QtGui.QDialog): if self.quirkadd: return self.quirkadd = PesterQuirkTypes(self, quirk) - self.connect(self.quirkadd, QtCore.SIGNAL('accepted()'), - self, QtCore.SLOT('addQuirk()')) - self.connect(self.quirkadd, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('closeQuirk()')) + self.quirkadd.accepted.connect(self.addQuirk) + self.quirkadd.rejected.connect(self.closeQuirk) self.quirkadd.show() @QtCore.pyqtSlot() def addQuirk(self): @@ -713,7 +675,7 @@ class PesterChooseQuirks(QtGui.QDialog): try: re.compile(vdict["from"]) except re.error, e: - quirkWarning = QtGui.QMessageBox(self) + quirkWarning = QtWidgets.QMessageBox(self) quirkWarning.setText("Not a valid regular expression!") quirkWarning.setInformativeText("H3R3S WHY DUMP4SS: %s" % (e)) quirkWarning.exec_() @@ -731,67 +693,59 @@ class PesterChooseQuirks(QtGui.QDialog): def closeQuirk(self): self.quirkadd = None -class PesterChooseTheme(QtGui.QDialog): +class PesterChooseTheme(QtWidgets.QDialog): def __init__(self, config, theme, parent): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.config = config self.theme = theme self.parent = parent self.setStyleSheet(self.theme["main/defaultwindow/style"]) self.setWindowTitle("Pick a theme") - instructions = QtGui.QLabel("Pick a theme:") + instructions = QtWidgets.QLabel("Pick a theme:") avail_themes = config.availableThemes() - self.themeBox = QtGui.QComboBox(self) + self.themeBox = QtWidgets.QComboBox(self) for (i, t) in enumerate(avail_themes): self.themeBox.addItem(t) if t == theme.name: self.themeBox.setCurrentIndex(i) - self.ok = QtGui.QPushButton("OK", self) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.accept) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('accept()')) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_ok = QtGui.QHBoxLayout() + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + layout_ok = QtWidgets.QHBoxLayout() layout_ok.addWidget(self.cancel) layout_ok.addWidget(self.ok) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(instructions) layout_0.addWidget(self.themeBox) layout_0.addLayout(layout_ok) self.setLayout(layout_0) - self.connect(self, QtCore.SIGNAL('accepted()'), - parent, QtCore.SLOT('themeSelected()')) - self.connect(self, QtCore.SIGNAL('rejected()'), - parent, QtCore.SLOT('closeTheme()')) + self.accepted.connect(parent.themeSelected) + self.rejected.connect(parent.closeTheme) -class PesterChooseProfile(QtGui.QDialog): +class PesterChooseProfile(QtWidgets.QDialog): def __init__(self, userprofile, config, theme, parent, collision=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.userprofile = userprofile self.theme = theme self.config = config self.parent = parent self.setStyleSheet(self.theme["main/defaultwindow/style"]) - self.currentHandle = QtGui.QLabel("CHANGING FROM %s" % userprofile.chat.handle) - self.chumHandle = QtGui.QLineEdit(self) + self.currentHandle = QtWidgets.QLabel("CHANGING FROM %s" % userprofile.chat.handle) + self.chumHandle = QtWidgets.QLineEdit(self) self.chumHandle.setMinimumWidth(200) - self.chumHandleLabel = QtGui.QLabel(self.theme["main/mychumhandle/label/text"], self) - self.chumColorButton = QtGui.QPushButton(self) + self.chumHandleLabel = QtWidgets.QLabel(self.theme["main/mychumhandle/label/text"], self) + self.chumColorButton = QtWidgets.QPushButton(self, clicked=self.openColorDialog) self.chumColorButton.resize(50, 20) self.chumColorButton.setStyleSheet("background: %s" % (userprofile.chat.colorhtml())) self.chumcolor = userprofile.chat.color - self.connect(self.chumColorButton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('openColorDialog()')) - layout_1 = QtGui.QHBoxLayout() + layout_1 = QtWidgets.QHBoxLayout() layout_1.addWidget(self.chumHandleLabel) layout_1.addWidget(self.chumHandle) layout_1.addWidget(self.chumColorButton) @@ -799,62 +753,54 @@ class PesterChooseProfile(QtGui.QDialog): # available profiles? avail_profiles = self.config.availableProfiles() if avail_profiles: - self.profileBox = QtGui.QComboBox(self) + self.profileBox = QtWidgets.QComboBox(self) self.profileBox.addItem("Choose a profile...") for p in avail_profiles: self.profileBox.addItem(p.chat.handle) else: self.profileBox = None - self.defaultcheck = QtGui.QCheckBox(self) - self.defaultlabel = QtGui.QLabel("Set This Profile As Default", self) - layout_2 = QtGui.QHBoxLayout() + self.defaultcheck = QtWidgets.QCheckBox(self) + self.defaultlabel = QtWidgets.QLabel("Set This Profile As Default", self) + layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self.defaultlabel) layout_2.addWidget(self.defaultcheck) - self.ok = QtGui.QPushButton("OK", self) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.validateProfile) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('validateProfile()')) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) if not collision and avail_profiles: - self.delete = QtGui.QPushButton("DELETE", self) - self.connect(self.delete, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('deleteProfile()')) - layout_ok = QtGui.QHBoxLayout() + self.delete = QtWidgets.QPushButton("DELETE", self, clicked=self.deleteProfile) + layout_ok = QtWidgets.QHBoxLayout() layout_ok.addWidget(self.cancel) layout_ok.addWidget(self.ok) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() if collision: - collision_warning = QtGui.QLabel("%s is taken already! Pick a new profile." % (collision)) + collision_warning = QtWidgets.QLabel("%s is taken already! Pick a new profile." % (collision)) layout_0.addWidget(collision_warning) else: layout_0.addWidget(self.currentHandle, alignment=QtCore.Qt.AlignHCenter) layout_0.addLayout(layout_1) if avail_profiles: - profileLabel = QtGui.QLabel("Or choose an existing profile:", self) + profileLabel = QtWidgets.QLabel("Or choose an existing profile:", self) layout_0.addWidget(profileLabel) layout_0.addWidget(self.profileBox) layout_0.addLayout(layout_ok) if not collision and avail_profiles: layout_0.addWidget(self.delete) layout_0.addLayout(layout_2) - self.errorMsg = QtGui.QLabel(self) + self.errorMsg = QtWidgets.QLabel(self) self.errorMsg.setStyleSheet("color:red;") layout_0.addWidget(self.errorMsg) self.setLayout(layout_0) - self.connect(self, QtCore.SIGNAL('accepted()'), - parent, QtCore.SLOT('profileSelected()')) - self.connect(self, QtCore.SIGNAL('rejected()'), - parent, QtCore.SLOT('closeProfile()')) + self.accepted.connect(parent.profileSelected) + self.rejected.connect(parent.closeProfile) @QtCore.pyqtSlot() def openColorDialog(self): - self.colorDialog = QtGui.QColorDialog(self) + self.colorDialog = QtWidgets.QColorDialog(self) color = self.colorDialog.getColor(initial=self.userprofile.chat.color) self.chumColorButton.setStyleSheet("background: %s" % color.name()) self.chumcolor = color @@ -877,68 +823,57 @@ class PesterChooseProfile(QtGui.QDialog): if self.profileBox and self.profileBox.currentIndex() > 0: handle = unicode(self.profileBox.currentText()) if handle == self.parent.profile().handle: - problem = QtGui.QMessageBox() + problem = QtWidgets.QMessageBox() problem.setStyleSheet(self.theme["main/defaultwindow/style"]) problem.setWindowTitle("Problem!") problem.setInformativeText("You can't delete the profile you're currently using!") - problem.setStandardButtons(QtGui.QMessageBox.Ok) + problem.setStandardButtons(QtWidgets.QMessageBox.Ok) problem.exec_() return - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() 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(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) ret = msgbox.exec_() - if ret == QtGui.QMessageBox.Ok: + if ret == QtWidgets.QMessageBox.Ok: try: remove(_datadir+"profiles/%s.js" % (handle)) except OSError: - problem = QtGui.QMessageBox() + problem = QtWidgets.QMessageBox() problem.setStyleSheet(self.theme["main/defaultwindow/style"]) problem.setWindowTitle("Problem!") problem.setInformativeText("There was a problem deleting the profile: %s" % (handle)) - problem.setStandardButtons(QtGui.QMessageBox.Ok) + problem.setStandardButtons(QtWidgets.QMessageBox.Ok) problem.exec_() -class PesterMentions(QtGui.QDialog): +class PesterMentions(QtWidgets.QDialog): def __init__(self, window, theme, parent): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle("Mentions") self.setModal(True) self.mainwindow = window self.theme = theme self.setStyleSheet(self.theme["main/defaultwindow/style"]) - self.mentionlist = QtGui.QListWidget(self) + self.mentionlist = QtWidgets.QListWidget(self) self.mentionlist.addItems(self.mainwindow.userprofile.getMentions()) - self.addBtn = QtGui.QPushButton("ADD MENTION", self) - self.connect(self.addBtn, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('addMention()')) - - self.editBtn = QtGui.QPushButton("EDIT", self) - self.connect(self.editBtn, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('editSelected()')) - self.rmBtn = QtGui.QPushButton("REMOVE", self) - self.connect(self.rmBtn, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('removeCurrent()')) - layout_1 = QtGui.QHBoxLayout() + self.addBtn = QtWidgets.QPushButton("ADD MENTION", self, clicked=self.addMention) + self.editBtn = QtWidgets.QPushButton("EDIT", self, clicked=self.editSelected) + self.rmBtn = QtWidgets.QPushButton("REMOVE", self, clicked=self.removeCurrent) + layout_1 = QtWidgets.QHBoxLayout() layout_1.addWidget(self.editBtn) layout_1.addWidget(self.rmBtn) - self.ok = QtGui.QPushButton("OK", self) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.accept) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('accept()')) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_2 = QtGui.QHBoxLayout() + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self.cancel) layout_2.addWidget(self.ok) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.mentionlist) layout_0.addWidget(self.addBtn) layout_0.addLayout(layout_1) @@ -964,7 +899,7 @@ class PesterMentions(QtGui.QDialog): try: re.compile(pdict["value"]) except re.error, e: - quirkWarning = QtGui.QMessageBox(self) + quirkWarning = QtWidgets.QMessageBox(self) quirkWarning.setText("Not a valid regular expression!") quirkWarning.setInformativeText("H3R3S WHY DUMP4SS: %s" % (e)) quirkWarning.exec_() @@ -980,86 +915,76 @@ class PesterMentions(QtGui.QDialog): if i >= 0: self.mentionlist.takeItem(i) -class PesterOptions(QtGui.QDialog): +class PesterOptions(QtWidgets.QDialog): def __init__(self, config, theme, parent): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setWindowTitle("Options") self.setModal(False) self.config = config self.theme = theme self.setStyleSheet(self.theme["main/defaultwindow/style"]) - layout_4 = QtGui.QVBoxLayout() + layout_4 = QtWidgets.QVBoxLayout() - hr = QtGui.QFrame() - hr.setFrameShape(QtGui.QFrame.HLine) - hr.setFrameShadow(QtGui.QFrame.Sunken) - vr = QtGui.QFrame() - vr.setFrameShape(QtGui.QFrame.VLine) - vr.setFrameShadow(QtGui.QFrame.Sunken) + hr = QtWidgets.QFrame() + hr.setFrameShape(QtWidgets.QFrame.HLine) + hr.setFrameShadow(QtWidgets.QFrame.Sunken) + vr = QtWidgets.QFrame() + vr.setFrameShape(QtWidgets.QFrame.VLine) + vr.setFrameShadow(QtWidgets.QFrame.Sunken) - self.tabs = QtGui.QButtonGroup(self) - self.connect(self.tabs, QtCore.SIGNAL('buttonClicked(int)'), - self, QtCore.SLOT('changePage(int)')) + self.tabs = QtWidgets.QButtonGroup(self) + self.tabs.buttonClicked[int].connect(self.changePage) tabNames = ["Chum List", "Conversations", "Interface", "Sound", "Notifications", "Logging", "Idle/Updates", "Theme", "Connection"] if parent.advanced: tabNames.append("Advanced") for t in tabNames: - button = QtGui.QPushButton(t) + button = QtWidgets.QPushButton(t) self.tabs.addButton(button) layout_4.addWidget(button) button.setCheckable(True) self.tabs.button(-2).setChecked(True) - self.pages = QtGui.QStackedWidget(self) + self.pages = QtWidgets.QStackedWidget(self) - self.bandwidthcheck = QtGui.QCheckBox("Low Bandwidth", self) + self.bandwidthcheck = QtWidgets.QCheckBox("Low Bandwidth", self) if self.config.lowBandwidth(): self.bandwidthcheck.setChecked(True) - bandwidthLabel = QtGui.QLabel("(Stops you for receiving the flood of MOODS,\n" + bandwidthLabel = QtWidgets.QLabel("(Stops you for receiving the flood of MOODS,\n" " though stops chumlist from working properly)") font = bandwidthLabel.font() font.setPointSize(8) bandwidthLabel.setFont(font) - self.autonickserv = QtGui.QCheckBox("Auto-Identify with NickServ", self) + self.autonickserv = QtWidgets.QCheckBox("Auto-Identify with NickServ", self) self.autonickserv.setChecked(parent.userprofile.getAutoIdentify()) - self.connect(self.autonickserv, QtCore.SIGNAL('stateChanged(int)'), - self, QtCore.SLOT('autoNickServChange(int)')) - self.nickservpass = QtGui.QLineEdit(self) + self.nickservpass = QtWidgets.QLineEdit(self) self.nickservpass.setPlaceholderText("NickServ Password") - self.nickservpass.setEchoMode(QtGui.QLineEdit.PasswordEchoOnEdit) + self.nickservpass.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit) self.nickservpass.setText(parent.userprofile.getNickServPass()) + self.autonickserv.stateChanged.connect(self.autoNickServChange) - self.autojoinlist = QtGui.QListWidget(self) + self.autojoinlist = QtWidgets.QListWidget(self) self.autojoinlist.addItems(parent.userprofile.getAutoJoins()) - self.addAutoJoinBtn = QtGui.QPushButton("Add", self) - self.connect(self.addAutoJoinBtn, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('addAutoJoin()')) - self.delAutoJoinBtn = QtGui.QPushButton("Remove", self) - self.connect(self.delAutoJoinBtn, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('delAutoJoin()')) + self.addAutoJoinBtn = QtWidgets.QPushButton("Add", self, clicked=self.addAutoJoin) + self.delAutoJoinBtn = QtWidgets.QPushButton("Remove", self, clicked=self.delAutoJoin) - self.tabcheck = QtGui.QCheckBox("Tabbed Conversations", self) + self.tabcheck = QtWidgets.QCheckBox("Tabbed Conversations", self) if self.config.tabs(): self.tabcheck.setChecked(True) - self.tabmemocheck = QtGui.QCheckBox("Tabbed Memos", self) + self.tabmemocheck = QtWidgets.QCheckBox("Tabbed Memos", self) if self.config.tabMemos(): self.tabmemocheck.setChecked(True) - self.hideOffline = QtGui.QCheckBox("Hide Offline Chums", self) + self.hideOffline = QtWidgets.QCheckBox("Hide Offline Chums", self) if self.config.hideOfflineChums(): self.hideOffline.setChecked(True) - self.soundcheck = QtGui.QCheckBox("Sounds On", self) - self.connect(self.soundcheck, QtCore.SIGNAL('stateChanged(int)'), - self, QtCore.SLOT('soundChange(int)')) - self.chatsoundcheck = QtGui.QCheckBox("Pester Sounds", self) + self.soundcheck = QtWidgets.QCheckBox("Sounds On", self, stateChanged=self.soundChange) + self.chatsoundcheck = QtWidgets.QCheckBox("Pester Sounds", self) self.chatsoundcheck.setChecked(self.config.chatSound()) - self.memosoundcheck = QtGui.QCheckBox("Memo Sounds", self) + self.memosoundcheck = QtWidgets.QCheckBox("Memo Sounds", self, stateChanged=self.memoSoundChange) self.memosoundcheck.setChecked(self.config.memoSound()) - self.connect(self.memosoundcheck, QtCore.SIGNAL('stateChanged(int)'), - self, QtCore.SLOT('memoSoundChange(int)')) - self.memopingcheck = QtGui.QCheckBox("Memo Ping", self) + self.memopingcheck = QtWidgets.QCheckBox("Memo Ping", self) self.memopingcheck.setChecked(self.config.memoPing()) - self.namesoundcheck = QtGui.QCheckBox("Memo Mention (initials)", self) + self.namesoundcheck = QtWidgets.QCheckBox("Memo Mention (initials)", self) self.namesoundcheck.setChecked(self.config.nameSound()) if self.config.soundOn(): self.soundcheck.setChecked(True) @@ -1070,98 +995,92 @@ class PesterOptions(QtGui.QDialog): self.memosoundcheck.setEnabled(False) self.memoSoundChange(0) - self.editMentions = QtGui.QPushButton("Edit Mentions", self) - self.connect(self.editMentions, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('openMentions()')) - self.editMentions2 = QtGui.QPushButton("Edit Mentions", self) - self.connect(self.editMentions2, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('openMentions()')) + self.editMentions = QtWidgets.QPushButton("Edit Mentions", self, clicked=self.openMentions) + self.editMentions2 = QtWidgets.QPushButton("Edit Mentions", self, clicked=self.openMentions) - self.volume = QtGui.QSlider(QtCore.Qt.Horizontal, self) + self.currentVol = QtWidgets.QLabel(str(self.config.volume())+"%", self) + self.currentVol.setAlignment(QtCore.Qt.AlignHCenter) + self.volume = QtWidgets.QSlider(QtCore.Qt.Horizontal, self) self.volume.setMinimum(0) self.volume.setMaximum(100) self.volume.setValue(self.config.volume()) - self.connect(self.volume, QtCore.SIGNAL('valueChanged(int)'), - self, QtCore.SLOT('printValue(int)')) - self.currentVol = QtGui.QLabel(str(self.config.volume())+"%", self) - self.currentVol.setAlignment(QtCore.Qt.AlignHCenter) + self.volume.valueChanged.connect(self.printValue) - - self.timestampcheck = QtGui.QCheckBox("Time Stamps", self) + self.timestampcheck = QtWidgets.QCheckBox("Time Stamps", self) if self.config.showTimeStamps(): self.timestampcheck.setChecked(True) - self.timestampBox = QtGui.QComboBox(self) + self.timestampBox = QtWidgets.QComboBox(self) self.timestampBox.addItem("12 hour") self.timestampBox.addItem("24 hour") if self.config.time12Format(): self.timestampBox.setCurrentIndex(0) else: self.timestampBox.setCurrentIndex(1) - self.secondscheck = QtGui.QCheckBox("Show Seconds", self) + self.secondscheck = QtWidgets.QCheckBox("Show Seconds", self) if self.config.showSeconds(): self.secondscheck.setChecked(True) - self.memomessagecheck = QtGui.QCheckBox("Show OP and Voice Messages in Memos", self) + self.memomessagecheck = QtWidgets.QCheckBox("Show OP and Voice Messages in Memos", self) if self.config.opvoiceMessages(): self.memomessagecheck.setChecked(True) if not ostools.isOSXBundle(): - self.animationscheck = QtGui.QCheckBox("Use animated smilies", self) + self.animationscheck = QtWidgets.QCheckBox("Use animated smilies", self) if self.config.animations(): self.animationscheck.setChecked(True) - animateLabel = QtGui.QLabel("(Disable if you leave chats open for LOOOONG periods of time)") + animateLabel = QtWidgets.QLabel("(Disable if you leave chats open for LOOOONG periods of time)") font = animateLabel.font() font.setPointSize(8) animateLabel.setFont(font) - self.userlinkscheck = QtGui.QCheckBox("Disable #Memo and @User Links", self) + self.userlinkscheck = QtWidgets.QCheckBox("Disable #Memo and @User Links", self) self.userlinkscheck.setChecked(self.config.disableUserLinks()) self.userlinkscheck.setVisible(False) # Will add ability to turn off groups later - #self.groupscheck = QtGui.QCheckBox("Use Groups", self) + #self.groupscheck = QtWidgets.QCheckBox("Use Groups", self) #self.groupscheck.setChecked(self.config.useGroups()) - self.showemptycheck = QtGui.QCheckBox("Show Empty Groups", self) + self.showemptycheck = QtWidgets.QCheckBox("Show Empty Groups", self) self.showemptycheck.setChecked(self.config.showEmptyGroups()) - self.showonlinenumbers = QtGui.QCheckBox("Show Number of Online Chums", self) + self.showonlinenumbers = QtWidgets.QCheckBox("Show Number of Online Chums", self) self.showonlinenumbers.setChecked(self.config.showOnlineNumbers()) - sortLabel = QtGui.QLabel("Sort Chums") - self.sortBox = QtGui.QComboBox(self) + sortLabel = QtWidgets.QLabel("Sort Chums") + self.sortBox = QtWidgets.QComboBox(self) self.sortBox.addItem("Alphabetically") self.sortBox.addItem("By Mood") self.sortBox.addItem("Manually") method = self.config.sortMethod() if method >= 0 and method < self.sortBox.count(): self.sortBox.setCurrentIndex(method) - layout_3 = QtGui.QHBoxLayout() + layout_3 = QtWidgets.QHBoxLayout() layout_3.addWidget(sortLabel) layout_3.addWidget(self.sortBox, 10) - self.logpesterscheck = QtGui.QCheckBox("Log all Pesters", self) + self.logpesterscheck = QtWidgets.QCheckBox("Log all Pesters", self) if self.config.logPesters() & self.config.LOG: self.logpesterscheck.setChecked(True) - self.logmemoscheck = QtGui.QCheckBox("Log all Memos", self) + self.logmemoscheck = QtWidgets.QCheckBox("Log all Memos", self) if self.config.logMemos() & self.config.LOG: self.logmemoscheck.setChecked(True) - self.stamppestercheck = QtGui.QCheckBox("Log Time Stamps for Pesters", self) + self.stamppestercheck = QtWidgets.QCheckBox("Log Time Stamps for Pesters", self) if self.config.logPesters() & self.config.STAMP: self.stamppestercheck.setChecked(True) - self.stampmemocheck = QtGui.QCheckBox("Log Time Stamps for Memos", self) + self.stampmemocheck = QtWidgets.QCheckBox("Log Time Stamps for Memos", self) if self.config.logMemos() & self.config.STAMP: self.stampmemocheck.setChecked(True) - self.idleBox = QtGui.QSpinBox(self) + self.idleBox = QtWidgets.QSpinBox(self) self.idleBox.setStyleSheet("background:#FFFFFF") self.idleBox.setRange(1, 1440) self.idleBox.setValue(self.config.idleTime()) - layout_5 = QtGui.QHBoxLayout() - layout_5.addWidget(QtGui.QLabel("Minutes before Idle:")) + layout_5 = QtWidgets.QHBoxLayout() + layout_5.addWidget(QtWidgets.QLabel("Minutes before Idle:")) layout_5.addWidget(self.idleBox) - self.updateBox = QtGui.QComboBox(self) + self.updateBox = QtWidgets.QComboBox(self) self.updateBox.addItem("Once a Day") self.updateBox.addItem("Once a Week") self.updateBox.addItem("Only on Start") @@ -1169,59 +1088,55 @@ class PesterOptions(QtGui.QDialog): check = self.config.checkForUpdates() if check >= 0 and check < self.updateBox.count(): self.updateBox.setCurrentIndex(check) - layout_6 = QtGui.QHBoxLayout() - layout_6.addWidget(QtGui.QLabel("Check for\nPesterchum Updates:")) + layout_6 = QtWidgets.QHBoxLayout() + layout_6.addWidget(QtWidgets.QLabel("Check for\nPesterchum Updates:")) layout_6.addWidget(self.updateBox) if not ostools.isOSXLeopard(): - self.mspaCheck = QtGui.QCheckBox("Check for MSPA Updates", self) + self.mspaCheck = QtWidgets.QCheckBox("Check for MSPA Updates", self) self.mspaCheck.setChecked(self.config.checkMSPA()) - self.randomscheck = QtGui.QCheckBox("Receive Random Encounters") + self.randomscheck = QtWidgets.QCheckBox("Receive Random Encounters") self.randomscheck.setChecked(parent.userprofile.randoms) if not parent.randhandler.running: self.randomscheck.setEnabled(False) avail_themes = self.config.availableThemes() - self.themeBox = QtGui.QComboBox(self) + self.themeBox = QtWidgets.QComboBox(self) notheme = (theme.name not in avail_themes) for (i, t) in enumerate(avail_themes): self.themeBox.addItem(t) if (not notheme and t == theme.name) or (notheme and t == "pesterchum"): self.themeBox.setCurrentIndex(i) - self.refreshtheme = QtGui.QPushButton("Refresh current theme", self) - self.connect(self.refreshtheme, QtCore.SIGNAL('clicked()'), - parent, QtCore.SLOT('themeSelectOverride()')) - self.ghostchum = QtGui.QCheckBox("Pesterdunk Ghostchum!!", self) + self.refreshtheme = QtWidgets.QPushButton("Refresh current theme", self, clicked=parent.themeSelectOverride) + self.ghostchum = QtWidgets.QCheckBox("Pesterdunk Ghostchum!!", self) self.ghostchum.setChecked(self.config.ghostchum()) self.buttonOptions = ["Minimize to Taskbar", "Minimize to Tray", "Quit"] - self.miniBox = QtGui.QComboBox(self) + self.miniBox = QtWidgets.QComboBox(self) self.miniBox.addItems(self.buttonOptions) self.miniBox.setCurrentIndex(self.config.minimizeAction()) - self.closeBox = QtGui.QComboBox(self) + self.closeBox = QtWidgets.QComboBox(self) self.closeBox.addItems(self.buttonOptions) self.closeBox.setCurrentIndex(self.config.closeAction()) - layout_mini = QtGui.QHBoxLayout() - layout_mini.addWidget(QtGui.QLabel("Minimize")) + layout_mini = QtWidgets.QHBoxLayout() + layout_mini.addWidget(QtWidgets.QLabel("Minimize")) layout_mini.addWidget(self.miniBox) - layout_close = QtGui.QHBoxLayout() - layout_close.addWidget(QtGui.QLabel("Close")) + layout_close = QtWidgets.QHBoxLayout() + layout_close.addWidget(QtWidgets.QLabel("Close")) layout_close.addWidget(self.closeBox) - self.pesterBlink = QtGui.QCheckBox("Blink Taskbar on Pesters", self) + self.pesterBlink = QtWidgets.QCheckBox("Blink Taskbar on Pesters", self) if self.config.blink() & self.config.PBLINK: self.pesterBlink.setChecked(True) - self.memoBlink = QtGui.QCheckBox("Blink Taskbar on Memos", self) + self.memoBlink = QtWidgets.QCheckBox("Blink Taskbar on Memos", self) if self.config.blink() & self.config.MBLINK: self.memoBlink.setChecked(True) - self.notifycheck = QtGui.QCheckBox("Toast Notifications", self) + self.notifycheck = QtWidgets.QCheckBox("Toast Notifications", self) if self.config.notify(): self.notifycheck.setChecked(True) - self.connect(self.notifycheck, QtCore.SIGNAL('stateChanged(int)'), - self, QtCore.SLOT('notifyChange(int)')) - self.notifyOptions = QtGui.QComboBox(self) + self.notifyOptions = QtWidgets.QComboBox(self) types = self.parent().tm.availableTypes() cur = self.parent().tm.currentType() self.notifyOptions.addItems(types) @@ -1229,48 +1144,45 @@ class PesterOptions(QtGui.QDialog): if t == cur: self.notifyOptions.setCurrentIndex(i) break - self.notifyTypeLabel = QtGui.QLabel("Type", self) - layout_type = QtGui.QHBoxLayout() + self.notifyTypeLabel = QtWidgets.QLabel("Type", self) + layout_type = QtWidgets.QHBoxLayout() layout_type.addWidget(self.notifyTypeLabel) layout_type.addWidget(self.notifyOptions) - self.notifySigninCheck = QtGui.QCheckBox("Chum signs in", self) + self.notifySigninCheck = QtWidgets.QCheckBox("Chum signs in", self) if self.config.notifyOptions() & self.config.SIGNIN: self.notifySigninCheck.setChecked(True) - self.notifySignoutCheck = QtGui.QCheckBox("Chum signs out", self) + self.notifySignoutCheck = QtWidgets.QCheckBox("Chum signs out", self) if self.config.notifyOptions() & self.config.SIGNOUT: self.notifySignoutCheck.setChecked(True) - self.notifyNewMsgCheck = QtGui.QCheckBox("New messages", self) + self.notifyNewMsgCheck = QtWidgets.QCheckBox("New messages", self) if self.config.notifyOptions() & self.config.NEWMSG: self.notifyNewMsgCheck.setChecked(True) - self.notifyNewConvoCheck = QtGui.QCheckBox("Only new conversations", self) + self.notifyNewConvoCheck = QtWidgets.QCheckBox("Only new conversations", self) if self.config.notifyOptions() & self.config.NEWCONVO: self.notifyNewConvoCheck.setChecked(True) - self.notifyMentionsCheck = QtGui.QCheckBox("Memo Mentions (initials)", self) + self.notifyMentionsCheck = QtWidgets.QCheckBox("Memo Mentions (initials)", self) if self.config.notifyOptions() & self.config.INITIALS: self.notifyMentionsCheck.setChecked(True) self.notifyChange(self.notifycheck.checkState()) + self.notifycheck.stateChanged.connect(self.notifyChange) if parent.advanced: - self.modechange = QtGui.QLineEdit(self) - layout_change = QtGui.QHBoxLayout() - layout_change.addWidget(QtGui.QLabel("Change:")) + self.modechange = QtWidgets.QLineEdit(self) + layout_change = QtWidgets.QHBoxLayout() + layout_change.addWidget(QtWidgets.QLabel("Change:")) layout_change.addWidget(self.modechange) - self.ok = QtGui.QPushButton("OK", self) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.accept) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('accept()')) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_2 = QtGui.QHBoxLayout() + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self.cancel) layout_2.addWidget(self.ok) # Tab layouts # Chum List - widget = QtGui.QWidget() - layout_chumlist = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_chumlist = QtWidgets.QVBoxLayout(widget) layout_chumlist.setAlignment(QtCore.Qt.AlignTop) layout_chumlist.addWidget(self.hideOffline) #layout_chumlist.addWidget(self.groupscheck) @@ -1280,8 +1192,8 @@ class PesterOptions(QtGui.QDialog): self.pages.addWidget(widget) # Conversations - widget = QtGui.QWidget() - layout_chat = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_chat = QtWidgets.QVBoxLayout(widget) layout_chat.setAlignment(QtCore.Qt.AlignTop) layout_chat.addWidget(self.timestampcheck) layout_chat.addWidget(self.timestampBox) @@ -1293,13 +1205,13 @@ class PesterOptions(QtGui.QDialog): layout_chat.addWidget(self.randomscheck) # Re-enable these when it's possible to disable User and Memo links #layout_chat.addWidget(hr) - #layout_chat.addWidget(QtGui.QLabel("User and Memo Links")) + #layout_chat.addWidget(QtWidgets.QLabel("User and Memo Links")) #layout_chat.addWidget(self.userlinkscheck) self.pages.addWidget(widget) # Interface - widget = QtGui.QWidget() - layout_interface = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_interface = QtWidgets.QVBoxLayout(widget) layout_interface.setAlignment(QtCore.Qt.AlignTop) layout_interface.addWidget(self.tabcheck) layout_interface.addWidget(self.tabmemocheck) @@ -1310,14 +1222,14 @@ class PesterOptions(QtGui.QDialog): self.pages.addWidget(widget) # Sound - widget = QtGui.QWidget() - layout_sound = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_sound = QtWidgets.QVBoxLayout(widget) layout_sound.setAlignment(QtCore.Qt.AlignTop) layout_sound.addWidget(self.soundcheck) - layout_indent = QtGui.QVBoxLayout() + layout_indent = QtWidgets.QVBoxLayout() layout_indent.addWidget(self.chatsoundcheck) layout_indent.addWidget(self.memosoundcheck) - layout_doubleindent = QtGui.QVBoxLayout() + layout_doubleindent = QtWidgets.QVBoxLayout() layout_doubleindent.addWidget(self.memopingcheck) layout_doubleindent.addWidget(self.namesoundcheck) layout_doubleindent.addWidget(self.editMentions) @@ -1326,23 +1238,23 @@ class PesterOptions(QtGui.QDialog): layout_indent.setContentsMargins(22,0,0,0) layout_sound.addLayout(layout_indent) layout_sound.addSpacing(15) - layout_sound.addWidget(QtGui.QLabel("Master Volume:", self)) + layout_sound.addWidget(QtWidgets.QLabel("Master Volume:", self)) layout_sound.addWidget(self.volume) layout_sound.addWidget(self.currentVol) self.pages.addWidget(widget) # Notifications - widget = QtGui.QWidget() - layout_notify = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_notify = QtWidgets.QVBoxLayout(widget) layout_notify.setAlignment(QtCore.Qt.AlignTop) layout_notify.addWidget(self.notifycheck) - layout_indent = QtGui.QVBoxLayout() + layout_indent = QtWidgets.QVBoxLayout() layout_indent.addLayout(layout_type) layout_indent.setContentsMargins(22,0,0,0) layout_indent.addWidget(self.notifySigninCheck) layout_indent.addWidget(self.notifySignoutCheck) layout_indent.addWidget(self.notifyNewMsgCheck) - layout_doubleindent = QtGui.QVBoxLayout() + layout_doubleindent = QtWidgets.QVBoxLayout() layout_doubleindent.addWidget(self.notifyNewConvoCheck) layout_doubleindent.setContentsMargins(22,0,0,0) layout_indent.addLayout(layout_doubleindent) @@ -1352,8 +1264,8 @@ class PesterOptions(QtGui.QDialog): self.pages.addWidget(widget) # Logging - widget = QtGui.QWidget() - layout_logs = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_logs = QtWidgets.QVBoxLayout(widget) layout_logs.setAlignment(QtCore.Qt.AlignTop) layout_logs.addWidget(self.logpesterscheck) layout_logs.addWidget(self.logmemoscheck) @@ -1362,8 +1274,8 @@ class PesterOptions(QtGui.QDialog): self.pages.addWidget(widget) # Idle/Updates - widget = QtGui.QWidget() - layout_idle = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_idle = QtWidgets.QVBoxLayout(widget) layout_idle.setAlignment(QtCore.Qt.AlignTop) layout_idle.addLayout(layout_5) layout_idle.addLayout(layout_6) @@ -1372,29 +1284,29 @@ class PesterOptions(QtGui.QDialog): self.pages.addWidget(widget) # Theme - widget = QtGui.QWidget() - layout_theme = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_theme = QtWidgets.QVBoxLayout(widget) layout_theme.setAlignment(QtCore.Qt.AlignTop) - layout_theme.addWidget(QtGui.QLabel("Pick a Theme:")) + layout_theme.addWidget(QtWidgets.QLabel("Pick a Theme:")) layout_theme.addWidget(self.themeBox) layout_theme.addWidget(self.refreshtheme) layout_theme.addWidget(self.ghostchum) self.pages.addWidget(widget) # Connection - widget = QtGui.QWidget() - layout_connect = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_connect = QtWidgets.QVBoxLayout(widget) layout_connect.setAlignment(QtCore.Qt.AlignTop) layout_connect.addWidget(self.bandwidthcheck) layout_connect.addWidget(bandwidthLabel) layout_connect.addWidget(self.autonickserv) - layout_indent = QtGui.QVBoxLayout() + layout_indent = QtWidgets.QVBoxLayout() layout_indent.addWidget(self.nickservpass) layout_indent.setContentsMargins(22,0,0,0) layout_connect.addLayout(layout_indent) - layout_connect.addWidget(QtGui.QLabel("Auto-Join Memos:")) + layout_connect.addWidget(QtWidgets.QLabel("Auto-Join Memos:")) layout_connect.addWidget(self.autojoinlist) - layout_8 = QtGui.QHBoxLayout() + layout_8 = QtWidgets.QHBoxLayout() layout_8.addWidget(self.addAutoJoinBtn) layout_8.addWidget(self.delAutoJoinBtn) layout_connect.addLayout(layout_8) @@ -1402,15 +1314,15 @@ class PesterOptions(QtGui.QDialog): # Advanced if parent.advanced: - widget = QtGui.QWidget() - layout_advanced = QtGui.QVBoxLayout(widget) + widget = QtWidgets.QWidget() + layout_advanced = QtWidgets.QVBoxLayout(widget) layout_advanced.setAlignment(QtCore.Qt.AlignTop) - layout_advanced.addWidget(QtGui.QLabel("Current User Mode: %s" % parent.modes)) + layout_advanced.addWidget(QtWidgets.QLabel("Current User Mode: %s" % parent.modes)) layout_advanced.addLayout(layout_change) self.pages.addWidget(widget) - layout_0 = QtGui.QVBoxLayout() - layout_1 = QtGui.QHBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() + layout_1 = QtWidgets.QHBoxLayout() layout_1.addLayout(layout_4) layout_1.addWidget(vr) layout_1.addWidget(self.pages) @@ -1501,10 +1413,8 @@ class PesterOptions(QtGui.QDialog): self.mentionmenu = None if not self.mentionmenu: self.mentionmenu = PesterMentions(self.parent(), self.theme, self) - self.connect(self.mentionmenu, QtCore.SIGNAL('accepted()'), - self, QtCore.SLOT('updateMentions()')) - self.connect(self.mentionmenu, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('closeMentions()')) + self.mentionmenu.accepted.connect(self.updateMentions) + self.mentionmenu.rejected.connect(self.closeMentions) self.mentionmenu.show() self.mentionmenu.raise_() self.mentionmenu.activateWindow() @@ -1520,9 +1430,9 @@ class PesterOptions(QtGui.QDialog): self.parent().userprofile.setMentions(m) self.mentionmenu = None -class PesterUserlist(QtGui.QDialog): +class PesterUserlist(QtWidgets.QDialog): def __init__(self, config, theme, parent): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setModal(False) self.config = config self.theme = theme @@ -1530,31 +1440,24 @@ class PesterUserlist(QtGui.QDialog): self.setStyleSheet(self.theme["main/defaultwindow/style"]) self.resize(200, 600) - self.searchbox = QtGui.QLineEdit(self) + self.searchbox = QtWidgets.QLineEdit(self, textChanged=self.updateUsers) #self.searchbox.setStyleSheet(theme["convo/input/style"]) # which style is better? self.searchbox.setPlaceholderText("Search") - self.connect(self.searchbox, QtCore.SIGNAL("textChanged(QString)"), self, QtCore.SLOT("updateUsers()")) - self.label = QtGui.QLabel("USERLIST") + self.label = QtWidgets.QLabel("USERLIST") self.userarea = RightClickList(self) self.userarea.setStyleSheet(self.theme["main/chums/style"]) - self.userarea.optionsMenu = QtGui.QMenu(self) + self.userarea.optionsMenu = QtWidgets.QMenu(self) - self.addChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self) - self.connect(self.addChumAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('addChumSlot()')) - self.pesterChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self) - self.connect(self.pesterChumAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('pesterChumSlot()')) + self.addChumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self, triggered=self.addChumSlot) + self.pesterChumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self, triggered=self.pesterChumSlot) self.userarea.optionsMenu.addAction(self.addChumAction) self.userarea.optionsMenu.addAction(self.pesterChumAction) - self.ok = QtGui.QPushButton("OK", self) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.accept) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('accept()')) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.label) layout_0.addWidget(self.userarea) layout_0.addWidget(self.searchbox) @@ -1562,13 +1465,8 @@ class PesterUserlist(QtGui.QDialog): self.setLayout(layout_0) - self.connect(self.mainwindow, QtCore.SIGNAL('namesUpdated()'), - self, QtCore.SLOT('updateUsers()')) - - self.connect(self.mainwindow, - QtCore.SIGNAL('userPresentSignal(QString, QString, QString)'), - self, - QtCore.SLOT('updateUserPresent(QString, QString, QString)')) + self.mainwindow.namesUpdated.connect(self.updateUsers) + self.mainwindow.userPresentSignal.connect(self.updateUserPresent) self.updateUsers() self.searchbox.setFocus() @@ -1578,11 +1476,11 @@ class PesterUserlist(QtGui.QDialog): self.userarea.clear() for n in names: if str(self.searchbox.text()) == "" or n.lower().find(str(self.searchbox.text()).lower()) != -1: - item = QtGui.QListWidgetItem(n) - item.setTextColor(QtGui.QColor(self.theme["main/chums/userlistcolor"])) + item = QtWidgets.QListWidgetItem(n) + item.setForeground(QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"]))) self.userarea.addItem(item) self.userarea.sortItems() - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString', 'QString') def updateUserPresent(self, handle, channel, update): h = unicode(handle) c = unicode(channel) @@ -1594,8 +1492,8 @@ class PesterUserlist(QtGui.QDialog): if str(self.searchbox.text()) == "" or h.lower().find(str(self.searchbox.text()).lower()) != -1: self.addUser(h) def addUser(self, name): - item = QtGui.QListWidgetItem(name) - item.setTextColor(QtGui.QColor(self.theme["main/chums/userlistcolor"])) + item = QtWidgets.QListWidgetItem(name) + item.setForeground(QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"]))) self.userarea.addItem(item) self.userarea.sortItems() def delUser(self, name): @@ -1609,7 +1507,7 @@ class PesterUserlist(QtGui.QDialog): self.userarea.setStyleSheet(theme["main/chums/style"]) self.addChumAction.setText(theme["main/menus/rclickchumlist/addchum"]) for item in [self.userarea.item(i) for i in range(0, self.userarea.count())]: - item.setTextColor(QtGui.QColor(theme["main/chums/userlistcolor"])) + item.setForeground(QtGui.QBrush(QtGui.QColor(theme["main/chums/userlistcolor"]))) @QtCore.pyqtSlot() def addChumSlot(self): @@ -1624,13 +1522,13 @@ class PesterUserlist(QtGui.QDialog): return self.pesterChum.emit(cur.text()) - addChum = QtCore.pyqtSignal(QtCore.QString) - pesterChum = QtCore.pyqtSignal(QtCore.QString) + addChum = QtCore.pyqtSignal('QString') + pesterChum = QtCore.pyqtSignal('QString') -class MemoListItem(QtGui.QTreeWidgetItem): +class MemoListItem(QtWidgets.QTreeWidgetItem): def __init__(self, channel, usercount): - QtGui.QTreeWidgetItem.__init__(self, [channel, str(usercount)]) + QtWidgets.QTreeWidgetItem.__init__(self, [channel, str(usercount)]) self.target = channel def __lt__(self, other): column = self.treeWidget().sortColumn() @@ -1638,20 +1536,20 @@ class MemoListItem(QtGui.QTreeWidgetItem): return int(self.text(column)) < int(other.text(column)) return self.text(column) < other.text(column) -class PesterMemoList(QtGui.QDialog): +class PesterMemoList(QtWidgets.QDialog): def __init__(self, parent, channel=""): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.setModal(False) self.theme = parent.theme self.mainwindow = parent self.setStyleSheet(self.theme["main/defaultwindow/style"]) self.resize(460, 300) - self.label = QtGui.QLabel("MEMOS") + self.label = QtWidgets.QLabel("MEMOS") self.channelarea = RightClickTree(self) - self.channelarea.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) + self.channelarea.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) self.channelarea.setStyleSheet(self.theme["main/chums/style"]) - self.channelarea.optionsMenu = QtGui.QMenu(self) + self.channelarea.optionsMenu = QtWidgets.QMenu(self) self.channelarea.setColumnCount(2) self.channelarea.setHeaderLabels(["Memo", "Users"]) self.channelarea.setIndentation(0) @@ -1659,35 +1557,29 @@ class PesterMemoList(QtGui.QDialog): self.channelarea.setColumnWidth(1,10) self.channelarea.setSortingEnabled(True) self.channelarea.sortByColumn(0, QtCore.Qt.AscendingOrder) - self.connect(self.channelarea, - QtCore.SIGNAL('itemDoubleClicked(QTreeWidgetItem *, int)'), - self, QtCore.SLOT('AcceptSelection()')) + self.channelarea.itemDoubleClicked.connect(self.AcceptSelection) - self.orjoinlabel = QtGui.QLabel("OR MAKE A NEW MEMO:") - self.newmemo = QtGui.QLineEdit(channel, self) - self.secretChannel = QtGui.QCheckBox("HIDDEN CHANNEL?", self) - self.inviteChannel = QtGui.QCheckBox("INVITATION ONLY?", self) + self.orjoinlabel = QtWidgets.QLabel("OR MAKE A NEW MEMO:") + self.newmemo = QtWidgets.QLineEdit(channel, self) + self.secretChannel = QtWidgets.QCheckBox("HIDDEN CHANNEL?", self) + self.inviteChannel = QtWidgets.QCheckBox("INVITATION ONLY?", self) - self.timelabel = QtGui.QLabel("TIMEFRAME:") + self.timelabel = QtWidgets.QLabel("TIMEFRAME:") self.timeslider = TimeSlider(QtCore.Qt.Horizontal, self) self.timeinput = TimeInput(self.timeslider, self) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - self.join = QtGui.QPushButton("JOIN", self) + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + self.join = QtWidgets.QPushButton("JOIN", self, clicked=self.AcceptIfSelectionMade) self.join.setDefault(True) - self.connect(self.join, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('AcceptIfSelectionMade()')) - layout_ok = QtGui.QHBoxLayout() + layout_ok = QtWidgets.QHBoxLayout() layout_ok.addWidget(self.cancel) layout_ok.addWidget(self.join) - layout_left = QtGui.QVBoxLayout() - layout_right = QtGui.QVBoxLayout() + layout_left = QtWidgets.QVBoxLayout() + layout_right = QtWidgets.QVBoxLayout() layout_right.setAlignment(QtCore.Qt.AlignTop) - layout_0 = QtGui.QVBoxLayout() - layout_1 = QtGui.QHBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() + layout_1 = QtWidgets.QHBoxLayout() layout_left.addWidget(self.label) layout_left.addWidget(self.channelarea) layout_right.addWidget(self.orjoinlabel) @@ -1716,8 +1608,8 @@ class PesterMemoList(QtGui.QDialog): def updateChannels(self, channels): for c in channels: item = MemoListItem(c[0][1:],c[1]) - item.setTextColor(0, QtGui.QColor(self.theme["main/chums/userlistcolor"])) - item.setTextColor(1, QtGui.QColor(self.theme["main/chums/userlistcolor"])) + item.setForeground(0, QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"]))) + item.setForeground(1, QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"]))) item.setIcon(0, QtGui.QIcon(self.theme["memos/memoicon"])) self.channelarea.addTopLevelItem(item) @@ -1725,7 +1617,7 @@ class PesterMemoList(QtGui.QDialog): self.theme = theme self.setStyleSheet(theme["main/defaultwindow/style"]) for item in [self.userarea.item(i) for i in range(0, self.channelarea.count())]: - item.setTextColor(QtGui.QColor(theme["main/chums/userlistcolor"])) + item.setForeground(QtGui.QBrush(QtGui.QColor(theme["main/chums/userlistcolor"]))) item.setIcon(QtGui.QIcon(theme["memos/memoicon"])) @QtCore.pyqtSlot() @@ -1738,24 +1630,20 @@ class PesterMemoList(QtGui.QDialog): self.accept() -class LoadingScreen(QtGui.QDialog): +class LoadingScreen(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent, (QtCore.Qt.CustomizeWindowHint | + QtWidgets.QDialog.__init__(self, parent, (QtCore.Qt.CustomizeWindowHint | QtCore.Qt.FramelessWindowHint)) self.mainwindow = parent self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) - self.loadinglabel = QtGui.QLabel("CONN3CT1NG", self) - self.cancel = QtGui.QPushButton("QU1T >:?", self) - self.ok = QtGui.QPushButton("R3CONN3CT >:]", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SIGNAL('tryAgain()')) + self.loadinglabel = QtWidgets.QLabel("CONN3CT1NG", self) + self.cancel = QtWidgets.QPushButton("QU1T >:?", self, clicked=self.reject) + self.ok = QtWidgets.QPushButton("R3CONN3CT >:]", self, clicked=self.tryAgain) - self.layout = QtGui.QVBoxLayout() + self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.loadinglabel) - layout_1 = QtGui.QHBoxLayout() + layout_1 = QtWidgets.QHBoxLayout() layout_1.addWidget(self.cancel) layout_1.addWidget(self.ok) self.layout.addLayout(layout_1) @@ -1768,14 +1656,14 @@ class LoadingScreen(QtGui.QDialog): tryAgain = QtCore.pyqtSignal() -class AboutPesterchum(QtGui.QDialog): +class AboutPesterchum(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.mainwindow = parent self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) - self.title = QtGui.QLabel("P3ST3RCHUM V. %s" % (_pcVersion)) - self.credits = QtGui.QLabel("Programming by:\n\ + self.title = QtWidgets.QLabel("P3ST3RCHUM V. %s" % (_pcVersion)) + self.credits = QtWidgets.QLabel("Programming by:\n\ illuminatedwax (ghostDunk)\n\ Kiooeht (evacipatedBox)\n\ Lexi (lexicalNuance)\n\ @@ -1792,39 +1680,33 @@ Special Thanks:\n\ gamblingGenocider\n\ Eco-Mono") - self.ok = QtGui.QPushButton("OK", self) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.reject) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.title) layout_0.addWidget(self.credits) layout_0.addWidget(self.ok) self.setLayout(layout_0) -class UpdatePesterchum(QtGui.QDialog): +class UpdatePesterchum(QtWidgets.QDialog): def __init__(self, ver, url, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.url = url self.mainwindow = parent self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) self.setWindowTitle("Pesterchum v%s Update" % (ver)) self.setModal(False) - self.title = QtGui.QLabel("An update to Pesterchum is available!") + self.title = QtWidgets.QLabel("An update to Pesterchum is available!") - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.title) - self.ok = QtGui.QPushButton("D0WNL04D 4ND 1NST4LL N0W", self) + self.ok = QtWidgets.QPushButton("D0WNL04D 4ND 1NST4LL N0W", self, clicked=self.accept) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('accept()')) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_2 = QtGui.QHBoxLayout() + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self.cancel) layout_2.addWidget(self.ok) @@ -1832,41 +1714,37 @@ class UpdatePesterchum(QtGui.QDialog): self.setLayout(layout_0) -class AddChumDialog(QtGui.QDialog): +class AddChumDialog(QtWidgets.QDialog): def __init__(self, avail_groups, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.mainwindow = parent self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) self.setWindowTitle("Enter Chum Handle") self.setModal(True) - self.title = QtGui.QLabel("Enter Chum Handle") - self.chumBox = QtGui.QLineEdit(self) - self.groupBox = QtGui.QComboBox(self) + self.title = QtWidgets.QLabel("Enter Chum Handle") + self.chumBox = QtWidgets.QLineEdit(self) + self.groupBox = QtWidgets.QComboBox(self) avail_groups.sort() avail_groups.pop(avail_groups.index("Chums")) avail_groups.insert(0, "Chums") for g in avail_groups: self.groupBox.addItem(g) - self.newgrouplabel = QtGui.QLabel("Or make a new group:") - self.newgroup = QtGui.QLineEdit(self) + self.newgrouplabel = QtWidgets.QLabel("Or make a new group:") + self.newgroup = QtWidgets.QLineEdit(self) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.title) layout_0.addWidget(self.chumBox) layout_0.addWidget(self.groupBox) layout_0.addWidget(self.newgrouplabel) layout_0.addWidget(self.newgroup) - self.ok = QtGui.QPushButton("OK", self) + self.ok = QtWidgets.QPushButton("OK", self, clicked=self.accept) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('accept()')) - self.cancel = QtGui.QPushButton("CANCEL", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_2 = QtGui.QHBoxLayout() + self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) + layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self.cancel) layout_2.addWidget(self.ok) diff --git a/mood.py b/mood.py index 8c71f6d..165cc1e 100644 --- a/mood.py +++ b/mood.py @@ -1,4 +1,4 @@ -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtWidgets from generic import PesterIcon @@ -49,10 +49,8 @@ class PesterMoodHandler(QtCore.QObject): self.buttons[b.mood.value()] = b if b.mood.value() == self.mainwindow.profile().mood.value(): b.setSelected(True) - self.connect(b, QtCore.SIGNAL('clicked()'), - b, QtCore.SLOT('updateMood()')) - self.connect(b, QtCore.SIGNAL('moodUpdated(int)'), - self, QtCore.SLOT('updateMood(int)')) + b.clicked.connect(b.updateMood) + b.moodUpdated.connect(self.updateMood) def removeButtons(self): for b in self.buttons.values(): b.close() @@ -85,10 +83,10 @@ class PesterMoodHandler(QtCore.QObject): c.myUpdateMood(newmood) self.mainwindow.moodUpdated.emit() -class PesterMoodButton(QtGui.QPushButton): +class PesterMoodButton(QtWidgets.QPushButton): def __init__(self, parent, **options): icon = PesterIcon(options["icon"]) - QtGui.QPushButton.__init__(self, icon, options["text"], parent) + QtWidgets.QPushButton.__init__(self, icon, options["text"], parent) self.setIconSize(icon.realsize()) self.setFlat(True) self.resize(*options["size"]) diff --git a/ostools.py b/ostools.py index 3ee17ee..7042021 100644 --- a/ostools.py +++ b/ostools.py @@ -1,6 +1,6 @@ import os, sys import platform -from PyQt4.QtGui import QDesktopServices +from PyQt5.QtCore import QStandardPaths def isOSX(): return sys.platform == "darwin" @@ -30,12 +30,13 @@ def getDataDir(): # Temporary fix for non-ascii usernames # If username has non-ascii characters, just store userdata # in the Pesterchum install directory (like before) + # TODO: fix error if standardLocations is not what we expect try: if isOSX(): - return os.path.join(unicode(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "Pesterchum/") + return os.path.join(unicode(QStandardPaths.standardLocations(QStandardPaths.DataLocation)[0]), "Pesterchum/") elif isLinux(): - return os.path.join(unicode(QDesktopServices.storageLocation(QDesktopServices.HomeLocation)), ".pesterchum/") + return os.path.join(unicode(QStandardPaths.standardLocations(QStandardPaths.HomeLocation)[0]), ".pesterchum/") else: - return os.path.join(unicode(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "pesterchum/") + return os.path.join(unicode(QStandardPaths.standardLocations(QStandardPaths.DataLocation)[0]), "pesterchum/") except UnicodeDecodeError: return '' diff --git a/oyoyo/cmdhandler.py b/oyoyo/cmdhandler.py index 48505f7..778020e 100644 --- a/oyoyo/cmdhandler.py +++ b/oyoyo/cmdhandler.py @@ -93,6 +93,7 @@ class CommandHandler(object): def run(self, command, *args): """ finds and runs a command """ logging.debug("processCommand %s(%s)" % (command, args)) + logging.info("processCommand %s(%s)" % (command, args)) try: f = self.get(command) diff --git a/parsetools.py b/parsetools.py index cc0feef..4abceed 100644 --- a/parsetools.py +++ b/parsetools.py @@ -3,7 +3,7 @@ import random import ostools from copy import copy from datetime import timedelta -from PyQt4 import QtGui +from PyQt5 import QtGui from generic import mysteryTime from quirks import ScriptQuirks diff --git a/pesterchum.py b/pesterchum.py index d9e5783..7bff675 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -14,7 +14,7 @@ import threading, Queue reqmissing = [] optmissing = [] try: - from PyQt4 import QtGui, QtCore + from PyQt5 import QtGui, QtCore, QtWidgets except ImportError, e: module = str(e) if module.startswith("No module named ") or \ @@ -137,9 +137,9 @@ class waitingMessageHolder(object): def __len__(self): return len(self.queue) -class chumListing(QtGui.QTreeWidgetItem): +class chumListing(QtWidgets.QTreeWidgetItem): def __init__(self, chum, window): - QtGui.QTreeWidgetItem.__init__(self, [chum.handle]) + QtWidgets.QTreeWidgetItem.__init__(self, [chum.handle]) self.mainwindow = window self.chum = chum self.handle = chum.handle @@ -184,16 +184,16 @@ class chumListing(QtGui.QTreeWidgetItem): else: self.setIcon(0, icon) try: - self.setTextColor(0, QtGui.QColor(self.mainwindow.theme["main/chums/moods"][self.mood.name()]["color"])) + self.setForeground(0, QtGui.QBrush(QtGui.QColor(self.mainwindow.theme["main/chums/moods"][self.mood.name()]["color"]))) except KeyError: - self.setTextColor(0, QtGui.QColor(self.mainwindow.theme["main/chums/moods/chummy/color"])) + self.setForeground(0, QtGui.QBrush(QtGui.QColor(self.mainwindow.theme["main/chums/moods/chummy/color"]))) def changeTheme(self, theme): icon = self.mood.icon(theme) self.setIcon(0, icon) try: - self.setTextColor(0, QtGui.QColor(self.mainwindow.theme["main/chums/moods"][self.mood.name()]["color"])) + self.setForeground(0, QtGui.QBrush(QtGui.QColor(self.mainwindow.theme["main/chums/moods"][self.mood.name()]["color"]))) except KeyError: - self.setTextColor(0, QtGui.QColor(self.mainwindow.theme["main/chums/moods/chummy/color"])) + self.setForeground(0, QtGui.QBrush(QtGui.QColor(self.mainwindow.theme["main/chums/moods/chummy/color"]))) def login(self): self.setIcon(0, PesterIcon("themes/arrow_right.png")) self.status = "in" @@ -218,9 +218,9 @@ class chumListing(QtGui.QTreeWidgetItem): class chumArea(RightClickTree): def __init__(self, chums, parent=None): - QtGui.QTreeWidget.__init__(self, parent) + QtWidgets.QTreeWidget.__init__(self, parent) self.notify = False - QtCore.QTimer.singleShot(30000, self, QtCore.SLOT('beginNotify()')) + QtCore.QTimer.singleShot(30000, self.beginNotify) self.mainwindow = parent theme = self.mainwindow.theme self.chums = chums @@ -232,43 +232,25 @@ class chumArea(RightClickTree): self.showAllChums() if not self.mainwindow.config.showEmptyGroups(): self.hideEmptyGroups() - self.groupMenu = QtGui.QMenu(self) - self.canonMenu = QtGui.QMenu(self) - self.optionsMenu = QtGui.QMenu(self) - self.pester = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self) - self.connect(self.pester, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('activateChum()')) - self.removechum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/removechum"], self) - self.connect(self.removechum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('removeChum()')) - self.blockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self) - self.connect(self.blockchum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('blockChum()')) - self.logchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self) - self.connect(self.logchum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('openChumLogs()')) - self.reportchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self) - self.connect(self.reportchum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('reportChum()')) - self.findalts = QtGui.QAction("Find Alts", self) - self.connect(self.findalts, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('findAlts()')) - self.removegroup = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/removegroup"], self) - self.connect(self.removegroup, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('removeGroup()')) - self.renamegroup = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/renamegroup"], self) - self.connect(self.renamegroup, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('renameGroup()')) - self.notes = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/notes"], self) - self.connect(self.notes, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('editNotes()')) + self.groupMenu = QtWidgets.QMenu(self) + self.canonMenu = QtWidgets.QMenu(self) + self.optionsMenu = QtWidgets.QMenu(self) + self.pester = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self, triggered=self.activateChum) + self.removechum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/removechum"], self, triggered=self.removeChum) + self.blockchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self, triggered=self.blockChum) + self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self, triggered=self.openChumLogs) + self.reportchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self, triggered=self.reportChum) + self.findalts = QtWidgets.QAction("Find Alts", self, triggered=self.findAlts) + self.removegroup = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/removegroup"], self, triggered=self.removeGroup) + self.renamegroup = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/renamegroup"], self, triggered=self.renameGroup) + self.notes = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/notes"], self, triggered=self.editNotes) self.optionsMenu.addAction(self.pester) self.optionsMenu.addAction(self.logchum) self.optionsMenu.addAction(self.notes) self.optionsMenu.addAction(self.blockchum) self.optionsMenu.addAction(self.removechum) - self.moveMenu = QtGui.QMenu(self.mainwindow.theme["main/menus/rclickchumlist/movechum"], self) + self.moveMenu = QtWidgets.QMenu(self.mainwindow.theme["main/menus/rclickchumlist/movechum"], self) self.optionsMenu.addMenu(self.moveMenu) self.optionsMenu.addAction(self.reportchum) self.moveGroupMenu() @@ -292,12 +274,11 @@ class chumArea(RightClickTree): self.setDropIndicatorShown(True) self.setIndentation(4) self.setDragEnabled(True) - self.setDragDropMode(QtGui.QAbstractItemView.InternalMove) + self.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove) self.setAnimated(True) self.setRootIsDecorated(False) - self.connect(self, QtCore.SIGNAL('itemDoubleClicked(QTreeWidgetItem *, int)'), - self, QtCore.SLOT('expandGroup()')) + self.itemDoubleClicked.connect(self.expandGroup) @QtCore.pyqtSlot() def beginNotify(self): @@ -431,7 +412,7 @@ class chumArea(RightClickTree): text = text[0:text.rfind(" (")] currentGroup = text self.moveMenu.clear() - actGroup = QtGui.QActionGroup(self) + actGroup = QtWidgets.QActionGroup(self) groups = self.groups[:] for gtext in groups: @@ -439,8 +420,7 @@ class chumArea(RightClickTree): continue movegroup = self.moveMenu.addAction(gtext) actGroup.addAction(movegroup) - self.connect(actGroup, QtCore.SIGNAL('triggered(QAction *)'), - self, QtCore.SLOT('moveToGroup(QAction *)')) + actGroup.triggered.connect(self.moveToGroup) def addChum(self, chum): if len([c for c in self.chums if c.handle == chum.handle]) != 0: @@ -478,7 +458,7 @@ class chumArea(RightClickTree): def showAllGroups(self, first=False): if first: for i,g in enumerate(self.groups): - child_1 = QtGui.QTreeWidgetItem(["%s" % (g)]) + child_1 = QtWidgets.QTreeWidgetItem(["%s" % (g)]) self.addTopLevelItem(child_1) if self.openGroups[i]: child_1.setExpanded(True) @@ -491,7 +471,7 @@ class chumArea(RightClickTree): curgroups.append(text) for i,g in enumerate(self.groups): if g not in curgroups: - child_1 = QtGui.QTreeWidgetItem(["%s" % (g)]) + child_1 = QtWidgets.QTreeWidgetItem(["%s" % (g)]) j = 0 for h in self.groups: if h == g: @@ -570,7 +550,7 @@ class chumArea(RightClickTree): curgroups.append(text) if not self.findItems(chumLabel.handle, QtCore.Qt.MatchContains | QtCore.Qt.MatchRecursive): if chumLabel.chum.group not in curgroups: - child_1 = QtGui.QTreeWidgetItem(["%s" % (chumLabel.chum.group)]) + child_1 = QtWidgets.QTreeWidgetItem(["%s" % (chumLabel.chum.group)]) i = 0 for g in self.groups: if g == chumLabel.chum.group: @@ -767,8 +747,8 @@ class chumArea(RightClickTree): return currentChum = currentChum.text(0) self.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) - self.connect(self.pesterlogviewer, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('closeActiveLog()')) + self.pesterlogviewer.rejected.connect(self.closeActiveLog) + self.pesterlogviewer.show() self.pesterlogviewer.raise_() self.pesterlogviewer.activateWindow() @@ -781,7 +761,7 @@ class chumArea(RightClickTree): currentChum = self.currentItem() if not currentChum: return - (notes, ok) = QtGui.QInputDialog.getText(self, "Notes", "Enter your notes...") + (notes, ok) = QtWidgets.QInputDialog.getText(self, "Notes", "Enter your notes...") if ok: notes = unicode(notes) self.mainwindow.chumdb.setNotes(currentChum.handle, notes) @@ -791,13 +771,13 @@ class chumArea(RightClickTree): if not hasattr(self, 'renamegroupdialog'): self.renamegroupdialog = None if not self.renamegroupdialog: - (gname, ok) = QtGui.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: gname = unicode(gname) if re.search("[^A-Za-z0-9_\s]", gname) is not None: - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME") - msgbox.setStandardButtons(QtGui.QMessageBox.Ok) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) ret = msgbox.exec_() self.addgroupdialog = None return @@ -846,7 +826,7 @@ class chumArea(RightClickTree): self.takeItem(chumLabel) self.addItem(chumLabel) self.takeTopLevelItem(i) - @QtCore.pyqtSlot(QtGui.QAction) + @QtCore.pyqtSlot(QtWidgets.QAction) def moveToGroup(self, item): if not item: return @@ -859,17 +839,17 @@ class chumArea(RightClickTree): self.takeItem(chumLabel) self.addItem(chumLabel) - removeChumSignal = QtCore.pyqtSignal(QtCore.QString) - blockChumSignal = QtCore.pyqtSignal(QtCore.QString) + removeChumSignal = QtCore.pyqtSignal('QString') + blockChumSignal = QtCore.pyqtSignal('QString') class trollSlum(chumArea): def __init__(self, trolls, mainwindow, parent=None): - QtGui.QListWidget.__init__(self, parent) + QtWidgets.QListWidget.__init__(self, parent) self.mainwindow = mainwindow theme = self.mainwindow.theme self.setStyleSheet(theme["main/trollslum/chumroll/style"]) self.chums = trolls - child_1 = QtGui.QTreeWidgetItem([""]) + child_1 = QtWidgets.QTreeWidgetItem([""]) self.addTopLevelItem(child_1) child_1.setExpanded(True) for c in self.chums: @@ -883,10 +863,8 @@ class trollSlum(chumArea): self.setDropIndicatorShown(False) self.setIndentation(0) - self.optionsMenu = QtGui.QMenu(self) - self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self) - self.connect(self.unblockchum, QtCore.SIGNAL('triggered()'), - self, QtCore.SIGNAL('unblockChumSignal()')) + self.optionsMenu = QtWidgets.QMenu(self) + self.unblockchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self, triggered=self.parent().removeCurrentTroll) self.optionsMenu.addAction(self.unblockchum) #self.sortItems() @@ -906,30 +884,26 @@ class trollSlum(chumArea): for c in chumlistings: c.changeTheme(theme) - unblockChumSignal = QtCore.pyqtSignal(QtCore.QString) + unblockChumSignal = QtCore.pyqtSignal('QString') -class TrollSlumWindow(QtGui.QFrame): +class TrollSlumWindow(QtWidgets.QFrame): def __init__(self, trolls, mainwindow, parent=None): - QtGui.QFrame.__init__(self, parent) + QtWidgets.QFrame.__init__(self, parent) self.mainwindow = mainwindow theme = self.mainwindow.theme - self.slumlabel = QtGui.QLabel(self) + self.slumlabel = QtWidgets.QLabel(self) self.initTheme(theme) self.trollslum = trollSlum(trolls, self.mainwindow, self) - self.connect(self.trollslum, QtCore.SIGNAL('unblockChumSignal()'), - self, QtCore.SLOT('removeCurrentTroll()')) - layout_1 = QtGui.QHBoxLayout() - self.addButton = QtGui.QPushButton("ADD", self) - self.connect(self.addButton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('addTrollWindow()')) - self.removeButton = QtGui.QPushButton("REMOVE", self) - self.connect(self.removeButton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('removeCurrentTroll()')) + self.trollslum.unblockChumSignal.connect(self.removeCurrentTroll) + layout_1 = QtWidgets.QHBoxLayout() + self.addButton = QtWidgets.QPushButton("ADD", self, clicked=self.addTrollWindow) + self.removeButton = QtWidgets.QPushButton("REMOVE", self) + self.removeButton.clicked.connect(self.removeCurrentTroll) layout_1.addWidget(self.addButton) layout_1.addWidget(self.removeButton) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.slumlabel) layout_0.addWidget(self.trollslum) layout_0.addLayout(layout_1) @@ -968,13 +942,13 @@ class TrollSlumWindow(QtGui.QFrame): self.addtrolldialog = None if self.addtrolldialog: return - self.addtrolldialog = QtGui.QInputDialog(self) + self.addtrolldialog = QtWidgets.QInputDialog(self) (handle, ok) = self.addtrolldialog.getText(self, "Add Troll", "Enter Troll Handle:") if ok: handle = unicode(handle) if not (PesterProfile.checkLength(handle) and PesterProfile.checkValid(handle)[0]): - errormsg = QtGui.QErrorMessage(self) + errormsg = QtWidgets.QErrorMessage(self) errormsg.showMessage("THIS IS NOT A VALID CHUMTAG!") self.addchumdialog = None return @@ -982,8 +956,8 @@ class TrollSlumWindow(QtGui.QFrame): self.blockChumSignal.emit(handle) self.addtrolldialog = None - blockChumSignal = QtCore.pyqtSignal(QtCore.QString) - unblockChumSignal = QtCore.pyqtSignal(QtCore.QString) + blockChumSignal = QtCore.pyqtSignal('QString') + unblockChumSignal = QtCore.pyqtSignal('QString') class PesterWindow(MovingWindow): def __init__(self, options, parent=None, app=None): @@ -1024,7 +998,7 @@ class PesterWindow(MovingWindow): themeChecker(self.theme) except ThemeException, (inst): print "Caught: "+inst.parameter - themeWarning = QtGui.QMessageBox(self) + themeWarning = QtWidgets.QMessageBox(self) themeWarning.setText("Theme Error: %s" % (inst)) themeWarning.exec_() self.theme = pesterTheme("pesterchum") @@ -1040,49 +1014,28 @@ class PesterWindow(MovingWindow): self.move(100, 100) - talk = QtGui.QAction(self.theme["main/menus/client/talk"], self) + talk = QtWidgets.QAction(self.theme["main/menus/client/talk"], self, triggered=self.openChat) self.talk = talk - self.connect(talk, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('openChat()')) - logv = QtGui.QAction(self.theme["main/menus/client/logviewer"], self) + logv = QtWidgets.QAction(self.theme["main/menus/client/logviewer"], self, triggered=self.openLogv) self.logv = logv - self.connect(logv, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('openLogv()')) - grps = QtGui.QAction(self.theme["main/menus/client/addgroup"], self) + grps = QtWidgets.QAction(self.theme["main/menus/client/addgroup"], self, triggered=self.addGroupWindow) self.grps = grps - self.connect(grps, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('addGroupWindow()')) - self.rand = QtGui.QAction(self.theme["main/menus/client/randen"], self) - self.connect(self.rand, QtCore.SIGNAL('triggered()'), - self.randhandler, QtCore.SLOT('getEncounter()')) - opts = QtGui.QAction(self.theme["main/menus/client/options"], self) + self.rand = QtWidgets.QAction(self.theme["main/menus/client/randen"], self, triggered=self.randhandler.getEncounter) + opts = QtWidgets.QAction(self.theme["main/menus/client/options"], self, triggered=self.openOpts) self.opts = opts - self.connect(opts, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('openOpts()')) - exitaction = QtGui.QAction(self.theme["main/menus/client/exit"], self) + exitaction = QtWidgets.QAction(self.theme["main/menus/client/exit"], self, triggered=self.app.quit) self.exitaction = exitaction - self.connect(exitaction, QtCore.SIGNAL('triggered()'), - self.app, QtCore.SLOT('quit()')) - userlistaction = QtGui.QAction(self.theme["main/menus/client/userlist"], self) + userlistaction = QtWidgets.QAction(self.theme["main/menus/client/userlist"], self, triggered=self.showAllUsers) self.userlistaction = userlistaction - self.connect(userlistaction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('showAllUsers()')) - memoaction = QtGui.QAction(self.theme["main/menus/client/memos"], self) + memoaction = QtWidgets.QAction(self.theme["main/menus/client/memos"], self, triggered=self.showMemos) self.memoaction = memoaction - self.connect(memoaction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('showMemos()')) - self.importaction = QtGui.QAction(self.theme["main/menus/client/import"], self) - self.connect(self.importaction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('importExternalConfig()')) - self.idleaction = QtGui.QAction(self.theme["main/menus/client/idle"], self) + self.importaction = QtWidgets.QAction(self.theme["main/menus/client/import"], self, triggered=self.importExternalConfig) + self.idleaction = QtWidgets.QAction(self.theme["main/menus/client/idle"], self) self.idleaction.setCheckable(True) - self.connect(self.idleaction, QtCore.SIGNAL('toggled(bool)'), - self, QtCore.SLOT('toggleIdle(bool)')) - self.reconnectAction = QtGui.QAction(self.theme["main/menus/client/reconnect"], self) - self.connect(self.reconnectAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SIGNAL('reconnectIRC()')) + self.idleaction.toggled.connect(self.toggleIdle) + self.reconnectAction = QtWidgets.QAction(self.theme["main/menus/client/reconnect"], self, triggered=self.reconnectIRC) - self.menu = QtGui.QMenuBar(self) + self.menu = QtWidgets.QMenuBar(self) self.menu.setNativeMenuBar(False) filemenu = self.menu.addMenu(self.theme["main/menus/client/_name"]) @@ -1101,24 +1054,16 @@ class PesterWindow(MovingWindow): filemenu.addAction(self.reconnectAction) filemenu.addAction(exitaction) - changequirks = QtGui.QAction(self.theme["main/menus/profile/quirks"], self) + changequirks = QtWidgets.QAction(self.theme["main/menus/profile/quirks"], self, triggered=self.openQuirks) self.changequirks = changequirks - self.connect(changequirks, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('openQuirks()')) - loadslum = QtGui.QAction(self.theme["main/menus/profile/block"], self) + loadslum = QtWidgets.QAction(self.theme["main/menus/profile/block"], self, triggered=self.showTrollSlum) self.loadslum = loadslum - self.connect(loadslum, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('showTrollSlum()')) - changecoloraction = QtGui.QAction(self.theme["main/menus/profile/color"], self) + changecoloraction = QtWidgets.QAction(self.theme["main/menus/profile/color"], self, triggered=self.changeMyColor) self.changecoloraction = changecoloraction - self.connect(changecoloraction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('changeMyColor()')) - switch = QtGui.QAction(self.theme["main/menus/profile/switch"], self) + switch = QtWidgets.QAction(self.theme["main/menus/profile/switch"], self, triggered=self.switchProfile) self.switch = switch - self.connect(switch, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('switchProfile()')) profilemenu = self.menu.addMenu(self.theme["main/menus/profile/_name"]) self.profilemenu = profilemenu @@ -1127,24 +1072,12 @@ class PesterWindow(MovingWindow): profilemenu.addAction(changecoloraction) profilemenu.addAction(switch) - self.helpAction = QtGui.QAction(self.theme["main/menus/help/help"], self) - self.connect(self.helpAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('launchHelp()')) - self.botAction = QtGui.QAction(self.theme["main/menus/help/calsprite"], self) - self.connect(self.botAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('loadCalsprite()')) - self.nickServAction = QtGui.QAction(self.theme["main/menus/help/nickserv"], self) - self.connect(self.nickServAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('loadNickServ()')) - self.chanServAction = QtGui.QAction(self.theme["main/menus/help/chanserv"], self) - self.connect(self.chanServAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('loadChanServ()')) - self.aboutAction = QtGui.QAction(self.theme["main/menus/help/about"], self) - self.connect(self.aboutAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('aboutPesterchum()')) - self.reportBugAction = QtGui.QAction("REPORT BUG", self) - self.connect(self.reportBugAction, QtCore.SIGNAL('triggered()'), - self, QtCore.SLOT('reportBug()')) + self.helpAction = QtWidgets.QAction(self.theme["main/menus/help/help"], self, triggered=self.launchHelp) + self.botAction = QtWidgets.QAction(self.theme["main/menus/help/calsprite"], self, triggered=self.loadCalsprite) + self.nickServAction = QtWidgets.QAction(self.theme["main/menus/help/nickserv"], self, triggered=self.loadNickServ) + self.chanServAction = QtWidgets.QAction(self.theme["main/menus/help/chanserv"], self, triggered=self.loadChanServ) + self.aboutAction = QtWidgets.QAction(self.theme["main/menus/help/about"], self, triggered=self.aboutPesterchum) + self.reportBugAction = QtWidgets.QAction("REPORT BUG", self, triggered=self.reportBug) helpmenu = self.menu.addMenu(self.theme["main/menus/help/_name"]) self.helpmenu = helpmenu self.helpmenu.addAction(self.helpAction) @@ -1164,40 +1097,21 @@ class PesterWindow(MovingWindow): chums = [PesterProfile(c, chumdb=self.chumdb) for c in set(self.config.chums())] self.chumList = chumArea(chums, self) - self.connect(self.chumList, - QtCore.SIGNAL('itemActivated(QTreeWidgetItem *, int)'), - self, - QtCore.SLOT('pesterSelectedChum()')) - self.connect(self.chumList, - QtCore.SIGNAL('removeChumSignal(QString)'), - self, - QtCore.SLOT('removeChum(QString)')) - self.connect(self.chumList, - QtCore.SIGNAL('blockChumSignal(QString)'), - self, - QtCore.SLOT('blockChum(QString)')) + self.chumList.itemActivated.connect(self.pesterSelectedChum) + self.chumList.removeChumSignal.connect(self.removeChum) + self.chumList.blockChumSignal.connect(self.blockChum) - self.addChumButton = QtGui.QPushButton(self.theme["main/addchum/text"], self) - self.connect(self.addChumButton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('addChumWindow()')) - self.pesterButton = QtGui.QPushButton(self.theme["main/pester/text"], self) - self.connect(self.pesterButton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('pesterSelectedChum()')) - self.blockButton = QtGui.QPushButton(self.theme["main/block/text"], self) - self.connect(self.blockButton, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('blockSelectedChum()')) + self.addChumButton = QtWidgets.QPushButton(self.theme["main/addchum/text"], self, clicked=self.addChumWindow) + self.pesterButton = QtWidgets.QPushButton(self.theme["main/pester/text"], self, clicked=self.pesterSelectedChum) + self.blockButton = QtWidgets.QPushButton(self.theme["main/block/text"], self, clicked=self.blockSelectedChum) - self.moodsLabel = QtGui.QLabel(self.theme["main/moodlabel/text"], self) + self.moodsLabel = QtWidgets.QLabel(self.theme["main/moodlabel/text"], self) - self.mychumhandleLabel = QtGui.QLabel(self.theme["main/mychumhandle/label/text"], self) - self.mychumhandle = QtGui.QPushButton(self.profile().handle, self) + self.mychumhandleLabel = QtWidgets.QLabel(self.theme["main/mychumhandle/label/text"], self) + self.mychumhandle = QtWidgets.QPushButton(self.profile().handle, self, clicked=self.switchProfile) self.mychumhandle.setFlat(True) - self.connect(self.mychumhandle, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('switchProfile()')) - self.mychumcolor = QtGui.QPushButton(self) - self.connect(self.mychumcolor, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('changeMyColor()')) + self.mychumcolor = QtWidgets.QPushButton(self, clicked=self.changeMyColor) self.initTheme(self.theme) @@ -1205,11 +1119,9 @@ class PesterWindow(MovingWindow): self.autoidle = False self.idlethreshold = 60*self.config.idleTime() - self.idletimer = QtCore.QTimer(self) + self.idletimer = QtCore.QTimer(self, timeout=self.checkIdle) self.idleposition = QtGui.QCursor.pos() self.idletime = 0 - self.connect(self.idletimer, QtCore.SIGNAL('timeout()'), - self, QtCore.SLOT('checkIdle()')) self.idletimer.start(1000) if not self.config.defaultprofile(): @@ -1217,14 +1129,11 @@ class PesterWindow(MovingWindow): # Fuck you some more OSX leopard! >:( if not ostools.isOSXLeopard(): - QtCore.QTimer.singleShot(1000, self, QtCore.SLOT('mspacheck()')) + QtCore.QTimer.singleShot(1000, self.mspacheck) - self.connect(self, QtCore.SIGNAL('pcUpdate(QString, QString)'), - self, QtCore.SLOT('updateMsg(QString, QString)')) + self.pcUpdate.connect(self.updateMsg) - self.pingtimer = QtCore.QTimer() - self.connect(self.pingtimer, QtCore.SIGNAL('timeout()'), - self, QtCore.SLOT('checkPing()')) + self.pingtimer = QtCore.QTimer(timeout=self.checkPing) self.lastping = int(time()) self.pingtimer.start(1000*90) @@ -1234,16 +1143,14 @@ class PesterWindow(MovingWindow): if not ostools.isOSXLeopard(): checker = MSPAChecker(self) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def updateMsg(self, ver, url): if not hasattr(self, 'updatemenu'): self.updatemenu = None if not self.updatemenu: self.updatemenu = UpdatePesterchum(ver, url, self) - self.connect(self.updatemenu, QtCore.SIGNAL('accepted()'), - self, QtCore.SLOT('updatePC()')) - self.connect(self.updatemenu, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('noUpdatePC()')) + self.updatemenu.accepted.connect(self.updatePC) + self.updatemenu.rejected.connect(self.noUpdatePC) self.updatemenu.show() self.updatemenu.raise_() self.updatemenu.activateWindow() @@ -1421,28 +1328,24 @@ class PesterWindow(MovingWindow): self.tabconvo.show() else: convoWindow = PesterConvo(chum, initiated, self) - self.connect(convoWindow, QtCore.SIGNAL('messageSent(QString, QString)'), - self, QtCore.SIGNAL('sendMessage(QString, QString)')) - self.connect(convoWindow, QtCore.SIGNAL('windowClosed(QString)'), - self, QtCore.SLOT('closeConvo(QString)')) + convoWindow.messageSent.connect(self.sendMessage) + convoWindow.windowClosed.connect(self.closeConvo) self.convos[chum.handle] = convoWindow if unicode(chum.handle).upper() in BOTNAMES: convoWindow.toggleQuirks(True) convoWindow.quirksOff.setChecked(True) if unicode(chum.handle).upper() in CUSTOMBOTS: - self.newConvoStarted.emit(QtCore.QString(chum.handle), initiated) + self.newConvoStarted.emit(chum.handle, initiated) else: - self.newConvoStarted.emit(QtCore.QString(chum.handle), initiated) + self.newConvoStarted.emit(chum.handle, initiated) convoWindow.show() def createTabWindow(self): self.tabconvo = PesterTabWindow(self) - self.connect(self.tabconvo, QtCore.SIGNAL('windowClosed()'), - self, QtCore.SLOT('tabsClosed()')) + self.tabconvo.windowClosed.connect(self.tabsClosed) def createMemoTabWindow(self): self.tabmemo = MemoTabWindow(self) - self.connect(self.tabmemo, QtCore.SIGNAL('windowClosed()'), - self, QtCore.SLOT('memoTabsClosed()')) + self.tabmemo.windowClosed.connect(self.memoTabsClosed) def newMemo(self, channel, timestr, secret=False, invite=False): if channel == "#pesterchum": @@ -1459,19 +1362,13 @@ class PesterWindow(MovingWindow): else: memoWindow = PesterMemo(channel, timestr, self, None) # connect signals - self.connect(self, QtCore.SIGNAL('inviteOnlyChan(QString)'), - memoWindow, QtCore.SLOT('closeInviteOnly(QString)')) - self.connect(memoWindow, QtCore.SIGNAL('messageSent(QString, QString)'), - self, QtCore.SIGNAL('sendMessage(QString, QString)')) - self.connect(memoWindow, QtCore.SIGNAL('windowClosed(QString)'), - self, QtCore.SLOT('closeMemo(QString)')) - self.connect(self, QtCore.SIGNAL('namesUpdated(QString)'), - memoWindow, QtCore.SLOT('namesUpdated(QString)')) - self.connect(self, QtCore.SIGNAL('modesUpdated(QString, QString)'), - memoWindow, QtCore.SLOT('modesUpdated(QString, QString)')) - self.connect(self, - QtCore.SIGNAL('userPresentSignal(QString, QString, QString)'), - memoWindow, QtCore.SLOT('userPresentChange(QString, QString, QString)')) + self.inviteOnlyChan.connect(memoWindow.closeInviteOnly) + self.namesUpdated.connect(memoWindow.namesUpdated) + self.modesUpdated.connect(memoWindow.modesUpdated) + self.userPresentSignal.connect(memoWindow.userPresentChange) + memoWindow.messageSent.connect(self.sendMessage) + memoWindow.windowClosed.connect(self.closeMemo) + # chat client send memo open self.memos[channel] = memoWindow self.joinChannel.emit(channel) # race condition? @@ -1610,7 +1507,7 @@ class PesterWindow(MovingWindow): if hasattr(self, 'currentMoodIcon') and self.currentMoodIcon: self.currentMoodIcon.hide() self.currentMoodIcon = None - self.currentMoodIcon = QtGui.QLabel(self) + self.currentMoodIcon = QtWidgets.QLabel(self) self.currentMoodIcon.setPixmap(moodicon.pixmap(moodicon.realsize())) self.currentMoodIcon.move(*theme["main/mychumhandle/currentMood"]) self.currentMoodIcon.show() @@ -1660,7 +1557,7 @@ class PesterWindow(MovingWindow): try: themeChecker(theme) except ThemeException, (inst): - themeWarning = QtGui.QMessageBox(self) + themeWarning = QtWidgets.QMessageBox(self) themeWarning.setText("Theme Error: %s" % (inst)) themeWarning.exec_() theme = pesterTheme("pesterchum") @@ -1726,7 +1623,7 @@ class PesterWindow(MovingWindow): @QtCore.pyqtSlot() def connected(self): if self.loadingscreen: - self.loadingscreen.done(QtGui.QDialog.Accepted) + self.loadingscreen.done(QtWidgets.QDialog.Accepted) self.loadingscreen = None self.doAutoIdentify() @@ -1748,7 +1645,7 @@ class PesterWindow(MovingWindow): if text not in self.chumList.groups and \ text != "Chums": self.newConversationWindow(curChum) - @QtCore.pyqtSlot(QtGui.QListWidgetItem) + @QtCore.pyqtSlot(QtWidgets.QListWidgetItem) def newConversationWindow(self, chumlisting): # check chumdb chum = chumlisting.chum @@ -1756,7 +1653,7 @@ class PesterWindow(MovingWindow): if color: chum.color = color self.newConversation(chum) - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def closeConvo(self, handle): h = unicode(handle) try: @@ -1772,7 +1669,7 @@ class PesterWindow(MovingWindow): self.convoClosed.emit(handle) self.chatlog.finish(h) del self.convos[h] - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def closeMemo(self, channel): c = unicode(channel) self.chatlog.finish(c) @@ -1790,35 +1687,35 @@ class PesterWindow(MovingWindow): del self.tabmemo self.tabmemo = None - @QtCore.pyqtSlot(QtCore.QString, Mood) + @QtCore.pyqtSlot('QString', Mood) def updateMoodSlot(self, handle, mood): h = unicode(handle) self.updateMood(h, mood) - @QtCore.pyqtSlot(QtCore.QString, QtGui.QColor) + @QtCore.pyqtSlot('QString', QtGui.QColor) def updateColorSlot(self, handle, color): h = unicode(handle) self.changeColor(h, color) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def deliverMessage(self, handle, msg): h = unicode(handle) m = unicode(msg) self.newMessage(h, m) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString', '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, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def deliverNotice(self, handle, msg): h = unicode(handle) m = unicode(msg) if m.startswith("Your nickname is now being changed to"): changedto = m[39:-1] - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() 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(QtGui.QMessageBox.Ok) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) ret = msgbox.exec_() elif h == self.randhandler.randNick: self.randhandler.incoming(msg) @@ -1829,31 +1726,31 @@ class PesterWindow(MovingWindow): if m: t = self.tm.Toast("NickServ:", m) t.show() - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def deliverInvite(self, handle, channel): - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setText("You're invited!") msgbox.setInformativeText("%s has invited you to the memo: %s\nWould you like to join them?" % (handle, channel)) - msgbox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel) ret = msgbox.exec_() - if ret == QtGui.QMessageBox.Ok: + if ret == QtWidgets.QMessageBox.Ok: self.newMemo(unicode(channel), "+0:00") - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def chanInviteOnly(self, channel): self.inviteOnlyChan.emit(channel) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def cannotSendToChan(self, channel, msg): self.deliverMemo(channel, "ChanServ", msg) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def modesUpdated(self, channel, modes): self.modesUpdated.emit(channel, modes) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString', 'QString') def timeCommand(self, chan, handle, command): (c, h, cmd) = (unicode(chan), unicode(handle), unicode(command)) if self.memos[c]: self.memos[c].timeUpdate(h, cmd) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString', 'QString') def quirkDisable(self, channel, msg, op): (c, msg, op) = (unicode(channel), unicode(msg), unicode(op)) if not self.memos.has_key(c): @@ -1861,14 +1758,14 @@ class PesterWindow(MovingWindow): memo = self.memos[c] memo.quirkDisable(op, msg) - @QtCore.pyqtSlot(QtCore.QString, PesterList) + @QtCore.pyqtSlot('QString', PesterList) def updateNames(self, channel, names): c = unicode(channel) # update name DB self.namesdb[c] = names # warn interested party of names self.namesUpdated.emit(c) - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString', 'QString') def userPresentUpdate(self, handle, channel, update): c = unicode(channel) n = unicode(handle) @@ -1932,12 +1829,12 @@ class PesterWindow(MovingWindow): return if not (PesterProfile.checkLength(handle) and PesterProfile.checkValid(handle)[0]): - errormsg = QtGui.QErrorMessage(self) + errormsg = QtWidgets.QErrorMessage(self) errormsg.showMessage("THIS IS NOT A VALID CHUMTAG!") self.addchumdialog = None return if re.search("[^A-Za-z0-9_\s]", group) is not None: - errormsg = QtGui.QErrorMessage(self) + errormsg = QtWidgets.QErrorMessage(self) errormsg.showMessage("THIS IS NOT A VALID GROUP NAME") self.addchumdialog = None return @@ -1948,15 +1845,15 @@ class PesterWindow(MovingWindow): self.chumdb.setGroup(handle, group) self.addChum(chum) self.addchumdialog = None - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def removeChum(self, chumlisting): self.config.removeChum(chumlisting) def reportChum(self, handle): - (reason, ok) = QtGui.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: self.sendMessage.emit("REPORT %s %s" % (handle, reason) , "calSprite") - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def blockChum(self, handle): h = unicode(handle) self.config.addBlocklist(h) @@ -1974,7 +1871,7 @@ class PesterWindow(MovingWindow): self.moodRequest.emit(newtroll) self.blockedChum.emit(handle) - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def unblockChum(self, handle): h = unicode(handle) self.config.delBlocklist(h) @@ -2028,7 +1925,7 @@ class PesterWindow(MovingWindow): self.idleposition = newpos @QtCore.pyqtSlot() def importExternalConfig(self): - f = QtGui.QFileDialog.getOpenFileName(self) + f = QtWidgets.QFileDialog.getOpenFileName(self) if f == "": return fp = open(f, 'r') @@ -2076,10 +1973,8 @@ class PesterWindow(MovingWindow): if self.memochooser: return self.memochooser = PesterMemoList(self, channel) - self.connect(self.memochooser, QtCore.SIGNAL('accepted()'), - self, QtCore.SLOT('joinSelectedMemo()')) - self.connect(self.memochooser, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('memoChooserClose()')) + self.memochooser.accepted.connect(self.joinSelectedMemo) + self.memochooser.rejected.connect(self.memoChooserClose) self.requestChannelList.emit() self.memochooser.show() @QtCore.pyqtSlot() @@ -2114,23 +2009,19 @@ class PesterWindow(MovingWindow): self.allusers = None if not self.allusers: self.allusers = PesterUserlist(self.config, self.theme, self) - self.connect(self.allusers, QtCore.SIGNAL('accepted()'), - self, QtCore.SLOT('userListClose()')) - self.connect(self.allusers, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('userListClose()')) - self.connect(self.allusers, QtCore.SIGNAL('addChum(QString)'), - self, QtCore.SLOT('userListAdd(QString)')) - self.connect(self.allusers, QtCore.SIGNAL('pesterChum(QString)'), - self, QtCore.SLOT('userListPester(QString)')) + self.allusers.accepted.connect(self.userListClose) + self.allusers.rejected.connect(self.userListClose) + self.allusers.addChum.connect(self.userListAdd) + self.allusers.pesterChum.connect(self.userListPester) self.requestNames.emit("#pesterchum") self.allusers.show() - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def userListAdd(self, handle): h = unicode(handle) chum = PesterProfile(h, chumdb=self.chumdb) self.addChum(chum) - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def userListPester(self, handle): h = unicode(handle) self.newConversation(h) @@ -2144,10 +2035,8 @@ class PesterWindow(MovingWindow): self.quirkmenu = None if not self.quirkmenu: self.quirkmenu = PesterChooseQuirks(self.config, self.theme, self) - self.connect(self.quirkmenu, QtCore.SIGNAL('accepted()'), - self, QtCore.SLOT('updateQuirks()')) - self.connect(self.quirkmenu, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('closeQuirks()')) + self.quirkmenu.accepted.connect(self.updateQuirks) + self.quirkmenu.rejected.connect(self.closeQuirks) self.quirkmenu.show() self.quirkmenu.raise_() self.quirkmenu.activateWindow() @@ -2174,7 +2063,7 @@ class PesterWindow(MovingWindow): if not hasattr(self, "openchatdialog"): self.openchatdialog = None if not self.openchatdialog: - (chum, ok) = QtGui.QInputDialog.getText(self, "Pester Chum", "Enter a handle to pester:") + (chum, ok) = QtWidgets.QInputDialog.getText(self, "Pester Chum", "Enter a handle to pester:") try: if ok: self.newConversation(unicode(chum)) @@ -2188,10 +2077,8 @@ class PesterWindow(MovingWindow): self.logusermenu = None if not self.logusermenu: self.logusermenu = PesterLogUserSelect(self.config, self.theme, self) - self.connect(self.logusermenu, QtCore.SIGNAL('accepted()'), - self, QtCore.SLOT('closeLogUsers()')) - self.connect(self.logusermenu, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('closeLogUsers()')) + self.logusermenu.accepted.connect(self.closeLogUsers) + self.logusermenu.rejected.connect(self.closeLogUsers) self.logusermenu.show() self.logusermenu.raise_() self.logusermenu.activateWindow() @@ -2205,13 +2092,13 @@ class PesterWindow(MovingWindow): if not hasattr(self, 'addgroupdialog'): self.addgroupdialog = None if not self.addgroupdialog: - (gname, ok) = QtGui.QInputDialog.getText(self, "Add Group", "Enter a name for the new group:") + (gname, ok) = QtWidgets.QInputDialog.getText(self, "Add Group", "Enter a name for the new group:") if ok: gname = unicode(gname) if re.search("[^A-Za-z0-9_\s]", gname) is not None: - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME") - msgbox.setStandardButtons(QtGui.QMessageBox.Ok) + msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) ret = msgbox.exec_() self.addgroupdialog = None return @@ -2224,10 +2111,8 @@ class PesterWindow(MovingWindow): self.optionmenu = None if not self.optionmenu: self.optionmenu = PesterOptions(self.config, self.theme, self) - self.connect(self.optionmenu, QtCore.SIGNAL('accepted()'), - self, QtCore.SLOT('updateOptions()')) - self.connect(self.optionmenu, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('closeOptions()')) + self.optionmenu.accepted.connect(self.updateOptions) + self.optionmenu.rejected.connect(self.closeOptions) self.optionmenu.show() self.optionmenu.raise_() self.optionmenu.activateWindow() @@ -2495,24 +2380,18 @@ class PesterWindow(MovingWindow): def setButtonAction(self, button, setting, old): if old == 0: # minimize to taskbar - self.disconnect(button, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('showMinimized()')); + button.clicked.disconnect(self.showMinimized) elif old == 1: # minimize to tray - self.disconnect(button, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('closeToTray()')); + button.clicked.disconnect(self.closeToTray) elif old == 2: # quit - self.disconnect(button, QtCore.SIGNAL('clicked()'), - self.app, QtCore.SLOT('quit()')); + button.clicked.disconnect(self.app.quit) if setting == 0: # minimize to taskbar - self.connect(button, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('showMinimized()')); + button.clicked.connect(self.showMinimized) elif setting == 1: # minimize to tray - self.connect(button, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('closeToTray()')); + button.clicked.connect(self.closeToTray) elif setting == 2: # quit - self.connect(button, QtCore.SIGNAL('clicked()'), - self.app, QtCore.SLOT('quit()')); + button.clicked.connect(self.app.quit) @QtCore.pyqtSlot() def themeSelectOverride(self): @@ -2528,7 +2407,7 @@ class PesterWindow(MovingWindow): try: self.changeTheme(pesterTheme(themename)) except ValueError, e: - themeWarning = QtGui.QMessageBox(self) + themeWarning = QtWidgets.QMessageBox(self) themeWarning.setText("Theme Error: %s" % (e)) themeWarning.exec_() self.choosetheme = None @@ -2577,11 +2456,8 @@ class PesterWindow(MovingWindow): return trolls = [PesterProfile(h) for h in self.config.getBlocklist()] self.trollslum = TrollSlumWindow(trolls, self) - self.connect(self.trollslum, QtCore.SIGNAL('blockChumSignal(QString)'), - self, QtCore.SLOT('blockChum(QString)')) - self.connect(self.trollslum, - QtCore.SIGNAL('unblockChumSignal(QString)'), - self, QtCore.SLOT('unblockChum(QString)')) + self.trollslum.blockChumSignal.connect(self.blockChum) + self.trollslum.unblockChumSignal.connect(self.unblockChum) self.moodsRequest.emit(PesterList(trolls)) self.trollslum.show() @QtCore.pyqtSlot() @@ -2593,7 +2469,7 @@ class PesterWindow(MovingWindow): self.colorDialog = None if self.colorDialog: return - self.colorDialog = QtGui.QColorDialog(self) + self.colorDialog = QtWidgets.QColorDialog(self) color = self.colorDialog.getColor(initial=self.profile().color) if not color.isValid(): color = self.profile().color @@ -2607,13 +2483,13 @@ class PesterWindow(MovingWindow): @QtCore.pyqtSlot() def switchProfile(self): if self.convos: - closeWarning = QtGui.QMessageBox() + 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(QtGui.QMessageBox.Cancel | QtGui.QMessageBox.Ok) - closeWarning.setDefaultButton(QtGui.QMessageBox.Ok) + closeWarning.setStandardButtons(QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Ok) + closeWarning.setDefaultButton(QtWidgets.QMessageBox.Ok) ret = closeWarning.exec_() - if ret == QtGui.QMessageBox.Cancel: + if ret == QtWidgets.QMessageBox.Cancel: return self.changeProfile() @QtCore.pyqtSlot() @@ -2643,7 +2519,7 @@ class PesterWindow(MovingWindow): self.bugreportwindow.exec_() self.bugreportwindow = None - @QtCore.pyqtSlot(QtCore.QString, QtCore.QString) + @QtCore.pyqtSlot('QString', 'QString') def nickCollision(self, handle, tmphandle): self.mychumhandle.setText(tmphandle) self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0))) @@ -2654,7 +2530,7 @@ class PesterWindow(MovingWindow): if not self.chooseprofile: h = unicode(handle) self.changeProfile(collision=h) - @QtCore.pyqtSlot(QtCore.QString) + @QtCore.pyqtSlot('QString') def myHandleChanged(self, handle): if self.profile().handle == handle: self.doAutoIdentify() @@ -2666,59 +2542,59 @@ class PesterWindow(MovingWindow): def pickTheme(self): self.themePicker() - @QtCore.pyqtSlot(QtGui.QSystemTrayIcon.ActivationReason) + @QtCore.pyqtSlot(QtWidgets.QSystemTrayIcon.ActivationReason) def systemTrayActivated(self, reason): - if reason == QtGui.QSystemTrayIcon.Trigger: + if reason == QtWidgets.QSystemTrayIcon.Trigger: self.systemTrayFunction() - elif reason == QtGui.QSystemTrayIcon.Context: + elif reason == QtWidgets.QSystemTrayIcon.Context: pass # show context menu i guess #self.showTrayContext.emit() @QtCore.pyqtSlot() def tooManyPeeps(self): - msg = QtGui.QMessageBox(self) + msg = QtWidgets.QMessageBox(self) msg.setText("D: TOO MANY PEOPLE!!!") msg.setInformativeText("The server has hit max capacity. Please try again later.") msg.show() - pcUpdate = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) + pcUpdate = QtCore.pyqtSignal('QString', 'QString') closeToTraySignal = QtCore.pyqtSignal() - newConvoStarted = QtCore.pyqtSignal(QtCore.QString, bool, name="newConvoStarted") - sendMessage = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - sendNotice = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - convoClosed = QtCore.pyqtSignal(QtCore.QString) + newConvoStarted = QtCore.pyqtSignal('QString', bool, name="newConvoStarted") + sendMessage = QtCore.pyqtSignal('QString', 'QString') + sendNotice = QtCore.pyqtSignal('QString', 'QString') + convoClosed = QtCore.pyqtSignal('QString') profileChanged = QtCore.pyqtSignal() animationSetting = QtCore.pyqtSignal(bool) moodRequest = QtCore.pyqtSignal(PesterProfile) moodsRequest = QtCore.pyqtSignal(PesterList) moodUpdated = QtCore.pyqtSignal() requestChannelList = QtCore.pyqtSignal() - requestNames = QtCore.pyqtSignal(QtCore.QString) - namesUpdated = QtCore.pyqtSignal(QtCore.QString) - modesUpdated = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - userPresentSignal = QtCore.pyqtSignal(QtCore.QString,QtCore.QString,QtCore.QString) + requestNames = QtCore.pyqtSignal('QString') + namesUpdated = QtCore.pyqtSignal('QString') + modesUpdated = QtCore.pyqtSignal('QString', 'QString') + userPresentSignal = QtCore.pyqtSignal('QString','QString','QString') mycolorUpdated = QtCore.pyqtSignal() trayIconSignal = QtCore.pyqtSignal(int) - blockedChum = QtCore.pyqtSignal(QtCore.QString) - unblockedChum = QtCore.pyqtSignal(QtCore.QString) - kickUser = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - joinChannel = QtCore.pyqtSignal(QtCore.QString) - leftChannel = QtCore.pyqtSignal(QtCore.QString) - setChannelMode = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, QtCore.QString) - channelNames = QtCore.pyqtSignal(QtCore.QString) - inviteChum = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) - inviteOnlyChan = QtCore.pyqtSignal(QtCore.QString) + blockedChum = QtCore.pyqtSignal('QString') + unblockedChum = QtCore.pyqtSignal('QString') + kickUser = QtCore.pyqtSignal('QString', 'QString') + joinChannel = QtCore.pyqtSignal('QString') + leftChannel = QtCore.pyqtSignal('QString') + setChannelMode = QtCore.pyqtSignal('QString', 'QString', 'QString') + channelNames = QtCore.pyqtSignal('QString') + inviteChum = QtCore.pyqtSignal('QString', 'QString') + inviteOnlyChan = QtCore.pyqtSignal('QString') closeSignal = QtCore.pyqtSignal() reconnectIRC = QtCore.pyqtSignal() - gainAttention = QtCore.pyqtSignal(QtGui.QWidget) + gainAttention = QtCore.pyqtSignal(QtWidgets.QWidget) pingServer = QtCore.pyqtSignal() setAway = QtCore.pyqtSignal(bool) - killSomeQuirks = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) + killSomeQuirks = QtCore.pyqtSignal('QString', 'QString') -class PesterTray(QtGui.QSystemTrayIcon): +class PesterTray(QtWidgets.QSystemTrayIcon): def __init__(self, icon, mainwindow, parent): - QtGui.QSystemTrayIcon.__init__(self, icon, parent) + QtWidgets.QSystemTrayIcon.__init__(self, icon, parent) self.mainwindow = mainwindow @QtCore.pyqtSlot(int) @@ -2734,7 +2610,7 @@ class PesterTray(QtGui.QSystemTrayIcon): class MainProgram(QtCore.QObject): def __init__(self): QtCore.QObject.__init__(self) - self.app = QtGui.QApplication(sys.argv) + self.app = QtWidgets.QApplication(sys.argv) self.app.setApplicationName("Pesterchum 3.14") self.app.setQuitOnLastWindowClosed(False) @@ -2753,58 +2629,36 @@ class MainProgram(QtCore.QObject): self.widget.show() self.trayicon = PesterTray(PesterIcon(self.widget.theme["main/icon"]), self.widget, self.app) - self.traymenu = QtGui.QMenu() + self.traymenu = QtWidgets.QMenu() moodMenu = self.traymenu.addMenu("SET MOOD") moodCategories = {} for k in Mood.moodcats: moodCategories[k] = moodMenu.addMenu(k.upper()) self.moodactions = {} for (i,m) in enumerate(Mood.moods): - maction = QtGui.QAction(m.upper(), self) mobj = PesterMoodAction(i, self.widget.moods.updateMood) - self.trayicon.connect(maction, QtCore.SIGNAL('triggered()'), - mobj, QtCore.SLOT('updateMood()')) + maction = QtWidgets.QAction(m.upper(), self, triggered=mobj.updateMood) self.moodactions[i] = mobj moodCategories[Mood.revmoodcats[m]].addAction(maction) - miniAction = QtGui.QAction("MINIMIZE", self) - self.trayicon.connect(miniAction, QtCore.SIGNAL('triggered()'), - self.widget, QtCore.SLOT('showMinimized()')) - exitAction = QtGui.QAction("EXIT", self) - self.trayicon.connect(exitAction, QtCore.SIGNAL('triggered()'), - self.app, QtCore.SLOT('quit()')) + miniAction = QtWidgets.QAction("MINIMIZE", self, triggered=self.widget.showMinimized) + exitAction = QtWidgets.QAction("EXIT", self, triggered=self.app.quit) self.traymenu.addAction(miniAction) self.traymenu.addAction(exitAction) self.trayicon.setContextMenu(self.traymenu) self.trayicon.show() - self.trayicon.connect(self.trayicon, - QtCore.SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), - self.widget, - QtCore.SLOT('systemTrayActivated(QSystemTrayIcon::ActivationReason)')) - self.trayicon.connect(self.widget, - QtCore.SIGNAL('trayIconSignal(int)'), - self.trayicon, - QtCore.SLOT('changeTrayIcon(int)')) - self.trayicon.connect(self.widget, - QtCore.SIGNAL('closeToTraySignal()'), - self, - QtCore.SLOT('trayiconShow()')) - self.trayicon.connect(self.widget, - QtCore.SIGNAL('closeSignal()'), - self.trayicon, - QtCore.SLOT('mainWindowClosed()')) - self.connect(self.trayicon, - QtCore.SIGNAL('messageClicked()'), - self, - QtCore.SLOT('trayMessageClick()')) + self.trayicon.activated.connect(self.widget.systemTrayActivated) + self.widget.trayIconSignal.connect(self.trayicon.changeTrayIcon) + self.widget.closeToTraySignal.connect(self.trayiconShow) + self.widget.closeSignal.connect(self.trayicon.mainWindowClosed) + self.trayicon.messageClicked.connect(self.trayMessageClick) self.attempts = 0 self.irc = PesterIRC(self.widget.config, self.widget) self.connectWidgets(self.irc, self.widget) - self.connect(self.widget, QtCore.SIGNAL('gainAttention(QWidget*)'), - self, QtCore.SLOT('alertWindow(QWidget*)')) + self.widget.gainAttention.connect(self.alertWindow) # 0 Once a day # 1 Once a week @@ -2818,13 +2672,13 @@ class MainProgram(QtCore.QObject): if int(time()) - self.widget.config.lastUCheck() < seconds: seconds -= int(time()) - self.widget.config.lastUCheck() if seconds < 0: seconds = 0 - QtCore.QTimer.singleShot(1000*seconds, self, QtCore.SLOT('runUpdateSlot()')) + QtCore.QTimer.singleShot(1000*seconds, self.runUpdateSlot) elif check == 1: seconds = 60 * 60 * 24 * 7 if int(time()) - self.widget.config.lastUCheck() < seconds: seconds -= int(time()) - self.widget.config.lastUCheck() if seconds < 0: seconds = 0 - QtCore.QTimer.singleShot(1000*seconds, self, QtCore.SLOT('runUpdateSlot()')) + QtCore.QTimer.singleShot(1000*seconds, self.runUpdateSlot) @QtCore.pyqtSlot() def runUpdateSlot(self): @@ -2841,9 +2695,9 @@ class MainProgram(QtCore.QObject): seconds = 60 * 60 * 24 * 7 else: return - QtCore.QTimer.singleShot(1000*seconds, self, QtCore.SLOT('runUpdateSlot()')) + QtCore.QTimer.singleShot(1000*seconds, self.runUpdateSlot) - @QtCore.pyqtSlot(QtGui.QWidget) + @QtCore.pyqtSlot(QtWidgets.QWidget) def alertWindow(self, widget): self.app.alert(widget) @@ -2859,101 +2713,61 @@ Click this message to never see this again.") def trayMessageClick(self): self.widget.config.set('traymsg', False) - widget2irc = [('sendMessage(QString, QString)', - 'sendMessage(QString, QString)'), - ('sendNotice(QString, QString)', - 'sendNotice(QString, QString)'), - ('newConvoStarted(QString, bool)', - 'startConvo(QString, bool)'), - ('convoClosed(QString)', - 'endConvo(QString)'), - ('profileChanged()', - 'updateProfile()'), - ('moodRequest(PyQt_PyObject)', - 'getMood(PyQt_PyObject)'), - ('moodsRequest(PyQt_PyObject)', - 'getMoods(PyQt_PyObject)'), - ('moodUpdated()', 'updateMood()'), - ('mycolorUpdated()','updateColor()'), - ('blockedChum(QString)', 'blockedChum(QString)'), - ('unblockedChum(QString)', 'unblockedChum(QString)'), - ('requestNames(QString)','requestNames(QString)'), - ('requestChannelList()', 'requestChannelList()'), - ('joinChannel(QString)', 'joinChannel(QString)'), - ('leftChannel(QString)', 'leftChannel(QString)'), - ('kickUser(QString, QString)', - 'kickUser(QString, QString)'), - ('setChannelMode(QString, QString, QString)', - 'setChannelMode(QString, QString, QString)'), - ('channelNames(QString)', - 'channelNames(QString)'), - ('inviteChum(QString, QString)', - 'inviteChum(QString, QString)'), - ('pingServer()', 'pingServer()'), - ('setAway(bool)', 'setAway(bool)'), - ('killSomeQuirks(QString, QString)', - 'killSomeQuirks(QString, QString)'), - ('reconnectIRC()', 'reconnectIRC()') - ] -# IRC --> Main window - irc2widget = [('connected()', 'connected()'), - ('moodUpdated(QString, PyQt_PyObject)', - 'updateMoodSlot(QString, PyQt_PyObject)'), - ('colorUpdated(QString, QColor)', - 'updateColorSlot(QString, QColor)'), - ('messageReceived(QString, QString)', - 'deliverMessage(QString, QString)'), - ('memoReceived(QString, QString, QString)', - 'deliverMemo(QString, QString, QString)'), - ('noticeReceived(QString, QString)', - 'deliverNotice(QString, QString)'), - ('inviteReceived(QString, QString)', - 'deliverInvite(QString, QString)'), - ('nickCollision(QString, QString)', - 'nickCollision(QString, QString)'), - ('myHandleChanged(QString)', - 'myHandleChanged(QString)'), - ('namesReceived(QString, PyQt_PyObject)', - 'updateNames(QString, PyQt_PyObject)'), - ('userPresentUpdate(QString, QString, QString)', - 'userPresentUpdate(QString, QString, QString)'), - ('channelListReceived(PyQt_PyObject)', - 'updateChannelList(PyQt_PyObject)'), - ('timeCommand(QString, QString, QString)', - 'timeCommand(QString, QString, QString)'), - ('chanInviteOnly(QString)', - 'chanInviteOnly(QString)'), - ('modesUpdated(QString, QString)', - 'modesUpdated(QString, QString)'), - ('cannotSendToChan(QString, QString)', - 'cannotSendToChan(QString, QString)'), - ('tooManyPeeps()', - 'tooManyPeeps()'), - ('quirkDisable(QString, QString, QString)', - 'quirkDisable(QString, QString, QString)') - ] + def ircQtConnections(self, irc, widget): + # IRC --> Main window + return ((widget.sendMessage, irc.sendMessage), + (widget.sendNotice, irc.sendNotice), + (widget.newConvoStarted, irc.startConvo), + (widget.convoClosed, irc.endConvo), + (widget.profileChanged, irc.updateProfile), + (widget.moodRequest, irc.getMood), + (widget.moodsRequest, irc.getMoods), + (widget.moodUpdated, irc.updateMood), + (widget.mycolorUpdated, irc.updateColor), + (widget.blockedChum, irc.blockedChum), + (widget.unblockedChum, irc.unblockedChum), + (widget.requestNames, irc.requestNames), + (widget.requestChannelList, irc.requestChannelList), + (widget.joinChannel, irc.joinChannel), + (widget.leftChannel, irc.leftChannel), + (widget.kickUser, irc.kickUser), + (widget.setChannelMode, irc.setChannelMode), + (widget.channelNames, irc.channelNames), + (widget.inviteChum, irc.inviteChum), + (widget.pingServer, irc.pingServer), + (widget.setAway, irc.setAway), + (widget.killSomeQuirks, irc.killSomeQuirks), + (widget.reconnectIRC, irc.reconnectIRC), + # Main window --> IRC + (irc.connected, widget.connected), + (irc.moodUpdated, widget.updateMoodSlot), + (irc.messageReceived, widget.deliverMessage), + (irc.memoReceived, widget.deliverMemo), + (irc.noticeReceived, widget.deliverNotice), + (irc.inviteReceived, widget.deliverInvite), + (irc.nickCollision, widget.nickCollision), + (irc.myHandleChanged, widget.myHandleChanged), + (irc.namesReceived, widget.updateNames), + (irc.userPresentUpdate, widget.userPresentUpdate), + (irc.channelListReceived, widget.updateChannelList), + (irc.timeCommand, widget.timeCommand), + (irc.chanInviteOnly, widget.chanInviteOnly), + (irc.modesUpdated, widget.modesUpdated), + (irc.cannotSendToChan, widget.cannotSendToChan), + (irc.tooManyPeeps, widget.tooManyPeeps), + (irc.quirkDisable, widget.quirkDisable)) + def connectWidgets(self, irc, widget): - self.connect(irc, QtCore.SIGNAL('finished()'), - self, QtCore.SLOT('restartIRC()')) - self.connect(irc, QtCore.SIGNAL('connected()'), - self, QtCore.SLOT('connected()')) - for c in self.widget2irc: - self.connect(widget, QtCore.SIGNAL(c[0]), - irc, QtCore.SLOT(c[1])) - for c in self.irc2widget: - self.connect(irc, QtCore.SIGNAL(c[0]), - widget, QtCore.SLOT(c[1])) + irc.finished.connect(self.restartIRC) + irc.connected.connect(self.connected) + for sig, slot in self.ircQtConnections(irc, widget): + sig.connect(slot) + def disconnectWidgets(self, irc, widget): - for c in self.widget2irc: - self.disconnect(widget, QtCore.SIGNAL(c[0]), - irc, QtCore.SLOT(c[1])) - for c in self.irc2widget: - self.disconnect(irc, QtCore.SIGNAL(c[0]), - widget, QtCore.SLOT(c[1])) - self.disconnect(irc, QtCore.SIGNAL('connected()'), - self, QtCore.SLOT('connected()')) - self.disconnect(self.irc, QtCore.SIGNAL('finished()'), - self, QtCore.SLOT('restartIRC()')) + for sig, slot in self.ircQtConnections(irc, widget): + sig.disconnect(slot) + irc.connected.disconnect(self.connected) + self.irc.finished.disconnect(self.restartIRC) def showUpdate(self, q): new_url = q.get() @@ -2983,10 +2797,8 @@ Click this message to never see this again.") else: widget.loadingscreen = LoadingScreen(widget) widget.loadingscreen.loadinglabel.setText(msg) - self.connect(widget.loadingscreen, QtCore.SIGNAL('rejected()'), - widget.app, QtCore.SLOT('quit()')) - self.connect(self.widget.loadingscreen, QtCore.SIGNAL('tryAgain()'), - self, QtCore.SLOT('tryAgain()')) + widget.loadingscreen.rejected.connect(widget.app.quit) + self.widget.loadingscreen.tryAgain.connect(self.tryAgain) if hasattr(self, 'irc') and self.irc.registeredIRC: return if self.reconnectok: @@ -2994,7 +2806,7 @@ Click this message to never see this again.") else: widget.loadingscreen.hideReconnect() status = widget.loadingscreen.exec_() - if status == QtGui.QDialog.Rejected: + if status == QtWidgets.QDialog.Rejected: sys.exit(0) else: if self.widget.tabmemo: @@ -3013,7 +2825,7 @@ Click this message to never see this again.") if not self.reconnectok: return if self.widget.loadingscreen: - self.widget.loadingscreen.done(QtGui.QDialog.Accepted) + self.widget.loadingscreen.done(QtWidgets.QDialog.Accepted) self.widget.loadingscreen = None self.attempts += 1 if hasattr(self, 'irc') and self.irc: diff --git a/profile.py b/profile.py index 029f9f5..64b6d28 100644 --- a/profile.py +++ b/profile.py @@ -7,7 +7,7 @@ import codecs import platform from datetime import * from time import strftime, time -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets import ostools from mood import Mood @@ -57,7 +57,7 @@ class PesterLog(object): try: fp = codecs.open("%s/%s/%s/%s/%s.%s.txt" % (self.logpath, self.handle, handle, format, handle, time), encoding='utf-8', mode='a') except IOError: - errmsg = QtGui.QMessageBox(self) + errmsg = QtWidgets.QMessageBox(self) 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.show() diff --git a/pyquirks.py b/pyquirks.py index 8ecf999..f4a5b37 100644 --- a/pyquirks.py +++ b/pyquirks.py @@ -1,6 +1,6 @@ import os, sys, imp, re, ostools from quirks import ScriptQuirks -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets class PythonQuirks(ScriptQuirks): def loadModule(self, name, filename): @@ -26,7 +26,7 @@ class PythonQuirks(ScriptQuirks): raise Exception except: print "Quirk malformed: %s" % (obj.command) - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setWindowTitle("Error!") msgbox.setText("Quirk malformed: %s" % (obj.command)) msgbox.exec_() diff --git a/quirks.py b/quirks.py index e07b14b..7499abe 100644 --- a/quirks.py +++ b/quirks.py @@ -1,5 +1,5 @@ import os, sys, re, ostools -from PyQt4 import QtGui, QtCore +from PyQt5 import QtWidgets, QtCore class ScriptQuirks(object): def __init__(self): @@ -66,7 +66,7 @@ class ScriptQuirks(object): continue except Exception, e: print "Error loading %s: %s (in quirks.py)" % (os.path.basename(name), e) - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setWindowTitle("Error!") msgbox.setText("Error loading %s: %s (in quirks.py)" % (os.path.basename(filename), e)) msgbox.exec_() diff --git a/randomer.py b/randomer.py index ff62399..af60239 100644 --- a/randomer.py +++ b/randomer.py @@ -1,4 +1,4 @@ -from PyQt4 import QtGui, QtCore +from PyQt5 import QtWidgets, QtCore RANDNICK = "randomEncounter" @@ -58,8 +58,7 @@ class RandomHandler(QtCore.QObject): pass elif code == "!": if l[1] == "x": - from PyQt4 import QtGui - msgbox = QtGui.QMessageBox() + msgbox = QtWidgets.QMessageBox() msgbox.setText("Unable to fetch you a random encounter!") msgbox.setInformativeText("Try again later :(") msgbox.exec_() diff --git a/toast.py b/toast.py index 7691332..c040d62 100644 --- a/toast.py +++ b/toast.py @@ -2,7 +2,7 @@ import inspect import threading import time, os import ostools -from PyQt4 import QtGui, QtCore +from PyQt5 import QtGui, QtCore, QtWidgets try: import pynotify @@ -10,11 +10,12 @@ except: pynotify = None class DefaultToast(object): - def __init__(self, machine, title, msg, icon): - self.machine = machine - self.title = title - self.msg = msg - self.icon = icon + def __init__(self, parent, **kwds): + super(DefaultToast, self).__init__(parent, **kwds) + self.machine = kwds.get('machine') + self.title = kwds.get('title') + self.msg = kwds.get('msg') + self.icon = kwds.get('icon') def show(self): print self.title, self.msg, self.icon self.done() @@ -176,9 +177,9 @@ class ToastMachine(object): self.showNext() -class PesterToast(QtGui.QWidget, DefaultToast): +class PesterToast(QtWidgets.QWidget, DefaultToast): def __init__(self, machine, title, msg, icon, time=3000, parent=None): - QtGui.QWidget.__init__(self, parent) + super(PesterToast, self).__init__(self, parent, machine=machine, title=title, msg=msg, icon=icon) self.machine = machine self.time = time @@ -189,33 +190,31 @@ class PesterToast(QtGui.QWidget, DefaultToast): self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.ToolTip) self.m_animation = QtCore.QParallelAnimationGroup() - anim = QtCore.QPropertyAnimation(self) + anim = QtCore.QPropertyAnimation(self, finished=self.reverseTrigger) anim.setTargetObject(self) self.m_animation.addAnimation(anim) anim.setEasingCurve(QtCore.QEasingCurve.OutBounce) anim.setDuration(1000) - self.connect(anim, QtCore.SIGNAL('finished()'), - self, QtCore.SLOT('reverseTrigger()')) self.m_animation.setDirection(QtCore.QAnimationGroup.Forward) - self.title = QtGui.QLabel(title, self) - self.msg = QtGui.QLabel(msg, self) + self.title = QtWidgets.QLabel(title, self) + self.msg = QtWidgets.QLabel(msg, self) self.content = msg if icon: - self.icon = QtGui.QLabel("") + self.icon = QtWidgets.QLabel("") self.icon.setPixmap(QtGui.QPixmap(icon).scaledToWidth(30)) else: - self.icon = QtGui.QLabel("") + self.icon = QtWidgets.QLabel("") self.icon.setPixmap(QtGui.QPixmap(30, 30)) self.icon.pixmap().fill(QtGui.QColor(0,0,0,0)) - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.setMargin(0) layout_0.setContentsMargins(0, 0, 0, 0) if self.icon: - layout_1 = QtGui.QGridLayout() + layout_1 = QtWidgets.QGridLayout() layout_1.addWidget(self.icon, 0,0, 1,1) layout_1.addWidget(self.title, 0,1, 1,7) layout_1.setAlignment(self.msg, QtCore.Qt.AlignTop) @@ -240,12 +239,11 @@ class PesterToast(QtGui.QWidget, DefaultToast): self.msg.setText(PesterToast.wrapText(self.msg.font(), unicode(self.msg.text()), self.parent().theme["toasts/width"], self.parent().theme["toasts/content/style"])) - p = QtGui.QApplication.desktop().availableGeometry(self).bottomRight() - o = QtGui.QApplication.desktop().screenGeometry(self).bottomRight() + p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight() + o = QtWidgets.QApplication.desktop().screenGeometry(self).bottomRight() anim.setStartValue(p.y() - o.y()) anim.setEndValue(100) - self.connect(anim, QtCore.SIGNAL('valueChanged(QVariant)'), - self, QtCore.SLOT('updateBottomLeftAnimation(QVariant)')) + anim.valueChanged.connect(self.updateBottomLeftAnimation) self.byebye = False @@ -255,7 +253,7 @@ class PesterToast(QtGui.QWidget, DefaultToast): @QtCore.pyqtSlot() def done(self): - QtGui.QWidget.hide(self) + QtWidgets.QWidget.hide(self) t = self.machine.toasts[0] if t.title == unicode(self.title.text()) and \ t.msg == unicode(self.content): @@ -277,19 +275,17 @@ class PesterToast(QtGui.QWidget, DefaultToast): anim = self.m_animation.animationAt(0) self.m_animation.setDirection(QtCore.QAnimationGroup.Backward) anim.setEasingCurve(QtCore.QEasingCurve.InCubic) - self.disconnect(anim, QtCore.SIGNAL('finished()'), - self, QtCore.SLOT('reverseTrigger()')) - self.connect(anim, QtCore.SIGNAL('finished()'), - self, QtCore.SLOT('done()')) + anim.finished.disconnect(self.reverseTrigger) + anim.finished.connect(self.done) self.m_animation.start() @QtCore.pyqtSlot(QtCore.QVariant) def updateBottomLeftAnimation(self, value): - p = QtGui.QApplication.desktop().availableGeometry(self).bottomRight() + p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight() val = float(self.height())/100 self.move(p.x()-self.width(), p.y() - (value.toInt()[0] * val) +1) self.layout().setSpacing(0) - QtGui.QWidget.show(self) + QtWidgets.QWidget.show(self) def mousePressEvent(self, event): if event.button() == QtCore.Qt.RightButton: @@ -397,7 +393,6 @@ class PesterToastMachine(ToastMachine, QtCore.QObject): pass #~ self.timer = QtCore.QTimer(self) #~ self.timer.setInterval(1000) - #~ self.connect(self.timer, QtCore.SIGNAL('timeout()'), - #~ self, QtCore.SLOT('showNext()')) + #~ self.timer.timeout.connect(self.showNext) #~ if self.on: #~ self.timer.start() diff --git a/updatecheck.py b/updatecheck.py index ef88e25..b5dfd5b 100644 --- a/updatecheck.py +++ b/updatecheck.py @@ -5,18 +5,16 @@ import pickle import os import threading from time import mktime -from PyQt4 import QtCore, QtGui +from PyQt5 import QtCore, QtGui, QtWidgets -class MSPAChecker(QtGui.QWidget): +class MSPAChecker(QtWidgets.QWidget): def __init__(self, parent=None): QtCore.QObject.__init__(self, parent) self.mainwindow = parent self.refreshRate = 30 # seconds self.status = None self.lock = False - self.timer = QtCore.QTimer(self) - self.connect(self.timer, QtCore.SIGNAL('timeout()'), - self, QtCore.SLOT('check_site_wrapper()')) + self.timer = QtCore.QTimer(self, timeout=self.check_site_wrapper) self.timer.start(1000*self.refreshRate) def save_state(self): @@ -38,7 +36,7 @@ class MSPAChecker(QtGui.QWidget): os.remove("status_old.pkl") except Exception, e: print e - msg = QtGui.QMessageBox(self) + msg = QtWidgets.QMessageBox(self) msg.setText("Problems writing save file.") msg.show() @@ -79,10 +77,8 @@ class MSPAChecker(QtGui.QWidget): self.mspa = None if not self.mspa: self.mspa = MSPAUpdateWindow(self.parent()) - self.connect(self.mspa, QtCore.SIGNAL('accepted()'), - self, QtCore.SLOT('visit_site()')) - self.connect(self.mspa, QtCore.SIGNAL('rejected()'), - self, QtCore.SLOT('nothing()')) + self.mspa.accepted.connect(self.visit_site) + self.mspa.rejected.connect(self.nothing) self.mspa.show() else: #print "No new updates :(" @@ -103,27 +99,23 @@ class MSPAChecker(QtGui.QWidget): def nothing(self): self.mspa = None -class MSPAUpdateWindow(QtGui.QDialog): +class MSPAUpdateWindow(QtWidgets.QDialog): def __init__(self, parent=None): - QtGui.QDialog.__init__(self, parent) + QtWidgets.QDialog.__init__(self, parent) self.mainwindow = parent self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) self.setWindowTitle("MSPA Update!") self.setModal(False) - self.title = QtGui.QLabel("You have an unread MSPA update! :o)") + self.title = QtWidgets.QLabel("You have an unread MSPA update! :o)") - layout_0 = QtGui.QVBoxLayout() + layout_0 = QtWidgets.QVBoxLayout() layout_0.addWidget(self.title) - self.ok = QtGui.QPushButton("GO READ NOW!", self) + self.ok = QtWidgets.QPushButton("GO READ NOW!", self, clicked=self.accept) self.ok.setDefault(True) - self.connect(self.ok, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('accept()')) - self.cancel = QtGui.QPushButton("LATER", self) - self.connect(self.cancel, QtCore.SIGNAL('clicked()'), - self, QtCore.SLOT('reject()')) - layout_2 = QtGui.QHBoxLayout() + self.cancel = QtWidgets.QPushButton("LATER", self, clicked=self.reject) + layout_2 = QtWidgets.QHBoxLayout() layout_2.addWidget(self.cancel) layout_2.addWidget(self.ok)