Port code to PyQt5

This commit is contained in:
illuminatedwax 2014-10-29 01:06:21 -05:00
parent f2a482b241
commit abe9342c4f
20 changed files with 922 additions and 1341 deletions

View file

@ -1,51 +1,47 @@
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore, QtWidgets
import urllib
import ostools
import version
class BugReporter(QtGui.QDialog):
class BugReporter(QtWidgets.QDialog):
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
QtWidgets.QDialog.__init__(self, parent)
self.mainwindow = parent
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
self.setWindowTitle("Report a Bug")
self.setModal(False)
self.title = QtGui.QLabel("Bug Report:")
self.title = QtWidgets.QLabel("Bug Report:")
layout_0 = QtGui.QVBoxLayout()
layout_0 = QtWidgets.QVBoxLayout()
layout_0.addWidget(self.title)
layout_0.addWidget(QtGui.QLabel("Chumhandle:"))
handleLabel = QtGui.QLabel("The best chumhandle to contact you at for further information.")
layout_0.addWidget(QtWidgets.QLabel("Chumhandle:"))
handleLabel = QtWidgets.QLabel("The best chumhandle to contact you at for further information.")
font = handleLabel.font()
font.setPointSize(8)
handleLabel.setFont(font)
layout_0.addWidget(handleLabel)
self.name = QtGui.QLineEdit(self)
self.name = QtWidgets.QLineEdit(self)
self.name.setStyleSheet("background:white; font-weight:bold; color:black; font-size: 10pt;")
layout_0.addWidget(self.name)
layout_0.addWidget(QtGui.QLabel("Description of bug:"))
descLabel = QtGui.QLabel("Include as much information as possible\n(theme, related options, what you were doing at the time, etc.)")
layout_0.addWidget(QtWidgets.QLabel("Description of bug:"))
descLabel = QtWidgets.QLabel("Include as much information as possible\n(theme, related options, what you were doing at the time, etc.)")
font = descLabel.font()
font.setPointSize(8)
descLabel.setFont(font)
layout_0.addWidget(descLabel)
self.textarea = QtGui.QTextEdit(self)
self.textarea = QtWidgets.QTextEdit(self)
self.textarea.setStyleSheet("background:white; font-weight:normal; color:black; font-size: 10pt;")
layout_0.addWidget(self.textarea)
self.ok = QtGui.QPushButton("SEND", self)
self.ok = QtWidgets.QPushButton("SEND", self, clicked=self.sendReport)
self.ok.setDefault(True)
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('sendReport()'))
self.cancel = QtGui.QPushButton("CANCEL", self)
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('reject()'))
layout_2 = QtGui.QHBoxLayout()
self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject)
layout_2 = QtWidgets.QHBoxLayout()
layout_2.addWidget(self.cancel)
layout_2.addWidget(self.ok)
@ -64,14 +60,14 @@ class BugReporter(QtGui.QDialog):
msg = unicode(self.textarea.toPlainText())
if len(bestname) <= 0 or len(msg) <= 0:
msgbox = QtGui.QMessageBox()
msgbox = QtWidgets.QMessageBox()
msgbox.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
msgbox.setText("You must fill out all fields first!")
msgbox.setStandardButtons(QtGui.QMessageBox.Ok)
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
ret = msgbox.exec_()
return
QtGui.QDialog.accept(self)
QtWidgets.QDialog.accept(self)
data = urllib.urlencode({"name":name, "version": version._pcVersion, "bestname":bestname, "os":os, "platform":full, "python":python, "qt":qt, "msg":msg})
print "Sending..."
f = urllib.urlopen("http://distantsphere.com/pc/reporter.php", data)

120
convo.py
View file

