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