Revert "Port code to PyQt5"

This reverts commit abe9342c4f.

That is to say, it reverts the PyQt5 port.
This commit is contained in:
karxi 2016-11-13 01:14:39 -05:00
parent 5d839aae47
commit d653af0fa4
20 changed files with 1341 additions and 922 deletions

View file

@ -1,47 +1,51 @@
from PyQt5 import QtGui, QtCore, QtWidgets from PyQt4 import QtGui, QtCore
import urllib import urllib
import ostools import ostools
import version import version
class BugReporter(QtWidgets.QDialog): class BugReporter(QtGui.QDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent) QtGui.QDialog.__init__(self, parent)
self.mainwindow = parent self.mainwindow = parent
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
self.setWindowTitle("Report a Bug") self.setWindowTitle("Report a Bug")
self.setModal(False) 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(self.title)
layout_0.addWidget(QtWidgets.QLabel("Chumhandle:")) layout_0.addWidget(QtGui.QLabel("Chumhandle:"))
handleLabel = QtWidgets.QLabel("The best chumhandle to contact you at for further information.") handleLabel = QtGui.QLabel("The best chumhandle to contact you at for further information.")
font = handleLabel.font() font = handleLabel.font()
font.setPointSize(8) font.setPointSize(8)
handleLabel.setFont(font) handleLabel.setFont(font)
layout_0.addWidget(handleLabel) 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;") self.name.setStyleSheet("background:white; font-weight:bold; color:black; font-size: 10pt;")
layout_0.addWidget(self.name) layout_0.addWidget(self.name)
layout_0.addWidget(QtWidgets.QLabel("Description of bug:")) layout_0.addWidget(QtGui.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.)") 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 = descLabel.font()
font.setPointSize(8) font.setPointSize(8)
descLabel.setFont(font) descLabel.setFont(font)
layout_0.addWidget(descLabel) 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;") self.textarea.setStyleSheet("background:white; font-weight:normal; color:black; font-size: 10pt;")
layout_0.addWidget(self.textarea) 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.ok.setDefault(True)
self.cancel = QtWidgets.QPushButton("CANCEL", self, clicked=self.reject) self.connect(self.ok, QtCore.SIGNAL('clicked()'),
layout_2 = QtWidgets.QHBoxLayout() 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.cancel)
layout_2.addWidget(self.ok) layout_2.addWidget(self.ok)
@ -60,14 +64,14 @@ class BugReporter(QtWidgets.QDialog):
msg = unicode(self.textarea.toPlainText()) msg = unicode(self.textarea.toPlainText())
if len(bestname) <= 0 or len(msg) <= 0: if len(bestname) <= 0 or len(msg) <= 0:
msgbox = QtWidgets.QMessageBox() msgbox = QtGui.QMessageBox()
msgbox.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) msgbox.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
msgbox.setText("You must fill out all fields first!") msgbox.setText("You must fill out all fields first!")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) msgbox.setStandardButtons(QtGui.QMessageBox.Ok)
ret = msgbox.exec_() ret = msgbox.exec_()
return 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}) data = urllib.urlencode({"name":name, "version": version._pcVersion, "bestname":bestname, "os":os, "platform":full, "python":python, "qt":qt, "msg":msg})
print "Sending..." print "Sending..."
f = urllib.urlopen("http://distantsphere.com/pc/reporter.php", data) 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 time import strftime
from copy import copy from copy import copy
from datetime import datetime, timedelta from datetime import datetime, timedelta
from PyQt5 import QtGui, QtCore, QtWidgets from PyQt4 import QtGui, QtCore
from mood import Mood from mood import Mood
from dataobjs import PesterProfile, PesterHistory from dataobjs import PesterProfile, PesterHistory
@ -13,22 +13,25 @@ from generic import PesterIcon
from parsetools import convertTags, lexMessage, splitMessage, mecmd, colorBegin, colorEnd, \ from parsetools import convertTags, lexMessage, splitMessage, mecmd, colorBegin, colorEnd, \
img2smiley, smiledict, oocre img2smiley, smiledict, oocre
class PesterTabWindow(QtWidgets.QFrame): class PesterTabWindow(QtGui.QFrame):
def __init__(self, mainwindow, parent=None, convo="convo"): 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.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
self.setFocusPolicy(QtCore.Qt.ClickFocus) self.setFocusPolicy(QtCore.Qt.ClickFocus)
self.mainwindow = mainwindow self.mainwindow = mainwindow
self.tabs = QtWidgets.QTabBar(self) self.tabs = QtGui.QTabBar(self)
self.tabs.setMovable(True) self.tabs.setMovable(True)
self.tabs.setTabsClosable(True) self.tabs.setTabsClosable(True)
self.tabs.currentChanged.connect(self.changeTab) self.connect(self.tabs, QtCore.SIGNAL('currentChanged(int)'),
self.tabs.tabCloseRequested.connect(self.tabClose) self, QtCore.SLOT('changeTab(int)'))
self.tabs.tabMoved.connect(self.tabMoved) 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.initTheme(self.mainwindow.theme)
self.layout = QtWidgets.QVBoxLayout() self.layout = QtGui.QVBoxLayout()
self.layout.setContentsMargins(0,0,0,0) self.layout.setContentsMargins(0,0,0,0)
self.layout.addWidget(self.tabs) self.layout.addWidget(self.tabs)
self.setLayout(self.layout) self.setLayout(self.layout)
@ -232,9 +235,9 @@ class PesterMovie(QtGui.QMovie):
text.urls[movie], movie.currentPixmap()) text.urls[movie], movie.currentPixmap())
text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth()) text.setLineWrapColumnOrWidth(text.lineWrapColumnOrWidth())
class PesterText(QtWidgets.QTextEdit): class PesterText(QtGui.QTextEdit):
def __init__(self, theme, parent=None): def __init__(self, theme, parent=None):
QtWidgets.QTextEdit.__init__(self, parent) QtGui.QTextEdit.__init__(self, parent)
if hasattr(self.parent(), 'mainwindow'): if hasattr(self.parent(), 'mainwindow'):
self.mainwindow = self.parent().mainwindow self.mainwindow = self.parent().mainwindow
else: else:
@ -248,18 +251,21 @@ class PesterText(QtWidgets.QTextEdit):
self.setReadOnly(True) self.setReadOnly(True)
self.setMouseTracking(True) self.setMouseTracking(True)
self.textSelected = False self.textSelected = False
self.copyAvailable.connect(self.textReady) self.connect(self, QtCore.SIGNAL('copyAvailable(bool)'),
self, QtCore.SLOT('textReady(bool)'))
self.urls = {} self.urls = {}
for k in smiledict: for k in smiledict:
self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k])) self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k]))
self.mainwindow.animationSetting.connect(self.animateChanged) self.connect(self.mainwindow, QtCore.SIGNAL('animationSetting(bool)'),
self, QtCore.SLOT('animateChanged(bool)'))
def addAnimation(self, url, fileName): def addAnimation(self, url, fileName):
movie = PesterMovie(self) movie = PesterMovie(self)
movie.setFileName(fileName) movie.setFileName(fileName)
movie.setCacheMode(QtGui.QMovie.CacheAll) movie.setCacheMode(QtGui.QMovie.CacheAll)
if movie.frameCount() > 1: if movie.frameCount() > 1:
self.urls[movie] = url self.urls[movie] = url
movie.frameChanged.connect(movie.animate) movie.connect(movie, QtCore.SIGNAL('frameChanged(int)'),
movie, QtCore.SLOT('animate(int)'))
#movie.start() #movie.start()
@QtCore.pyqtSlot(bool) @QtCore.pyqtSlot(bool)
def animateChanged(self, animate): def animateChanged(self, animate):
@ -377,14 +383,14 @@ class PesterText(QtWidgets.QTextEdit):
sb.setValue(sb.maximum()) sb.setValue(sb.maximum())
def focusInEvent(self, event): def focusInEvent(self, event):
self.parent().clearNewMessage() self.parent().clearNewMessage()
QtWidgets.QTextEdit.focusInEvent(self, event) QtGui.QTextEdit.focusInEvent(self, event)
def keyPressEvent(self, event): def keyPressEvent(self, event):
if hasattr(self.parent(), 'textInput'): if hasattr(self.parent(), 'textInput'):
if event.key() not in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown, \ if event.key() not in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown, \
QtCore.Qt.Key_Up, QtCore.Qt.Key_Down]: QtCore.Qt.Key_Up, QtCore.Qt.Key_Down]:
self.parent().textInput.keyPressEvent(event) self.parent().textInput.keyPressEvent(event)
QtWidgets.QTextEdit.keyPressEvent(self, event) QtGui.QTextEdit.keyPressEvent(self, event)
def mousePressEvent(self, event): def mousePressEvent(self, event):
if event.button() == QtCore.Qt.LeftButton: if event.button() == QtCore.Qt.LeftButton:
@ -397,12 +403,12 @@ class PesterText(QtWidgets.QTextEdit):
self.parent().mainwindow.newConversation(handle) self.parent().mainwindow.newConversation(handle)
else: else:
if event.modifiers() == QtCore.Qt.ControlModifier: if event.modifiers() == QtCore.Qt.ControlModifier:
QtWidgets.QApplication.clipboard().setText(url) QtGui.QApplication.clipboard().setText(url)
else: else:
QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode)) QtGui.QDesktopServices.openUrl(QtCore.QUrl(url, QtCore.QUrl.TolerantMode))
QtWidgets.QTextEdit.mousePressEvent(self, event) QtGui.QTextEdit.mousePressEvent(self, event)
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
QtWidgets.QTextEdit.mouseMoveEvent(self, event) QtGui.QTextEdit.mouseMoveEvent(self, event)
if self.anchorAt(event.pos()): if self.anchorAt(event.pos()):
if self.viewport().cursor().shape != QtCore.Qt.PointingHandCursor: if self.viewport().cursor().shape != QtCore.Qt.PointingHandCursor:
self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor)) self.viewport().setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
@ -412,7 +418,9 @@ class PesterText(QtWidgets.QTextEdit):
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
textMenu = self.createStandardContextMenu() textMenu = self.createStandardContextMenu()
if self.textSelected: 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.addAction(self.submitLogAction)
textMenu.exec_(event.globalPos()) textMenu.exec_(event.globalPos())
@ -427,10 +435,12 @@ class PesterText(QtWidgets.QTextEdit):
textdoc = QtGui.QTextDocument() textdoc = QtGui.QTextDocument()
textdoc.setHtml(htmldata) textdoc.setHtml(htmldata)
logdata = "%s\n%s" % (self.submitLogTitle(), textdoc.toPlainText()) logdata = "%s\n%s" % (self.submitLogTitle(), textdoc.toPlainText())
self.sending = QtWidgets.QDialog(self) self.sending = QtGui.QDialog(self)
layout = QtWidgets.QVBoxLayout() layout = QtGui.QVBoxLayout()
self.sending.sendinglabel = QtWidgets.QLabel("S3ND1NG...", self.sending) self.sending.sendinglabel = QtGui.QLabel("S3ND1NG...", self.sending)
cancelbutton = QtWidgets.QPushButton("OK", self.sending, clicked=self.sending.close) 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(self.sending.sendinglabel)
layout.addWidget(cancelbutton) layout.addWidget(cancelbutton)
self.sending.setLayout(layout) self.sending.setLayout(layout)
@ -453,16 +463,16 @@ class PesterText(QtWidgets.QTextEdit):
self.sending.sendinglabel.setText("F41L3D: %s" % (e)) self.sending.sendinglabel.setText("F41L3D: %s" % (e))
del self.sending del self.sending
class PesterInput(QtWidgets.QLineEdit): class PesterInput(QtGui.QLineEdit):
def __init__(self, theme, parent=None): def __init__(self, theme, parent=None):
QtWidgets.QLineEdit.__init__(self, parent) QtGui.QLineEdit.__init__(self, parent)
self.setStyleSheet(theme["convo/input/style"]) self.setStyleSheet(theme["convo/input/style"])
def changeTheme(self, theme): def changeTheme(self, theme):
self.setStyleSheet(theme["convo/input/style"]) self.setStyleSheet(theme["convo/input/style"])
def focusInEvent(self, event): def focusInEvent(self, event):
self.parent().clearNewMessage() self.parent().clearNewMessage()
self.parent().textArea.textCursor().clearSelection() self.parent().textArea.textCursor().clearSelection()
QtWidgets.QLineEdit.focusInEvent(self, event) QtGui.QLineEdit.focusInEvent(self, event)
def keyPressEvent(self, event): def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Up: if event.key() == QtCore.Qt.Key_Up:
text = unicode(self.text()) text = unicode(self.text())
@ -476,11 +486,11 @@ class PesterInput(QtWidgets.QLineEdit):
elif event.key() in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]: elif event.key() in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]:
self.parent().textArea.keyPressEvent(event) self.parent().textArea.keyPressEvent(event)
self.parent().mainwindow.idletime = 0 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): 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.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
self.setObjectName(chum.handle) self.setObjectName(chum.handle)
self.setFocusPolicy(QtCore.Qt.ClickFocus) self.setFocusPolicy(QtCore.Qt.ClickFocus)
@ -494,19 +504,20 @@ class PesterConvo(QtWidgets.QFrame):
t = Template(self.mainwindow.theme["convo/chumlabel/text"]) 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.setStyleSheet(self.mainwindow.theme["convo/chumlabel/style"])
self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]]) self.chumLabel.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]])
self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"]) self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"])
self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"]) self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"])
self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding)) self.chumLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding))
self.textArea = PesterText(self.mainwindow.theme, self) self.textArea = PesterText(self.mainwindow.theme, self)
self.textInput = PesterInput(self.mainwindow.theme, self) self.textInput = PesterInput(self.mainwindow.theme, self)
self.textInput.setFocus() self.textInput.setFocus()
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.chumLabel)
self.layout.addWidget(self.textArea) self.layout.addWidget(self.textArea)
self.layout.addWidget(self.textInput) self.layout.addWidget(self.textInput)
@ -517,17 +528,31 @@ class PesterConvo(QtWidgets.QFrame):
self.setLayout(self.layout) self.setLayout(self.layout)
self.optionsMenu = QtWidgets.QMenu(self) self.optionsMenu = QtGui.QMenu(self)
self.optionsMenu.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"]) 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.addChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.blockAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"], self, triggered=self.blockThisChum) self.connect(self.addChumAction, QtCore.SIGNAL('triggered()'),
self.quirksOff = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"], self, toggled=self.toggleQuirks) 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.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.oocToggle.setCheckable(True)
self.unblockchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self, triggered=self.unblockChumSlot) self.connect(self.oocToggle, QtCore.SIGNAL('toggled(bool)'),
self.reportchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/report"], self, triggered=self.reportThisChum) self, QtCore.SLOT('toggleOOC(bool)'))
self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self, triggered=self.openChumLogs) 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.quirksOff)
self.optionsMenu.addAction(self.oocToggle) 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.setAlignment(self.aligndict["h"][self.mainwindow.theme["convo/chumlabel/align/h"]] | self.aligndict["v"][self.mainwindow.theme["convo/chumlabel/align/v"]])
self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"]) self.chumLabel.setMaximumHeight(self.mainwindow.theme["convo/chumlabel/maxheight"])
self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"]) self.chumLabel.setMinimumHeight(self.mainwindow.theme["convo/chumlabel/minheight"])
self.chumLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.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.quirksOff.setText(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"])
self.addChumAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/addchum"]) self.addChumAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/addchum"])
self.blockAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"]) self.blockAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"])
@ -709,7 +734,7 @@ class PesterConvo(QtWidgets.QFrame):
try: try:
lexmsg = quirks.apply(lexmsg) lexmsg = quirks.apply(lexmsg)
except: except:
msgbox = QtWidgets.QMessageBox() msgbox = QtGui.QMessageBox()
msgbox.setText("Whoa there! There seems to be a problem.") 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.setInformativeText("A quirk seems to be having a problem. (Possibly you're trying to capture a non-existant group?)")
msgbox.exec_() msgbox.exec_()
@ -721,7 +746,7 @@ class PesterConvo(QtWidgets.QFrame):
self.addMessage(lm, True) self.addMessage(lm, True)
# if ceased, rebegin # if ceased, rebegin
if hasattr(self, 'chumopen') and not self.chumopen: 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) self.setChumOpen(True)
text = convertTags(serverMsg, "ctag") text = convertTags(serverMsg, "ctag")
self.messageSent.emit(text, self.title()) self.messageSent.emit(text, self.title())
@ -749,13 +774,14 @@ class PesterConvo(QtWidgets.QFrame):
def openChumLogs(self): def openChumLogs(self):
currentChum = self.chum.handle currentChum = self.chum.handle
self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow)
self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog) self.connect(self.mainwindow.chumList.pesterlogviewer, QtCore.SIGNAL('rejected()'),
self.mainwindow.chumList, QtCore.SLOT('closeActiveLog()'))
self.mainwindow.chumList.pesterlogviewer.show() self.mainwindow.chumList.pesterlogviewer.show()
self.mainwindow.chumList.pesterlogviewer.raise_() self.mainwindow.chumList.pesterlogviewer.raise_()
self.mainwindow.chumList.pesterlogviewer.activateWindow() self.mainwindow.chumList.pesterlogviewer.activateWindow()
messageSent = QtCore.pyqtSignal('QString', 'QString') messageSent = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
windowClosed = QtCore.pyqtSignal('QString') windowClosed = QtCore.pyqtSignal(QtCore.QString)
aligndict = {"h": {"center": QtCore.Qt.AlignHCenter, aligndict = {"h": {"center": QtCore.Qt.AlignHCenter,
"left": QtCore.Qt.AlignLeft, "left": QtCore.Qt.AlignLeft,

View file

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

View file

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

62
irc.py
View file

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

View file

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

View file

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

167
memos.py
View file

@ -1,7 +1,7 @@
from string import Template from string import Template
import re import re
from copy import copy from copy import copy
from PyQt5 import QtGui, QtCore, QtWidgets from PyQt4 import QtGui, QtCore
from datetime import time, timedelta, datetime from datetime import time, timedelta, datetime
from mood import Mood from mood import Mood
@ -178,13 +178,15 @@ class TimeTracker(list):
return TimeGrammar(temporal, pcf, when, 0) return TimeGrammar(temporal, pcf, when, 0)
return TimeGrammar(temporal, pcf, when, self.getRecord(timed)) return TimeGrammar(temporal, pcf, when, self.getRecord(timed))
class TimeInput(QtWidgets.QLineEdit): class TimeInput(QtGui.QLineEdit):
def __init__(self, timeslider, parent): def __init__(self, timeslider, parent):
QtWidgets.QLineEdit.__init__(self, parent) QtGui.QLineEdit.__init__(self, parent)
self.timeslider = timeslider self.timeslider = timeslider
self.setText("+0:00") self.setText("+0:00")
self.timeslider.valueChanged.connect(self.setTime) self.connect(self.timeslider, QtCore.SIGNAL('valueChanged(int)'),
self.editingFinished.connect(self.setSlider) self, QtCore.SLOT('setTime(int)'))
self.connect(self, QtCore.SIGNAL('editingFinished()'),
self, QtCore.SLOT('setSlider()'))
@QtCore.pyqtSlot(int) @QtCore.pyqtSlot(int)
def setTime(self, sliderval): def setTime(self, sliderval):
self.setText(self.timeslider.getTime()) self.setText(self.timeslider.getTime())
@ -207,9 +209,9 @@ class TimeInput(QtWidgets.QLineEdit):
text = delta2txt(timed) text = delta2txt(timed)
self.setText(text) self.setText(text)
class TimeSlider(QtWidgets.QSlider): class TimeSlider(QtGui.QSlider):
def __init__(self, orientation, parent): def __init__(self, orientation, parent):
QtWidgets.QSlider.__init__(self, orientation, parent) QtGui.QSlider.__init__(self, orientation, parent)
self.setTracking(True) self.setTracking(True)
self.setMinimum(-50) self.setMinimum(-50)
self.setMaximum(50) self.setMaximum(50)
@ -241,7 +243,7 @@ _ctag_begin = re.compile(r'<c=(.*?)>')
class MemoText(PesterText): class MemoText(PesterText):
def __init__(self, theme, parent=None): def __init__(self, theme, parent=None):
QtWidgets.QTextEdit.__init__(self, parent) QtGui.QTextEdit.__init__(self, parent)
if hasattr(self.parent(), 'mainwindow'): if hasattr(self.parent(), 'mainwindow'):
self.mainwindow = self.parent().mainwindow self.mainwindow = self.parent().mainwindow
else: else:
@ -255,11 +257,13 @@ class MemoText(PesterText):
self.setReadOnly(True) self.setReadOnly(True)
self.setMouseTracking(True) self.setMouseTracking(True)
self.textSelected = False self.textSelected = False
self.copyAvailable.connect(self.textReady) self.connect(self, QtCore.SIGNAL('copyAvailable(bool)'),
self, QtCore.SLOT('textReady(bool)'))
self.urls = {} self.urls = {}
for k in smiledict: for k in smiledict:
self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k])) self.addAnimation(QtCore.QUrl("smilies/%s" % (smiledict[k])), "smilies/%s" % (smiledict[k]))
self.mainwindow.animationSetting.connect(self.animateChanged) self.connect(self.mainwindow, QtCore.SIGNAL('animationSetting(bool)'),
self, QtCore.SLOT('animateChanged(bool)'))
def initTheme(self, theme): def initTheme(self, theme):
if theme.has_key("memos/scrollbar"): if theme.has_key("memos/scrollbar"):
@ -339,62 +343,91 @@ class MemoText(PesterText):
class MemoInput(PesterInput): class MemoInput(PesterInput):
def __init__(self, theme, parent=None): def __init__(self, theme, parent=None):
QtWidgets.QLineEdit.__init__(self, parent) QtGui.QLineEdit.__init__(self, parent)
self.setStyleSheet(theme["memos/input/style"]) self.setStyleSheet(theme["memos/input/style"])
def changeTheme(self, theme): def changeTheme(self, theme):
self.setStyleSheet(theme["memos/input/style"]) self.setStyleSheet(theme["memos/input/style"])
class PesterMemo(PesterConvo): class PesterMemo(PesterConvo):
def __init__(self, channel, timestr, mainwindow, parent=None): 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.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
self.channel = channel self.channel = channel
self.setObjectName(self.channel) self.setObjectName(self.channel)
self.mainwindow = mainwindow self.mainwindow = mainwindow
self.time = TimeTracker(txt2delta(timestr)) self.time = TimeTracker(txt2delta(timestr))
self.setWindowTitle(channel) self.setWindowTitle(channel)
self.channelLabel = QtWidgets.QLabel(self) self.channelLabel = QtGui.QLabel(self)
self.channelLabel.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Expanding)) self.channelLabel.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Expanding))
self.textArea = MemoText(self.mainwindow.theme, self) self.textArea = MemoText(self.mainwindow.theme, self)
self.textInput = MemoInput(self.mainwindow.theme, self) self.textInput = MemoInput(self.mainwindow.theme, self)
self.textInput.setFocus() 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.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 = RightClickList(self)
self.userlist.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)) self.userlist.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding))
self.userlist.optionsMenu = QtWidgets.QMenu(self) self.userlist.optionsMenu = QtGui.QMenu(self)
self.addchumAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self, triggered=self.addChumSlot) self.addchumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
self.banuserAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self, triggered=self.banSelectedUser) self.connect(self.addchumAction, QtCore.SIGNAL('triggered()'),
self.opAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/opuser"], self, triggered=self.opSelectedUser) self, QtCore.SLOT('addChumSlot()'))
self.voiceAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/voiceuser"], self, triggered=self.voiceSelectedUser) self.banuserAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/banuser"], self)
self.quirkDisableAction = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/quirkkill"], self, triggered=self.killQuirkUser) 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) self.userlist.optionsMenu.addAction(self.addchumAction)
# ban & op list added if we are op # ban & op list added if we are op
self.optionsMenu = QtWidgets.QMenu(self) self.optionsMenu = QtGui.QMenu(self)
self.oocToggle = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self, toggled=self.toggleOOC) self.oocToggle = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/ooc"], self)
self.oocToggle.setCheckable(True) 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.quirksOff.setCheckable(True)
self.logchum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/viewlog"], self, triggered=self.openChumLogs) self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'),
self.invitechum = QtWidgets.QAction(self.mainwindow.theme["main/menus/rclickchumlist/invitechum"], self, triggered=self.inviteChums) 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.quirksOff)
self.optionsMenu.addAction(self.oocToggle) self.optionsMenu.addAction(self.oocToggle)
self.optionsMenu.addAction(self.logchum) self.optionsMenu.addAction(self.logchum)
self.optionsMenu.addAction(self.invitechum) self.optionsMenu.addAction(self.invitechum)
self.chanModeMenu = QtWidgets.QMenu(self.mainwindow.theme["main/menus/rclickchumlist/memosetting"], self) self.chanModeMenu = QtGui.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 = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/memonoquirk"], self)
self.chanNoquirks.setCheckable(True) 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.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.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.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.chanNoquirks)
self.chanModeMenu.addAction(self.chanHide) self.chanModeMenu.addAction(self.chanHide)
self.chanModeMenu.addAction(self.chanInvite) self.chanModeMenu.addAction(self.chanInvite)
@ -404,38 +437,48 @@ class PesterMemo(PesterConvo):
self.timeinput = TimeInput(self.timeslider, self) self.timeinput = TimeInput(self.timeslider, self)
self.timeinput.setText(timestr) self.timeinput.setText(timestr)
self.timeinput.setSlider() self.timeinput.setSlider()
self.timetravel = QtWidgets.QPushButton("GO", self, clicked=self.sendtime) self.timetravel = QtGui.QPushButton("GO", self)
self.timeclose = QtWidgets.QPushButton("CLOSE", self, clicked=self.smashclock) self.timeclose = QtGui.QPushButton("CLOSE", self)
self.timeswitchl = QtWidgets.QPushButton(self, clicked=self.prevtime) self.timeswitchl = QtGui.QPushButton(self)
self.timeswitchr = QtWidgets.QPushButton(self, clicked=self.nexttime) 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.times = {}
self.initTheme(self.mainwindow.theme) self.initTheme(self.mainwindow.theme)
# connect # 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.textArea)
layout_0.addWidget(self.textInput) layout_0.addWidget(self.textInput)
layout_1 = QtWidgets.QHBoxLayout() layout_1 = QtGui.QHBoxLayout()
layout_1.addLayout(layout_0) layout_1.addLayout(layout_0)
layout_1.addWidget(self.miniUserlist) layout_1.addWidget(self.miniUserlist)
layout_1.addWidget(self.userlist) 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.timeslider, 0, 1, QtCore.Qt.AlignHCenter)
# layout_1.addWidget(self.timeinput, 1, 0, 1, 3) # 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.timeslider)
layout_2.addWidget(self.timeinput) layout_2.addWidget(self.timeinput)
layout_2.addWidget(self.timetravel) layout_2.addWidget(self.timetravel)
layout_2.addWidget(self.timeclose) layout_2.addWidget(self.timeclose)
layout_2.addWidget(self.timeswitchl) layout_2.addWidget(self.timeswitchl)
layout_2.addWidget(self.timeswitchr) layout_2.addWidget(self.timeswitchr)
self.layout = QtWidgets.QVBoxLayout() self.layout = QtGui.QVBoxLayout()
self.layout.addWidget(self.channelLabel) self.layout.addWidget(self.channelLabel)
self.layout.addLayout(layout_1) self.layout.addLayout(layout_1)
@ -495,7 +538,7 @@ class PesterMemo(PesterConvo):
def updateColor(self, handle, color): def updateColor(self, handle, color):
chums = self.userlist.findItems(handle, QtCore.Qt.MatchFlags(0)) chums = self.userlist.findItems(handle, QtCore.Qt.MatchFlags(0))
for c in chums: for c in chums:
c.setForeground(QtGui.QBrush(color)) c.setTextColor(color)
def addMessage(self, text, handle): def addMessage(self, text, handle):
if type(handle) is bool: if type(handle) is bool:
chum = self.mainwindow.profile() chum = self.mainwindow.profile()
@ -610,13 +653,13 @@ class PesterMemo(PesterConvo):
elif handle[0] == '&': elif handle[0] == '&':
admin = True admin = True
handle = handle[1:] handle = handle[1:]
item = QtWidgets.QListWidgetItem(handle) item = QtGui.QListWidgetItem(handle)
if handle == self.mainwindow.profile().handle: if handle == self.mainwindow.profile().handle:
color = self.mainwindow.profile().color color = self.mainwindow.profile().color
else: else:
color = chumdb.getColor(handle, defaultcolor) color = chumdb.getColor(handle, defaultcolor)
item.box = (handle == "evacipatedBox") item.box = (handle == "evacipatedBox")
item.setForeground(QtGui.QBrush(color)) item.setTextColor(color)
item.founder = founder item.founder = founder
item.op = op item.op = op
item.halfop = halfop item.halfop = halfop
@ -792,7 +835,7 @@ class PesterMemo(PesterConvo):
self.messageSent.emit(serverText, self.title()) self.messageSent.emit(serverText, self.title())
self.textInput.setText("") self.textInput.setText("")
@QtCore.pyqtSlot('QString') @QtCore.pyqtSlot(QtCore.QString)
def namesUpdated(self, channel): def namesUpdated(self, channel):
c = unicode(channel) c = unicode(channel)
if c.lower() != self.channel.lower(): return if c.lower() != self.channel.lower(): return
@ -802,27 +845,28 @@ class PesterMemo(PesterConvo):
self.userlist.clear() self.userlist.clear()
for n in self.mainwindow.namesdb[self.channel]: for n in self.mainwindow.namesdb[self.channel]:
self.addUser(n) self.addUser(n)
@QtCore.pyqtSlot('QString', 'QString') @QtCore.pyqtSlot(QtCore.QString, QtCore.QString)
def modesUpdated(self, channel, modes): def modesUpdated(self, channel, modes):
c = unicode(channel) c = unicode(channel)
if c.lower() == self.channel.lower(): if c.lower() == self.channel.lower():
self.updateChanModes(modes, None) self.updateChanModes(modes, None)
@QtCore.pyqtSlot('QString') @QtCore.pyqtSlot(QtCore.QString)
def closeInviteOnly(self, channel): def closeInviteOnly(self, channel):
c = unicode(channel) c = unicode(channel)
if c.lower() == self.channel.lower(): 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(): if self.parent():
print self.channel print self.channel
i = self.parent().tabIndices[self.channel] i = self.parent().tabIndices[self.channel]
self.parent().tabClose(i) self.parent().tabClose(i)
else: else:
self.close() self.close()
msgbox = QtWidgets.QMessageBox() msgbox = QtGui.QMessageBox()
msgbox.setText("%s: Invites only!" % (c)) msgbox.setText("%s: Invites only!" % (c))
msgbox.setInformativeText("This channel is invite-only. You must get an invitation from someone on the inside before entering.") msgbox.setInformativeText("This channel is invite-only. You must get an invitation from someone on the inside before entering.")
msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) msgbox.setStandardButtons(QtGui.QMessageBox.Ok)
ret = msgbox.exec_() ret = msgbox.exec_()
def quirkDisable(self, op, msg): def quirkDisable(self, op, msg):
@ -885,7 +929,7 @@ class PesterMemo(PesterConvo):
self.mainwindow.chatlog.log(self.channel, msg) self.mainwindow.chatlog.log(self.channel, msg)
del self.netsplit del self.netsplit
@QtCore.pyqtSlot('QString', 'QString', 'QString') @QtCore.pyqtSlot(QtCore.QString, QtCore.QString, QtCore.QString)
def userPresentChange(self, handle, channel, update): def userPresentChange(self, handle, channel, update):
h = unicode(handle) h = unicode(handle)
c = unicode(channel) c = unicode(channel)
@ -916,7 +960,7 @@ class PesterMemo(PesterConvo):
if update == "netsplit": if update == "netsplit":
if not hasattr(self, "netsplit"): if not hasattr(self, "netsplit"):
self.netsplit = [] self.netsplit = []
QtCore.QTimer.singleShot(1500, self.dumpNetsplit) QtCore.QTimer.singleShot(1500, self, QtCore.SLOT('dumpNetsplit()'))
for c in chums: for c in chums:
chum = PesterProfile(h) chum = PesterProfile(h)
self.userlist.takeItem(self.userlist.row(c)) self.userlist.takeItem(self.userlist.row(c))
@ -976,12 +1020,12 @@ class PesterMemo(PesterConvo):
if chum is self.mainwindow.profile(): if chum is self.mainwindow.profile():
# are you next? # are you next?
msgbox = QtWidgets.QMessageBox() msgbox = QtGui.QMessageBox()
msgbox.setText(self.mainwindow.theme["convo/text/kickedmemo"]) msgbox.setText(self.mainwindow.theme["convo/text/kickedmemo"])
msgbox.setInformativeText("press 0k to rec0nnect or cancel to absc0nd") 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_() ret = msgbox.exec_()
if ret == QtWidgets.QMessageBox.Ok: if ret == QtGui.QMessageBox.Ok:
self.userlist.clear() self.userlist.clear()
self.time = TimeTracker(curtime) self.time = TimeTracker(curtime)
self.resetSlider(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) msg = me.memoopenmsg(systemColor, self.time.getTime(), self.time.getGrammar(), self.mainwindow.theme["convo/text/openmemo"], self.channel)
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.channel, msg) self.mainwindow.chatlog.log(self.channel, msg)
elif ret == QtWidgets.QMessageBox.Cancel: elif ret == QtGui.QMessageBox.Cancel:
if self.parent(): if self.parent():
i = self.parent().tabIndices[self.channel] i = self.parent().tabIndices[self.channel]
self.parent().tabClose(i) self.parent().tabClose(i)
@ -1127,7 +1171,7 @@ class PesterMemo(PesterConvo):
if not self.userlist.currentItem(): if not self.userlist.currentItem():
return return
currentHandle = unicode(self.userlist.currentItem().text()) 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: if ok:
self.mainwindow.kickUser.emit("%s:%s" % (currentHandle, reason), self.channel) self.mainwindow.kickUser.emit("%s:%s" % (currentHandle, reason), self.channel)
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
@ -1159,7 +1203,8 @@ class PesterMemo(PesterConvo):
def openChumLogs(self): def openChumLogs(self):
currentChum = self.channel currentChum = self.channel
self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow) self.mainwindow.chumList.pesterlogviewer = PesterLogViewer(currentChum, self.mainwindow.config, self.mainwindow.theme, self.mainwindow)
self.mainwindow.chumList.pesterlogviewer.rejected.connect(self.mainwindow.chumList.closeActiveLog) self.connect(self.mainwindow.chumList.pesterlogviewer, QtCore.SIGNAL('rejected()'),
self.mainwindow.chumList, QtCore.SLOT('closeActiveLog()'))
self.mainwindow.chumList.pesterlogviewer.show() self.mainwindow.chumList.pesterlogviewer.show()
self.mainwindow.chumList.pesterlogviewer.raise_() self.mainwindow.chumList.pesterlogviewer.raise_()
self.mainwindow.chumList.pesterlogviewer.activateWindow() self.mainwindow.chumList.pesterlogviewer.activateWindow()
@ -1169,7 +1214,7 @@ class PesterMemo(PesterConvo):
if not hasattr(self, 'invitechums'): if not hasattr(self, 'invitechums'):
self.invitechums = None self.invitechums = None
if not self.invitechums: if not self.invitechums:
(chum, ok) = QtWidgets.QInputDialog.getText(self, "Invite to Chat", "Enter the chumhandle of the user you'd like to invite:") (chum, ok) = QtGui.QInputDialog.getText(self, "Invite to Chat", "Enter the chumhandle of the user you'd like to invite:")
if ok: if ok:
chum = unicode(chum) chum = unicode(chum)
self.mainwindow.inviteChum.emit(chum, self.channel) self.mainwindow.inviteChum.emit(chum, self.channel)
@ -1235,7 +1280,7 @@ class PesterMemo(PesterConvo):
self.mainwindow.waitingMessages.messageAnswered(self.channel) self.mainwindow.waitingMessages.messageAnswered(self.channel)
self.windowClosed.emit(self.title()) 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"] 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 PyQt5 import QtCore, QtWidgets from PyQt4 import QtCore, QtGui
from generic import PesterIcon from generic import PesterIcon
@ -49,8 +49,10 @@ class PesterMoodHandler(QtCore.QObject):
self.buttons[b.mood.value()] = b self.buttons[b.mood.value()] = b
if b.mood.value() == self.mainwindow.profile().mood.value(): if b.mood.value() == self.mainwindow.profile().mood.value():
b.setSelected(True) b.setSelected(True)
b.clicked.connect(b.updateMood) self.connect(b, QtCore.SIGNAL('clicked()'),
b.moodUpdated.connect(self.updateMood) b, QtCore.SLOT('updateMood()'))
self.connect(b, QtCore.SIGNAL('moodUpdated(int)'),
self, QtCore.SLOT('updateMood(int)'))
def removeButtons(self): def removeButtons(self):
for b in self.buttons.values(): for b in self.buttons.values():
b.close() b.close()
@ -83,10 +85,10 @@ class PesterMoodHandler(QtCore.QObject):
c.myUpdateMood(newmood) c.myUpdateMood(newmood)
self.mainwindow.moodUpdated.emit() self.mainwindow.moodUpdated.emit()
class PesterMoodButton(QtWidgets.QPushButton): class PesterMoodButton(QtGui.QPushButton):
def __init__(self, parent, **options): def __init__(self, parent, **options):
icon = PesterIcon(options["icon"]) 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.setIconSize(icon.realsize())
self.setFlat(True) self.setFlat(True)
self.resize(*options["size"]) self.resize(*options["size"])

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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