@ -5,7 +5,7 @@ import httplib, urllib
from time import strftime
from copy import copy
from datetime import datetime, timedelta
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore, QtWidgets
from mood import Mood
from dataobjs import PesterProfile, PesterHistory
@ -13,25 +13,22 @@ from generic import PesterIcon
from parsetools import convertTags, lexMessage, splitMessage, mecmd, colorBegin, colorEnd, \
img2smiley, smiledict, oocre
class PesterTabWindow(QtGui.QFrame):
class PesterTabWindow(QtWidgets.QFrame):
def __init__(self, mainwindow, parent=None, convo="convo"):
QtGui.QFrame.__init__(self, parent)
QtWidgets.QFrame.__init__(self, parent)
self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
self.setFocusPolicy(QtCore.Qt.ClickFocus)
self.mainwindow = mainwindow
self.tabs = QtGui.QTabBar(self)
self.tabs = QtWidgets.QTabBar(self)
self.tabs.setMovable(True)
self.tabs.setTabsClosable(True)
self.connect(self.tabs, QtCore.SIGNAL('currentChanged(int)'),
self, QtCore.SLOT('changeTab(int)'))
self.connect(self.tabs, QtCore.SIGNAL('tabCloseRequested(int)'),
self, QtCore.SLOT('tabClose(int)'))
self.connect(self.tabs, QtCore.SIGNAL('tabMoved(int, int)'),
self, QtCore.SLOT('tabMoved(int, int)'))
self.tabs.currentChanged.connect(self.changeTab)
self.tabs.tabCloseRequested.connect(self.tabClose)
self.tabs.tabMoved.connect(self.tabMoved)
self.initTheme(self.mainwindow.theme)
self.layout = QtGui.QVBoxLayout()
self.layout = QtWidgets.QVBoxLayout()
self.layout.setContentsMargins(0,0,0,0)
self.layout.addWidget(self.tabs)
self.setLayout(self.layout)
@ -235,9 +232,9 @@ class PesterMovie(QtGui.QMovie):
text.urls[movie], movie.currentPixmap())
text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth())
class PesterText(QtGui.QTextEdit):
class PesterText(QtWidgets.QTextEdit):
def __init__(self, theme, parent=None):
QtGui.QTextEdit.__init__(self, parent)
QtWidgets.QTextEdit.__init__(self, parent)
if hasattr(self.parent(), 'mainwindow'):
self.mainwindow = self.parent().mainwindow
else:
@ -251,21 +248,18 @@ class PesterText(QtGui.QTextEdit):
self.setReadOnly(True)
self.setMouseTracking(True)
self.textSelected = False
self.connect(self, QtCore.SIGNAL('copyAvailable(bool)'),
self, QtCore.SLOT('textReady(bool)'))
self.copyAvailable.connect(self.textReady)
self.urls = {}
for k in smiledict:
self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k]))
self.connect(self.mainwindow, QtCore.SIGNAL('animationSetting(bool)'),
self, QtCore.SLOT('animateChanged(bool)'))
self.mainwindow.animationSetting.connect(self.animateChanged)
def addAnimation(self, url, fileName):
movie = PesterMovie(self)
movie.setFileName(fileName)
movie.setCacheMode(QtGui.QMovie.CacheAll)
if movie.frameCount() > 1:
self.urls[movie] = url
movie.connect(movie, QtCore.SIGNAL('frameChanged(int)'),
movie, QtCore.SLOT('animate(int)'))
movie.frameChanged.connect(movie.animate)
#movie.start()
@QtCore.pyqtSlot(bool)
def animateChanged(self, animate):
@ -383,14 +377,14 @@ class PesterText(QtGui.QTextEdit):
sb.setValue(sb.maximum())
def focusInEvent(self, event):
self.parent().clearNewMessage()
QtGui.QTextEdit.focusInEvent(self, event)
QtWidgets.QTextEdit.focusInEvent(self, event)
def keyPressEvent(self, event):
if hasattr(self.parent(), 'textInput'):
if event.key() not in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown, \
QtCore.Qt.Key_Up, QtCore.Qt.Key_Down]:
self.parent().textInput.keyPressEvent(event)
QtGui.QTextEdit.keyPressEvent(self, event)
QtWidgets.QTextEdit.keyPressEvent(self, event)
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.LeftButton:
@ -403,12 +397,12 @@ class PesterText(QtGui.QTextEdit):
self.parent().mainwindow.newConversation(handle)
else:
if event.modifiers() == QtCore.Qt.ControlModifier:
QtGui.QApplication.clipboard().setText(url)
QtWidgets.QApplication.clipboard().setText(url)
else:
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode))
QtGui.QTextEdit.mousePressEvent(self, event)
QtWidgets.QTextEdit.mousePressEvent(self, event)
def mouseMoveEvent(self, event):
QtGui.QTextEdit.mouseMoveEvent(self, event)
QtWidgets.QTextEdit.mouseMoveEvent(self, event)
if self.anchorAt(event.pos()):
if self.viewport().cursor().shape != QtCore.Qt.PointingHandCursor:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
@ -418,9 +412,7 @@ class PesterText(QtGui.QTextEdit):
def contextMenuEvent(self, event):
textMenu = self.createStandardContextMenu()
if self.textSelected:
self.submitLogAction = QtGui.QAction("Submit to Pesterchum QDB", self)
self.connect(self.submitLogAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('submitLog()'))
self.submitLogAction = QtWidgets.QAction("Submit to Pesterchum QDB", self, triggered=self.submitLog)
textMenu.addAction(self.submitLogAction)
textMenu.exec_(event.globalPos())
@ -435,12 +427,10 @@ class PesterText(QtGui.QTextEdit):
textdoc = QtGui.QTextDocument()
textdoc.setHtml(htmldata)
logdata = "%s\n%s" % (self.submitLogTitle(), textdoc.toPlainText())
self.sending = QtGui.QDialog(self)
layout = QtGui.QVBoxLayout()
self.sending.sendinglabel = QtGui.QLabel("S3ND1NG...", self.sending)
cancelbutton = QtGui.QPushButton("OK", self.sending)
self.sending.connect(cancelbutton, QtCore.SIGNAL('clicked()'),
self.sending, QtCore.SLOT('close()'))
self.sending = QtWidgets.QDialog(self)
layout = QtWidgets.QVBoxLayout()
self.sending.sendinglabel = QtWidgets.QLabel("S3ND1NG...", self.sending)
cancelbutton = QtWidgets.QPushButton("OK", self.sending, clicked=self.sending.close)
layout.addWidget(self.sending.sendinglabel)
layout.addWidget(cancelbutton)
self.sending.setLayout(layout)
@ -463,16 +453,16 @@ class PesterText(QtGui.QTextEdit):
self.sending.sendinglabel.setText("F41L3D: %s" % (e))
del self.sending
class PesterInput(QtGui.QLineEdit):
class PesterInput(QtWidgets.QLineEdit):
def __init__(self, theme, parent=None):
QtGui.QLineEdit.__init__(self, parent)
QtWidgets.QLineEdit.__init__(self, parent)
self.setStyleSheet(theme["convo/input/style"])
def changeTheme(self, theme):
self.setStyleSheet(theme["convo/input/style"])
def focusInEvent(self, event):
self.parent().clearNewMessage()
self.parent().textArea.textCursor().clearSelection()
QtGui.QLineEdit.focusInEvent(self, event)
QtWidgets.QLineEdit.focusInEvent(self, event)
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Up:
text = unicode(self.text())
@ -486,11 +476,11 @@ class PesterInput(QtGui.QLineEdit):
elif event.key() in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]:
self.parent().textArea.keyPressEvent(event)
self.parent().mainwindow.idletime = 0
QtGui.QLineEdit.keyPressEvent(self, event)
QtWidgets.QLineEdit.keyPressEvent(self, event)
class PesterConvo(QtGui.QFrame):
class PesterConvo(QtWidgets.QFrame):
def __init__(self, chum, initiated, mainwindow, parent=None):
QtGui.QFrame.__init__(self, parent)
QtWidgets.QFrame.__init__(self, parent)
self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
self.setObjectName(chum.handle)
self.setFocusPolicy(QtCore.Qt.ClickFocus)
@ -504,20 +494,19 @@ class PesterConvo(QtGui.QFrame):
t = Template(self.mainwindow.theme["convo/chumlabel/text"])
self.chumLabel = QtGui.QLabel(t.safe_substitute(handle=chum.handle), self)
self.chumLabel = QtWidgets.QLabel(t.safe_substitute(handle=chum.handle), self)
self.chumLabel.setStyleSheet(self.mainwindow.theme["convo/chumlabel/style"])
self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]])
self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"])
self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"])
self.chumLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding))
self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding))
self.textArea = PesterText(self.mainwindow.theme, self)
self.textInput = PesterInput(self.mainwindow.theme, self)
self.textInput.setFocus()
self.connect(self.textInput, QtCore.SIGNAL('returnPressed()'),
self, QtCore.SLOT('sentMessage()'))
self.textInput.returnPressed.connect(self.sentMessage)
self.layout = QtGui.QVBoxLayout()
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.chumLabel)
self.layout.addWidget(self.textArea)
self.layout.addWidget(self.textInput)
@ -528,31 +517,17 @@ class PesterConvo(QtGui.QFrame):
self.setLayout(self.layout)
self.optionsMenu = QtGui.QMenu(self)
self.optionsMenu = QtWidgets.QMenu(self)
self.optionsMenu.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
self.addChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.connect(self.addChumAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('addThisChum()'))
self.blockAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self)
self.connect(self.blockAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('blockThisChum()'))
self.quirksOff = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self)
self.addChumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self, triggered=self.addThisChum)
self.blockAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self, triggered=self.blockThisChum)
self.quirksOff = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self, toggled=self.toggleQuirks)
self.quirksOff.setCheckable(True)
self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'),
self, QtCore.SLOT('toggleQuirks(bool)'))
self.oocToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self)
self.oocToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self, toggled=self.toggleOOC)
self.oocToggle.setCheckable(True)
self.connect(self.oocToggle, QtCore.SIGNAL('toggled(bool)'),
self, QtCore.SLOT('toggleOOC(bool)'))
self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
self.connect(self.unblockchum, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('unblockChumSlot()'))
self.reportchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self)
self.connect(self.reportchum, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('reportThisChum()'))
self.logchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self)
self.connect(self.logchum, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('openChumLogs()'))
self.unblockchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self, triggered=self.unblockChumSlot)
self.reportchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self, triggered=self.reportThisChum)
self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self, triggered=self.openChumLogs)
self.optionsMenu.addAction(self.quirksOff)
self.optionsMenu.addAction(self.oocToggle)
@ -708,7 +683,7 @@ class PesterConvo(QtGui.QFrame):
self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]])
self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"])
self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"])
self.chumLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding))
self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding))
self.quirksOff.setText(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"])
self.addChumAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/addchum"])
self.blockAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"])
@ -734,7 +709,7 @@ class PesterConvo(QtGui.QFrame):
try:
lexmsg = quirks.apply(lexmsg)
except:
msgbox = QtGui.QMessageBox()
msgbox = QtWidgets.QMessageBox()
msgbox.setText("Whoa there! There seems to be a problem.")
msgbox.setInformativeText("A quirk seems to be having a problem. (Possibly you're trying to capture a non-existant group?)")
msgbox.exec_()
@ -746,7 +721,7 @@ class PesterConvo(QtGui.QFrame):
self.addMessage(lm, True)
# if ceased, rebegin
if hasattr(self, 'chumopen') and not self.chumopen:
self.mainwindow.newConvoStarted.emit(QtCore.QString(self.title()), True)
self.mainwindow.newConvoStarted.emit(self.title(), True)
self.setChumOpen(True)
text = convertTags(serverMsg, "ctag")
self.messageSent.emit(text, self.title())
@ -774,14 +749,13 @@ class PesterConvo(QtGui.QFrame):
def openChumLogs(self):
currentChum = self.chum.handle
self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow)
self.connect(self.mainwindow.chumList.pesterlogviewer, QtCore.SIGNAL('rejected()'),
self.mainwindow.chumList, QtCore.SLOT('closeActiveLog()'))
self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog)
self.mainwindow.chumList.pesterlogviewer.show()
self.mainwindow.chumList.pesterlogviewer.raise_()
self.mainwindow.chumList.pesterlogviewer.activateWindow()
messageSent = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
windowClosed = QtCore.pyqtSignal(QtCore.QString)
messageSent = QtCore.pyqtSignal('QString', 'QString')
windowClosed = QtCore.pyqtSignal('QString')
aligndict = {"h": {"center": QtCore.Qt.AlignHCenter,
"left": QtCore.Qt.AlignLeft,

View file

@ -1,4 +1,4 @@
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore
from datetime import *
import re
import random

View file

@ -1,4 +1,4 @@
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore, QtWidgets
from datetime import timedelta
class mysteryTime(timedelta):
@ -41,7 +41,7 @@ class PesterIcon(QtGui.QIcon):
except IndexError:
return None
class RightClickList(QtGui.QListWidget):
class RightClickList(QtWidgets.QListWidget):
def contextMenuEvent(self, event):
#fuckin Qt
if event.reason() == QtGui.QContextMenuEvent.Mouse:
@ -53,7 +53,7 @@ class RightClickList(QtGui.QListWidget):
def getOptionsMenu(self):
return self.optionsMenu
class RightClickTree(QtGui.QTreeWidget):
class RightClickTree(QtWidgets.QTreeWidget):
def contextMenuEvent(self, event):
if event.reason() == QtGui.QContextMenuEvent.Mouse:
listing = self.itemAt(event.pos())
@ -64,41 +64,37 @@ class RightClickTree(QtGui.QTreeWidget):
def getOptionsMenu(self):
return self.optionsMenu
class MultiTextDialog(QtGui.QDialog):
class MultiTextDialog(QtWidgets.QDialog):
def __init__(self, title, parent, *queries):
QtGui.QDialog.__init__(self, parent)
QtWidgets.QDialog.__init__(self, parent)
self.setWindowTitle(title)
if len(queries) == 0:
return
self.inputs = {}
layout_1 = QtGui.QHBoxLayout()
layout_1 = QtWidgets.QHBoxLayout()
for d in queries:
label = d["label"]
inputname = d["inputname"]
value = d.get("value", "")
l = QtGui.QLabel(label, self)
l = QtWidgets.QLabel(label, self)
layout_1.addWidget(l)
self.inputs[inputname] = QtGui.QLineEdit(value, self)
self.inputs[inputname] = QtWidgets.QLineEdit(value, self)
layout_1.addWidget(self.inputs[inputname])
self.ok = QtGui.QPushButton("OK", self)
self.ok = QtWidgets.QPushButton("OK", self, clicked=self.accept)
self.ok.setDefault(True)
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('accept()'))
self.cancel = QtGui.QPushButton("CANCEL", self)
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('reject()'))
layout_ok = QtGui.QHBoxLayout()
self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject)
layout_ok = QtWidgets.QHBoxLayout()
layout_ok.addWidget(self.cancel)
layout_ok.addWidget(self.ok)
layout_0 = QtGui.QVBoxLayout()
layout_0 = QtWidgets.QVBoxLayout()
layout_0.addLayout(layout_1)
layout_0.addLayout(layout_ok)
self.setLayout(layout_0)
def getText(self):
r = self.exec_()
if r == QtGui.QDialog.Accepted:
if r == QtWidgets.QDialog.Accepted:
retval = {}
for (name, widget) in self.inputs.iteritems():
retval[name] = unicode(widget.text())
@ -106,9 +102,9 @@ class MultiTextDialog(QtGui.QDialog):
else:
return None
class MovingWindow(QtGui.QFrame):
class MovingWindow(QtWidgets.QFrame):
def __init__(self, *x, **y):
QtGui.QFrame.__init__(self, *x, **y)
QtWidgets.QFrame.__init__(self, *x, **y)
self.moving = None
self.moveupdate = 0
def mouseMoveEvent(self, event):
@ -131,9 +127,9 @@ class NoneSound(object):
def play(self): pass
def set_volume(self, v): pass
class WMButton(QtGui.QPushButton):
class WMButton(QtWidgets.QPushButton):
def __init__(self, icon, parent=None):
QtGui.QPushButton.__init__(self, icon, "", parent)
QtWidgets.QPushButton.__init__(self, icon, "", parent)
self.setIconSize(icon.realsize())
self.resize(icon.realsize())
self.setFlat(True)

