2022-03-19 19:48:19 -04:00
|
|
|
import re
|
|
|
|
from os import remove
|
|
|
|
|
2022-06-26 22:18:37 -04:00
|
|
|
from PyQt6 import QtCore, QtGui, QtWidgets
|
2011-02-02 19:32:35 -05:00
|
|
|
|
2022-03-19 19:48:19 -04:00
|
|
|
import ostools
|
2022-04-10 23:57:13 -04:00
|
|
|
import parsetools
|
|
|
|
from generic import RightClickList, RightClickTree, MultiTextDialog
|
|
|
|
from dataobjs import pesterQuirk, PesterProfile, PesterHistory
|
2011-02-05 12:17:33 -05:00
|
|
|
from memos import TimeSlider, TimeInput
|
2011-05-26 03:40:30 -04:00
|
|
|
from version import _pcVersion
|
2022-04-10 23:57:13 -04:00
|
|
|
from convo import PesterInput, PesterText
|
|
|
|
from parsetools import lexMessage
|
2011-02-02 19:32:35 -05:00
|
|
|
|
2022-03-19 19:48:19 -04:00
|
|
|
QString = str
|
2011-11-30 18:45:50 -05:00
|
|
|
_datadir = ostools.getDataDir()
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterQuirkItem(QtWidgets.QTreeWidgetItem):
|
2011-05-25 04:38:36 -04:00
|
|
|
def __init__(self, quirk):
|
|
|
|
parent = None
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QTreeWidgetItem.__init__(self, parent)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.quirk = quirk
|
2021-03-23 17:36:43 -04:00
|
|
|
self.setText(0, str(quirk))
|
2011-02-23 06:06:00 -05:00
|
|
|
def update(self, quirk):
|
|
|
|
self.quirk = quirk
|
2021-03-23 17:36:43 -04:00
|
|
|
self.setText(0, str(quirk))
|
2011-02-02 19:32:35 -05:00
|
|
|
def __lt__(self, quirkitem):
|
2011-03-31 17:57:30 -04:00
|
|
|
"""Sets the order of quirks if auto-sorted by Qt. Obsolete now."""
|
2011-02-02 19:32:35 -05:00
|
|
|
if self.quirk.type == "prefix":
|
|
|
|
return True
|
|
|
|
elif (self.quirk.type == "replace" or self.quirk.type == "regexp") and \
|
|
|
|
quirkitem.type == "suffix":
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterQuirkList(QtWidgets.QTreeWidget):
|
2011-02-02 19:32:35 -05:00
|
|
|
def __init__(self, mainwindow, parent):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QTreeWidget.__init__(self, parent)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.resize(400, 200)
|
2011-03-31 17:57:30 -04:00
|
|
|
# make sure we have access to mainwindow info like profiles
|
2011-04-02 04:45:55 -04:00
|
|
|
self.mainwindow = mainwindow
|
2011-02-02 19:32:35 -05:00
|
|
|
self.setStyleSheet("background:black; color:white;")
|
|
|
|
|
2021-03-23 17:58:58 -04:00
|
|
|
self.itemChanged[QtWidgets.QTreeWidgetItem, int].connect(self.changeCheckState)
|
2011-05-25 04:38:36 -04:00
|
|
|
|
2011-04-02 04:45:55 -04:00
|
|
|
for q in mainwindow.userprofile.quirks:
|
2011-05-25 04:38:36 -04:00
|
|
|
item = PesterQuirkItem(q)
|
|
|
|
self.addItem(item, False)
|
|
|
|
self.changeCheckState()
|
|
|
|
#self.setDragEnabled(True)
|
2022-06-26 22:18:37 -04:00
|
|
|
#self.setDragDropMode(QtGui.QAbstractItemView.DragDropMode.InternalMove)
|
2011-05-25 04:38:36 -04:00
|
|
|
self.setDropIndicatorShown(True)
|
|
|
|
self.setSortingEnabled(False)
|
|
|
|
self.setIndentation(15)
|
|
|
|
self.header().hide()
|
|
|
|
|
|
|
|
def addItem(self, item, new=True):
|
2022-06-26 22:18:37 -04:00
|
|
|
item.setFlags(QtCore.Qt.ItemFlag.ItemIsSelectable
|
|
|
|
| QtCore.Qt.ItemFlag.ItemIsDragEnabled
|
|
|
|
| QtCore.Qt.ItemFlag.ItemIsUserCheckable
|
|
|
|
| QtCore.Qt.ItemFlag.ItemIsEnabled)
|
2011-04-17 03:46:11 -04:00
|
|
|
if item.quirk.on:
|
2022-06-26 22:18:37 -04:00
|
|
|
item.setCheckState(0, QtCore.Qt.CheckState.Checked)
|
2011-05-25 04:38:36 -04:00
|
|
|
else:
|
2022-06-26 22:18:37 -04:00
|
|
|
item.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
|
2011-05-25 04:38:36 -04:00
|
|
|
if new:
|
|
|
|
curgroup = self.currentItem()
|
|
|
|
if curgroup:
|
|
|
|
if curgroup.parent(): curgroup = curgroup.parent()
|
|
|
|
item.quirk.quirk["group"] = item.quirk.group = curgroup.text(0)
|
2022-06-26 22:18:37 -04:00
|
|
|
found = self.findItems(item.quirk.group, QtCore.Qt.MatchFlag.MatchExactly)
|
2011-05-25 04:38:36 -04:00
|
|
|
if len(found) > 0:
|
|
|
|
found[0].addChild(item)
|
2011-04-17 03:46:11 -04:00
|
|
|
else:
|
2021-03-23 17:36:43 -04:00
|
|
|
child_1 = QtWidgets.QTreeWidgetItem([item.quirk.group])
|
2011-05-25 04:38:36 -04:00
|
|
|
self.addTopLevelItem(child_1)
|
2022-06-26 22:18:37 -04:00
|
|
|
child_1.setFlags(child_1.flags() | QtCore.Qt.ItemFlag.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
|
|
|
child_1.setChildIndicatorPolicy(QtWidgets.QTreeWidgetItem.ChildIndicatorPolicy.DontShowIndicatorWhenChildless)
|
|
|
|
child_1.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
|
2011-05-25 04:38:36 -04:00
|
|
|
child_1.setExpanded(True)
|
|
|
|
child_1.addChild(item)
|
2011-06-09 03:42:56 -04:00
|
|
|
self.changeCheckState()
|
2011-04-17 03:46:11 -04:00
|
|
|
|
2011-02-23 06:06:00 -05:00
|
|
|
def currentQuirk(self):
|
2011-05-25 04:38:36 -04:00
|
|
|
if type(self.currentItem()) is PesterQuirkItem:
|
|
|
|
return self.currentItem()
|
|
|
|
else: return None
|
2011-02-23 06:06:00 -05:00
|
|
|
|
2011-05-25 04:38:36 -04:00
|
|
|
@QtCore.pyqtSlot()
|
2011-03-31 17:57:30 -04:00
|
|
|
def upShiftQuirk(self):
|
2022-06-28 19:50:08 -04:00
|
|
|
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchFlag.MatchExactly)
|
2011-05-25 04:38:36 -04:00
|
|
|
if len(found): # group
|
|
|
|
i = self.indexOfTopLevelItem(found[0])
|
|
|
|
if i > 0:
|
|
|
|
expand = found[0].isExpanded()
|
|
|
|
shifted_item = self.takeTopLevelItem(i)
|
|
|
|
self.insertTopLevelItem(i-1, shifted_item)
|
|
|
|
shifted_item.setExpanded(expand)
|
|
|
|
self.setCurrentItem(shifted_item)
|
|
|
|
else: # quirk
|
2022-06-26 22:18:37 -04:00
|
|
|
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)
|
2011-05-25 04:38:36 -04:00
|
|
|
for f in found:
|
|
|
|
if not f.isSelected(): continue
|
|
|
|
if not f.parent(): continue
|
|
|
|
i = f.parent().indexOfChild(f)
|
|
|
|
if i > 0: # keep in same group
|
|
|
|
p = f.parent()
|
|
|
|
shifted_item = f.parent().takeChild(i)
|
|
|
|
p.insertChild(i-1, shifted_item)
|
|
|
|
self.setCurrentItem(shifted_item)
|
|
|
|
else: # move to another group
|
|
|
|
j = self.indexOfTopLevelItem(f.parent())
|
|
|
|
if j <= 0: continue
|
|
|
|
shifted_item = f.parent().takeChild(i)
|
|
|
|
self.topLevelItem(j-1).addChild(shifted_item)
|
|
|
|
self.setCurrentItem(shifted_item)
|
|
|
|
self.changeCheckState()
|
2011-03-31 17:57:30 -04:00
|
|
|
|
2011-05-25 04:38:36 -04:00
|
|
|
@QtCore.pyqtSlot()
|
2011-03-31 17:57:30 -04:00
|
|
|
def downShiftQuirk(self):
|
2022-06-26 22:18:37 -04:00
|
|
|
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchFlag.MatchExactly)
|
2011-05-25 04:38:36 -04:00
|
|
|
if len(found): # group
|
|
|
|
i = self.indexOfTopLevelItem(found[0])
|
|
|
|
if i < self.topLevelItemCount()-1 and i >= 0:
|
|
|
|
expand = found[0].isExpanded()
|
|
|
|
shifted_item = self.takeTopLevelItem(i)
|
|
|
|
self.insertTopLevelItem(i+1, shifted_item)
|
|
|
|
shifted_item.setExpanded(expand)
|
|
|
|
self.setCurrentItem(shifted_item)
|
|
|
|
else: # quirk
|
2022-06-26 22:18:37 -04:00
|
|
|
found = self.findItems(self.currentItem().text(0), QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)
|
2011-05-25 04:38:36 -04:00
|
|
|
for f in found:
|
|
|
|
if not f.isSelected(): continue
|
|
|
|
if not f.parent(): continue
|
|
|
|
i = f.parent().indexOfChild(f)
|
|
|
|
if i < f.parent().childCount()-1 and i >= 0:
|
|
|
|
p = f.parent()
|
|
|
|
shifted_item = f.parent().takeChild(i)
|
|
|
|
p.insertChild(i+1, shifted_item)
|
|
|
|
self.setCurrentItem(shifted_item)
|
|
|
|
else:
|
|
|
|
j = self.indexOfTopLevelItem(f.parent())
|
|
|
|
if j >= self.topLevelItemCount()-1 or j < 0: continue
|
|
|
|
shifted_item = f.parent().takeChild(i)
|
|
|
|
self.topLevelItem(j+1).insertChild(0, shifted_item)
|
|
|
|
self.setCurrentItem(shifted_item)
|
|
|
|
self.changeCheckState()
|
2011-03-31 17:57:30 -04:00
|
|
|
|
2011-02-02 19:32:35 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def removeCurrent(self):
|
2011-05-25 04:38:36 -04:00
|
|
|
i = self.currentItem()
|
2022-06-26 22:18:37 -04:00
|
|
|
found = self.findItems(i.text(0), QtCore.Qt.MatchFlag.MatchExactly | QtCore.Qt.MatchFlag.MatchRecursive)
|
2011-05-25 04:38:36 -04:00
|
|
|
for f in found:
|
|
|
|
if not f.isSelected(): continue
|
|
|
|
if not f.parent(): # group
|
2021-03-23 17:36:43 -04:00
|
|
|
msgbox = QtWidgets.QMessageBox()
|
2011-05-25 04:38:36 -04:00
|
|
|
msgbox.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
|
2017-01-25 10:50:09 -05:00
|
|
|
msgbox.setObjectName("delquirkwarning")
|
2011-05-25 04:38:36 -04:00
|
|
|
msgbox.setWindowTitle("WARNING!")
|
|
|
|
msgbox.setInformativeText("Are you sure you want to delete the quirk group: %s" % (f.text(0)))
|
2022-06-28 19:50:08 -04:00
|
|
|
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel)
|
2017-01-13 20:10:15 -05:00
|
|
|
# Find the Cancel button and make it default
|
|
|
|
for b in msgbox.buttons():
|
2022-06-28 19:50:08 -04:00
|
|
|
if msgbox.buttonRole(b) == QtWidgets.QMessageBox.ButtonRole.RejectRole:
|
2017-01-13 20:10:15 -05:00
|
|
|
# We found the 'OK' button, set it as the default
|
|
|
|
b.setDefault(True)
|
|
|
|
b.setAutoDefault(True)
|
|
|
|
# Actually set it as the selected option, since we're
|
|
|
|
# already stealing focus
|
|
|
|
b.setFocus()
|
|
|
|
break
|
2022-06-26 22:18:37 -04:00
|
|
|
ret = msgbox.exec()
|
2022-06-28 19:50:08 -04:00
|
|
|
if ret == QtWidgets.QMessageBox.StandardButton.Ok:
|
2011-05-25 04:38:36 -04:00
|
|
|
self.takeTopLevelItem(self.indexOfTopLevelItem(f))
|
|
|
|
else:
|
|
|
|
f.parent().takeChild(f.parent().indexOfChild(f))
|
2011-06-09 03:42:56 -04:00
|
|
|
self.changeCheckState()
|
2011-05-25 04:38:36 -04:00
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def addQuirkGroup(self):
|
|
|
|
if not hasattr(self, 'addgroupdialog'):
|
|
|
|
self.addgroupdialog = None
|
|
|
|
if not self.addgroupdialog:
|
2021-03-23 17:36:43 -04:00
|
|
|
(gname, ok) = QtWidgets.QInputDialog.getText(self, "Add Group", "Enter a name for the new quirk group:")
|
2011-05-25 04:38:36 -04:00
|
|
|
if ok:
|
2021-03-23 17:36:43 -04:00
|
|
|
gname = str(gname)
|
2011-05-25 04:38:36 -04:00
|
|
|
if re.search("[^A-Za-z0-9_\s]", gname) is not None:
|
2021-03-23 17:36:43 -04:00
|
|
|
msgbox = QtWidgets.QMessageBox()
|
2011-05-25 04:38:36 -04:00
|
|
|
msgbox.setInformativeText("THIS IS NOT A VALID GROUP NAME")
|
2022-06-28 19:50:08 -04:00
|
|
|
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
|
2022-06-26 22:18:37 -04:00
|
|
|
msgbox.exec()
|
2011-05-25 04:38:36 -04:00
|
|
|
self.addgroupdialog = None
|
|
|
|
return
|
2022-06-26 22:18:37 -04:00
|
|
|
found = self.findItems(gname, QtCore.Qt.MatchFlag.MatchExactly)
|
2011-05-25 04:38:36 -04:00
|
|
|
if found:
|
2021-03-23 17:36:43 -04:00
|
|
|
msgbox = QtWidgets.QMessageBox()
|
2011-05-25 04:38:36 -04:00
|
|
|
msgbox.setInformativeText("THIS QUIRK GROUP ALREADY EXISTS")
|
2022-06-28 19:50:08 -04:00
|
|
|
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
|
2022-06-26 22:18:37 -04:00
|
|
|
msgbox.exec()
|
2011-05-25 04:38:36 -04:00
|
|
|
return
|
2021-03-23 17:36:43 -04:00
|
|
|
child_1 = QtWidgets.QTreeWidgetItem([gname])
|
2011-05-25 04:38:36 -04:00
|
|
|
self.addTopLevelItem(child_1)
|
2022-06-26 22:18:37 -04:00
|
|
|
child_1.setFlags(child_1.flags() | QtCore.Qt.ItemFlag.ItemIsUserCheckable | QtCore.Qt.ItemFlag.ItemIsEnabled)
|
|
|
|
child_1.setChildIndicatorPolicy(QtWidgets.QTreeWidgetItem.ChildIndicatorPolicy.DontShowIndicatorWhenChildless)
|
|
|
|
child_1.setCheckState(0, QtCore.Qt.CheckState.Unchecked)
|
2011-05-25 04:38:36 -04:00
|
|
|
child_1.setExpanded(True)
|
|
|
|
|
|
|
|
self.addgroupdialog = None
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def changeCheckState(self):
|
|
|
|
index = self.indexOfTopLevelItem(self.currentItem())
|
|
|
|
if index == -1:
|
|
|
|
for i in range(self.topLevelItemCount()):
|
|
|
|
allChecked = True
|
|
|
|
noneChecked = True
|
|
|
|
for j in range(self.topLevelItem(i).childCount()):
|
|
|
|
if self.topLevelItem(i).child(j).checkState(0):
|
|
|
|
noneChecked = False
|
|
|
|
else:
|
|
|
|
allChecked = False
|
2022-06-26 22:18:37 -04:00
|
|
|
if allChecked: self.topLevelItem(i).setCheckState(0, QtCore.Qt.CheckState.Checked)
|
|
|
|
elif noneChecked: self.topLevelItem(i).setCheckState(0, QtCore.Qt.CheckState.PartiallyChecked)
|
|
|
|
else: self.topLevelItem(i).setCheckState(0, QtCore.Qt.CheckState.Checked)
|
2011-05-25 04:38:36 -04:00
|
|
|
else:
|
|
|
|
state = self.topLevelItem(index).checkState(0)
|
|
|
|
for j in range(self.topLevelItem(index).childCount()):
|
|
|
|
self.topLevelItem(index).child(j).setCheckState(0, state)
|
2011-02-02 19:32:35 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class QuirkTesterWindow(QtWidgets.QDialog):
|
2011-06-07 11:48:35 -04:00
|
|
|
def __init__(self, parent):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-10-30 00:06:03 -04:00
|
|
|
self.prnt = parent
|
2011-06-11 03:07:29 -04:00
|
|
|
self.mainwindow = parent.mainwindow
|
2011-06-07 11:48:35 -04:00
|
|
|
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
|
2011-06-11 03:07:29 -04:00
|
|
|
self.setWindowTitle("Quirk Tester")
|
|
|
|
self.resize(350,300)
|
2011-06-07 11:48:35 -04:00
|
|
|
|
2011-06-11 03:07:29 -04:00
|
|
|
self.textArea = PesterText(self.mainwindow.theme, self)
|
|
|
|
self.textInput = PesterInput(self.mainwindow.theme, self)
|
|
|
|
self.textInput.setFocus()
|
2011-06-07 11:48:35 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.textInput.returnPressed.connect(self.sentMessage)
|
2011-06-11 03:07:29 -04:00
|
|
|
|
|
|
|
self.chumopen = True
|
|
|
|
self.chum = self.mainwindow.profile()
|
|
|
|
self.history = PesterHistory()
|
2011-06-07 11:48:35 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-06-11 03:07:29 -04:00
|
|
|
layout_0.addWidget(self.textArea)
|
|
|
|
layout_0.addWidget(self.textInput)
|
2011-06-07 11:48:35 -04:00
|
|
|
self.setLayout(layout_0)
|
|
|
|
|
2011-10-30 00:06:03 -04:00
|
|
|
def parent(self):
|
|
|
|
return self.prnt
|
|
|
|
|
2011-06-11 03:07:29 -04:00
|
|
|
def clearNewMessage(self):
|
|
|
|
pass
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def sentMessage(self):
|
2021-03-23 17:36:43 -04:00
|
|
|
text = str(self.textInput.text())
|
2011-06-11 03:07:29 -04:00
|
|
|
|
2016-11-18 03:37:22 -05:00
|
|
|
return parsetools.kxhandleInput(self, text, "menus")
|
|
|
|
|
2011-06-11 03:07:29 -04:00
|
|
|
def addMessage(self, msg, me=True):
|
2021-03-23 17:36:43 -04:00
|
|
|
if type(msg) in [str, str]:
|
2011-06-11 03:07:29 -04:00
|
|
|
lexmsg = lexMessage(msg)
|
|
|
|
else:
|
|
|
|
lexmsg = msg
|
|
|
|
if me:
|
|
|
|
chum = self.mainwindow.profile()
|
|
|
|
else:
|
|
|
|
chum = self.chum
|
|
|
|
self.textArea.addMessage(lexmsg, chum)
|
|
|
|
|
2011-06-07 11:48:35 -04:00
|
|
|
def closeEvent(self, event):
|
2011-10-30 00:06:03 -04:00
|
|
|
self.parent().quirktester = None
|
2011-06-07 11:48:35 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterQuirkTypes(QtWidgets.QDialog):
|
2011-06-17 09:37:38 -04:00
|
|
|
def __init__(self, parent, quirk=None):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-06-17 09:37:38 -04:00
|
|
|
self.mainwindow = parent.mainwindow
|
|
|
|
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
|
|
|
|
self.setWindowTitle("Quirk Wizard")
|
|
|
|
self.resize(500,310)
|
|
|
|
|
|
|
|
self.quirk = quirk
|
2021-03-23 17:36:43 -04:00
|
|
|
self.pages = QtWidgets.QStackedWidget(self)
|
2011-06-17 09:37:38 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.next = QtWidgets.QPushButton("Next", self)
|
2011-06-17 09:37:38 -04:00
|
|
|
self.next.setDefault(True)
|
2021-03-23 17:58:58 -04:00
|
|
|
self.next.clicked.connect(self.nextPage)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.back = QtWidgets.QPushButton("Back", self)
|
2011-06-17 09:37:38 -04:00
|
|
|
self.back.setEnabled(False)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.back.clicked.connect(self.backPage)
|
|
|
|
self.cancel = QtWidgets.QPushButton("Cancel", self)
|
|
|
|
self.cancel.clicked.connect(self.reject)
|
|
|
|
layout_2 = QtWidgets.QHBoxLayout()
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_2.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight)
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_2.addWidget(self.back)
|
2021-03-23 17:58:58 -04:00
|
|
|
layout_2.addWidget(self.next)
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_2.addSpacing(5)
|
|
|
|
layout_2.addWidget(self.cancel)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
vr = QtWidgets.QFrame()
|
2022-06-26 22:18:37 -04:00
|
|
|
vr.setFrameShape(QtWidgets.QFrame.Shape.VLine)
|
|
|
|
vr.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
|
2021-03-23 17:36:43 -04:00
|
|
|
vr2 = QtWidgets.QFrame()
|
2022-06-26 22:18:37 -04:00
|
|
|
vr2.setFrameShape(QtWidgets.QFrame.Shape.VLine)
|
|
|
|
vr2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
|
2011-06-17 09:37:38 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.funclist = QtWidgets.QListWidget(self)
|
2011-06-17 09:37:38 -04:00
|
|
|
self.funclist.setStyleSheet("color: #000000; background-color: #FFFFFF;")
|
2021-03-23 17:36:43 -04:00
|
|
|
self.funclist2 = QtWidgets.QListWidget(self)
|
2011-06-17 09:37:38 -04:00
|
|
|
self.funclist2.setStyleSheet("color: #000000; background-color: #FFFFFF;")
|
|
|
|
|
|
|
|
from parsetools import quirkloader
|
2021-03-23 17:36:43 -04:00
|
|
|
funcs = [q+"()" for q in list(quirkloader.quirks.keys())]
|
2011-06-17 09:37:38 -04:00
|
|
|
funcs.sort()
|
|
|
|
self.funclist.addItems(funcs)
|
|
|
|
self.funclist2.addItems(funcs)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.reloadQuirkFuncButton = QtWidgets.QPushButton("RELOAD FUNCTIONS", self)
|
|
|
|
self.reloadQuirkFuncButton.clicked.connect(self.reloadQuirkFuncSlot)
|
|
|
|
self.reloadQuirkFuncButton2 = QtWidgets.QPushButton("RELOAD FUNCTIONS", self)
|
|
|
|
self.reloadQuirkFuncButton2.clicked.connect(self.reloadQuirkFuncSlot)
|
2011-06-17 09:37:38 -04:00
|
|
|
|
|
|
|
self.funclist.setMaximumWidth(160)
|
|
|
|
self.funclist.resize(160,50)
|
|
|
|
self.funclist2.setMaximumWidth(160)
|
|
|
|
self.funclist2.resize(160,50)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_f = QtWidgets.QVBoxLayout()
|
|
|
|
layout_f.addWidget(QtWidgets.QLabel("Available Regexp\nFunctions"))
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_f.addWidget(self.funclist)
|
|
|
|
layout_f.addWidget(self.reloadQuirkFuncButton)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_g = QtWidgets.QVBoxLayout()
|
|
|
|
layout_g.addWidget(QtWidgets.QLabel("Available Regexp\nFunctions"))
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_g.addWidget(self.funclist2)
|
|
|
|
layout_g.addWidget(self.reloadQuirkFuncButton2)
|
|
|
|
|
|
|
|
# Pages
|
|
|
|
# Type select
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
2011-06-17 09:37:38 -04:00
|
|
|
self.pages.addWidget(widget)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_select = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_select.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2011-06-17 09:37:38 -04:00
|
|
|
self.radios = []
|
2021-03-23 17:36:43 -04:00
|
|
|
self.radios.append(QtWidgets.QRadioButton("Prefix", self))
|
|
|
|
self.radios.append(QtWidgets.QRadioButton("Suffix", self))
|
|
|
|
self.radios.append(QtWidgets.QRadioButton("Simple Replace", self))
|
|
|
|
self.radios.append(QtWidgets.QRadioButton("Regexp Replace", self))
|
|
|
|
self.radios.append(QtWidgets.QRadioButton("Random Replace", self))
|
|
|
|
self.radios.append(QtWidgets.QRadioButton("Mispeller", self))
|
|
|
|
|
|
|
|
layout_select.addWidget(QtWidgets.QLabel("Select Quirk Type:"))
|
2011-06-17 09:37:38 -04:00
|
|
|
for r in self.radios:
|
|
|
|
layout_select.addWidget(r)
|
|
|
|
|
|
|
|
# Prefix
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
2011-06-17 09:37:38 -04:00
|
|
|
self.pages.addWidget(widget)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_prefix = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_prefix.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_prefix.addWidget(QtWidgets.QLabel("Prefix"))
|
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
|
|
|
layout_3.addWidget(QtWidgets.QLabel("Value:"))
|
|
|
|
layout_3.addWidget(QtWidgets.QLineEdit())
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_prefix.addLayout(layout_3)
|
|
|
|
|
|
|
|
# Suffix
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
2011-06-17 09:37:38 -04:00
|
|
|
self.pages.addWidget(widget)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_suffix = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_suffix.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_suffix.addWidget(QtWidgets.QLabel("Suffix"))
|
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
|
|
|
layout_3.addWidget(QtWidgets.QLabel("Value:"))
|
|
|
|
layout_3.addWidget(QtWidgets.QLineEdit())
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_suffix.addLayout(layout_3)
|
|
|
|
|
|
|
|
# Simple Replace
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
2011-06-17 09:37:38 -04:00
|
|
|
self.pages.addWidget(widget)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_replace = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_replace.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_replace.addWidget(QtWidgets.QLabel("Simple Replace"))
|
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
|
|
|
layout_3.addWidget(QtWidgets.QLabel("Replace:"))
|
|
|
|
layout_3.addWidget(QtWidgets.QLineEdit())
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_replace.addLayout(layout_3)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
|
|
|
layout_3.addWidget(QtWidgets.QLabel("With:"))
|
|
|
|
layout_3.addWidget(QtWidgets.QLineEdit())
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_replace.addLayout(layout_3)
|
2022-06-23 13:14:28 -04:00
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
|
|
|
excludeCheckbox = QtWidgets.QCheckBox("Exclude links and smilies")
|
|
|
|
excludeCheckbox.setToolTip("Splits input to exclude smilies, weblinks, @handles, and #memos."
|
|
|
|
+ "\nThe replace is applied on every substring individually.")
|
|
|
|
layout_3.addWidget(excludeCheckbox)
|
|
|
|
layout_replace.addLayout(layout_3)
|
2011-06-17 09:37:38 -04:00
|
|
|
|
|
|
|
# Regexp Replace
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
2011-06-17 09:37:38 -04:00
|
|
|
self.pages.addWidget(widget)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_all = QtWidgets.QHBoxLayout(widget)
|
|
|
|
layout_regexp = QtWidgets.QVBoxLayout()
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_regexp.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_regexp.addWidget(QtWidgets.QLabel("Regexp Replace"))
|
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
|
|
|
layout_3.addWidget(QtWidgets.QLabel("Regexp:"))
|
|
|
|
layout_3.addWidget(QtWidgets.QLineEdit())
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_regexp.addLayout(layout_3)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
|
|
|
layout_3.addWidget(QtWidgets.QLabel("Replace With:"))
|
|
|
|
layout_3.addWidget(QtWidgets.QLineEdit())
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_regexp.addLayout(layout_3)
|
2022-06-21 15:50:48 -04:00
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
2022-06-23 13:14:28 -04:00
|
|
|
excludeCheckbox = QtWidgets.QCheckBox("Exclude links and smilies")
|
|
|
|
excludeCheckbox.setToolTip("Splits input to exclude smilies, weblinks, @handles, and #memos."
|
|
|
|
+ "\nSince the replace is applied on every substring individually,"
|
|
|
|
+ "\ncertain patterns or functions like gradients may not work correctly.")
|
2022-06-21 15:50:48 -04:00
|
|
|
layout_3.addWidget(excludeCheckbox)
|
|
|
|
layout_regexp.addLayout(layout_3)
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_all.addLayout(layout_f)
|
|
|
|
layout_all.addWidget(vr)
|
|
|
|
layout_all.addLayout(layout_regexp)
|
|
|
|
|
|
|
|
# Random Replace
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
2011-06-17 09:37:38 -04:00
|
|
|
self.pages.addWidget(widget)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_all = QtWidgets.QHBoxLayout(widget)
|
|
|
|
layout_random = QtWidgets.QVBoxLayout()
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_random.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_random.addWidget(QtWidgets.QLabel("Random Replace"))
|
|
|
|
layout_5 = QtWidgets.QHBoxLayout()
|
|
|
|
regexpl = QtWidgets.QLabel("Regexp:", self)
|
|
|
|
self.regexp = QtWidgets.QLineEdit("", self)
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_5.addWidget(regexpl)
|
|
|
|
layout_5.addWidget(self.regexp)
|
2021-03-23 17:36:43 -04:00
|
|
|
replacewithl = QtWidgets.QLabel("Replace With:", self)
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_all.addLayout(layout_g)
|
|
|
|
layout_all.addWidget(vr2)
|
|
|
|
layout_all.addLayout(layout_random)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_6 = QtWidgets.QVBoxLayout()
|
|
|
|
layout_7 = QtWidgets.QHBoxLayout()
|
|
|
|
self.replacelist = QtWidgets.QListWidget(self)
|
|
|
|
self.replaceinput = QtWidgets.QLineEdit(self)
|
|
|
|
addbutton = QtWidgets.QPushButton("ADD", self)
|
|
|
|
addbutton.clicked.connect(self.addRandomString)
|
|
|
|
removebutton = QtWidgets.QPushButton("REMOVE", self)
|
|
|
|
removebutton.clicked.connect(self.removeRandomString)
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_7.addWidget(addbutton)
|
|
|
|
layout_7.addWidget(removebutton)
|
|
|
|
layout_6.addLayout(layout_5)
|
|
|
|
layout_6.addWidget(replacewithl)
|
|
|
|
layout_6.addWidget(self.replacelist)
|
|
|
|
layout_6.addWidget(self.replaceinput)
|
|
|
|
layout_6.addLayout(layout_7)
|
|
|
|
layout_random.addLayout(layout_6)
|
2022-06-23 13:14:28 -04:00
|
|
|
layout_9 = QtWidgets.QHBoxLayout()
|
|
|
|
excludeCheckbox = QtWidgets.QCheckBox("Exclude links and smilies")
|
|
|
|
excludeCheckbox.setToolTip("Splits input to exclude smilies, weblinks, @handles, and #memos."
|
|
|
|
+ "\nSince the replace is applied on every substring individually,"
|
|
|
|
+ "\ncertain patterns or functions like gradients may not work correctly.")
|
|
|
|
layout_9.addWidget(excludeCheckbox)
|
|
|
|
layout_random.addLayout(layout_9)
|
2011-06-17 09:37:38 -04:00
|
|
|
|
|
|
|
# Misspeller
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
2011-06-17 09:37:38 -04:00
|
|
|
self.pages.addWidget(widget)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_mispeller = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_mispeller.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_mispeller.addWidget(QtWidgets.QLabel("Mispeller"))
|
|
|
|
layout_1 = QtWidgets.QHBoxLayout()
|
|
|
|
zero = QtWidgets.QLabel("1%", self)
|
|
|
|
hund = QtWidgets.QLabel("100%", self)
|
|
|
|
self.current = QtWidgets.QLabel("50%", self)
|
2022-06-26 22:18:37 -04:00
|
|
|
self.current.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
|
|
|
|
self.slider = QtWidgets.QSlider(QtCore.Qt.Orientation.Horizontal, self)
|
2011-06-17 09:37:38 -04:00
|
|
|
self.slider.setMinimum(1)
|
|
|
|
self.slider.setMaximum(100)
|
|
|
|
self.slider.setValue(50)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.slider.valueChanged[int].connect(self.printValue)
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_1.addWidget(zero)
|
|
|
|
layout_1.addWidget(self.slider)
|
|
|
|
layout_1.addWidget(hund)
|
|
|
|
layout_mispeller.addLayout(layout_1)
|
|
|
|
layout_mispeller.addWidget(self.current)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_0.addWidget(self.pages)
|
|
|
|
layout_0.addLayout(layout_2)
|
|
|
|
|
2022-06-23 13:14:28 -04:00
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
|
|
|
excludeCheckbox = QtWidgets.QCheckBox("Exclude links and smilies")
|
|
|
|
excludeCheckbox.setToolTip("Splits input to exclude smilies, weblinks, @handles, and #memos."
|
|
|
|
+ "\nThe replace is applied on every substring individually.")
|
|
|
|
layout_3.addWidget(excludeCheckbox)
|
|
|
|
layout_mispeller.addLayout(layout_3)
|
|
|
|
|
2011-06-17 09:37:38 -04:00
|
|
|
if quirk:
|
|
|
|
types = ["prefix","suffix","replace","regexp","random","spelling"]
|
|
|
|
for (i,r) in enumerate(self.radios):
|
|
|
|
if i == types.index(quirk.quirk.type):
|
|
|
|
r.setChecked(True)
|
|
|
|
self.changePage(types.index(quirk.quirk.type)+1)
|
|
|
|
page = self.pages.currentWidget().layout()
|
|
|
|
q = quirk.quirk.quirk
|
|
|
|
if q["type"] in ("prefix","suffix"):
|
|
|
|
page.itemAt(1).layout().itemAt(1).widget().setText(q["value"])
|
|
|
|
elif q["type"] == "replace":
|
|
|
|
page.itemAt(1).layout().itemAt(1).widget().setText(q["from"])
|
|
|
|
page.itemAt(2).layout().itemAt(1).widget().setText(q["to"])
|
2022-06-23 13:14:28 -04:00
|
|
|
try:
|
2022-06-26 22:18:37 -04:00
|
|
|
page.itemAt(3).layout().itemAt(0).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
2022-06-23 13:14:28 -04:00
|
|
|
except (KeyError, ValueError) as e:
|
|
|
|
print("KeyError: %s" % str(e))
|
2011-06-17 09:37:38 -04:00
|
|
|
elif q["type"] == "regexp":
|
|
|
|
page.itemAt(2).layout().itemAt(1).layout().itemAt(1).widget().setText(q["from"])
|
|
|
|
page.itemAt(2).layout().itemAt(2).layout().itemAt(1).widget().setText(q["to"])
|
2022-06-21 15:50:48 -04:00
|
|
|
try:
|
2022-06-26 22:18:37 -04:00
|
|
|
page.itemAt(2).layout().itemAt(3).layout().itemAt(0).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
2022-06-23 13:14:28 -04:00
|
|
|
except (KeyError, ValueError) as e:
|
2022-06-21 15:50:48 -04:00
|
|
|
print("KeyError: %s" % str(e))
|
2011-06-17 09:37:38 -04:00
|
|
|
elif q["type"] == "random":
|
|
|
|
self.regexp.setText(q["from"])
|
|
|
|
for v in q["randomlist"]:
|
2021-03-23 17:36:43 -04:00
|
|
|
item = QtWidgets.QListWidgetItem(v, self.replacelist)
|
2022-06-23 13:14:28 -04:00
|
|
|
try:
|
2022-06-26 22:18:37 -04:00
|
|
|
page.itemAt(2).layout().itemAt(2).layout().itemAt(0).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
2022-06-23 13:14:28 -04:00
|
|
|
except (KeyError, ValueError) as e:
|
|
|
|
print("KeyError: %s" % str(e))
|
2011-06-17 09:37:38 -04:00
|
|
|
elif q["type"] == "spelling":
|
|
|
|
self.slider.setValue(q["percentage"])
|
2022-06-23 13:14:28 -04:00
|
|
|
try:
|
2022-06-26 22:18:37 -04:00
|
|
|
page.itemAt(3).layout().itemAt(0).widget().setCheckState(QtCore.Qt.CheckState(int(q["checkstate"])))
|
2022-06-23 13:14:28 -04:00
|
|
|
except (KeyError, ValueError) as e:
|
|
|
|
print("KeyError: %s" % str(e))
|
2011-06-17 09:37:38 -04:00
|
|
|
|
|
|
|
self.setLayout(layout_0)
|
|
|
|
|
|
|
|
def closeEvent(self, event):
|
|
|
|
self.parent().quirkadd = None
|
|
|
|
|
|
|
|
def changePage(self, page):
|
|
|
|
c = self.pages.count()
|
|
|
|
if page >= c or page < 0: return
|
|
|
|
self.back.setEnabled(page > 0)
|
|
|
|
if page >= 1 and page <= 6:
|
|
|
|
self.next.setText("Finish")
|
|
|
|
else:
|
|
|
|
self.next.setText("Next")
|
|
|
|
self.pages.setCurrentIndex(page)
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def nextPage(self):
|
|
|
|
if self.next.text() == "Finish":
|
|
|
|
self.accept()
|
|
|
|
return
|
|
|
|
cur = self.pages.currentIndex()
|
|
|
|
if cur == 0:
|
|
|
|
for (i,r) in enumerate(self.radios):
|
|
|
|
if r.isChecked():
|
|
|
|
self.changePage(i+1)
|
|
|
|
else:
|
|
|
|
self.changePage(cur+1)
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def backPage(self):
|
|
|
|
cur = self.pages.currentIndex()
|
|
|
|
if cur >= 1 and cur <= 6:
|
|
|
|
self.changePage(0)
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot(int)
|
|
|
|
def printValue(self, value):
|
|
|
|
self.current.setText(str(value)+"%")
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def addRandomString(self):
|
2021-03-23 17:36:43 -04:00
|
|
|
text = str(self.replaceinput.text())
|
|
|
|
item = QtWidgets.QListWidgetItem(text, self.replacelist)
|
2011-06-17 09:37:38 -04:00
|
|
|
self.replaceinput.setText("")
|
|
|
|
self.replaceinput.setFocus()
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def removeRandomString(self):
|
|
|
|
if not self.replacelist.currentItem():
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
self.replacelist.takeItem(self.replacelist.currentRow())
|
|
|
|
self.replaceinput.setFocus()
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def reloadQuirkFuncSlot(self):
|
|
|
|
from parsetools import reloadQuirkFunctions, quirkloader
|
|
|
|
reloadQuirkFunctions()
|
2021-03-23 17:36:43 -04:00
|
|
|
funcs = [q+"()" for q in list(quirkloader.quirks.keys())]
|
2011-06-17 09:37:38 -04:00
|
|
|
funcs.sort()
|
|
|
|
self.funclist.clear()
|
|
|
|
self.funclist.addItems(funcs)
|
|
|
|
self.funclist2.clear()
|
|
|
|
self.funclist2.addItems(funcs)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterChooseQuirks(QtWidgets.QDialog):
|
2011-02-02 19:32:35 -05:00
|
|
|
def __init__(self, config, theme, parent):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.setModal(False)
|
|
|
|
self.config = config
|
|
|
|
self.theme = theme
|
|
|
|
self.mainwindow = parent
|
|
|
|
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
|
|
|
self.setWindowTitle("Set Quirks")
|
|
|
|
|
|
|
|
self.quirkList = PesterQuirkList(self.mainwindow, self)
|
2011-03-12 02:44:59 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.addQuirkButton = QtWidgets.QPushButton("ADD QUIRK", self)
|
|
|
|
self.addQuirkButton.clicked.connect(self.addQuirkDialog)
|
2011-05-25 04:38:36 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.upShiftButton = QtWidgets.QPushButton("^", self)
|
|
|
|
self.downShiftButton = QtWidgets.QPushButton("v", self)
|
2011-05-25 04:38:36 -04:00
|
|
|
self.upShiftButton.setToolTip("Move quirk up one")
|
|
|
|
self.downShiftButton.setToolTip("Move quirk down one")
|
2021-03-23 17:36:43 -04:00
|
|
|
self.upShiftButton.clicked.connect(self.quirkList.upShiftQuirk)
|
|
|
|
self.downShiftButton.clicked.connect(self.quirkList.downShiftQuirk)
|
2011-05-25 04:38:36 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.newGroupButton = QtWidgets.QPushButton("*", self)
|
2011-05-25 04:38:36 -04:00
|
|
|
self.newGroupButton.setToolTip("New Quirk Group")
|
2021-03-23 17:36:43 -04:00
|
|
|
self.newGroupButton.clicked.connect(self.quirkList.addQuirkGroup)
|
2011-03-31 17:57:30 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_quirklist = QtWidgets.QHBoxLayout() #the nude layout quirklist
|
|
|
|
layout_shiftbuttons = QtWidgets.QVBoxLayout() #the shift button layout
|
2011-03-31 17:57:30 -04:00
|
|
|
layout_shiftbuttons.addWidget(self.upShiftButton)
|
2011-05-25 04:38:36 -04:00
|
|
|
layout_shiftbuttons.addWidget(self.newGroupButton)
|
2011-03-31 17:57:30 -04:00
|
|
|
layout_shiftbuttons.addWidget(self.downShiftButton)
|
|
|
|
layout_quirklist.addWidget(self.quirkList)
|
|
|
|
layout_quirklist.addLayout(layout_shiftbuttons)
|
2011-02-13 20:32:02 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_1 = QtWidgets.QHBoxLayout()
|
2011-06-17 09:37:38 -04:00
|
|
|
layout_1.addWidget(self.addQuirkButton)
|
2011-02-02 19:32:35 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.editSelectedButton = QtWidgets.QPushButton("EDIT", self)
|
|
|
|
self.editSelectedButton.clicked.connect(self.editSelected)
|
|
|
|
self.removeSelectedButton = QtWidgets.QPushButton("REMOVE", self)
|
|
|
|
self.removeSelectedButton.clicked.connect(self.quirkList.removeCurrent)
|
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
2011-02-23 06:06:00 -05:00
|
|
|
layout_3.addWidget(self.editSelectedButton)
|
|
|
|
layout_3.addWidget(self.removeSelectedButton)
|
2011-03-12 02:44:59 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok = QtWidgets.QPushButton("OK", self)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.ok.setDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok.clicked.connect(self.accept)
|
|
|
|
self.test = QtWidgets.QPushButton("TEST QUIRKS", self)
|
|
|
|
self.test.clicked.connect(self.testQuirks)
|
|
|
|
self.cancel = QtWidgets.QPushButton("CANCEL", self)
|
|
|
|
self.cancel.clicked.connect(self.reject)
|
|
|
|
layout_ok = QtWidgets.QHBoxLayout()
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_ok.addWidget(self.cancel)
|
2011-06-11 03:07:29 -04:00
|
|
|
layout_ok.addWidget(self.test)
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_ok.addWidget(self.ok)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-03-31 17:57:30 -04:00
|
|
|
layout_0.addLayout(layout_quirklist)
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_0.addLayout(layout_1)
|
2011-06-17 09:37:38 -04:00
|
|
|
#layout_0.addLayout(layout_2)
|
2011-02-23 06:06:00 -05:00
|
|
|
layout_0.addLayout(layout_3)
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_0.addLayout(layout_ok)
|
2011-06-11 03:07:29 -04:00
|
|
|
|
2011-06-17 09:37:38 -04:00
|
|
|
self.setLayout(layout_0)
|
2011-02-02 19:32:35 -05:00
|
|
|
|
|
|
|
def quirks(self):
|
2011-05-25 04:38:36 -04:00
|
|
|
u = []
|
|
|
|
for i in range(self.quirkList.topLevelItemCount()):
|
|
|
|
for j in range(self.quirkList.topLevelItem(i).childCount()):
|
|
|
|
u.append(self.quirkList.topLevelItem(i).child(j).quirk)
|
|
|
|
return u
|
|
|
|
#return [self.quirkList.item(i).quirk for i in range(self.quirkList.count())]
|
2011-06-11 03:07:29 -04:00
|
|
|
def testquirks(self):
|
|
|
|
u = []
|
|
|
|
for i in range(self.quirkList.topLevelItemCount()):
|
|
|
|
for j in range(self.quirkList.topLevelItem(i).childCount()):
|
|
|
|
item = self.quirkList.topLevelItem(i).child(j)
|
2022-06-26 22:18:37 -04:00
|
|
|
if (item.checkState(0) == QtCore.Qt.CheckState.Checked):
|
2011-06-11 03:07:29 -04:00
|
|
|
u.append(item.quirk)
|
|
|
|
return u
|
2011-02-23 06:06:00 -05:00
|
|
|
|
2011-06-07 11:48:35 -04:00
|
|
|
@QtCore.pyqtSlot()
|
2011-06-11 03:07:29 -04:00
|
|
|
def testQuirks(self):
|
|
|
|
if not hasattr(self, 'quirktester'):
|
|
|
|
self.quirktester = None
|
|
|
|
if self.quirktester:
|
2011-06-07 11:48:35 -04:00
|
|
|
return
|
2011-06-11 03:07:29 -04:00
|
|
|
self.quirktester = QuirkTesterWindow(self)
|
|
|
|
self.quirktester.show()
|
2011-06-07 11:48:35 -04:00
|
|
|
|
2011-02-23 06:06:00 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def editSelected(self):
|
|
|
|
q = self.quirkList.currentQuirk()
|
2011-05-25 04:38:36 -04:00
|
|
|
if not q: return
|
2022-04-10 23:57:13 -04:00
|
|
|
#quirk = q.quirk
|
2011-06-17 09:37:38 -04:00
|
|
|
self.addQuirkDialog(q)
|
2011-02-23 06:06:00 -05:00
|
|
|
|
2011-02-02 19:32:35 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-06-17 09:37:38 -04:00
|
|
|
def addQuirkDialog(self, quirk=None):
|
|
|
|
if not hasattr(self, 'quirkadd'):
|
|
|
|
self.quirkadd = None
|
|
|
|
if self.quirkadd:
|
2011-02-13 05:30:08 -05:00
|
|
|
return
|
2011-06-17 09:37:38 -04:00
|
|
|
self.quirkadd = PesterQuirkTypes(self, quirk)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.quirkadd.accepted.connect(self.addQuirk)
|
|
|
|
self.quirkadd.rejected.connect(self.closeQuirk)
|
2011-06-17 09:37:38 -04:00
|
|
|
self.quirkadd.show()
|
2011-02-02 19:32:35 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-06-17 09:37:38 -04:00
|
|
|
def addQuirk(self):
|
|
|
|
types = ["prefix","suffix","replace","regexp","random","spelling"]
|
|
|
|
vdict = {}
|
|
|
|
vdict["type"] = types[self.quirkadd.pages.currentIndex()-1]
|
|
|
|
page = self.quirkadd.pages.currentWidget().layout()
|
|
|
|
if vdict["type"] in ("prefix","suffix"):
|
2021-03-23 17:36:43 -04:00
|
|
|
vdict["value"] = str(page.itemAt(1).layout().itemAt(1).widget().text())
|
2011-06-17 09:37:38 -04:00
|
|
|
elif vdict["type"] == "replace":
|
2021-03-23 17:36:43 -04:00
|
|
|
vdict["from"] = str(page.itemAt(1).layout().itemAt(1).widget().text())
|
|
|
|
vdict["to"] = str(page.itemAt(2).layout().itemAt(1).widget().text())
|
2022-06-26 22:18:37 -04:00
|
|
|
vdict["checkstate"] = str(page.itemAt(3).layout().itemAt(0).widget().checkState().value)
|
2011-06-17 09:37:38 -04:00
|
|
|
elif vdict["type"] == "regexp":
|
2021-03-23 17:36:43 -04:00
|
|
|
vdict["from"] = str(page.itemAt(2).layout().itemAt(1).layout().itemAt(1).widget().text())
|
|
|
|
vdict["to"] = str(page.itemAt(2).layout().itemAt(2).layout().itemAt(1).widget().text())
|
2022-06-26 22:18:37 -04:00
|
|
|
vdict["checkstate"] = str(page.itemAt(2).layout().itemAt(3).layout().itemAt(0).widget().checkState().value)
|
2011-06-17 09:37:38 -04:00
|
|
|
elif vdict["type"] == "random":
|
2021-03-23 17:36:43 -04:00
|
|
|
vdict["from"] = str(self.quirkadd.regexp.text())
|
2022-06-26 22:18:37 -04:00
|
|
|
vdict["checkstate"] = str(page.itemAt(2).layout().itemAt(2).layout().itemAt(0).widget().checkState().value)
|
2021-03-23 17:36:43 -04:00
|
|
|
randomlist = [str(self.quirkadd.replacelist.item(i).text())
|
2011-06-17 09:37:38 -04:00
|
|
|
for i in range(0,self.quirkadd.replacelist.count())]
|
|
|
|
vdict["randomlist"] = randomlist
|
|
|
|
elif vdict["type"] == "spelling":
|
|
|
|
vdict["percentage"] = self.quirkadd.slider.value()
|
2022-06-26 22:18:37 -04:00
|
|
|
vdict["checkstate"] = str(page.itemAt(3).layout().itemAt(0).widget().checkState().value)
|
2011-06-17 09:37:38 -04:00
|
|
|
if vdict["type"] in ("regexp", "random"):
|
|
|
|
try:
|
|
|
|
re.compile(vdict["from"])
|
2021-03-23 17:36:43 -04:00
|
|
|
except re.error as e:
|
|
|
|
quirkWarning = QtWidgets.QMessageBox(self)
|
2011-06-17 09:37:38 -04:00
|
|
|
quirkWarning.setText("Not a valid regular expression!")
|
|
|
|
quirkWarning.setInformativeText("H3R3S WHY DUMP4SS: %s" % (e))
|
2022-06-26 22:18:37 -04:00
|
|
|
quirkWarning.exec()
|
2011-06-17 09:37:38 -04:00
|
|
|
self.quirkadd = None
|
|
|
|
return
|
2011-03-12 02:44:59 -05:00
|
|
|
|
2011-06-17 09:37:38 -04:00
|
|
|
quirk = pesterQuirk(vdict)
|
|
|
|
if self.quirkadd.quirk is None:
|
|
|
|
item = PesterQuirkItem(quirk)
|
2011-02-23 06:06:00 -05:00
|
|
|
self.quirkList.addItem(item)
|
|
|
|
else:
|
2011-06-17 09:37:38 -04:00
|
|
|
self.quirkadd.quirk.update(quirk)
|
|
|
|
self.quirkadd = None
|
2011-02-13 04:27:12 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2011-06-17 09:37:38 -04:00
|
|
|
def closeQuirk(self):
|
|
|
|
self.quirkadd = None
|
2011-02-02 19:32:35 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterChooseTheme(QtWidgets.QDialog):
|
2011-02-02 19:32:35 -05:00
|
|
|
def __init__(self, config, theme, parent):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.config = config
|
|
|
|
self.theme = theme
|
|
|
|
self.parent = parent
|
|
|
|
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
|
|
|
self.setWindowTitle("Pick a theme")
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
instructions = QtWidgets.QLabel("Pick a theme:")
|
2011-02-02 19:32:35 -05:00
|
|
|
|
|
|
|
avail_themes = config.availableThemes()
|
2021-03-23 17:36:43 -04:00
|
|
|
self.themeBox = QtWidgets.QComboBox(self)
|
2011-02-02 19:32:35 -05:00
|
|
|
for (i, t) in enumerate(avail_themes):
|
|
|
|
self.themeBox.addItem(t)
|
|
|
|
if t == theme.name:
|
|
|
|
self.themeBox.setCurrentIndex(i)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok = QtWidgets.QPushButton("OK", self)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.ok.setDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok.clicked.connect(self.accept)
|
|
|
|
self.cancel = QtWidgets.QPushButton("CANCEL", self)
|
|
|
|
self.cancel.clicked.connect(self.reject)
|
|
|
|
layout_ok = QtWidgets.QHBoxLayout()
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_ok.addWidget(self.cancel)
|
|
|
|
layout_ok.addWidget(self.ok)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_0.addWidget(instructions)
|
|
|
|
layout_0.addWidget(self.themeBox)
|
|
|
|
layout_0.addLayout(layout_ok)
|
|
|
|
|
|
|
|
self.setLayout(layout_0)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.accepted.connect(parent.themeSelected)
|
|
|
|
self.rejected.connect(parent.closeTheme)
|
2011-02-02 19:32:35 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterChooseProfile(QtWidgets.QDialog):
|
2011-02-02 19:32:35 -05:00
|
|
|
def __init__(self, userprofile, config, theme, parent, collision=None):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.userprofile = userprofile
|
|
|
|
self.theme = theme
|
|
|
|
self.config = config
|
|
|
|
self.parent = parent
|
|
|
|
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.currentHandle = QtWidgets.QLabel("CHANGING FROM %s" % userprofile.chat.handle)
|
|
|
|
self.chumHandle = QtWidgets.QLineEdit(self)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.chumHandle.setMinimumWidth(200)
|
2017-01-25 10:50:09 -05:00
|
|
|
self.chumHandle.setObjectName("setprofilehandle")
|
2021-03-23 17:36:43 -04:00
|
|
|
self.chumHandleLabel = QtWidgets.QLabel(self.theme["main/mychumhandle/label/text"], self)
|
|
|
|
self.chumColorButton = QtWidgets.QPushButton(self)
|
2017-01-25 10:50:09 -05:00
|
|
|
self.chumColorButton.setObjectName("setprofilecolor")
|
2011-02-02 19:32:35 -05:00
|
|
|
self.chumColorButton.resize(50, 20)
|
|
|
|
self.chumColorButton.setStyleSheet("background: %s" % (userprofile.chat.colorhtml()))
|
|
|
|
self.chumcolor = userprofile.chat.color
|
2021-03-23 17:36:43 -04:00
|
|
|
self.chumColorButton.clicked.connect(self.openColorDialog)
|
|
|
|
layout_1 = QtWidgets.QHBoxLayout()
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_1.addWidget(self.chumHandleLabel)
|
|
|
|
layout_1.addWidget(self.chumHandle)
|
|
|
|
layout_1.addWidget(self.chumColorButton)
|
|
|
|
|
|
|
|
# available profiles?
|
|
|
|
avail_profiles = self.config.availableProfiles()
|
|
|
|
if avail_profiles:
|
2021-03-23 17:36:43 -04:00
|
|
|
self.profileBox = QtWidgets.QComboBox(self)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.profileBox.addItem("Choose a profile...")
|
|
|
|
for p in avail_profiles:
|
2022-03-17 21:05:14 -04:00
|
|
|
#PchumLog.debug("Adding profile: %s" % p.chat.handle)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.profileBox.addItem(p.chat.handle)
|
|
|
|
else:
|
|
|
|
self.profileBox = None
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.defaultcheck = QtWidgets.QCheckBox(self)
|
|
|
|
self.defaultlabel = QtWidgets.QLabel("Set This Profile As Default", self)
|
|
|
|
layout_2 = QtWidgets.QHBoxLayout()
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_2.addWidget(self.defaultlabel)
|
|
|
|
layout_2.addWidget(self.defaultcheck)
|
2011-03-12 02:44:59 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok = QtWidgets.QPushButton("OK", self)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.ok.setDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok.clicked.connect(self.validateProfile)
|
|
|
|
self.cancel = QtWidgets.QPushButton("CANCEL", self)
|
|
|
|
self.cancel.clicked.connect(self.reject)
|
2011-05-13 10:37:36 -04:00
|
|
|
if not collision and avail_profiles:
|
2021-03-23 17:36:43 -04:00
|
|
|
self.delete = QtWidgets.QPushButton("DELETE", self)
|
|
|
|
self.delete.clicked.connect(self.deleteProfile)
|
|
|
|
layout_ok = QtWidgets.QHBoxLayout()
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_ok.addWidget(self.cancel)
|
|
|
|
layout_ok.addWidget(self.ok)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-02-02 19:32:35 -05:00
|
|
|
if collision:
|
2021-03-23 17:36:43 -04:00
|
|
|
collision_warning = QtWidgets.QLabel("%s is taken already! Pick a new profile." % (collision))
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_0.addWidget(collision_warning)
|
2011-02-06 19:50:21 -05:00
|
|
|
else:
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_0.addWidget(self.currentHandle, alignment=QtCore.Qt.AlignmentFlag.AlignHCenter)
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_0.addLayout(layout_1)
|
|
|
|
if avail_profiles:
|
2021-03-23 17:36:43 -04:00
|
|
|
profileLabel = QtWidgets.QLabel("Or choose an existing profile:", self)
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_0.addWidget(profileLabel)
|
|
|
|
layout_0.addWidget(self.profileBox)
|
|
|
|
layout_0.addLayout(layout_ok)
|
2011-05-13 10:37:36 -04:00
|
|
|
if not collision and avail_profiles:
|
2011-05-03 21:04:08 -04:00
|
|
|
layout_0.addWidget(self.delete)
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_0.addLayout(layout_2)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.errorMsg = QtWidgets.QLabel(self)
|
2017-01-25 10:50:09 -05:00
|
|
|
self.errorMsg.setObjectName("errormsg")
|
2011-02-02 19:32:35 -05:00
|
|
|
self.errorMsg.setStyleSheet("color:red;")
|
|
|
|
layout_0.addWidget(self.errorMsg)
|
|
|
|
self.setLayout(layout_0)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.accepted.connect(parent.profileSelected)
|
|
|
|
self.rejected.connect(parent.closeProfile)
|
2011-02-02 19:32:35 -05:00
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def openColorDialog(self):
|
2021-03-23 17:36:43 -04:00
|
|
|
self.colorDialog = QtWidgets.QColorDialog(self)
|
2011-02-02 19:32:35 -05:00
|
|
|
color = self.colorDialog.getColor(initial=self.userprofile.chat.color)
|
|
|
|
self.chumColorButton.setStyleSheet("background: %s" % color.name())
|
|
|
|
self.chumcolor = color
|
|
|
|
self.colorDialog = None
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def validateProfile(self):
|
|
|
|
if not self.profileBox or self.profileBox.currentIndex() == 0:
|
2021-03-23 17:36:43 -04:00
|
|
|
handle = str(self.chumHandle.text())
|
2011-02-02 19:32:35 -05:00
|
|
|
if not PesterProfile.checkLength(handle):
|
|
|
|
self.errorMsg.setText("PROFILE HANDLE IS TOO LONG")
|
|
|
|
return
|
2011-08-23 06:23:59 -04:00
|
|
|
if not PesterProfile.checkValid(handle)[0]:
|
|
|
|
self.errorMsg.setText("NOT A VALID CHUMTAG. REASON:\n%s" % (PesterProfile.checkValid(handle)[1]))
|
2011-02-02 19:32:35 -05:00
|
|
|
return
|
|
|
|
self.accept()
|
|
|
|
|
2011-05-03 21:04:08 -04:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def deleteProfile(self):
|
|
|
|
if self.profileBox and self.profileBox.currentIndex() > 0:
|
2021-03-23 17:36:43 -04:00
|
|
|
handle = str(self.profileBox.currentText())
|
2011-05-03 21:04:08 -04:00
|
|
|
if handle == self.parent.profile().handle:
|
2021-03-23 17:36:43 -04:00
|
|
|
problem = QtWidgets.QMessageBox()
|
2017-01-25 10:50:09 -05:00
|
|
|
# karxi Will probably change this to its own name later.
|
|
|
|
problem.setObjectName("errmsg")
|
2011-05-03 21:04:08 -04:00
|
|
|
problem.setStyleSheet(self.theme["main/defaultwindow/style"])
|
|
|
|
problem.setWindowTitle("Problem!")
|
|
|
|
problem.setInformativeText("You can't delete the profile you're currently using!")
|
2022-06-28 19:50:08 -04:00
|
|
|
problem.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
|
2022-06-26 22:18:37 -04:00
|
|
|
problem.exec()
|
2011-05-03 21:04:08 -04:00
|
|
|
return
|
2017-01-25 10:50:09 -05:00
|
|
|
# TODO: Make this select 'no' as the default, as usual.
|
2021-03-23 17:36:43 -04:00
|
|
|
msgbox = QtWidgets.QMessageBox()
|
2011-05-03 21:04:08 -04:00
|
|
|
msgbox.setStyleSheet(self.theme["main/defaultwindow/style"])
|
|
|
|
msgbox.setWindowTitle("WARNING!")
|
|
|
|
msgbox.setInformativeText("Are you sure you want to delete the profile: %s" % (handle))
|
2022-06-28 19:50:08 -04:00
|
|
|
msgbox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok | QtWidgets.QMessageBox.StandardButton.Cancel)
|
2022-06-26 22:18:37 -04:00
|
|
|
ret = msgbox.exec()
|
2022-06-28 19:50:08 -04:00
|
|
|
if ret == QtWidgets.QMessageBox.StandardButton.Ok:
|
2011-05-03 21:04:08 -04:00
|
|
|
try:
|
2011-11-30 18:45:50 -05:00
|
|
|
remove(_datadir+"profiles/%s.js" % (handle))
|
2011-05-03 21:04:08 -04:00
|
|
|
except OSError:
|
2021-03-23 17:36:43 -04:00
|
|
|
problem = QtWidgets.QMessageBox()
|
2017-01-25 10:50:09 -05:00
|
|
|
problem.setObjectName("errmsg")
|
2011-05-03 21:04:08 -04:00
|
|
|
problem.setStyleSheet(self.theme["main/defaultwindow/style"])
|
|
|
|
problem.setWindowTitle("Problem!")
|
|
|
|
problem.setInformativeText("There was a problem deleting the profile: %s" % (handle))
|
2022-06-28 19:50:08 -04:00
|
|
|
problem.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
|
2022-06-26 22:18:37 -04:00
|
|
|
problem.exec()
|
2011-05-03 21:04:08 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterMentions(QtWidgets.QDialog):
|
2011-08-23 03:51:50 -04:00
|
|
|
def __init__(self, window, theme, parent):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-08-23 03:51:50 -04:00
|
|
|
self.setWindowTitle("Mentions")
|
|
|
|
self.setModal(True)
|
|
|
|
self.mainwindow = window
|
|
|
|
self.theme = theme
|
|
|
|
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.mentionlist = QtWidgets.QListWidget(self)
|
2011-08-23 03:51:50 -04:00
|
|
|
self.mentionlist.addItems(self.mainwindow.userprofile.getMentions())
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.addBtn = QtWidgets.QPushButton("ADD MENTION", self)
|
|
|
|
self.addBtn.clicked.connect(self.addMention)
|
|
|
|
|
|
|
|
self.editBtn = QtWidgets.QPushButton("EDIT", self)
|
|
|
|
self.editBtn.clicked.connect(self.editSelected)
|
|
|
|
self.rmBtn = QtWidgets.QPushButton("REMOVE", self)
|
|
|
|
self.rmBtn.clicked.connect(self.removeCurrent)
|
|
|
|
layout_1 = QtWidgets.QHBoxLayout()
|
2011-08-23 03:51:50 -04:00
|
|
|
layout_1.addWidget(self.editBtn)
|
|
|
|
layout_1.addWidget(self.rmBtn)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok = QtWidgets.QPushButton("OK", self)
|
2011-08-23 03:51:50 -04:00
|
|
|
self.ok.setDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok.clicked.connect(self.accept)
|
|
|
|
self.cancel = QtWidgets.QPushButton("CANCEL", self)
|
|
|
|
self.cancel.clicked.connect(self.reject)
|
|
|
|
layout_2 = QtWidgets.QHBoxLayout()
|
2011-08-23 03:51:50 -04:00
|
|
|
layout_2.addWidget(self.cancel)
|
|
|
|
layout_2.addWidget(self.ok)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-08-23 03:51:50 -04:00
|
|
|
layout_0.addWidget(self.mentionlist)
|
|
|
|
layout_0.addWidget(self.addBtn)
|
|
|
|
layout_0.addLayout(layout_1)
|
|
|
|
layout_0.addLayout(layout_2)
|
|
|
|
|
|
|
|
self.setLayout(layout_0)
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def editSelected(self):
|
|
|
|
m = self.mentionlist.currentItem()
|
|
|
|
if not m:
|
|
|
|
return
|
|
|
|
self.addMention(m)
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def addMention(self, mitem=None):
|
|
|
|
d = {"label": "Mention:", "inputname": "value" }
|
|
|
|
if mitem is not None:
|
|
|
|
d["value"] = str(mitem.text())
|
|
|
|
pdict = MultiTextDialog("ENTER MENTION", self, d).getText()
|
|
|
|
if pdict is None:
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
re.compile(pdict["value"])
|
2021-03-23 17:36:43 -04:00
|
|
|
except re.error as e:
|
|
|
|
quirkWarning = QtWidgets.QMessageBox(self)
|
2011-08-23 03:51:50 -04:00
|
|
|
quirkWarning.setText("Not a valid regular expression!")
|
|
|
|
quirkWarning.setInformativeText("H3R3S WHY DUMP4SS: %s" % (e))
|
2022-06-26 22:18:37 -04:00
|
|
|
quirkWarning.exec()
|
2011-08-23 03:51:50 -04:00
|
|
|
else:
|
|
|
|
if mitem is None:
|
|
|
|
self.mentionlist.addItem(pdict["value"])
|
|
|
|
else:
|
|
|
|
mitem.setText(pdict["value"])
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def removeCurrent(self):
|
|
|
|
i = self.mentionlist.currentRow()
|
|
|
|
if i >= 0:
|
|
|
|
self.mentionlist.takeItem(i)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterOptions(QtWidgets.QDialog):
|
2011-02-02 19:32:35 -05:00
|
|
|
def __init__(self, config, theme, parent):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-04-28 01:20:44 -04:00
|
|
|
self.setWindowTitle("Options")
|
2011-02-02 19:32:35 -05:00
|
|
|
self.setModal(False)
|
|
|
|
self.config = config
|
|
|
|
self.theme = theme
|
|
|
|
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_4 = QtWidgets.QVBoxLayout()
|
2011-04-28 01:20:44 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
hr = QtWidgets.QFrame()
|
2022-06-26 22:18:37 -04:00
|
|
|
hr.setFrameShape(QtWidgets.QFrame.Shape.HLine)
|
|
|
|
hr.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
|
2021-03-23 17:36:43 -04:00
|
|
|
vr = QtWidgets.QFrame()
|
2022-06-26 22:18:37 -04:00
|
|
|
vr.setFrameShape(QtWidgets.QFrame.Shape.VLine)
|
|
|
|
vr.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
|
2011-04-14 03:04:33 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.tabs = QtWidgets.QButtonGroup(self)
|
2022-06-26 22:18:37 -04:00
|
|
|
self.tabs.buttonClicked.connect(self.changePage) # Verify working
|
|
|
|
self.tabNames = ["Chum List", "Conversations", "Interface", "Sound", "Notifications", "Logging", "Idle/Updates", "Theme", "Connection"]
|
|
|
|
if parent.advanced: self.tabNames.append("Advanced")
|
|
|
|
for t in self.tabNames:
|
2021-03-23 17:36:43 -04:00
|
|
|
button = QtWidgets.QPushButton(t)
|
2011-04-28 01:20:44 -04:00
|
|
|
self.tabs.addButton(button)
|
|
|
|
layout_4.addWidget(button)
|
2011-05-03 15:01:56 -04:00
|
|
|
button.setCheckable(True)
|
|
|
|
self.tabs.button(-2).setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.pages = QtWidgets.QStackedWidget(self)
|
2011-04-27 21:53:03 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.bandwidthcheck = QtWidgets.QCheckBox("Low Bandwidth", self)
|
2011-09-13 00:03:05 -04:00
|
|
|
if self.config.lowBandwidth():
|
|
|
|
self.bandwidthcheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
bandwidthLabel = QtWidgets.QLabel("(Stops you for receiving the flood of MOODS,\n"
|
2011-09-13 00:03:05 -04:00
|
|
|
" though stops chumlist from working properly)")
|
|
|
|
font = bandwidthLabel.font()
|
|
|
|
font.setPointSize(8)
|
|
|
|
bandwidthLabel.setFont(font)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.autonickserv = QtWidgets.QCheckBox("Auto-Identify with NickServ", self)
|
2014-01-12 03:14:16 -05:00
|
|
|
self.autonickserv.setChecked(parent.userprofile.getAutoIdentify())
|
2021-03-23 17:36:43 -04:00
|
|
|
self.autonickserv.stateChanged[int].connect(self.autoNickServChange)
|
|
|
|
self.nickservpass = QtWidgets.QLineEdit(self)
|
2014-01-12 03:14:16 -05:00
|
|
|
self.nickservpass.setPlaceholderText("NickServ Password")
|
2022-06-26 22:18:37 -04:00
|
|
|
self.nickservpass.setEchoMode(QtWidgets.QLineEdit.EchoMode.PasswordEchoOnEdit)
|
2014-01-12 03:14:16 -05:00
|
|
|
self.nickservpass.setText(parent.userprofile.getNickServPass())
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.autojoinlist = QtWidgets.QListWidget(self)
|
2014-01-12 20:50:01 -05:00
|
|
|
self.autojoinlist.addItems(parent.userprofile.getAutoJoins())
|
2021-03-23 17:36:43 -04:00
|
|
|
self.addAutoJoinBtn = QtWidgets.QPushButton("Add", self)
|
|
|
|
self.addAutoJoinBtn.clicked.connect(self.addAutoJoin)
|
|
|
|
self.delAutoJoinBtn = QtWidgets.QPushButton("Remove", self)
|
|
|
|
self.delAutoJoinBtn.clicked.connect(self.delAutoJoin)
|
|
|
|
|
|
|
|
self.tabcheck = QtWidgets.QCheckBox("Tabbed Conversations", self)
|
2011-02-02 19:32:35 -05:00
|
|
|
if self.config.tabs():
|
|
|
|
self.tabcheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.tabmemocheck = QtWidgets.QCheckBox("Tabbed Memos", self)
|
2011-11-07 22:44:17 -05:00
|
|
|
if self.config.tabMemos():
|
|
|
|
self.tabmemocheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.hideOffline = QtWidgets.QCheckBox("Hide Offline Chums", self)
|
2011-02-24 18:46:09 -05:00
|
|
|
if self.config.hideOfflineChums():
|
|
|
|
self.hideOffline.setChecked(True)
|
2011-02-08 02:56:30 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.soundcheck = QtWidgets.QCheckBox("Sounds On", self)
|
|
|
|
self.soundcheck.stateChanged[int].connect(self.soundChange)
|
|
|
|
self.chatsoundcheck = QtWidgets.QCheckBox("Pester Sounds", self)
|
2011-04-28 05:02:15 -04:00
|
|
|
self.chatsoundcheck.setChecked(self.config.chatSound())
|
2021-03-23 17:36:43 -04:00
|
|
|
self.memosoundcheck = QtWidgets.QCheckBox("Memo Sounds", self)
|
2011-04-28 05:02:15 -04:00
|
|
|
self.memosoundcheck.setChecked(self.config.memoSound())
|
2021-03-23 17:36:43 -04:00
|
|
|
self.memosoundcheck.stateChanged[int].connect(self.memoSoundChange)
|
|
|
|
self.memopingcheck = QtWidgets.QCheckBox("Memo Ping", self)
|
2011-07-08 04:41:49 -04:00
|
|
|
self.memopingcheck.setChecked(self.config.memoPing())
|
2021-03-23 17:36:43 -04:00
|
|
|
self.namesoundcheck = QtWidgets.QCheckBox("Memo Mention (initials)", self)
|
2011-06-20 11:22:54 -04:00
|
|
|
self.namesoundcheck.setChecked(self.config.nameSound())
|
2011-02-08 02:56:30 -05:00
|
|
|
if self.config.soundOn():
|
|
|
|
self.soundcheck.setChecked(True)
|
2011-07-08 04:41:49 -04:00
|
|
|
if not self.memosoundcheck.isChecked():
|
|
|
|
self.memoSoundChange(0)
|
2011-04-28 05:02:15 -04:00
|
|
|
else:
|
|
|
|
self.chatsoundcheck.setEnabled(False)
|
|
|
|
self.memosoundcheck.setEnabled(False)
|
2011-07-08 04:41:49 -04:00
|
|
|
self.memoSoundChange(0)
|
2011-08-23 03:51:50 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.editMentions = QtWidgets.QPushButton("Edit Mentions", self)
|
|
|
|
self.editMentions.clicked.connect(self.openMentions)
|
|
|
|
self.editMentions2 = QtWidgets.QPushButton("Edit Mentions", self)
|
|
|
|
self.editMentions2.clicked.connect(self.openMentions)
|
2011-08-23 03:51:50 -04:00
|
|
|
|
2022-06-26 22:18:37 -04:00
|
|
|
self.volume = QtWidgets.QSlider(QtCore.Qt.Orientation.Horizontal, self)
|
2011-06-24 12:27:18 -04:00
|
|
|
self.volume.setMinimum(0)
|
|
|
|
self.volume.setMaximum(100)
|
|
|
|
self.volume.setValue(self.config.volume())
|
2021-03-23 17:36:43 -04:00
|
|
|
self.volume.valueChanged[int].connect(self.printValue)
|
2017-01-09 18:59:57 -05:00
|
|
|
# Disable the volume slider if we can't actually use it.
|
|
|
|
if parent.canSetVolume():
|
2021-03-23 17:36:43 -04:00
|
|
|
self.currentVol = QtWidgets.QLabel(
|
2017-01-09 18:59:57 -05:00
|
|
|
"{0!s}%".format(self.config.volume()), self)
|
|
|
|
# We don't need to explicitly set this, but it helps drive the
|
|
|
|
# point home
|
|
|
|
self.volume.setEnabled(True)
|
|
|
|
else:
|
|
|
|
# We can't set the volume....
|
2021-03-23 17:36:43 -04:00
|
|
|
self.currentVol = QtWidgets.QLabel(
|
2017-01-09 18:59:57 -05:00
|
|
|
"(Disabled: Sound Mixer Error)", self)
|
|
|
|
self.volume.setEnabled(False)
|
2022-06-26 22:18:37 -04:00
|
|
|
self.currentVol.setAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter)
|
2011-04-28 05:02:15 -04:00
|
|
|
|
2016-11-13 01:14:39 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.timestampcheck = QtWidgets.QCheckBox("Time Stamps", self)
|
2011-03-12 02:44:59 -05:00
|
|
|
if self.config.showTimeStamps():
|
|
|
|
self.timestampcheck.setChecked(True)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.timestampBox = QtWidgets.QComboBox(self)
|
2011-03-12 02:44:59 -05:00
|
|
|
self.timestampBox.addItem("12 hour")
|
|
|
|
self.timestampBox.addItem("24 hour")
|
|
|
|
if self.config.time12Format():
|
|
|
|
self.timestampBox.setCurrentIndex(0)
|
|
|
|
else:
|
|
|
|
self.timestampBox.setCurrentIndex(1)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.secondscheck = QtWidgets.QCheckBox("Show Seconds", self)
|
2011-03-12 02:44:59 -05:00
|
|
|
if self.config.showSeconds():
|
|
|
|
self.secondscheck.setChecked(True)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.memomessagecheck = QtWidgets.QCheckBox("Show OP and Voice Messages in Memos", self)
|
2011-05-12 02:28:07 -04:00
|
|
|
if self.config.opvoiceMessages():
|
|
|
|
self.memomessagecheck.setChecked(True)
|
|
|
|
|
2011-08-11 04:59:51 -04:00
|
|
|
if not ostools.isOSXBundle():
|
2021-03-23 17:36:43 -04:00
|
|
|
self.animationscheck = QtWidgets.QCheckBox("Use animated smilies", self)
|
2011-08-11 04:59:51 -04:00
|
|
|
if self.config.animations():
|
|
|
|
self.animationscheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
animateLabel = QtWidgets.QLabel("(Disable if you leave chats open for LOOOONG periods of time)")
|
2011-08-11 04:59:51 -04:00
|
|
|
font = animateLabel.font()
|
|
|
|
font.setPointSize(8)
|
|
|
|
animateLabel.setFont(font)
|
2011-05-13 16:39:52 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.userlinkscheck = QtWidgets.QCheckBox("Disable #Memo and @User Links", self)
|
2011-04-28 01:20:44 -04:00
|
|
|
self.userlinkscheck.setChecked(self.config.disableUserLinks())
|
|
|
|
self.userlinkscheck.setVisible(False)
|
|
|
|
|
|
|
|
|
2011-04-14 03:04:33 -04:00
|
|
|
# Will add ability to turn off groups later
|
2016-11-13 01:14:39 -05:00
|
|
|
#self.groupscheck = QtGui.QCheckBox("Use Groups", self)
|
2011-04-14 03:04:33 -04:00
|
|
|
#self.groupscheck.setChecked(self.config.useGroups())
|
2021-03-23 17:36:43 -04:00
|
|
|
self.showemptycheck = QtWidgets.QCheckBox("Show Empty Groups", self)
|
2011-04-14 03:04:33 -04:00
|
|
|
self.showemptycheck.setChecked(self.config.showEmptyGroups())
|
2021-03-23 17:36:43 -04:00
|
|
|
self.showonlinenumbers = QtWidgets.QCheckBox("Show Number of Online Chums", self)
|
2011-04-07 17:00:25 -04:00
|
|
|
self.showonlinenumbers.setChecked(self.config.showOnlineNumbers())
|
2011-04-14 03:04:33 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
sortLabel = QtWidgets.QLabel("Sort Chums")
|
|
|
|
self.sortBox = QtWidgets.QComboBox(self)
|
2011-04-20 04:04:16 -04:00
|
|
|
self.sortBox.addItem("Alphabetically")
|
|
|
|
self.sortBox.addItem("By Mood")
|
2011-11-25 21:45:20 -05:00
|
|
|
self.sortBox.addItem("Manually")
|
2011-04-20 04:04:16 -04:00
|
|
|
method = self.config.sortMethod()
|
|
|
|
if method >= 0 and method < self.sortBox.count():
|
|
|
|
self.sortBox.setCurrentIndex(method)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_3 = QtWidgets.QHBoxLayout()
|
2011-04-25 04:31:47 -04:00
|
|
|
layout_3.addWidget(sortLabel)
|
|
|
|
layout_3.addWidget(self.sortBox, 10)
|
2011-04-20 04:04:16 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.logpesterscheck = QtWidgets.QCheckBox("Log all Pesters", self)
|
2011-05-12 16:09:30 -04:00
|
|
|
if self.config.logPesters() & self.config.LOG:
|
|
|
|
self.logpesterscheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.logmemoscheck = QtWidgets.QCheckBox("Log all Memos", self)
|
2011-05-12 16:09:30 -04:00
|
|
|
if self.config.logMemos() & self.config.LOG:
|
|
|
|
self.logmemoscheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.stamppestercheck = QtWidgets.QCheckBox("Log Time Stamps for Pesters", self)
|
2011-05-12 16:09:30 -04:00
|
|
|
if self.config.logPesters() & self.config.STAMP:
|
|
|
|
self.stamppestercheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.stampmemocheck = QtWidgets.QCheckBox("Log Time Stamps for Memos", self)
|
2011-05-12 16:09:30 -04:00
|
|
|
if self.config.logMemos() & self.config.STAMP:
|
|
|
|
self.stampmemocheck.setChecked(True)
|
2011-04-27 21:53:03 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.idleBox = QtWidgets.QSpinBox(self)
|
2011-05-09 17:41:12 -04:00
|
|
|
self.idleBox.setStyleSheet("background:#FFFFFF")
|
|
|
|
self.idleBox.setRange(1, 1440)
|
|
|
|
self.idleBox.setValue(self.config.idleTime())
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_5 = QtWidgets.QHBoxLayout()
|
|
|
|
layout_5.addWidget(QtWidgets.QLabel("Minutes before Idle:"))
|
2011-04-28 03:51:02 -04:00
|
|
|
layout_5.addWidget(self.idleBox)
|
|
|
|
|
2021-03-24 15:36:17 -04:00
|
|
|
#self.updateBox = QtWidgets.QComboBox(self)
|
|
|
|
#self.updateBox.addItem("Once a Day")
|
|
|
|
#self.updateBox.addItem("Once a Week")
|
|
|
|
#self.updateBox.addItem("Only on Start")
|
|
|
|
#self.updateBox.addItem("Never")
|
|
|
|
#check = self.config.checkForUpdates()
|
|
|
|
#if check >= 0 and check < self.updateBox.count():
|
|
|
|
# self.updateBox.setCurrentIndex(check)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_6 = QtWidgets.QHBoxLayout()
|
2021-03-24 15:36:17 -04:00
|
|
|
#layout_6.addWidget(QtWidgets.QLabel("Check for\nPesterchum Updates:"))
|
|
|
|
#layout_6.addWidget(self.updateBox)
|
2011-05-26 03:42:05 -04:00
|
|
|
|
2021-03-24 15:36:17 -04:00
|
|
|
#if not ostools.isOSXLeopard():
|
|
|
|
# self.mspaCheck = QtWidgets.QCheckBox("Check for MSPA Updates", self)
|
|
|
|
# self.mspaCheck.setChecked(self.config.checkMSPA())
|
2011-06-23 16:40:22 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.randomscheck = QtWidgets.QCheckBox("Receive Random Encounters")
|
2011-08-29 04:56:44 -04:00
|
|
|
self.randomscheck.setChecked(parent.userprofile.randoms)
|
|
|
|
if not parent.randhandler.running:
|
|
|
|
self.randomscheck.setEnabled(False)
|
2011-06-09 03:42:56 -04:00
|
|
|
|
2011-05-04 00:24:11 -04:00
|
|
|
avail_themes = self.config.availableThemes()
|
2021-03-23 17:36:43 -04:00
|
|
|
self.themeBox = QtWidgets.QComboBox(self)
|
2011-09-13 00:15:35 -04:00
|
|
|
notheme = (theme.name not in avail_themes)
|
2011-05-04 00:24:11 -04:00
|
|
|
for (i, t) in enumerate(avail_themes):
|
|
|
|
self.themeBox.addItem(t)
|
2011-09-13 00:15:35 -04:00
|
|
|
if (not notheme and t == theme.name) or (notheme and t == "pesterchum"):
|
2011-05-04 00:24:11 -04:00
|
|
|
self.themeBox.setCurrentIndex(i)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.refreshtheme = QtWidgets.QPushButton("Refresh current theme", self)
|
|
|
|
self.refreshtheme.clicked.connect(parent.themeSelectOverride)
|
|
|
|
self.ghostchum = QtWidgets.QCheckBox("Pesterdunk Ghostchum!!", self)
|
2012-06-08 05:02:12 -04:00
|
|
|
self.ghostchum.setChecked(self.config.ghostchum())
|
2011-05-04 00:24:11 -04:00
|
|
|
|
2011-05-05 02:48:44 -04:00
|
|
|
self.buttonOptions = ["Minimize to Taskbar", "Minimize to Tray", "Quit"]
|
2021-03-23 17:36:43 -04:00
|
|
|
self.miniBox = QtWidgets.QComboBox(self)
|
2011-05-05 02:48:44 -04:00
|
|
|
self.miniBox.addItems(self.buttonOptions)
|
|
|
|
self.miniBox.setCurrentIndex(self.config.minimizeAction())
|
2021-03-23 17:36:43 -04:00
|
|
|
self.closeBox = QtWidgets.QComboBox(self)
|
2011-05-05 02:48:44 -04:00
|
|
|
self.closeBox.addItems(self.buttonOptions)
|
|
|
|
self.closeBox.setCurrentIndex(self.config.closeAction())
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_mini = QtWidgets.QHBoxLayout()
|
|
|
|
layout_mini.addWidget(QtWidgets.QLabel("Minimize"))
|
2011-05-05 02:48:44 -04:00
|
|
|
layout_mini.addWidget(self.miniBox)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_close = QtWidgets.QHBoxLayout()
|
|
|
|
layout_close.addWidget(QtWidgets.QLabel("Close"))
|
2011-05-05 02:48:44 -04:00
|
|
|
layout_close.addWidget(self.closeBox)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.pesterBlink = QtWidgets.QCheckBox("Blink Taskbar on Pesters", self)
|
2011-06-27 02:27:47 -04:00
|
|
|
if self.config.blink() & self.config.PBLINK:
|
|
|
|
self.pesterBlink.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.memoBlink = QtWidgets.QCheckBox("Blink Taskbar on Memos", self)
|
2011-06-27 02:27:47 -04:00
|
|
|
if self.config.blink() & self.config.MBLINK:
|
|
|
|
self.memoBlink.setChecked(True)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.notifycheck = QtWidgets.QCheckBox("Toast Notifications", self)
|
2011-08-25 08:30:43 -04:00
|
|
|
if self.config.notify():
|
|
|
|
self.notifycheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.notifycheck.stateChanged[int].connect(self.notifyChange)
|
|
|
|
self.notifyOptions = QtWidgets.QComboBox(self)
|
2011-09-13 00:18:18 -04:00
|
|
|
types = self.parent().tm.availableTypes()
|
2011-08-25 08:30:43 -04:00
|
|
|
cur = self.parent().tm.currentType()
|
|
|
|
self.notifyOptions.addItems(types)
|
|
|
|
for (i,t) in enumerate(types):
|
|
|
|
if t == cur:
|
|
|
|
self.notifyOptions.setCurrentIndex(i)
|
|
|
|
break
|
2021-03-23 17:36:43 -04:00
|
|
|
self.notifyTypeLabel = QtWidgets.QLabel("Type", self)
|
|
|
|
layout_type = QtWidgets.QHBoxLayout()
|
2011-08-25 08:30:43 -04:00
|
|
|
layout_type.addWidget(self.notifyTypeLabel)
|
|
|
|
layout_type.addWidget(self.notifyOptions)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.notifySigninCheck = QtWidgets.QCheckBox("Chum signs in", self)
|
2011-08-27 13:51:50 -04:00
|
|
|
if self.config.notifyOptions() & self.config.SIGNIN:
|
|
|
|
self.notifySigninCheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.notifySignoutCheck = QtWidgets.QCheckBox("Chum signs out", self)
|
2011-08-27 13:51:50 -04:00
|
|
|
if self.config.notifyOptions() & self.config.SIGNOUT:
|
|
|
|
self.notifySignoutCheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.notifyNewMsgCheck = QtWidgets.QCheckBox("New messages", self)
|
2011-08-27 13:51:50 -04:00
|
|
|
if self.config.notifyOptions() & self.config.NEWMSG:
|
|
|
|
self.notifyNewMsgCheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.notifyNewConvoCheck = QtWidgets.QCheckBox("Only new conversations", self)
|
2011-08-27 13:51:50 -04:00
|
|
|
if self.config.notifyOptions() & self.config.NEWCONVO:
|
|
|
|
self.notifyNewConvoCheck.setChecked(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.notifyMentionsCheck = QtWidgets.QCheckBox("Memo Mentions (initials)", self)
|
2011-08-27 13:51:50 -04:00
|
|
|
if self.config.notifyOptions() & self.config.INITIALS:
|
|
|
|
self.notifyMentionsCheck.setChecked(True)
|
2011-08-25 08:30:43 -04:00
|
|
|
self.notifyChange(self.notifycheck.checkState())
|
|
|
|
|
2011-05-13 10:37:36 -04:00
|
|
|
if parent.advanced:
|
2017-01-09 18:59:57 -05:00
|
|
|
# NOTE: This doesn't do anything right now - so change it!
|
2021-03-23 17:36:43 -04:00
|
|
|
self.modechange = QtWidgets.QLineEdit(self)
|
|
|
|
layout_change = QtWidgets.QHBoxLayout()
|
|
|
|
layout_change.addWidget(QtWidgets.QLabel("Change:"))
|
2011-05-13 10:37:36 -04:00
|
|
|
layout_change.addWidget(self.modechange)
|
2011-05-12 02:46:53 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok = QtWidgets.QPushButton("OK", self)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.ok.setDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok.clicked.connect(self.accept)
|
|
|
|
self.cancel = QtWidgets.QPushButton("CANCEL", self)
|
|
|
|
self.cancel.clicked.connect(self.reject)
|
|
|
|
layout_2 = QtWidgets.QHBoxLayout()
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_2.addWidget(self.cancel)
|
|
|
|
layout_2.addWidget(self.ok)
|
|
|
|
|
2011-04-27 21:53:03 -04:00
|
|
|
# Tab layouts
|
|
|
|
# Chum List
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_chumlist = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_chumlist.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2011-04-27 21:53:03 -04:00
|
|
|
layout_chumlist.addWidget(self.hideOffline)
|
|
|
|
#layout_chumlist.addWidget(self.groupscheck)
|
|
|
|
layout_chumlist.addWidget(self.showemptycheck)
|
|
|
|
layout_chumlist.addWidget(self.showonlinenumbers)
|
|
|
|
layout_chumlist.addLayout(layout_3)
|
2011-04-28 01:20:44 -04:00
|
|
|
self.pages.addWidget(widget)
|
2011-04-27 21:53:03 -04:00
|
|
|
|
|
|
|
# Conversations
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_chat = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_chat.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2011-04-27 21:53:03 -04:00
|
|
|
layout_chat.addWidget(self.timestampcheck)
|
|
|
|
layout_chat.addWidget(self.timestampBox)
|
|
|
|
layout_chat.addWidget(self.secondscheck)
|
2011-05-12 02:28:07 -04:00
|
|
|
layout_chat.addWidget(self.memomessagecheck)
|
2011-08-11 04:59:51 -04:00
|
|
|
if not ostools.isOSXBundle():
|
|
|
|
layout_chat.addWidget(self.animationscheck)
|
|
|
|
layout_chat.addWidget(animateLabel)
|
2011-08-29 04:56:44 -04:00
|
|
|
layout_chat.addWidget(self.randomscheck)
|
2011-04-28 01:20:44 -04:00
|
|
|
# Re-enable these when it's possible to disable User and Memo links
|
|
|
|
#layout_chat.addWidget(hr)
|
2016-11-13 01:14:39 -05:00
|
|
|
#layout_chat.addWidget(QtGui.QLabel("User and Memo Links"))
|
2011-04-28 01:20:44 -04:00
|
|
|
#layout_chat.addWidget(self.userlinkscheck)
|
|
|
|
self.pages.addWidget(widget)
|
2011-04-27 21:53:03 -04:00
|
|
|
|
2011-05-05 02:48:44 -04:00
|
|
|
# Interface
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_interface = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_interface.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2011-05-09 12:32:30 -04:00
|
|
|
layout_interface.addWidget(self.tabcheck)
|
2011-11-07 22:44:17 -05:00
|
|
|
layout_interface.addWidget(self.tabmemocheck)
|
2011-05-05 02:48:44 -04:00
|
|
|
layout_interface.addLayout(layout_mini)
|
|
|
|
layout_interface.addLayout(layout_close)
|
2011-06-27 02:27:47 -04:00
|
|
|
layout_interface.addWidget(self.pesterBlink)
|
|
|
|
layout_interface.addWidget(self.memoBlink)
|
2011-05-05 02:48:44 -04:00
|
|
|
self.pages.addWidget(widget)
|
|
|
|
|
2011-04-28 05:02:15 -04:00
|
|
|
# Sound
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_sound = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_sound.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2011-04-28 05:02:15 -04:00
|
|
|
layout_sound.addWidget(self.soundcheck)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_indent = QtWidgets.QVBoxLayout()
|
2011-04-28 05:02:15 -04:00
|
|
|
layout_indent.addWidget(self.chatsoundcheck)
|
|
|
|
layout_indent.addWidget(self.memosoundcheck)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_doubleindent = QtWidgets.QVBoxLayout()
|
2011-07-08 04:41:49 -04:00
|
|
|
layout_doubleindent.addWidget(self.memopingcheck)
|
|
|
|
layout_doubleindent.addWidget(self.namesoundcheck)
|
2011-08-23 03:51:50 -04:00
|
|
|
layout_doubleindent.addWidget(self.editMentions)
|
2011-07-08 04:41:49 -04:00
|
|
|
layout_doubleindent.setContentsMargins(22,0,0,0)
|
|
|
|
layout_indent.addLayout(layout_doubleindent)
|
2011-04-28 05:02:15 -04:00
|
|
|
layout_indent.setContentsMargins(22,0,0,0)
|
|
|
|
layout_sound.addLayout(layout_indent)
|
2011-06-24 12:27:18 -04:00
|
|
|
layout_sound.addSpacing(15)
|
2021-03-23 17:36:43 -04:00
|
|
|
mvol = QtWidgets.QLabel("Master Volume:", self)
|
2017-01-09 18:59:57 -05:00
|
|
|
# If we can't set the volume, grey this out as well
|
|
|
|
#~mvol.setEnabled(parent.canSetVolume())
|
|
|
|
# Normally we'd grey this out, but that presently makes things
|
|
|
|
# rather unreadable
|
|
|
|
# Later we can look into changing the color to a theme[] entry
|
|
|
|
layout_sound.addWidget(mvol)
|
2011-06-24 12:27:18 -04:00
|
|
|
layout_sound.addWidget(self.volume)
|
|
|
|
layout_sound.addWidget(self.currentVol)
|
2011-04-28 05:02:15 -04:00
|
|
|
self.pages.addWidget(widget)
|
|
|
|
|
2011-08-27 13:51:50 -04:00
|
|
|
# Notifications
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_notify = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_notify.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2011-08-27 13:51:50 -04:00
|
|
|
layout_notify.addWidget(self.notifycheck)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_indent = QtWidgets.QVBoxLayout()
|
2011-08-27 13:51:50 -04:00
|
|
|
layout_indent.addLayout(layout_type)
|
|
|
|
layout_indent.setContentsMargins(22,0,0,0)
|
|
|
|
layout_indent.addWidget(self.notifySigninCheck)
|
|
|
|
layout_indent.addWidget(self.notifySignoutCheck)
|
|
|
|
layout_indent.addWidget(self.notifyNewMsgCheck)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_doubleindent = QtWidgets.QVBoxLayout()
|
2011-08-27 13:51:50 -04:00
|
|
|
layout_doubleindent.addWidget(self.notifyNewConvoCheck)
|
|
|
|
layout_doubleindent.setContentsMargins(22,0,0,0)
|
|
|
|
layout_indent.addLayout(layout_doubleindent)
|
|
|
|
layout_indent.addWidget(self.notifyMentionsCheck)
|
|
|
|
layout_indent.addWidget(self.editMentions2)
|
|
|
|
layout_notify.addLayout(layout_indent)
|
|
|
|
self.pages.addWidget(widget)
|
|
|
|
|
2011-04-27 21:53:03 -04:00
|
|
|
# Logging
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_logs = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_logs.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2011-04-27 21:53:03 -04:00
|
|
|
layout_logs.addWidget(self.logpesterscheck)
|
|
|
|
layout_logs.addWidget(self.logmemoscheck)
|
2011-05-12 16:09:30 -04:00
|
|
|
layout_logs.addWidget(self.stamppestercheck)
|
|
|
|
layout_logs.addWidget(self.stampmemocheck)
|
2011-04-28 01:20:44 -04:00
|
|
|
self.pages.addWidget(widget)
|
2011-04-27 21:53:03 -04:00
|
|
|
|
2011-05-26 03:42:05 -04:00
|
|
|
# Idle/Updates
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_idle = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_idle.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2011-04-28 03:51:02 -04:00
|
|
|
layout_idle.addLayout(layout_5)
|
2011-06-17 16:52:03 -04:00
|
|
|
layout_idle.addLayout(layout_6)
|
2021-03-24 15:36:17 -04:00
|
|
|
#if not ostools.isOSXLeopard():
|
|
|
|
# layout_idle.addWidget(self.mspaCheck)
|
2011-04-28 03:51:02 -04:00
|
|
|
self.pages.addWidget(widget)
|
|
|
|
|
2011-05-04 00:24:11 -04:00
|
|
|
# Theme
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_theme = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_theme.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_theme.addWidget(QtWidgets.QLabel("Pick a Theme:"))
|
2011-05-04 00:24:11 -04:00
|
|
|
layout_theme.addWidget(self.themeBox)
|
2011-11-07 21:07:06 -05:00
|
|
|
layout_theme.addWidget(self.refreshtheme)
|
2012-06-08 05:02:12 -04:00
|
|
|
layout_theme.addWidget(self.ghostchum)
|
2011-05-04 00:24:11 -04:00
|
|
|
self.pages.addWidget(widget)
|
|
|
|
|
2014-01-12 03:14:16 -05:00
|
|
|
# Connection
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_connect = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_connect.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2014-01-12 03:14:16 -05:00
|
|
|
layout_connect.addWidget(self.bandwidthcheck)
|
|
|
|
layout_connect.addWidget(bandwidthLabel)
|
|
|
|
layout_connect.addWidget(self.autonickserv)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_indent = QtWidgets.QVBoxLayout()
|
2014-01-12 03:14:16 -05:00
|
|
|
layout_indent.addWidget(self.nickservpass)
|
|
|
|
layout_indent.setContentsMargins(22,0,0,0)
|
|
|
|
layout_connect.addLayout(layout_indent)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_connect.addWidget(QtWidgets.QLabel("Auto-Join Memos:"))
|
2014-01-12 20:50:01 -05:00
|
|
|
layout_connect.addWidget(self.autojoinlist)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_8 = QtWidgets.QHBoxLayout()
|
2014-01-12 20:50:01 -05:00
|
|
|
layout_8.addWidget(self.addAutoJoinBtn)
|
|
|
|
layout_8.addWidget(self.delAutoJoinBtn)
|
|
|
|
layout_connect.addLayout(layout_8)
|
2014-01-12 03:14:16 -05:00
|
|
|
self.pages.addWidget(widget)
|
|
|
|
|
2011-05-12 02:46:53 -04:00
|
|
|
# Advanced
|
|
|
|
if parent.advanced:
|
2021-03-23 17:36:43 -04:00
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
layout_advanced = QtWidgets.QVBoxLayout(widget)
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_advanced.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_advanced.addWidget(QtWidgets.QLabel("Current User Mode: %s" % parent.modes))
|
2011-05-12 02:46:53 -04:00
|
|
|
layout_advanced.addLayout(layout_change)
|
|
|
|
self.pages.addWidget(widget)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
|
|
|
layout_1 = QtWidgets.QHBoxLayout()
|
2011-04-28 01:20:44 -04:00
|
|
|
layout_1.addLayout(layout_4)
|
2011-04-28 05:02:15 -04:00
|
|
|
layout_1.addWidget(vr)
|
2011-04-28 01:20:44 -04:00
|
|
|
layout_1.addWidget(self.pages)
|
|
|
|
layout_0.addLayout(layout_1)
|
|
|
|
layout_0.addSpacing(30)
|
2011-02-02 19:32:35 -05:00
|
|
|
layout_0.addLayout(layout_2)
|
|
|
|
|
|
|
|
self.setLayout(layout_0)
|
|
|
|
|
2022-06-26 22:18:37 -04:00
|
|
|
@QtCore.pyqtSlot(QtWidgets.QAbstractButton)
|
|
|
|
def changePage(self, button):
|
|
|
|
self.pages.setCurrentIndex(self.tabNames.index(button.text()))
|
2011-08-25 08:30:43 -04:00
|
|
|
|
|
|
|
@QtCore.pyqtSlot(int)
|
|
|
|
def notifyChange(self, state):
|
|
|
|
if state == 0:
|
|
|
|
self.notifyTypeLabel.setEnabled(False)
|
|
|
|
self.notifyOptions.setEnabled(False)
|
2011-08-27 13:51:50 -04:00
|
|
|
self.notifySigninCheck.setEnabled(False)
|
|
|
|
self.notifySignoutCheck.setEnabled(False)
|
|
|
|
self.notifyNewMsgCheck.setEnabled(False)
|
|
|
|
self.notifyNewConvoCheck.setEnabled(False)
|
|
|
|
self.notifyMentionsCheck.setEnabled(False)
|
2011-08-25 08:30:43 -04:00
|
|
|
else:
|
|
|
|
self.notifyTypeLabel.setEnabled(True)
|
|
|
|
self.notifyOptions.setEnabled(True)
|
2011-08-27 13:51:50 -04:00
|
|
|
self.notifySigninCheck.setEnabled(True)
|
|
|
|
self.notifySignoutCheck.setEnabled(True)
|
|
|
|
self.notifyNewMsgCheck.setEnabled(True)
|
|
|
|
self.notifyNewConvoCheck.setEnabled(True)
|
|
|
|
self.notifyMentionsCheck.setEnabled(True)
|
2011-08-25 08:30:43 -04:00
|
|
|
|
2014-01-12 03:14:16 -05:00
|
|
|
@QtCore.pyqtSlot(int)
|
|
|
|
def autoNickServChange(self, state):
|
|
|
|
self.nickservpass.setEnabled(state != 0)
|
|
|
|
|
2014-01-12 20:50:01 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def addAutoJoin(self, mitem=None):
|
|
|
|
d = {"label": "Memo:", "inputname": "value" }
|
|
|
|
if mitem is not None:
|
|
|
|
d["value"] = str(mitem.text())
|
|
|
|
pdict = MultiTextDialog("ENTER MEMO", self, d).getText()
|
|
|
|
if pdict is None:
|
|
|
|
return
|
|
|
|
pdict["value"] = "#" + pdict["value"]
|
|
|
|
if mitem is None:
|
2022-06-26 22:18:37 -04:00
|
|
|
items = self.autojoinlist.findItems(pdict["value"], QtCore.Qt.MatchFlag.MatchFixedString)
|
2014-01-12 20:50:01 -05:00
|
|
|
if len(items) == 0:
|
|
|
|
self.autojoinlist.addItem(pdict["value"])
|
|
|
|
else:
|
|
|
|
mitem.setText(pdict["value"])
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def delAutoJoin(self):
|
|
|
|
i = self.autojoinlist.currentRow()
|
|
|
|
if i >= 0:
|
|
|
|
self.autojoinlist.takeItem(i)
|
|
|
|
|
2011-04-28 05:02:15 -04:00
|
|
|
@QtCore.pyqtSlot(int)
|
|
|
|
def soundChange(self, state):
|
|
|
|
if state == 0:
|
|
|
|
self.chatsoundcheck.setEnabled(False)
|
|
|
|
self.memosoundcheck.setEnabled(False)
|
2011-07-08 04:41:49 -04:00
|
|
|
self.memoSoundChange(0)
|
2011-04-28 05:02:15 -04:00
|
|
|
else:
|
|
|
|
self.chatsoundcheck.setEnabled(True)
|
|
|
|
self.memosoundcheck.setEnabled(True)
|
2011-07-08 04:41:49 -04:00
|
|
|
if self.memosoundcheck.isChecked():
|
|
|
|
self.memoSoundChange(1)
|
|
|
|
@QtCore.pyqtSlot(int)
|
|
|
|
def memoSoundChange(self, state):
|
|
|
|
if state == 0:
|
|
|
|
self.memopingcheck.setEnabled(False)
|
|
|
|
self.namesoundcheck.setEnabled(False)
|
|
|
|
else:
|
|
|
|
self.memopingcheck.setEnabled(True)
|
2011-06-20 11:22:54 -04:00
|
|
|
self.namesoundcheck.setEnabled(True)
|
2011-06-24 12:27:18 -04:00
|
|
|
@QtCore.pyqtSlot(int)
|
|
|
|
def printValue(self, v):
|
|
|
|
self.currentVol.setText(str(v)+"%")
|
2011-04-28 01:20:44 -04:00
|
|
|
|
2011-08-23 03:51:50 -04:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def openMentions(self):
|
|
|
|
if not hasattr(self, 'mentionmenu'):
|
|
|
|
self.mentionmenu = None
|
|
|
|
if not self.mentionmenu:
|
|
|
|
self.mentionmenu = PesterMentions(self.parent(), self.theme, self)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.mentionmenu.accepted.connect(self.updateMentions)
|
|
|
|
self.mentionmenu.rejected.connect(self.closeMentions)
|
2011-08-23 03:51:50 -04:00
|
|
|
self.mentionmenu.show()
|
|
|
|
self.mentionmenu.raise_()
|
|
|
|
self.mentionmenu.activateWindow()
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def closeMentions(self):
|
|
|
|
self.mentionmenu.close()
|
|
|
|
self.mentionmenu = None
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def updateMentions(self):
|
|
|
|
m = []
|
|
|
|
for i in range(self.mentionmenu.mentionlist.count()):
|
|
|
|
m.append(str(self.mentionmenu.mentionlist.item(i).text()))
|
|
|
|
self.parent().userprofile.setMentions(m)
|
|
|
|
self.mentionmenu = None
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterUserlist(QtWidgets.QDialog):
|
2011-02-02 19:32:35 -05:00
|
|
|
def __init__(self, config, theme, parent):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.setModal(False)
|
|
|
|
self.config = config
|
|
|
|
self.theme = theme
|
2011-02-03 01:20:37 -05:00
|
|
|
self.mainwindow = parent
|
2011-02-02 19:32:35 -05:00
|
|
|
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
2011-02-03 01:20:37 -05:00
|
|
|
self.resize(200, 600)
|
2011-02-02 19:32:35 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.searchbox = QtWidgets.QLineEdit(self)
|
2012-06-04 12:43:56 -04:00
|
|
|
#self.searchbox.setStyleSheet(theme["convo/input/style"]) # which style is better?
|
|
|
|
self.searchbox.setPlaceholderText("Search")
|
2021-03-23 17:36:43 -04:00
|
|
|
self.searchbox.textChanged['QString'].connect(self.updateUsers)
|
2012-06-04 12:43:56 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.label = QtWidgets.QLabel("USERLIST")
|
2011-02-02 19:32:35 -05:00
|
|
|
self.userarea = RightClickList(self)
|
|
|
|
self.userarea.setStyleSheet(self.theme["main/chums/style"])
|
2021-03-23 17:36:43 -04:00
|
|
|
self.userarea.optionsMenu = QtWidgets.QMenu(self)
|
|
|
|
|
2022-06-26 22:18:37 -04:00
|
|
|
self.addChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/addchum"], self)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.addChumAction.triggered.connect(self.addChumSlot)
|
2022-06-26 22:18:37 -04:00
|
|
|
self.pesterChumAction = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/pester"], self)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.pesterChumAction.triggered.connect(self.pesterChumSlot)
|
2011-02-03 01:20:37 -05:00
|
|
|
self.userarea.optionsMenu.addAction(self.addChumAction)
|
2011-04-13 02:12:19 -04:00
|
|
|
self.userarea.optionsMenu.addAction(self.pesterChumAction)
|
2011-02-02 19:32:35 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok = QtWidgets.QPushButton("OK", self)
|
2011-02-02 19:32:35 -05:00
|
|
|
self.ok.setDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok.clicked.connect(self.accept)
|
2011-02-02 19:32:35 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-02-03 01:20:37 -05:00
|
|
|
layout_0.addWidget(self.label)
|
|
|
|
layout_0.addWidget(self.userarea)
|
2012-06-04 21:22:09 -04:00
|
|
|
layout_0.addWidget(self.searchbox)
|
2011-02-03 01:20:37 -05:00
|
|
|
layout_0.addWidget(self.ok)
|
2011-03-12 02:44:59 -05:00
|
|
|
|
2011-02-03 01:20:37 -05:00
|
|
|
self.setLayout(layout_0)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.mainwindow.namesUpdated.connect(self.updateUsers)
|
2016-11-13 01:14:39 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.mainwindow.userPresentSignal['QString', 'QString', 'QString'].connect(self.updateUserPresent)
|
2011-02-03 01:20:37 -05:00
|
|
|
self.updateUsers()
|
2012-06-04 21:22:09 -04:00
|
|
|
|
|
|
|
self.searchbox.setFocus()
|
2011-02-03 01:20:37 -05:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def updateUsers(self):
|
2011-04-14 05:50:55 -04:00
|
|
|
names = self.mainwindow.namesdb["#pesterchum"]
|
2011-02-03 01:20:37 -05:00
|
|
|
self.userarea.clear()
|
|
|
|
for n in names:
|
2012-06-04 12:43:56 -04:00
|
|
|
if str(self.searchbox.text()) == "" or n.lower().find(str(self.searchbox.text()).lower()) != -1:
|
2022-06-26 22:18:37 -04:00
|
|
|
# Strip channel membership prefixes
|
|
|
|
n = n.strip('~').strip('@').strip('+').strip('&').strip('%')
|
2021-03-23 17:36:43 -04:00
|
|
|
item = QtWidgets.QListWidgetItem(n)
|
2021-03-24 16:38:54 -04:00
|
|
|
item.setForeground(QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"])))
|
2012-06-04 12:43:56 -04:00
|
|
|
self.userarea.addItem(item)
|
2011-02-03 01:20:37 -05:00
|
|
|
self.userarea.sortItems()
|
2021-03-23 17:36:43 -04:00
|
|
|
@QtCore.pyqtSlot(QString, QString, QString)
|
2011-02-03 01:20:37 -05:00
|
|
|
def updateUserPresent(self, handle, channel, update):
|
2021-03-23 17:36:43 -04:00
|
|
|
h = str(handle)
|
|
|
|
c = str(channel)
|
2011-02-03 01:20:37 -05:00
|
|
|
if update == "quit":
|
|
|
|
self.delUser(h)
|
|
|
|
elif update == "left" and c == "#pesterchum":
|
|
|
|
self.delUser(h)
|
|
|
|
elif update == "join" and c == "#pesterchum":
|
2012-06-04 21:30:26 -04:00
|
|
|
if str(self.searchbox.text()) == "" or h.lower().find(str(self.searchbox.text()).lower()) != -1:
|
2012-06-04 12:43:56 -04:00
|
|
|
self.addUser(h)
|
2011-02-03 01:20:37 -05:00
|
|
|
def addUser(self, name):
|
2021-03-23 17:36:43 -04:00
|
|
|
item = QtWidgets.QListWidgetItem(name)
|
2021-03-24 16:38:54 -04:00
|
|
|
item.setForeground(QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"])))
|
2011-02-03 01:20:37 -05:00
|
|
|
self.userarea.addItem(item)
|
|
|
|
self.userarea.sortItems()
|
|
|
|
def delUser(self, name):
|
2022-06-26 22:18:37 -04:00
|
|
|
matches = self.userarea.findItems(name, QtCore.Qt.MatchFlag.MatchExactly)
|
2011-02-03 01:20:37 -05:00
|
|
|
for m in matches:
|
|
|
|
self.userarea.takeItem(self.userarea.row(m))
|
|
|
|
|
|
|
|
def changeTheme(self, theme):
|
2011-02-03 01:56:59 -05:00
|
|
|
self.theme = theme
|
2011-02-03 01:20:37 -05:00
|
|
|
self.setStyleSheet(theme["main/defaultwindow/style"])
|
|
|
|
self.userarea.setStyleSheet(theme["main/chums/style"])
|
|
|
|
self.addChumAction.setText(theme["main/menus/rclickchumlist/addchum"])
|
2011-02-03 01:56:59 -05:00
|
|
|
for item in [self.userarea.item(i) for i in range(0, self.userarea.count())]:
|
2021-03-23 17:40:47 -04:00
|
|
|
item.setForeground(0, QtGui.QBrush(QtGui.QColor(theme["main/chums/userlistcolor"])))
|
2011-02-03 01:20:37 -05:00
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def addChumSlot(self):
|
|
|
|
cur = self.userarea.currentItem()
|
|
|
|
if not cur:
|
|
|
|
return
|
|
|
|
self.addChum.emit(cur.text())
|
2011-04-13 02:12:19 -04:00
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def pesterChumSlot(self):
|
|
|
|
cur = self.userarea.currentItem()
|
|
|
|
if not cur:
|
|
|
|
return
|
|
|
|
self.pesterChum.emit(cur.text())
|
2011-02-03 01:20:37 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
addChum = QtCore.pyqtSignal('QString')
|
|
|
|
pesterChum = QtCore.pyqtSignal('QString')
|
2011-02-03 01:20:37 -05:00
|
|
|
|
2011-03-31 17:57:30 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class MemoListItem(QtWidgets.QTreeWidgetItem):
|
2011-03-31 17:57:30 -04:00
|
|
|
def __init__(self, channel, usercount):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QTreeWidgetItem.__init__(self, [channel, str(usercount)])
|
2011-03-31 17:57:30 -04:00
|
|
|
self.target = channel
|
2011-09-05 18:17:07 -04:00
|
|
|
def __lt__(self, other):
|
|
|
|
column = self.treeWidget().sortColumn()
|
|
|
|
if str(self.text(column)).isdigit() and str(other.text(column)).isdigit():
|
|
|
|
return int(self.text(column)) < int(other.text(column))
|
|
|
|
return self.text(column) < other.text(column)
|
2011-03-31 17:57:30 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class PesterMemoList(QtWidgets.QDialog):
|
2011-02-06 19:50:21 -05:00
|
|
|
def __init__(self, parent, channel=""):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-02-04 16:17:27 -05:00
|
|
|
self.setModal(False)
|
|
|
|
self.theme = parent.theme
|
|
|
|
self.mainwindow = parent
|
|
|
|
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
2011-05-09 09:03:01 -04:00
|
|
|
self.resize(460, 300)
|
2011-02-04 16:17:27 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.label = QtWidgets.QLabel("MEMOS")
|
2011-05-09 09:03:01 -04:00
|
|
|
self.channelarea = RightClickTree(self)
|
2022-06-26 22:18:37 -04:00
|
|
|
self.channelarea.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)
|
2011-02-04 16:17:27 -05:00
|
|
|
self.channelarea.setStyleSheet(self.theme["main/chums/style"])
|
2021-03-23 17:36:43 -04:00
|
|
|
self.channelarea.optionsMenu = QtWidgets.QMenu(self)
|
2011-05-09 09:03:01 -04:00
|
|
|
self.channelarea.setColumnCount(2)
|
|
|
|
self.channelarea.setHeaderLabels(["Memo", "Users"])
|
|
|
|
self.channelarea.setIndentation(0)
|
|
|
|
self.channelarea.setColumnWidth(0,200)
|
|
|
|
self.channelarea.setColumnWidth(1,10)
|
2011-09-05 18:17:07 -04:00
|
|
|
self.channelarea.setSortingEnabled(True)
|
2022-06-26 22:18:37 -04:00
|
|
|
self.channelarea.sortByColumn(0, QtCore.Qt.SortOrder.AscendingOrder)
|
2021-03-23 17:40:47 -04:00
|
|
|
self.channelarea.itemDoubleClicked[QtWidgets.QTreeWidgetItem, int].connect(self.AcceptSelection)
|
2011-02-04 16:17:27 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.orjoinlabel = QtWidgets.QLabel("OR MAKE A NEW MEMO:")
|
|
|
|
self.newmemo = QtWidgets.QLineEdit(channel, self)
|
|
|
|
self.secretChannel = QtWidgets.QCheckBox("HIDDEN CHANNEL?", self)
|
|
|
|
self.inviteChannel = QtWidgets.QCheckBox("INVITATION ONLY?", self)
|
2011-02-04 16:17:27 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.timelabel = QtWidgets.QLabel("TIMEFRAME:")
|
2022-06-26 22:18:37 -04:00
|
|
|
self.timeslider = TimeSlider(QtCore.Qt.Orientation.Horizontal, self)
|
2011-02-05 12:17:33 -05:00
|
|
|
self.timeinput = TimeInput(self.timeslider, self)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.cancel = QtWidgets.QPushButton("CANCEL", self)
|
|
|
|
self.cancel.clicked.connect(self.reject)
|
|
|
|
self.join = QtWidgets.QPushButton("JOIN", self)
|
2011-02-04 16:17:27 -05:00
|
|
|
self.join.setDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.join.clicked.connect(self.AcceptIfSelectionMade)
|
|
|
|
layout_ok = QtWidgets.QHBoxLayout()
|
2011-02-04 16:17:27 -05:00
|
|
|
layout_ok.addWidget(self.cancel)
|
|
|
|
layout_ok.addWidget(self.join)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_left = QtWidgets.QVBoxLayout()
|
|
|
|
layout_right = QtWidgets.QVBoxLayout()
|
2022-06-26 22:18:37 -04:00
|
|
|
layout_right.setAlignment(QtCore.Qt.AlignmentFlag.AlignTop)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
|
|
|
layout_1 = QtWidgets.QHBoxLayout()
|
2011-05-09 09:03:01 -04:00
|
|
|
layout_left.addWidget(self.label)
|
|
|
|
layout_left.addWidget(self.channelarea)
|
|
|
|
layout_right.addWidget(self.orjoinlabel)
|
|
|
|
layout_right.addWidget(self.newmemo)
|
|
|
|
layout_right.addWidget(self.secretChannel)
|
2011-05-19 09:49:21 -04:00
|
|
|
layout_right.addWidget(self.inviteChannel)
|
2011-05-09 09:03:01 -04:00
|
|
|
layout_right.addWidget(self.timelabel)
|
|
|
|
layout_right.addWidget(self.timeslider)
|
|
|
|
layout_right.addWidget(self.timeinput)
|
|
|
|
layout_1.addLayout(layout_left)
|
|
|
|
layout_1.addLayout(layout_right)
|
|
|
|
layout_0.addLayout(layout_1)
|
2011-02-04 16:17:27 -05:00
|
|
|
layout_0.addLayout(layout_ok)
|
2011-03-12 02:44:59 -05:00
|
|
|
|
2011-02-04 16:17:27 -05:00
|
|
|
self.setLayout(layout_0)
|
|
|
|
|
|
|
|
def newmemoname(self):
|
|
|
|
return self.newmemo.text()
|
2013-02-06 13:36:14 -05:00
|
|
|
|
|
|
|
def SelectedMemos(self):
|
|
|
|
return self.channelarea.selectedItems()
|
2014-01-12 03:14:16 -05:00
|
|
|
|
2013-02-06 13:36:14 -05:00
|
|
|
def HasSelection(self):
|
|
|
|
return len(self.SelectedMemos()) > 0 or self.newmemoname()
|
2011-02-04 16:17:27 -05:00
|
|
|
|
|
|
|
def updateChannels(self, channels):
|
|
|
|
for c in channels:
|
2011-03-31 17:57:30 -04:00
|
|
|
item = MemoListItem(c[0][1:],c[1])
|
2021-03-23 17:40:47 -04:00
|
|
|
item.setForeground(0, QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"])))
|
|
|
|
item.setForeground(1, QtGui.QBrush(QtGui.QColor(self.theme["main/chums/userlistcolor"])))
|
2011-05-09 09:03:01 -04:00
|
|
|
item.setIcon(0, QtGui.QIcon(self.theme["memos/memoicon"]))
|
|
|
|
self.channelarea.addTopLevelItem(item)
|
2011-02-04 16:17:27 -05:00
|
|
|
|
|
|
|
def updateTheme(self, theme):
|
|
|
|
self.theme = theme
|
|
|
|
self.setStyleSheet(theme["main/defaultwindow/style"])
|
|
|
|
for item in [self.userarea.item(i) for i in range(0, self.channelarea.count())]:
|
2021-03-23 17:40:47 -04:00
|
|
|
item.setForeground(0, QtGui.QBrush(QtGui.QColor(theme["main/chums/userlistcolor"])))
|
2011-02-04 16:17:27 -05:00
|
|
|
item.setIcon(QtGui.QIcon(theme["memos/memoicon"]))
|
2011-03-12 02:44:59 -05:00
|
|
|
|
2011-02-05 12:17:33 -05:00
|
|
|
@QtCore.pyqtSlot()
|
2013-02-06 13:36:14 -05:00
|
|
|
def AcceptIfSelectionMade(self):
|
|
|
|
if self.HasSelection():
|
|
|
|
self.AcceptSelection()
|
|
|
|
|
2011-06-01 14:17:35 -04:00
|
|
|
@QtCore.pyqtSlot()
|
2013-02-06 13:36:14 -05:00
|
|
|
def AcceptSelection(self):
|
2011-02-04 16:17:27 -05:00
|
|
|
self.accept()
|
2011-02-04 19:50:56 -05:00
|
|
|
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class LoadingScreen(QtWidgets.QDialog):
|
|
|
|
tryAgain = QtCore.pyqtSignal()
|
|
|
|
|
2011-02-04 19:50:56 -05:00
|
|
|
def __init__(self, parent=None):
|
2022-06-26 22:18:37 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent, (QtCore.Qt.WindowType.CustomizeWindowHint |
|
|
|
|
QtCore.Qt.WindowType.FramelessWindowHint))
|
2011-02-04 19:50:56 -05:00
|
|
|
self.mainwindow = parent
|
|
|
|
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.loadinglabel = QtWidgets.QLabel("CONN3CT1NG", self)
|
|
|
|
self.cancel = QtWidgets.QPushButton("QU1T >:?", self)
|
|
|
|
self.ok = QtWidgets.QPushButton("R3CONN3CT >:]", self)
|
2017-01-09 01:18:59 -05:00
|
|
|
# Help reduce the number of accidental Pesterchum closures... :|
|
|
|
|
self.cancel.setAutoDefault(False)
|
|
|
|
self.ok.setAutoDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.cancel.clicked.connect(self.reject)
|
|
|
|
self.ok.clicked.connect(self.tryAgain)
|
2011-02-04 19:50:56 -05:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.layout = QtWidgets.QVBoxLayout()
|
2011-02-04 19:50:56 -05:00
|
|
|
self.layout.addWidget(self.loadinglabel)
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_1 = QtWidgets.QHBoxLayout()
|
2011-02-18 03:17:13 -05:00
|
|
|
layout_1.addWidget(self.cancel)
|
|
|
|
layout_1.addWidget(self.ok)
|
|
|
|
self.layout.addLayout(layout_1)
|
2011-02-04 19:50:56 -05:00
|
|
|
self.setLayout(self.layout)
|
2017-01-09 19:26:37 -05:00
|
|
|
# Help reduce the number of accidental Pesterchum closures... :|
|
|
|
|
self.cancel.setDefault(False)
|
|
|
|
self.ok.setDefault(True)
|
2017-01-13 10:08:29 -05:00
|
|
|
self.ok.setFocus()
|
|
|
|
self.timer = None
|
2011-02-09 01:26:23 -05:00
|
|
|
|
2017-01-13 10:08:29 -05:00
|
|
|
def hideReconnect(self, safe=True):
|
2011-02-21 14:07:59 -05:00
|
|
|
self.ok.hide()
|
2017-01-13 10:08:29 -05:00
|
|
|
if safe:
|
|
|
|
# Set a timer so that we don't immediately disconnect anyway.
|
|
|
|
self.cancel.setEnabled(False)
|
|
|
|
# A few seconds should be enough.
|
2021-03-23 17:40:24 -04:00
|
|
|
self.timer = QtCore.QTimer.singleShot(2000, self.enableQuit)
|
2017-01-13 10:08:29 -05:00
|
|
|
|
2011-02-21 14:07:59 -05:00
|
|
|
def showReconnect(self):
|
|
|
|
self.ok.show()
|
2017-01-13 10:08:29 -05:00
|
|
|
# Again...stop accidental closes.
|
|
|
|
self.ok.setFocus()
|
|
|
|
|
|
|
|
@QtCore.pyqtSlot()
|
|
|
|
def enableQuit(self):
|
|
|
|
self.cancel.setEnabled(True)
|
2011-02-21 14:07:59 -05:00
|
|
|
|
2011-02-18 03:17:13 -05:00
|
|
|
tryAgain = QtCore.pyqtSignal()
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class AboutPesterchum(QtWidgets.QDialog):
|
2011-02-09 01:26:23 -05:00
|
|
|
def __init__(self, parent=None):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-02-09 01:26:23 -05:00
|
|
|
self.mainwindow = parent
|
2011-05-09 09:03:01 -04:00
|
|
|
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
|
|
|
|
|
2021-03-24 17:34:55 -04:00
|
|
|
self.title = QtWidgets.QLabel("P3ST3RCHUM %s" % (_pcVersion))
|
2021-03-23 17:36:43 -04:00
|
|
|
self.credits = QtWidgets.QLabel("Programming by:\n\
|
2011-05-09 09:03:01 -04:00
|
|
|
illuminatedwax (ghostDunk)\n\
|
|
|
|
Kiooeht (evacipatedBox)\n\
|
2011-07-12 06:10:10 -04:00
|
|
|
Lexi (lexicalNuance)\n\
|
2012-06-04 21:17:55 -04:00
|
|
|
oakwhiz\n\
|
2011-05-09 09:03:01 -04:00
|
|
|
alGore\n\
|
2012-06-26 02:54:12 -04:00
|
|
|
Cerxi (binaryCabalist)\n\
|
2021-02-21 10:40:03 -05:00
|
|
|
Arcane (arcaneAgilmente)\n\
|
2016-12-10 21:53:29 -05:00
|
|
|
karxi (Midna)\n\
|
2021-03-24 17:34:55 -04:00
|
|
|
Shou :)\n\
|
2011-05-09 09:03:01 -04:00
|
|
|
\n\
|
|
|
|
Art by:\n\
|
|
|
|
Grimlive (aquaMarinist)\n\
|
2012-06-26 02:54:12 -04:00
|
|
|
Cerxi (binaryCabalist)\n\
|
2011-05-09 09:03:01 -04:00
|
|
|
\n\
|
|
|
|
Special Thanks:\n\
|
|
|
|
ABT\n\
|
2011-06-23 16:40:22 -04:00
|
|
|
gamblingGenocider\n\
|
|
|
|
Eco-Mono")
|
2011-05-09 09:03:01 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok = QtWidgets.QPushButton("OK", self)
|
|
|
|
self.ok.clicked.connect(self.reject)
|
2011-05-09 09:03:01 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-05-09 09:03:01 -04:00
|
|
|
layout_0.addWidget(self.title)
|
|
|
|
layout_0.addWidget(self.credits)
|
|
|
|
layout_0.addWidget(self.ok)
|
|
|
|
|
|
|
|
self.setLayout(layout_0)
|
2011-05-26 03:42:05 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class UpdatePesterchum(QtWidgets.QDialog):
|
2011-05-26 03:42:05 -04:00
|
|
|
def __init__(self, ver, url, parent=None):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-05-26 03:42:05 -04:00
|
|
|
self.url = url
|
|
|
|
self.mainwindow = parent
|
|
|
|
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
|
|
|
|
self.setWindowTitle("Pesterchum v%s Update" % (ver))
|
|
|
|
self.setModal(False)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.title = QtWidgets.QLabel("An update to Pesterchum is available!")
|
2011-05-26 03:42:05 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-05-26 03:42:05 -04:00
|
|
|
layout_0.addWidget(self.title)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok = QtWidgets.QPushButton("D0WNL04D 4ND 1NST4LL N0W", self)
|
2011-05-26 03:42:05 -04:00
|
|
|
self.ok.setDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok.clicked.connect(self.accept)
|
|
|
|
self.cancel = QtWidgets.QPushButton("CANCEL", self)
|
|
|
|
self.cancel.clicked.connect(self.reject)
|
|
|
|
layout_2 = QtWidgets.QHBoxLayout()
|
2011-05-26 03:42:05 -04:00
|
|
|
layout_2.addWidget(self.cancel)
|
|
|
|
layout_2.addWidget(self.ok)
|
|
|
|
|
|
|
|
layout_0.addLayout(layout_2)
|
|
|
|
|
|
|
|
self.setLayout(layout_0)
|
2011-10-24 20:24:40 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
class AddChumDialog(QtWidgets.QDialog):
|
2011-10-24 20:24:40 -04:00
|
|
|
def __init__(self, avail_groups, parent=None):
|
2021-03-23 17:36:43 -04:00
|
|
|
QtWidgets.QDialog.__init__(self, parent)
|
2011-10-24 20:24:40 -04:00
|
|
|
|
|
|
|
self.mainwindow = parent
|
|
|
|
self.setStyleSheet(self.mainwindow.theme["main/defaultwindow/style"])
|
|
|
|
self.setWindowTitle("Enter Chum Handle")
|
|
|
|
self.setModal(True)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.title = QtWidgets.QLabel("Enter Chum Handle")
|
|
|
|
self.chumBox = QtWidgets.QLineEdit(self)
|
|
|
|
self.groupBox = QtWidgets.QComboBox(self)
|
2011-10-24 20:24:40 -04:00
|
|
|
avail_groups.sort()
|
|
|
|
avail_groups.pop(avail_groups.index("Chums"))
|
|
|
|
avail_groups.insert(0, "Chums")
|
|
|
|
for g in avail_groups:
|
|
|
|
self.groupBox.addItem(g)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.newgrouplabel = QtWidgets.QLabel("Or make a new group:")
|
|
|
|
self.newgroup = QtWidgets.QLineEdit(self)
|
2011-10-24 20:24:40 -04:00
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
layout_0 = QtWidgets.QVBoxLayout()
|
2011-10-24 20:24:40 -04:00
|
|
|
layout_0.addWidget(self.title)
|
|
|
|
layout_0.addWidget(self.chumBox)
|
|
|
|
layout_0.addWidget(self.groupBox)
|
|
|
|
layout_0.addWidget(self.newgrouplabel)
|
|
|
|
layout_0.addWidget(self.newgroup)
|
|
|
|
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok = QtWidgets.QPushButton("OK", self)
|
2011-10-24 20:24:40 -04:00
|
|
|
self.ok.setDefault(True)
|
2021-03-23 17:36:43 -04:00
|
|
|
self.ok.clicked.connect(self.accept)
|
|
|
|
self.cancel = QtWidgets.QPushButton("CANCEL", self)
|
|
|
|
self.cancel.clicked.connect(self.reject)
|
|
|
|
layout_2 = QtWidgets.QHBoxLayout()
|
2011-10-24 20:24:40 -04:00
|
|
|
layout_2.addWidget(self.cancel)
|
|
|
|
layout_2.addWidget(self.ok)
|
|
|
|
|
|
|
|
layout_0.addLayout(layout_2)
|
|
|
|
|
|
|
|
self.setLayout(layout_0)
|