62
irc.py
View file

@ -1,4 +1,4 @@
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore
from oyoyo.client import IRCClient
from oyoyo.cmdhandler import DefaultCommandHandler
from oyoyo import helpers, services
@ -97,7 +97,7 @@ class PesterIRC(QtCore.QThread):
@QtCore.pyqtSlot(PesterList)
def getMoods(self, chums):
self.cli.command_handler.getMood(*chums)
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
@QtCore.pyqtSlot('QString', 'QString')
def sendNotice(self, text, handle):
h = unicode(handle)
t = unicode(text)
@ -105,7 +105,7 @@ class PesterIRC(QtCore.QThread):
helpers.notice(self.cli, h, t)
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
@QtCore.pyqtSlot('QString', 'QString')
def sendMessage(self, text, handle):
h = unicode(handle)
textl = [unicode(text)]
@ -151,7 +151,7 @@ class PesterIRC(QtCore.QThread):
helpers.msg(self.cli, h, t)
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString, bool)
@QtCore.pyqtSlot('QString', bool)
def startConvo(self, handle, initiated):
h = unicode(handle)
try:
@ -160,7 +160,7 @@ class PesterIRC(QtCore.QThread):
helpers.msg(self.cli, h, "COLOR >%s" % (self.mainwindow.profile().colorcmd()))
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString)
@QtCore.pyqtSlot('QString')
def endConvo(self, handle):
h = unicode(handle)
try:
@ -195,21 +195,21 @@ class PesterIRC(QtCore.QThread):
helpers.msg(self.cli, h, "COLOR >%s" % (self.mainwindow.profile().colorcmd()))
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString)
@QtCore.pyqtSlot('QString')
def blockedChum(self, handle):
h = unicode(handle)
try:
helpers.msg(self.cli, h, "PESTERCHUM:BLOCK")
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString)
@QtCore.pyqtSlot('QString')
def unblockedChum(self, handle):
h = unicode(handle)
try:
helpers.msg(self.cli, h, "PESTERCHUM:UNBLOCK")
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString)
@QtCore.pyqtSlot('QString')
def requestNames(self, channel):
c = unicode(channel)
try:
@ -222,7 +222,7 @@ class PesterIRC(QtCore.QThread):
helpers.channel_list(self.cli)
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString)
@QtCore.pyqtSlot('QString')
def joinChannel(self, channel):
c = unicode(channel)
try:
@ -230,7 +230,7 @@ class PesterIRC(QtCore.QThread):
helpers.mode(self.cli, c, "", None)
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString)
@QtCore.pyqtSlot('QString')
def leftChannel(self, channel):
c = unicode(channel)
try:
@ -238,7 +238,7 @@ class PesterIRC(QtCore.QThread):
self.cli.command_handler.joined = False
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
@QtCore.pyqtSlot('QString', 'QString')
def kickUser(self, handle, channel):
l = handle.split(":")
c = unicode(channel)
@ -254,7 +254,7 @@ class PesterIRC(QtCore.QThread):
helpers.kick(self.cli, h, c, reason)
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString)
@QtCore.pyqtSlot('QString', 'QString', 'QString')
def setChannelMode(self, channel, mode, command):
c = unicode(channel)
m = unicode(mode)
@ -265,14 +265,14 @@ class PesterIRC(QtCore.QThread):
helpers.mode(self.cli, c, m, cmd)
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString)
@QtCore.pyqtSlot('QString')
def channelNames(self, channel):
c = unicode(channel)
try:
helpers.names(self.cli, c)
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
@QtCore.pyqtSlot('QString', 'QString')
def inviteChum(self, handle, channel):
h = unicode(handle)
c = unicode(channel)
@ -298,7 +298,7 @@ class PesterIRC(QtCore.QThread):
except socket.error:
self.setConnectionBroken()
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
@QtCore.pyqtSlot('QString', 'QString')
def killSomeQuirks(self, channel, handle):
c = unicode(channel)
h = unicode(handle)
@ -307,25 +307,25 @@ class PesterIRC(QtCore.QThread):
except socket.error:
self.setConnectionBroken()
moodUpdated = QtCore.pyqtSignal(QtCore.QString, Mood)
colorUpdated = QtCore.pyqtSignal(QtCore.QString, QtGui.QColor)
messageReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
memoReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, QtCore.QString)
noticeReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
inviteReceived = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
timeCommand = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, QtCore.QString)
namesReceived = QtCore.pyqtSignal(QtCore.QString, PesterList)
moodUpdated = QtCore.pyqtSignal('QString', Mood)
colorUpdated = QtCore.pyqtSignal('QString', QtGui.QColor)
messageReceived = QtCore.pyqtSignal('QString', 'QString')
memoReceived = QtCore.pyqtSignal('QString', 'QString', 'QString')
noticeReceived = QtCore.pyqtSignal('QString', 'QString')
inviteReceived = QtCore.pyqtSignal('QString', 'QString')
timeCommand = QtCore.pyqtSignal('QString', 'QString', 'QString')
namesReceived = QtCore.pyqtSignal('QString', PesterList)
channelListReceived = QtCore.pyqtSignal(PesterList)
nickCollision = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
myHandleChanged = QtCore.pyqtSignal(QtCore.QString)
chanInviteOnly = QtCore.pyqtSignal(QtCore.QString)
modesUpdated = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
nickCollision = QtCore.pyqtSignal('QString', 'QString')
myHandleChanged = QtCore.pyqtSignal('QString')
chanInviteOnly = QtCore.pyqtSignal('QString')
modesUpdated = QtCore.pyqtSignal('QString', 'QString')
connected = QtCore.pyqtSignal()
userPresentUpdate = QtCore.pyqtSignal(QtCore.QString, QtCore.QString,
QtCore.QString)
cannotSendToChan = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
userPresentUpdate = QtCore.pyqtSignal('QString', 'QString',
'QString')
cannotSendToChan = QtCore.pyqtSignal('QString', 'QString')
tooManyPeeps = QtCore.pyqtSignal()
quirkDisable = QtCore.pyqtSignal(QtCore.QString, QtCore.QString, QtCore.QString)
quirkDisable = QtCore.pyqtSignal('QString', 'QString', 'QString')
class PesterHandler(DefaultCommandHandler):
def notice(self, nick, chan, msg):

View file

@ -3,19 +3,19 @@ import codecs
import re
import ostools
from time import strftime, strptime
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore, QtWidgets
from generic import RightClickList, RightClickTree
from parsetools import convertTags
from convo import PesterText
_datadir = ostools.getDataDir()
class PesterLogSearchInput(QtGui.QLineEdit):
class PesterLogSearchInput(QtWidgets.QLineEdit):
def __init__(self, theme, parent=None):
QtGui.QLineEdit.__init__(self, parent)
QtWidgets.QLineEdit.__init__(self, parent)
self.setStyleSheet(theme["convo/input/style"] + "margin-right:0px;")
def keyPressEvent(self, event):
QtGui.QLineEdit.keyPressEvent(self, event)
QtWidgets.QLineEdit.keyPressEvent(self, event)
if hasattr(self.parent(), 'textArea'):
if event.key() == QtCore.Qt.Key_Return:
self.parent().logSearch(self.text())
@ -36,9 +36,9 @@ class PesterLogHighlighter(QtGui.QSyntaxHighlighter):
if unicode(text[i:i+len(self.searchTerm)]).lower() == unicode(self.searchTerm).lower():
self.setFormat(i, len(self.searchTerm), self.hilightstyle)
class PesterLogUserSelect(QtGui.QDialog):
class PesterLogUserSelect(QtWidgets.QDialog):
def __init__(self, config, theme, parent):
QtGui.QDialog.__init__(self, parent)
QtWidgets.QDialog.__init__(self, parent)
self.setModal(False)
self.config = config
self.theme = theme
@ -49,7 +49,7 @@ class PesterLogUserSelect(QtGui.QDialog):
self.setStyleSheet(self.theme["main/defaultwindow/style"])
self.setWindowTitle("Pesterlogs")
instructions = QtGui.QLabel("Pick a memo or chumhandle:")
instructions = QtWidgets.QLabel("Pick a memo or chumhandle:")
if os.path.exists("%s/%s" % (self.logpath, self.handle)):
chumMemoList = os.listdir("%s/%s/" % (self.logpath, self.handle))
@ -63,31 +63,25 @@ class PesterLogUserSelect(QtGui.QDialog):
self.chumsBox = RightClickList(self)
self.chumsBox.setStyleSheet(self.theme["main/chums/style"])
self.chumsBox.optionsMenu = QtGui.QMenu(self)
self.chumsBox.optionsMenu = QtWidgets.QMenu(self)
for (i, t) in enumerate(chumMemoList):
item = QtGui.QListWidgetItem(t)
item.setTextColor(QtGui.QColor(self.theme["main/chums/userlistcolor"]))
item = QtWidgets.QListWidgetItem(t)
item.setForeground(QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"])))
self.chumsBox.addItem(item)
self.search = PesterLogSearchInput(theme, self)
self.search.setFocus()
self.cancel = QtGui.QPushButton("CANCEL", self)
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('reject()'))
self.ok = QtGui.QPushButton("OK", self)
self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject)
self.ok = QtWidgets.QPushButton("OK", self, clicked=self.viewActivatedLog)
self.ok.setDefault(True)
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('viewActivatedLog()'))
layout_ok = QtGui.QHBoxLayout()
layout_ok = QtWidgets.QHBoxLayout()
layout_ok.addWidget(self.cancel)
layout_ok.addWidget(self.ok)
self.directory = QtGui.QPushButton("LOG DIRECTORY", self)
self.connect(self.directory, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('openDir()'))
self.directory = QtWidgets.QPushButton("LOG DIRECTORY", self, clicked=self.openDir)
layout_0 = QtGui.QVBoxLayout()
layout_0 = QtWidgets.QVBoxLayout()
layout_0.addWidget(instructions)
layout_0.addWidget(self.chumsBox)
layout_0.addWidget(self.search)
@ -111,8 +105,7 @@ class PesterLogUserSelect(QtGui.QDialog):
self.pesterlogviewer = None
if not self.pesterlogviewer:
self.pesterlogviewer = PesterLogViewer(selectedchum, self.config, self.theme, self.parent)
self.connect(self.pesterlogviewer, QtCore.SIGNAL('rejected()'),
self, QtCore.SLOT('closeActiveLog()'))
self.pesterlogviewer.rejected.connect(self.closeActiveLog)
self.pesterlogviewer.show()
self.pesterlogviewer.raise_()
self.pesterlogviewer.activateWindow()
@ -127,9 +120,9 @@ class PesterLogUserSelect(QtGui.QDialog):
def openDir(self):
QtGui.QDesktopServices.openUrl(QtCore.QUrl("file:///" + os.path.join(_datadir, "logs"), QtCore.QUrl.TolerantMode))
class PesterLogViewer(QtGui.QDialog):
class PesterLogViewer(QtWidgets.QDialog):
def __init__(self, chum, config, theme, parent):
QtGui.QDialog.__init__(self, parent)
QtWidgets.QDialog.__init__(self, parent)
self.setModal(False)
self.config = config
self.theme = theme
@ -151,22 +144,20 @@ class PesterLogViewer(QtGui.QDialog):
self.logList = []
if not os.path.exists("%s/%s/%s/%s" % (self.logpath, self.handle, chum, self.format)) or len(self.logList) == 0:
instructions = QtGui.QLabel("No Pesterlogs were found")
instructions = QtWidgets.QLabel("No Pesterlogs were found")
self.ok = QtGui.QPushButton("CLOSE", self)
self.ok = QtWidgets.QPushButton("CLOSE", self, clicked=self.reject)
self.ok.setDefault(True)
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('reject()'))
layout_ok = QtGui.QHBoxLayout()
layout_ok = QtWidgets.QHBoxLayout()
layout_ok.addWidget(self.ok)
layout_0 = QtGui.QVBoxLayout()
layout_0 = QtWidgets.QVBoxLayout()
layout_0.addWidget(instructions)
layout_0.addLayout(layout_ok)
self.setLayout(layout_0)
else:
self.instructions = QtGui.QLabel("Pesterlog with " +self.chum+ " on")
self.instructions = QtWidgets.QLabel("Pesterlog with " +self.chum+ " on")
self.textArea = PesterLogText(theme, self.parent)
self.textArea.setReadOnly(True)
@ -180,15 +171,14 @@ class PesterLogViewer(QtGui.QDialog):
self.logList.reverse()
self.tree = RightClickTree()
self.tree.optionsMenu = QtGui.QMenu(self)
self.tree.optionsMenu = QtWidgets.QMenu(self)
self.tree.setFixedSize(260, 300)
self.tree.header().hide()
if theme.has_key("convo/scrollbar"):
self.tree.setStyleSheet("QTreeWidget { %s } QScrollBar:vertical { %s } QScrollBar::handle:vertical { %s } QScrollBar::add-line:vertical { %s } QScrollBar::sub-line:vertical { %s } QScrollBar:up-arrow:vertical { %s } QScrollBar:down-arrow:vertical { %s }" % (theme["convo/textarea/style"], theme["convo/scrollbar/style"], theme["convo/scrollbar/handle"], theme["convo/scrollbar/downarrow"], theme["convo/scrollbar/uparrow"], theme["convo/scrollbar/uarrowstyle"], theme["convo/scrollbar/darrowstyle"] ))
else:
self.tree.setStyleSheet("%s" % (theme["convo/textarea/style"]))
self.connect(self.tree, QtCore.SIGNAL('itemSelectionChanged()'),
self, QtCore.SLOT('loadSelectedLog()'))
self.tree.itemSelectionChanged.connect(self.loadSelectedLog)
self.tree.setSortingEnabled(False)
child_1 = None
@ -196,11 +186,11 @@ class PesterLogViewer(QtGui.QDialog):
for (i,l) in enumerate(self.logList):
my = self.fileToMonthYear(l)
if my[0] != last[0]:
child_1 = QtGui.QTreeWidgetItem(["%s %s" % (my[0], my[1])])
child_1 = QtWidgets.QTreeWidgetItem(["%s %s" % (my[0], my[1])])
self.tree.addTopLevelItem(child_1)
if i == 0:
child_1.setExpanded(True)
child_1.addChild(QtGui.QTreeWidgetItem([self.fileToTime(l)]))
child_1.addChild(QtWidgets.QTreeWidgetItem([self.fileToTime(l)]))
last = self.fileToMonthYear(l)
self.hilight = PesterLogHighlighter(self.textArea)
@ -208,37 +198,33 @@ class PesterLogViewer(QtGui.QDialog):
self.search = PesterLogSearchInput(theme, self)
self.search.setFocus()
self.find = QtGui.QPushButton("Find", self)
self.find = QtWidgets.QPushButton("Find", self)
font = self.find.font()
font.setPointSize(8)
self.find.setFont(font)
self.find.setDefault(True)
self.find.setFixedSize(40, 20)
layout_search = QtGui.QHBoxLayout()
layout_search = QtWidgets.QHBoxLayout()
layout_search.addWidget(self.search)
layout_search.addWidget(self.find)
self.qdb = QtGui.QPushButton("Pesterchum QDB", self)
self.qdb = QtWidgets.QPushButton("Pesterchum QDB", self, clicked=self.openQDB)
self.qdb.setFixedWidth(260)
self.connect(self.qdb, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('openQDB()'))
self.ok = QtGui.QPushButton("CLOSE", self)
self.ok = QtWidgets.QPushButton("CLOSE", self, clicked=self.reject)
self.ok.setFixedWidth(80)
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('reject()'))
layout_ok = QtGui.QHBoxLayout()
layout_ok = QtWidgets.QHBoxLayout()
layout_ok.addWidget(self.qdb)
layout_ok.addWidget(self.ok)
layout_ok.setAlignment(self.ok, QtCore.Qt.AlignRight)
layout_logs = QtGui.QHBoxLayout()
layout_logs = QtWidgets.QHBoxLayout()
layout_logs.addWidget(self.tree)
layout_right = QtGui.QVBoxLayout()
layout_right = QtWidgets.QVBoxLayout()
layout_right.addWidget(self.textArea)
layout_right.addLayout(layout_search)
layout_logs.addLayout(layout_right)
layout_0 = QtGui.QVBoxLayout()
layout_0 = QtWidgets.QVBoxLayout()
layout_0.addWidget(self.instructions)
layout_0.addLayout(layout_logs)
layout_0.addLayout(layout_ok)
@ -284,7 +270,7 @@ class PesterLogText(PesterText):
PesterText.__init__(self, theme, parent)
def focusInEvent(self, event):
QtGui.QTextEdit.focusInEvent(self, event)
QtWidgets.QTextEdit.focusInEvent(self, event)
def mousePressEvent(self, event):
url = self.anchorAt(event.pos())
if url != "":
@ -295,9 +281,9 @@ class PesterLogText(PesterText):
self.parent().parent.newConversation(handle)
else:
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode))
QtGui.QTextEdit.mousePressEvent(self, event)
QtWidgets.QTextEdit.mousePressEvent(self, event)
def mouseMoveEvent(self, event):
QtGui.QTextEdit.mouseMoveEvent(self, event)
QtWidgets.QTextEdit.mouseMoveEvent(self, event)
if self.anchorAt(event.pos()):
if self.viewport().cursor().shape != QtCore.Qt.PointingHandCursor:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
@ -307,9 +293,7 @@ class PesterLogText(PesterText):
def contextMenuEvent(self, event):
textMenu = self.createStandardContextMenu()
if self.textSelected:
self.submitLogAction = QtGui.QAction("Submit to Pesterchum QDB", self)
self.connect(self.submitLogAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('submitLog()'))
self.submitLogAction = QtWidgets.QAction("Submit to Pesterchum QDB", self, triggered=self.submitLog)
textMenu.addAction(self.submitLogAction)
a = textMenu.actions()
a[0].setText("Copy Plain Text")

View file

@ -4,7 +4,7 @@ try:
except ImportError:
lua = None
from quirks import ScriptQuirks
from PyQt4 import QtGui, QtCore
from PyQt5 import QtWidgets
class LuaQuirks(ScriptQuirks):
def loadModule(self, name, filename):
@ -52,7 +52,7 @@ class LuaQuirks(ScriptQuirks):
raise Exception
except:
print "Quirk malformed: %s" % (name)
msgbox = QtGui.QMessageBox()
msgbox = QtWidgets.QMessageBox()
msgbox.setWindowTitle("Error!")
msgbox.setText("Quirk malformed: %s" % (name))
msgbox.exec_()

167
memos.py
View file

@ -1,7 +1,7 @@
from string import Template
import re
from copy import copy
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore, QtWidgets
from datetime import time, timedelta, datetime
from mood import Mood
@ -178,15 +178,13 @@ class TimeTracker(list):
return TimeGrammar(temporal, pcf, when, 0)
return TimeGrammar(temporal, pcf, when, self.getRecord(timed))
class TimeInput(QtGui.QLineEdit):
class TimeInput(QtWidgets.QLineEdit):
def __init__(self, timeslider, parent):
QtGui.QLineEdit.__init__(self, parent)
QtWidgets.QLineEdit.__init__(self, parent)
self.timeslider = timeslider
self.setText("+0:00")
self.connect(self.timeslider, QtCore.SIGNAL('valueChanged(int)'),
self, QtCore.SLOT('setTime(int)'))
self.connect(self, QtCore.SIGNAL('editingFinished()'),
self, QtCore.SLOT('setSlider()'))
self.timeslider.valueChanged.connect(self.setTime)
self.editingFinished.connect(self.setSlider)
@QtCore.pyqtSlot(int)
def setTime(self, sliderval):
self.setText(self.timeslider.getTime())
@ -209,9 +207,9 @@ class TimeInput(QtGui.QLineEdit):
text = delta2txt(timed)
self.setText(text)
class TimeSlider(QtGui.QSlider):
class TimeSlider(QtWidgets.QSlider):
def __init__(self, orientation, parent):
QtGui.QSlider.__init__(self, orientation, parent)
QtWidgets.QSlider.__init__(self, orientation, parent)
self.setTracking(True)
self.setMinimum(-50)
self.setMaximum(50)
@ -243,7 +241,7 @@ _ctag_begin = re.compile(r'<c=(.*?)>')
class MemoText(PesterText):
def __init__(self, theme, parent=None):
QtGui.QTextEdit.__init__(self, parent)
QtWidgets.QTextEdit.__init__(self, parent)
if hasattr(self.parent(), 'mainwindow'):
self.mainwindow = self.parent().mainwindow
else:
@ -257,13 +255,11 @@ class MemoText(PesterText):
self.setReadOnly(True)
self.setMouseTracking(True)
self.textSelected = False
self.connect(self, QtCore.SIGNAL('copyAvailable(bool)'),
self, QtCore.SLOT('textReady(bool)'))
self.copyAvailable.connect(self.textReady)
self.urls = {}
for k in smiledict:
self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k]))
self.connect(self.mainwindow, QtCore.SIGNAL('animationSetting(bool)'),
self, QtCore.SLOT('animateChanged(bool)'))
self.mainwindow.animationSetting.connect(self.animateChanged)
def initTheme(self, theme):
if theme.has_key("memos/scrollbar"):
@ -343,91 +339,62 @@ class MemoText(PesterText):
class MemoInput(PesterInput):
def __init__(self, theme, parent=None):
QtGui.QLineEdit.__init__(self, parent)
QtWidgets.QLineEdit.__init__(self, parent)
self.setStyleSheet(theme["memos/input/style"])
def changeTheme(self, theme):
self.setStyleSheet(theme["memos/input/style"])
class PesterMemo(PesterConvo):
def __init__(self, channel, timestr, mainwindow, parent=None):
QtGui.QFrame.__init__(self, parent)
QtWidgets.QFrame.__init__(self, parent)
self.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
self.channel = channel
self.setObjectName(self.channel)
self.mainwindow = mainwindow
self.time = TimeTracker(txt2delta(timestr))
self.setWindowTitle(channel)
self.channelLabel = QtGui.QLabel(self)
self.channelLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding))
self.channelLabel = QtWidgets.QLabel(self)
self.channelLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding))
self.textArea = MemoText(self.mainwindow.theme, self)
self.textInput = MemoInput(self.mainwindow.theme, self)
self.textInput.setFocus()
self.miniUserlist = QtGui.QPushButton(">\n>", self)
self.miniUserlist = QtWidgets.QPushButton(">\n>", self, clicked=self.toggleUserlist)
#self.miniUserlist.setStyleSheet("border:1px solid #a68168; border-width: 2px 0px 2px 2px; height: 90px; width: 10px; color: #cd8f9d; font-family: 'Arial'; background: white; margin-left: 2px;")
self.connect(self.miniUserlist, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('toggleUserlist()'))
self.userlist = RightClickList(self)
self.userlist.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding))
self.userlist.optionsMenu = QtGui.QMenu(self)
self.addchumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.connect(self.addchumAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('addChumSlot()'))
self.banuserAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self)
self.connect(self.banuserAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('banSelectedUser()'))
self.opAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/opuser"], self)
self.connect(self.opAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('opSelectedUser()'))
self.voiceAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/voiceuser"], self)
self.connect(self.voiceAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('voiceSelectedUser()'))
self.quirkDisableAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirkkill"], self)
self.connect(self.quirkDisableAction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('killQuirkUser()'))
self.userlist.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding))
self.userlist.optionsMenu = QtWidgets.QMenu(self)
self.addchumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self, triggered=self.addChumSlot)
self.banuserAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self, triggered=self.banSelectedUser)
self.opAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/opuser"], self, triggered=self.opSelectedUser)
self.voiceAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/voiceuser"], self, triggered=self.voiceSelectedUser)
self.quirkDisableAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirkkill"], self, triggered=self.killQuirkUser)
self.userlist.optionsMenu.addAction(self.addchumAction)
# ban & op list added if we are op
self.optionsMenu = QtGui.QMenu(self)
self.oocToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self)
self.optionsMenu = QtWidgets.QMenu(self)
self.oocToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self, toggled=self.toggleOOC)
self.oocToggle.setCheckable(True)
self.connect(self.oocToggle, QtCore.SIGNAL('toggled(bool)'),
self, QtCore.SLOT('toggleOOC(bool)'))
self.quirksOff = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self)
self.quirksOff = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self, toggled=self.toggleQuirks)
self.quirksOff.setCheckable(True)
self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'),
self, QtCore.SLOT('toggleQuirks(bool)'))
self.logchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self)
self.connect(self.logchum, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('openChumLogs()'))
self.invitechum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/invitechum"], self)
self.connect(self.invitechum, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('inviteChums()'))
self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self, triggered=self.openChumLogs)
self.invitechum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/invitechum"], self, triggered=self.inviteChums)
self.optionsMenu.addAction(self.quirksOff)
self.optionsMenu.addAction(self.oocToggle)
self.optionsMenu.addAction(self.logchum)
self.optionsMenu.addAction(self.invitechum)
self.chanModeMenu = QtGui.QMenu(self.mainwindow.theme["main/menus/rclickchumlist/memosetting"], self)
self.chanNoquirks = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memonoquirk"], self)
self.chanModeMenu = QtWidgets.QMenu(self.mainwindow.theme["main/menus/rclickchumlist/memosetting"], self)
self.chanNoquirks = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memonoquirk"], self, toggled=self.noquirksChan)
self.chanNoquirks.setCheckable(True)
self.connect(self.chanNoquirks, QtCore.SIGNAL('toggled(bool)'),
self, QtCore.SLOT('noquirksChan(bool)'))
self.chanHide = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memohidden"], self)
self.chanHide = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memohidden"], self, toggled=self.hideChan)
self.chanHide.setCheckable(True)
self.connect(self.chanHide, QtCore.SIGNAL('toggled(bool)'),
self, QtCore.SLOT('hideChan(bool)'))
self.chanInvite = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memoinvite"], self)
self.chanInvite = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memoinvite"], self, toggled=self.inviteChan)
self.chanInvite.setCheckable(True)
self.connect(self.chanInvite, QtCore.SIGNAL('toggled(bool)'),
self, QtCore.SLOT('inviteChan(bool)'))
self.chanMod = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memomute"], self)
self.chanMod = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memomute"], self, toggled=self.modChan)
self.chanMod.setCheckable(True)
self.connect(self.chanMod, QtCore.SIGNAL('toggled(bool)'),
self, QtCore.SLOT('modChan(bool)'))
self.chanModeMenu.addAction(self.chanNoquirks)
self.chanModeMenu.addAction(self.chanHide)
self.chanModeMenu.addAction(self.chanInvite)
@ -437,48 +404,38 @@ class PesterMemo(PesterConvo):
self.timeinput = TimeInput(self.timeslider, self)
self.timeinput.setText(timestr)
self.timeinput.setSlider()
self.timetravel = QtGui.QPushButton("GO", self)
self.timeclose = QtGui.QPushButton("CLOSE", self)
self.timeswitchl = QtGui.QPushButton(self)
self.timeswitchr = QtGui.QPushButton(self)
self.connect(self.timetravel, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('sendtime()'))
self.connect(self.timeclose, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('smashclock()'))
self.connect(self.timeswitchl, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('prevtime()'))
self.connect(self.timeswitchr, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('nexttime()'))
self.timetravel = QtWidgets.QPushButton("GO", self, clicked=self.sendtime)
self.timeclose = QtWidgets.QPushButton("CLOSE", self, clicked=self.smashclock)
self.timeswitchl = QtWidgets.QPushButton(self, clicked=self.prevtime)
self.timeswitchr = QtWidgets.QPushButton(self, clicked=self.nexttime)
self.times = {}
self.initTheme(self.mainwindow.theme)
# connect
self.connect(self.textInput, QtCore.SIGNAL('returnPressed()'),
self, QtCore.SLOT('sentMessage()'))
self.textInput.returnPressed.connect(self.sentMessage)
layout_0 = QtGui.QVBoxLayout()
layout_0 = QtWidgets.QVBoxLayout()
layout_0.addWidget(self.textArea)
layout_0.addWidget(self.textInput)
layout_1 = QtGui.QHBoxLayout()
layout_1 = QtWidgets.QHBoxLayout()
layout_1.addLayout(layout_0)
layout_1.addWidget(self.miniUserlist)
layout_1.addWidget(self.userlist)
# layout_1 = QtGui.QGridLayout()
# layout_1 = QtWidgets.QGridLayout()
# layout_1.addWidget(self.timeslider, 0, 1, QtCore.Qt.AlignHCenter)
# layout_1.addWidget(self.timeinput, 1, 0, 1, 3)
layout_2 = QtGui.QHBoxLayout()
layout_2 = QtWidgets.QHBoxLayout()
layout_2.addWidget(self.timeslider)
layout_2.addWidget(self.timeinput)
layout_2.addWidget(self.timetravel)
layout_2.addWidget(self.timeclose)
layout_2.addWidget(self.timeswitchl)
layout_2.addWidget(self.timeswitchr)
self.layout = QtGui.QVBoxLayout()
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.channelLabel)
self.layout.addLayout(layout_1)
@ -538,7 +495,7 @@ class PesterMemo(PesterConvo):
def updateColor(self, handle, color):
chums = self.userlist.findItems(handle, QtCore.Qt.MatchFlags(0))
for c in chums:
c.setTextColor(color)
c.setForeground(QtGui.QBrush(color))
def addMessage(self, text, handle):
if type(handle) is bool:
chum = self.mainwindow.profile()
@ -653,13 +610,13 @@ class PesterMemo(PesterConvo):
elif handle[0] == '&':
admin = True
handle = handle[1:]
item = QtGui.QListWidgetItem(handle)
item = QtWidgets.QListWidgetItem(handle)
if handle == self.mainwindow.profile().handle:
color = self.mainwindow.profile().color
else:
color = chumdb.getColor(handle, defaultcolor)
item.box = (handle == "evacipatedBox")
item.setTextColor(color)
item.setForeground(QtGui.QBrush(color))
item.founder = founder
item.op = op
item.halfop = halfop
@ -835,7 +792,7 @@ class PesterMemo(PesterConvo):
self.messageSent.emit(serverText, self.title())
self.textInput.setText("")
@QtCore.pyqtSlot(QtCore.QString)
@QtCore.pyqtSlot('QString')
def namesUpdated(self, channel):
c = unicode(channel)
if c.lower() != self.channel.lower(): return
@ -845,28 +802,27 @@ class PesterMemo(PesterConvo):
self.userlist.clear()
for n in self.mainwindow.namesdb[self.channel]:
self.addUser(n)
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
@QtCore.pyqtSlot('QString', 'QString')
def modesUpdated(self, channel, modes):
c = unicode(channel)
if c.lower() == self.channel.lower():
self.updateChanModes(modes, None)
@QtCore.pyqtSlot(QtCore.QString)
@QtCore.pyqtSlot('QString')
def closeInviteOnly(self, channel):
c = unicode(channel)
if c.lower() == self.channel.lower():
self.disconnect(self.mainwindow, QtCore.SIGNAL('inviteOnlyChan(QString)'),
self, QtCore.SLOT('closeInviteOnly(QString)'))
self.mainwindow.inviteOnlyChan.disconnect(self.closeInviteOnly)
if self.parent():
print self.channel
i = self.parent().tabIndices[self.channel]
self.parent().tabClose(i)
else:
self.close()
msgbox = QtGui.QMessageBox()
msgbox = QtWidgets.QMessageBox()
msgbox.setText("%s: Invites only!" % (c))
msgbox.setInformativeText("This channel is invite-only. You must get an invitation from someone on the inside before entering.")
msgbox.setStandardButtons(QtGui.QMessageBox.Ok)
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok)
ret = msgbox.exec_()
def quirkDisable(self, op, msg):
@ -929,7 +885,7 @@ class PesterMemo(PesterConvo):
self.mainwindow.chatlog.log(self.channel, msg)
del self.netsplit
@QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString)
@QtCore.pyqtSlot('QString', 'QString', 'QString')
def userPresentChange(self, handle, channel, update):
h = unicode(handle)
c = unicode(channel)
@ -960,7 +916,7 @@ class PesterMemo(PesterConvo):
if update == "netsplit":
if not hasattr(self, "netsplit"):
self.netsplit = []
QtCore.QTimer.singleShot(1500, self, QtCore.SLOT('dumpNetsplit()'))
QtCore.QTimer.singleShot(1500, self.dumpNetsplit)
for c in chums:
chum = PesterProfile(h)
self.userlist.takeItem(self.userlist.row(c))
@ -1020,12 +976,12 @@ class PesterMemo(PesterConvo):
if chum is self.mainwindow.profile():
# are you next?
msgbox = QtGui.QMessageBox()
msgbox = QtWidgets.QMessageBox()
msgbox.setText(self.mainwindow.theme["convo/text/kickedmemo"])
msgbox.setInformativeText("press 0k to rec0nnect or cancel to absc0nd")
msgbox.setStandardButtons(QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel)
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)
ret = msgbox.exec_()
if ret == QtGui.QMessageBox.Ok:
if ret == QtWidgets.QMessageBox.Ok:
self.userlist.clear()
self.time = TimeTracker(curtime)
self.resetSlider(curtime)
@ -1035,7 +991,7 @@ class PesterMemo(PesterConvo):
msg = me.memoopenmsg(systemColor, self.time.getTime(), self.time.getGrammar(), self.mainwindow.theme["convo/text/openmemo"], self.channel)
self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg)
elif ret == QtGui.QMessageBox.Cancel:
elif ret == QtWidgets.QMessageBox.Cancel:
if self.parent():
i = self.parent().tabIndices[self.channel]
self.parent().tabClose(i)
@ -1171,7 +1127,7 @@ class PesterMemo(PesterConvo):
if not self.userlist.currentItem():
return
currentHandle = unicode(self.userlist.currentItem().text())
(reason, ok) = QtGui.QInputDialog.getText(self, "Ban User", "Enter the reason you are banning this user (optional):")
(reason, ok) = QtWidgets.QInputDialog.getText(self, "Ban User", "Enter the reason you are banning this user (optional):")
if ok:
self.mainwindow.kickUser.emit("%s:%s" % (currentHandle, reason), self.channel)
@QtCore.pyqtSlot()
@ -1203,8 +1159,7 @@ class PesterMemo(PesterConvo):
def openChumLogs(self):
currentChum = self.channel
self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow)
self.connect(self.mainwindow.chumList.pesterlogviewer, QtCore.SIGNAL('rejected()'),
self.mainwindow.chumList, QtCore.SLOT('closeActiveLog()'))
self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog)
self.mainwindow.chumList.pesterlogviewer.show()
self.mainwindow.chumList.pesterlogviewer.raise_()
self.mainwindow.chumList.pesterlogviewer.activateWindow()
@ -1214,7 +1169,7 @@ class PesterMemo(PesterConvo):
if not hasattr(self, 'invitechums'):
self.invitechums = None
if not self.invitechums:
(chum, ok) = QtGui.QInputDialog.getText(self, "Invite to Chat", "Enter the chumhandle of the user you'd like to invite:")
(chum, ok) = QtWidgets.QInputDialog.getText(self, "Invite to Chat", "Enter the chumhandle of the user you'd like to invite:")
if ok:
chum = unicode(chum)
self.mainwindow.inviteChum.emit(chum, self.channel)
@ -1280,7 +1235,7 @@ class PesterMemo(PesterConvo):
self.mainwindow.waitingMessages.messageAnswered(self.channel)
self.windowClosed.emit(self.title())
windowClosed = QtCore.pyqtSignal(QtCore.QString)
windowClosed = QtCore.pyqtSignal('QString')
timelist = ["0:00", "0:01", "0:02", "0:04", "0:06", "0:10", "0:14", "0:22", "0:30", "0:41", "1:00", "1:34", "2:16", "3:14", "4:13", "4:20", "5:25", "6:12", "7:30", "8:44", "10:25", "11:34", "14:13", "16:12", "17:44", "22:22", "25:10", "33:33", "42:00", "43:14", "50:00", "62:12", "75:00", "88:44", "100", "133", "143", "188", "200", "222", "250", "314", "333", "413", "420", "500", "600", "612", "888", "1000", "1025"]

874
menus.py

File diff suppressed because it is too large Load diff

12
mood.py
View file

@ -1,4 +1,4 @@
from PyQt4 import QtCore, QtGui
from PyQt5 import QtCore, QtWidgets
from generic import PesterIcon
@ -49,10 +49,8 @@ class PesterMoodHandler(QtCore.QObject):
self.buttons[b.mood.value()] = b
if b.mood.value() == self.mainwindow.profile().mood.value():
b.setSelected(True)
self.connect(b, QtCore.SIGNAL('clicked()'),
b, QtCore.SLOT('updateMood()'))
self.connect(b, QtCore.SIGNAL('moodUpdated(int)'),
self, QtCore.SLOT('updateMood(int)'))
b.clicked.connect(b.updateMood)
b.moodUpdated.connect(self.updateMood)
def removeButtons(self):
for b in self.buttons.values():
b.close()
@ -85,10 +83,10 @@ class PesterMoodHandler(QtCore.QObject):
c.myUpdateMood(newmood)
self.mainwindow.moodUpdated.emit()
class PesterMoodButton(QtGui.QPushButton):
class PesterMoodButton(QtWidgets.QPushButton):
def __init__(self, parent, **options):
icon = PesterIcon(options["icon"])
QtGui.QPushButton.__init__(self, icon, options["text"], parent)
QtWidgets.QPushButton.__init__(self, icon, options["text"], parent)
self.setIconSize(icon.realsize())
self.setFlat(True)
self.resize(*options["size"])

View file

@ -1,6 +1,6 @@
import os, sys
import platform
from PyQt4.QtGui import QDesktopServices
from PyQt5.QtCore import QStandardPaths
def isOSX():
return sys.platform == "darwin"
@ -30,12 +30,13 @@ def getDataDir():
# Temporary fix for non-ascii usernames
# If username has non-ascii characters, just store userdata
# in the Pesterchum install directory (like before)
# TODO: fix error if standardLocations is not what we expect
try:
if isOSX():
return os.path.join(unicode(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "Pesterchum/")
return os.path.join(unicode(QStandardPaths.standardLocations(QStandardPaths.DataLocation)[0]), "Pesterchum/")
elif isLinux():
return os.path.join(unicode(QDesktopServices.storageLocation(QDesktopServices.HomeLocation)), ".pesterchum/")
return os.path.join(unicode(QStandardPaths.standardLocations(QStandardPaths.HomeLocation)[0]), ".pesterchum/")
else:
return os.path.join(unicode(QDesktopServices.storageLocation(QDesktopServices.DataLocation)), "pesterchum/")
return os.path.join(unicode(QStandardPaths.standardLocations(QStandardPaths.DataLocation)[0]), "pesterchum/")
except UnicodeDecodeError:
return ''

View file

@ -93,6 +93,7 @@ class CommandHandler(object):
def run(self, command, *args):
""" finds and runs a command """
logging.debug("processCommand %s(%s)" % (command, args))
logging.info("processCommand %s(%s)" % (command, args))
try:
f = self.get(command)

View file

@ -3,7 +3,7 @@ import random
import ostools
from copy import copy
from datetime import timedelta
from PyQt4 import QtGui
from PyQt5 import QtGui
from generic import mysteryTime
from quirks import ScriptQuirks

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@ import codecs
import platform
from datetime import *
from time import strftime, time
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore, QtWidgets
import ostools
from mood import Mood
@ -57,7 +57,7 @@ class PesterLog(object):
try:
fp = codecs.open("%s/%s/%s/%s/%s.%s.txt" % (self.logpath, self.handle, handle, format, handle, time), encoding='utf-8', mode='a')
except IOError:
errmsg = QtGui.QMessageBox(self)
errmsg = QtWidgets.QMessageBox(self)
errmsg.setText("Warning: Pesterchum could not open the log file for %s!" % (handle))
errmsg.setInformativeText("Your log for %s will not be saved because something went wrong. We suggest restarting Pesterchum. Sorry :(" % (handle))
errmsg.show()

View file

@ -1,6 +1,6 @@
import os, sys, imp, re, ostools
from quirks import ScriptQuirks
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore, QtWidgets
class PythonQuirks(ScriptQuirks):
def loadModule(self, name, filename):
@ -26,7 +26,7 @@ class PythonQuirks(ScriptQuirks):
raise Exception
except:
print "Quirk malformed: %s" % (obj.command)
msgbox = QtGui.QMessageBox()
msgbox = QtWidgets.QMessageBox()
msgbox.setWindowTitle("Error!")
msgbox.setText("Quirk malformed: %s" % (obj.command))
msgbox.exec_()

View file

@ -1,5 +1,5 @@
import os, sys, re, ostools
from PyQt4 import QtGui, QtCore
from PyQt5 import QtWidgets, QtCore
class ScriptQuirks(object):
def __init__(self):
@ -66,7 +66,7 @@ class ScriptQuirks(object):
continue
except Exception, e:
print "Error loading %s: %s (in quirks.py)" % (os.path.basename(name), e)
msgbox = QtGui.QMessageBox()
msgbox = QtWidgets.QMessageBox()
msgbox.setWindowTitle("Error!")
msgbox.setText("Error loading %s: %s (in quirks.py)" % (os.path.basename(filename), e))
msgbox.exec_()

View file

@ -1,4 +1,4 @@
from PyQt4 import QtGui, QtCore
from PyQt5 import QtWidgets, QtCore
RANDNICK = "randomEncounter"
@ -58,8 +58,7 @@ class RandomHandler(QtCore.QObject):
pass
elif code == "!":
if l[1] == "x":
from PyQt4 import QtGui
msgbox = QtGui.QMessageBox()
msgbox = QtWidgets.QMessageBox()
msgbox.setText("Unable to fetch you a random encounter!")
msgbox.setInformativeText("Try again later :(")
msgbox.exec_()

View file

@ -2,7 +2,7 @@ import inspect
import threading
import time, os
import ostools
from PyQt4 import QtGui, QtCore
from PyQt5 import QtGui, QtCore, QtWidgets
try:
import pynotify
@ -10,11 +10,12 @@ except:
pynotify = None
class DefaultToast(object):
def __init__(self, machine, title, msg, icon):
self.machine = machine
self.title = title
self.msg = msg
self.icon = icon
def __init__(self, parent, **kwds):
super(DefaultToast, self).__init__(parent, **kwds)
self.machine = kwds.get('machine')
self.title = kwds.get('title')
self.msg = kwds.get('msg')
self.icon = kwds.get('icon')
def show(self):
print self.title, self.msg, self.icon
self.done()
@ -176,9 +177,9 @@ class ToastMachine(object):
self.showNext()
class PesterToast(QtGui.QWidget, DefaultToast):
class PesterToast(QtWidgets.QWidget, DefaultToast):
def __init__(self, machine, title, msg, icon, time=3000, parent=None):
QtGui.QWidget.__init__(self, parent)
super(PesterToast, self).__init__(self, parent, machine=machine, title=title, msg=msg, icon=icon)
self.machine = machine
self.time = time
@ -189,33 +190,31 @@ class PesterToast(QtGui.QWidget, DefaultToast):
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.X11BypassWindowManagerHint | QtCore.Qt.ToolTip)
self.m_animation = QtCore.QParallelAnimationGroup()
anim = QtCore.QPropertyAnimation(self)
anim = QtCore.QPropertyAnimation(self, finished=self.reverseTrigger)
anim.setTargetObject(self)
self.m_animation.addAnimation(anim)
anim.setEasingCurve(QtCore.QEasingCurve.OutBounce)
anim.setDuration(1000)
self.connect(anim, QtCore.SIGNAL('finished()'),
self, QtCore.SLOT('reverseTrigger()'))
self.m_animation.setDirection(QtCore.QAnimationGroup.Forward)
self.title = QtGui.QLabel(title, self)
self.msg = QtGui.QLabel(msg, self)
self.title = QtWidgets.QLabel(title, self)
self.msg = QtWidgets.QLabel(msg, self)
self.content = msg
if icon:
self.icon = QtGui.QLabel("")
self.icon = QtWidgets.QLabel("")
self.icon.setPixmap(QtGui.QPixmap(icon).scaledToWidth(30))
else:
self.icon = QtGui.QLabel("")
self.icon = QtWidgets.QLabel("")
self.icon.setPixmap(QtGui.QPixmap(30, 30))
self.icon.pixmap().fill(QtGui.QColor(0,0,0,0))
layout_0 = QtGui.QVBoxLayout()
layout_0 = QtWidgets.QVBoxLayout()
layout_0.setMargin(0)
layout_0.setContentsMargins(0, 0, 0, 0)
if self.icon:
layout_1 = QtGui.QGridLayout()
layout_1 = QtWidgets.QGridLayout()
layout_1.addWidget(self.icon, 0,0, 1,1)
layout_1.addWidget(self.title, 0,1, 1,7)
layout_1.setAlignment(self.msg, QtCore.Qt.AlignTop)
@ -240,12 +239,11 @@ class PesterToast(QtGui.QWidget, DefaultToast):
self.msg.setText(PesterToast.wrapText(self.msg.font(), unicode(self.msg.text()), self.parent().theme["toasts/width"], self.parent().theme["toasts/content/style"]))
p = QtGui.QApplication.desktop().availableGeometry(self).bottomRight()
o = QtGui.QApplication.desktop().screenGeometry(self).bottomRight()
p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight()
o = QtWidgets.QApplication.desktop().screenGeometry(self).bottomRight()
anim.setStartValue(p.y() - o.y())
anim.setEndValue(100)
self.connect(anim, QtCore.SIGNAL('valueChanged(QVariant)'),
self, QtCore.SLOT('updateBottomLeftAnimation(QVariant)'))
anim.valueChanged.connect(self.updateBottomLeftAnimation)
self.byebye = False
@ -255,7 +253,7 @@ class PesterToast(QtGui.QWidget, DefaultToast):
@QtCore.pyqtSlot()
def done(self):
QtGui.QWidget.hide(self)
QtWidgets.QWidget.hide(self)
t = self.machine.toasts[0]
if t.title == unicode(self.title.text()) and \
t.msg == unicode(self.content):
@ -277,19 +275,17 @@ class PesterToast(QtGui.QWidget, DefaultToast):
anim = self.m_animation.animationAt(0)
self.m_animation.setDirection(QtCore.QAnimationGroup.Backward)
anim.setEasingCurve(QtCore.QEasingCurve.InCubic)
self.disconnect(anim, QtCore.SIGNAL('finished()'),
self, QtCore.SLOT('reverseTrigger()'))
self.connect(anim, QtCore.SIGNAL('finished()'),
self, QtCore.SLOT('done()'))
anim.finished.disconnect(self.reverseTrigger)
anim.finished.connect(self.done)
self.m_animation.start()
@QtCore.pyqtSlot(QtCore.QVariant)
def updateBottomLeftAnimation(self, value):
p = QtGui.QApplication.desktop().availableGeometry(self).bottomRight()
p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight()
val = float(self.height())/100
self.move(p.x()-self.width(), p.y() - (value.toInt()[0] * val) +1)
self.layout().setSpacing(0)
QtGui.QWidget.show(self)
QtWidgets.QWidget.show(self)
def mousePressEvent(self, event):
if event.button() == QtCore.Qt.RightButton:
@ -397,7 +393,6 @@ class PesterToastMachine(ToastMachine, QtCore.QObject):
pass
#~ self.timer = QtCore.QTimer(self)
#~ self.timer.setInterval(1000)
#~ self.connect(self.timer, QtCore.SIGNAL('timeout()'),
#~ self, QtCore.SLOT('showNext()'))
#~ self.timer.timeout.connect(self.showNext)
#~ if self.on:
#~ self.timer.start()

View file

@ -5,18 +5,16 @@ import pickle
import os
import threading
from time import mktime
from PyQt4 import QtCore, QtGui
from PyQt5 import QtCore, QtGui, QtWidgets
class MSPAChecker(QtGui.QWidget):
class MSPAChecker(QtWidgets.QWidget):
def __init__(self, parent=None):
QtCore.QObject.__init__(self, parent)
self.mainwindow = parent
self.refreshRate = 30 # seconds
self.status = None
self.lock = False
self.timer = QtCore.QTimer(self)
self.connect(self.timer, QtCore.SIGNAL('timeout()'),
self, QtCore.SLOT('check_site_wrapper()'))
self.timer = QtCore.QTimer(self, timeout=self.check_site_wrapper)
self.timer.start(1000*self.refreshRate)
def save_state(self):
@ -38,7 +36,7 @@ class MSPAChecker(QtGui.QWidget):
os.remove("status_old.pkl")
except Exception, e:
print e
msg = QtGui.QMessageBox(self)
msg = QtWidgets.QMessageBox(self)
msg.setText("Problems writing save file.")
msg.show()
@ -79,10 +77,8 @@ class MSPAChecker(QtGui.QWidget):
self.mspa = None
if not self.mspa:
self.mspa = MSPAUpdateWindow(self.parent())
self.connect(self.mspa, QtCore.SIGNAL('accepted()'),
self, QtCore.SLOT('visit_site()'))
self.connect(self.mspa, QtCore.SIGNAL('rejected()'),
self, QtCore.SLOT('nothing()'))
self.mspa.accepted.connect(self.visit_site)
self.mspa.rejected.connect(self.nothing)
self.mspa.show()
else:
#print "No new updates :("
@ -103,27 +99,23 @@ class MSPAChecker(QtGui.QWidget):
def nothing(self):
self.mspa = None
class MSPAUpdateWindow(QtGui.QDialog):
class MSPAUpdateWindow(QtWidgets.QDialog):
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
QtWidgets.QDialog.__init__(self, parent)
self.mainwindow = parent
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
self.setWindowTitle("MSPA Update!")
self.setModal(False)
self.title = QtGui.QLabel("You have an unread MSPA update! :o)")
self.title = QtWidgets.QLabel("You have an unread MSPA update! :o)")
layout_0 = QtGui.QVBoxLayout()
layout_0 = QtWidgets.QVBoxLayout()
layout_0.addWidget(self.title)
self.ok = QtGui.QPushButton("GO READ NOW!", self)
self.ok = QtWidgets.QPushButton("GO READ NOW!", self, clicked=self.accept)
self.ok.setDefault(True)
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('accept()'))
self.cancel = QtGui.QPushButton("LATER", self)
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
self, QtCore.SLOT('reject()'))
layout_2 = QtGui.QHBoxLayout()
self.cancel = QtWidgets.QPushButton("LATER", self, clicked=self.reject)
layout_2 = QtWidgets.QHBoxLayout()
layout_2.addWidget(self.cancel)
layout_2.addWidget(self.ok)