different files, started userlist
This commit is contained in:
parent
d815822e66
commit
2ae6763f5b
7 changed files with 336 additions and 306 deletions
3
TODO
3
TODO
|
@ -9,13 +9,14 @@ Features:
|
|||
* help menu -- about and forum
|
||||
* new sound on CEASE and BEGIN?
|
||||
-- release alpha
|
||||
* Chat rooms/browser
|
||||
* shared buddy lists - changes to the buddy list should refresh it?
|
||||
multiple clients share buddy list???
|
||||
* System tray menu
|
||||
* tab right-click menu on tabbed convos
|
||||
* comment history (up button)
|
||||
* page up/down scrolling
|
||||
* ctrl-tab should prefer new convos
|
||||
* Chat rooms/browser
|
||||
* More complex quirks: random, spelling, by-sound
|
||||
* Implement TC options
|
||||
* spell check?
|
||||
|
|
9
generic.py
Normal file
9
generic.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from PyQt4 import QtGui
|
||||
class RightClickList(QtGui.QListWidget):
|
||||
def contextMenuEvent(self, event):
|
||||
#fuckin Qt
|
||||
if event.reason() == QtGui.QContextMenuEvent.Mouse:
|
||||
listing = self.itemAt(event.pos())
|
||||
self.setCurrentItem(listing)
|
||||
self.optionsMenu.popup(event.globalPos())
|
||||
|
BIN
generic.pyc
Normal file
BIN
generic.pyc
Normal file
Binary file not shown.
310
pesterchum.py
310
pesterchum.py
|
@ -13,6 +13,10 @@ import re
|
|||
from PyQt4 import QtGui, QtCore
|
||||
import pygame
|
||||
|
||||
from pestermenus import PesterChooseQuirks, PesterChooseTheme, \
|
||||
PesterChooseProfile, PesterOptions, PesterUserlist
|
||||
from generic import RightClickList
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
class Mood(object):
|
||||
|
@ -481,293 +485,6 @@ class MultiTextDialog(QtGui.QDialog):
|
|||
return retval
|
||||
else:
|
||||
return None
|
||||
class PesterQuirkItem(QtGui.QListWidgetItem):
|
||||
def __init__(self, quirk, parent):
|
||||
QtGui.QListWidgetItem.__init__(self, parent)
|
||||
self.quirk = quirk
|
||||
self.setText(unicode(quirk))
|
||||
|
||||
def __lt__(self, quirkitem):
|
||||
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
|
||||
|
||||
class PesterQuirkList(QtGui.QListWidget):
|
||||
def __init__(self, mainwindow, parent):
|
||||
QtGui.QListWidget.__init__(self, parent)
|
||||
self.resize(400, 200)
|
||||
self.mainwindow = mainwindow
|
||||
self.setStyleSheet("background:black; color:white;")
|
||||
|
||||
for q in mainwindow.userprofile.quirks:
|
||||
item = PesterQuirkItem(q, self)
|
||||
self.addItem(item)
|
||||
self.sortItems()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def removeCurrent(self):
|
||||
i = self.currentRow()
|
||||
if i >= 0:
|
||||
self.takeItem(i)
|
||||
|
||||
class PesterChooseQuirks(QtGui.QDialog):
|
||||
def __init__(self, config, theme, parent):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
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)
|
||||
|
||||
self.addPrefixButton = QtGui.QPushButton("ADD PREFIX", self)
|
||||
self.connect(self.addPrefixButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('addPrefixDialog()'))
|
||||
self.addSuffixButton = QtGui.QPushButton("ADD SUFFIX", self)
|
||||
self.connect(self.addSuffixButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('addSuffixDialog()'))
|
||||
self.addSimpleReplaceButton = QtGui.QPushButton("SIMPLE REPLACE", self)
|
||||
self.connect(self.addSimpleReplaceButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('addSimpleReplaceDialog()'))
|
||||
self.addRegexpReplaceButton = QtGui.QPushButton("REGEXP REPLACE", self)
|
||||
self.connect(self.addRegexpReplaceButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('addRegexpDialog()'))
|
||||
layout_1 = QtGui.QHBoxLayout()
|
||||
layout_1.addWidget(self.addPrefixButton)
|
||||
layout_1.addWidget(self.addSuffixButton)
|
||||
layout_1.addWidget(self.addSimpleReplaceButton)
|
||||
layout_1.addWidget(self.addRegexpReplaceButton)
|
||||
|
||||
self.removeSelectedButton = QtGui.QPushButton("REMOVE", self)
|
||||
self.connect(self.removeSelectedButton, QtCore.SIGNAL('clicked()'),
|
||||
self.quirkList, QtCore.SLOT('removeCurrent()'))
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('accept()'))
|
||||
self.cancel = QtGui.QPushButton("CANCEL", self)
|
||||
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('reject()'))
|
||||
layout_ok = QtGui.QHBoxLayout()
|
||||
layout_ok.addWidget(self.cancel)
|
||||
layout_ok.addWidget(self.ok)
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
layout_0.addWidget(self.quirkList)
|
||||
layout_0.addLayout(layout_1)
|
||||
layout_0.addWidget(self.removeSelectedButton)
|
||||
layout_0.addLayout(layout_ok)
|
||||
self.setLayout(layout_0)
|
||||
|
||||
def quirks(self):
|
||||
return [self.quirkList.item(i).quirk for i in
|
||||
range(0,self.quirkList.count())]
|
||||
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def addPrefixDialog(self):
|
||||
pdict = MultiTextDialog("ENTER PREFIX", self, {"label": "Value:", "inputname": "value"}).getText()
|
||||
pdict["type"] = "prefix"
|
||||
prefix = pesterQuirk(pdict)
|
||||
pitem = PesterQuirkItem(prefix, self.quirkList)
|
||||
self.quirkList.addItem(pitem)
|
||||
self.quirkList.sortItems()
|
||||
@QtCore.pyqtSlot()
|
||||
def addSuffixDialog(self):
|
||||
vdict = MultiTextDialog("ENTER SUFFIX", self, {"label": "Value:", "inputname": "value"}).getText()
|
||||
vdict["type"] = "suffix"
|
||||
quirk = pesterQuirk(vdict)
|
||||
item = PesterQuirkItem(quirk, self.quirkList)
|
||||
self.quirkList.addItem(item)
|
||||
self.quirkList.sortItems()
|
||||
@QtCore.pyqtSlot()
|
||||
def addSimpleReplaceDialog(self):
|
||||
vdict = MultiTextDialog("REPLACE", self, {"label": "Replace:", "inputname": "from"}, {"label": "With:", "inputname": "to"}).getText()
|
||||
vdict["type"] = "replace"
|
||||
quirk = pesterQuirk(vdict)
|
||||
item = PesterQuirkItem(quirk, self.quirkList)
|
||||
self.quirkList.addItem(item)
|
||||
self.quirkList.sortItems()
|
||||
@QtCore.pyqtSlot()
|
||||
def addRegexpDialog(self):
|
||||
vdict = MultiTextDialog("REGEXP REPLACE", self, {"label": "Regexp:", "inputname": "from"}, {"label": "Replace With:", "inputname": "to"}).getText()
|
||||
vdict["type"] = "regexp"
|
||||
quirk = pesterQuirk(vdict)
|
||||
item = PesterQuirkItem(quirk, self.quirkList)
|
||||
self.quirkList.addItem(item)
|
||||
self.quirkList.sortItems()
|
||||
|
||||
class PesterChooseTheme(QtGui.QDialog):
|
||||
def __init__(self, config, theme, parent):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.config = config
|
||||
self.theme = theme
|
||||
self.parent = parent
|
||||
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
||||
self.setWindowTitle("Pick a theme")
|
||||
|
||||
instructions = QtGui.QLabel("Pick a theme:")
|
||||
|
||||
avail_themes = config.availableThemes()
|
||||
self.themeBox = QtGui.QComboBox(self)
|
||||
for (i, t) in enumerate(avail_themes):
|
||||
self.themeBox.addItem(t)
|
||||
if t == theme.name:
|
||||
self.themeBox.setCurrentIndex(i)
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('accept()'))
|
||||
self.cancel = QtGui.QPushButton("CANCEL", self)
|
||||
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('reject()'))
|
||||
layout_ok = QtGui.QHBoxLayout()
|
||||
layout_ok.addWidget(self.cancel)
|
||||
layout_ok.addWidget(self.ok)
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
layout_0.addWidget(instructions)
|
||||
layout_0.addWidget(self.themeBox)
|
||||
layout_0.addLayout(layout_ok)
|
||||
|
||||
self.setLayout(layout_0)
|
||||
|
||||
self.connect(self, QtCore.SIGNAL('accepted()'),
|
||||
parent, QtCore.SLOT('themeSelected()'))
|
||||
self.connect(self, QtCore.SIGNAL('rejected()'),
|
||||
parent, QtCore.SLOT('closeTheme()'))
|
||||
|
||||
class PesterChooseProfile(QtGui.QDialog):
|
||||
def __init__(self, userprofile, config, theme, parent, collision=None):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.userprofile = userprofile
|
||||
self.theme = theme
|
||||
self.config = config
|
||||
self.parent = parent
|
||||
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
||||
|
||||
self.chumHandle = QtGui.QLineEdit(self)
|
||||
self.chumHandle.setMinimumWidth(200)
|
||||
self.chumHandleLabel = QtGui.QLabel(self.theme["main/mychumhandle/label/text"], self)
|
||||
self.chumColorButton = QtGui.QPushButton(self)
|
||||
self.chumColorButton.resize(50, 20)
|
||||
self.chumColorButton.setStyleSheet("background: %s" % (userprofile.chat.colorhtml()))
|
||||
self.chumcolor = userprofile.chat.color
|
||||
self.connect(self.chumColorButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('openColorDialog()'))
|
||||
layout_1 = QtGui.QHBoxLayout()
|
||||
layout_1.addWidget(self.chumHandleLabel)
|
||||
layout_1.addWidget(self.chumHandle)
|
||||
layout_1.addWidget(self.chumColorButton)
|
||||
|
||||
# available profiles?
|
||||
avail_profiles = self.config.availableProfiles()
|
||||
if avail_profiles:
|
||||
self.profileBox = QtGui.QComboBox(self)
|
||||
self.profileBox.addItem("Choose a profile...")
|
||||
for p in avail_profiles:
|
||||
self.profileBox.addItem(p.chat.handle)
|
||||
else:
|
||||
self.profileBox = None
|
||||
|
||||
self.defaultcheck = QtGui.QCheckBox(self)
|
||||
self.defaultlabel = QtGui.QLabel("Set This Profile As Default", self)
|
||||
layout_2 = QtGui.QHBoxLayout()
|
||||
layout_2.addWidget(self.defaultlabel)
|
||||
layout_2.addWidget(self.defaultcheck)
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('validateProfile()'))
|
||||
self.cancel = QtGui.QPushButton("CANCEL", self)
|
||||
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('reject()'))
|
||||
layout_ok = QtGui.QHBoxLayout()
|
||||
layout_ok.addWidget(self.cancel)
|
||||
layout_ok.addWidget(self.ok)
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
if collision:
|
||||
collision_warning = QtGui.QLabel("%s is taken already! Pick a new profile." % (collision))
|
||||
layout_0.addWidget(collision_warning)
|
||||
layout_0.addLayout(layout_1)
|
||||
if avail_profiles:
|
||||
profileLabel = QtGui.QLabel("Or choose an existing profile:", self)
|
||||
layout_0.addWidget(profileLabel)
|
||||
layout_0.addWidget(self.profileBox)
|
||||
layout_0.addLayout(layout_ok)
|
||||
layout_0.addLayout(layout_2)
|
||||
self.errorMsg = QtGui.QLabel(self)
|
||||
self.errorMsg.setStyleSheet("color:red;")
|
||||
layout_0.addWidget(self.errorMsg)
|
||||
self.setLayout(layout_0)
|
||||
|
||||
self.connect(self, QtCore.SIGNAL('accepted()'),
|
||||
parent, QtCore.SLOT('profileSelected()'))
|
||||
self.connect(self, QtCore.SIGNAL('rejected()'),
|
||||
parent, QtCore.SLOT('closeProfile()'))
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def openColorDialog(self):
|
||||
self.colorDialog = QtGui.QColorDialog(self)
|
||||
color = self.colorDialog.getColor(initial=self.userprofile.chat.color)
|
||||
self.chumColorButton.setStyleSheet("background: %s" % color.name())
|
||||
self.chumcolor = color
|
||||
self.colorDialog = None
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def validateProfile(self):
|
||||
if not self.profileBox or self.profileBox.currentIndex() == 0:
|
||||
handle = unicode(self.chumHandle.text())
|
||||
if not PesterProfile.checkLength(handle):
|
||||
self.errorMsg.setText("PROFILE HANDLE IS TOO LONG")
|
||||
return
|
||||
if not PesterProfile.checkValid(handle):
|
||||
self.errorMsg.setText("NOT A VALID CHUMTAG")
|
||||
return
|
||||
self.accept()
|
||||
|
||||
class PesterOptions(QtGui.QDialog):
|
||||
def __init__(self, config, theme, parent):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setModal(False)
|
||||
self.config = config
|
||||
self.theme = theme
|
||||
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
||||
|
||||
self.tabcheck = QtGui.QCheckBox(self)
|
||||
if self.config.tabs():
|
||||
self.tabcheck.setChecked(True)
|
||||
self.tablabel = QtGui.QLabel("Tabbed Conversations", self)
|
||||
layout_1 = QtGui.QHBoxLayout()
|
||||
layout_1.addWidget(self.tablabel)
|
||||
layout_1.addWidget(self.tabcheck)
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('accept()'))
|
||||
self.cancel = QtGui.QPushButton("CANCEL", self)
|
||||
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('reject()'))
|
||||
layout_2 = QtGui.QHBoxLayout()
|
||||
layout_2.addWidget(self.cancel)
|
||||
layout_2.addWidget(self.ok)
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
layout_0.addLayout(layout_1)
|
||||
layout_0.addLayout(layout_2)
|
||||
|
||||
self.setLayout(layout_0)
|
||||
|
||||
class WMButton(QtGui.QPushButton):
|
||||
def __init__(self, icon, parent=None):
|
||||
|
@ -802,7 +519,7 @@ class chumListing(QtGui.QListWidgetItem):
|
|||
h2 = cl.handle.lower()
|
||||
return (h1 < h2)
|
||||
|
||||
class chumArea(QtGui.QListWidget):
|
||||
class chumArea(RightClickList):
|
||||
def __init__(self, chums, parent=None):
|
||||
QtGui.QListWidget.__init__(self, parent)
|
||||
self.mainwindow = parent
|
||||
|
@ -861,12 +578,6 @@ class chumArea(QtGui.QListWidget):
|
|||
chumlistings = [self.item(i) for i in range(0, self.count())]
|
||||
for c in chumlistings:
|
||||
c.changeTheme(theme)
|
||||
def contextMenuEvent(self, event):
|
||||
#fuckin Qt
|
||||
if event.reason() == QtGui.QContextMenuEvent.Mouse:
|
||||
chumlisting = self.itemAt(event.pos())
|
||||
self.setCurrentItem(chumlisting)
|
||||
self.optionsMenu.popup(event.globalPos())
|
||||
@QtCore.pyqtSlot()
|
||||
def activateChum(self):
|
||||
self.itemActivated.emit(self.currentItem())
|
||||
|
@ -906,11 +617,11 @@ class trollSlum(chumArea):
|
|||
chumLabel = chumListing(c, self.mainwindow)
|
||||
self.addItem(chumLabel)
|
||||
|
||||
self.blockedMenu = QtGui.QMenu(self)
|
||||
self.optionsMenu = QtGui.QMenu(self)
|
||||
self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
|
||||
self.connect(self.unblockchum, QtCore.SIGNAL('triggered()'),
|
||||
self, QtCore.SIGNAL('unblockChumSignal()'))
|
||||
self.blockedMenu.addAction(self.unblockchum)
|
||||
self.optionsMenu.addAction(self.unblockchum)
|
||||
|
||||
self.sortItems()
|
||||
def changeTheme(self, theme):
|
||||
|
@ -922,13 +633,6 @@ class trollSlum(chumArea):
|
|||
for c in chumlistings:
|
||||
c.changeTheme(theme)
|
||||
|
||||
def contextMenuEvent(self, event):
|
||||
#fuckin Qt
|
||||
if event.reason() == QtGui.QContextMenuEvent.Mouse:
|
||||
chumlisting = self.itemAt(event.pos())
|
||||
self.setCurrentItem(chumlisting)
|
||||
self.blockedMenu.popup(event.globalPos())
|
||||
|
||||
unblockChumSignal = QtCore.pyqtSignal(QtCore.QString)
|
||||
|
||||
class TrollSlumWindow(QtGui.QFrame):
|
||||
|
|
316
pestermenus.py
Normal file
316
pestermenus.py
Normal file
|
@ -0,0 +1,316 @@
|
|||
from PyQt4 import QtGui, QtCore
|
||||
|
||||
from generic import RightClickList
|
||||
|
||||
class PesterQuirkItem(QtGui.QListWidgetItem):
|
||||
def __init__(self, quirk, parent):
|
||||
QtGui.QListWidgetItem.__init__(self, parent)
|
||||
self.quirk = quirk
|
||||
self.setText(unicode(quirk))
|
||||
|
||||
def __lt__(self, quirkitem):
|
||||
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
|
||||
|
||||
class PesterQuirkList(QtGui.QListWidget):
|
||||
def __init__(self, mainwindow, parent):
|
||||
QtGui.QListWidget.__init__(self, parent)
|
||||
self.resize(400, 200)
|
||||
self.mainwindow = mainwindow
|
||||
self.setStyleSheet("background:black; color:white;")
|
||||
|
||||
for q in mainwindow.userprofile.quirks:
|
||||
item = PesterQuirkItem(q, self)
|
||||
self.addItem(item)
|
||||
self.sortItems()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def removeCurrent(self):
|
||||
i = self.currentRow()
|
||||
if i >= 0:
|
||||
self.takeItem(i)
|
||||
|
||||
class PesterChooseQuirks(QtGui.QDialog):
|
||||
def __init__(self, config, theme, parent):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
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)
|
||||
|
||||
self.addPrefixButton = QtGui.QPushButton("ADD PREFIX", self)
|
||||
self.connect(self.addPrefixButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('addPrefixDialog()'))
|
||||
self.addSuffixButton = QtGui.QPushButton("ADD SUFFIX", self)
|
||||
self.connect(self.addSuffixButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('addSuffixDialog()'))
|
||||
self.addSimpleReplaceButton = QtGui.QPushButton("SIMPLE REPLACE", self)
|
||||
self.connect(self.addSimpleReplaceButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('addSimpleReplaceDialog()'))
|
||||
self.addRegexpReplaceButton = QtGui.QPushButton("REGEXP REPLACE", self)
|
||||
self.connect(self.addRegexpReplaceButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('addRegexpDialog()'))
|
||||
layout_1 = QtGui.QHBoxLayout()
|
||||
layout_1.addWidget(self.addPrefixButton)
|
||||
layout_1.addWidget(self.addSuffixButton)
|
||||
layout_1.addWidget(self.addSimpleReplaceButton)
|
||||
layout_1.addWidget(self.addRegexpReplaceButton)
|
||||
|
||||
self.removeSelectedButton = QtGui.QPushButton("REMOVE", self)
|
||||
self.connect(self.removeSelectedButton, QtCore.SIGNAL('clicked()'),
|
||||
self.quirkList, QtCore.SLOT('removeCurrent()'))
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('accept()'))
|
||||
self.cancel = QtGui.QPushButton("CANCEL", self)
|
||||
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('reject()'))
|
||||
layout_ok = QtGui.QHBoxLayout()
|
||||
layout_ok.addWidget(self.cancel)
|
||||
layout_ok.addWidget(self.ok)
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
layout_0.addWidget(self.quirkList)
|
||||
layout_0.addLayout(layout_1)
|
||||
layout_0.addWidget(self.removeSelectedButton)
|
||||
layout_0.addLayout(layout_ok)
|
||||
self.setLayout(layout_0)
|
||||
|
||||
def quirks(self):
|
||||
return [self.quirkList.item(i).quirk for i in
|
||||
range(0,self.quirkList.count())]
|
||||
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def addPrefixDialog(self):
|
||||
pdict = MultiTextDialog("ENTER PREFIX", self, {"label": "Value:", "inputname": "value"}).getText()
|
||||
pdict["type"] = "prefix"
|
||||
prefix = pesterQuirk(pdict)
|
||||
pitem = PesterQuirkItem(prefix, self.quirkList)
|
||||
self.quirkList.addItem(pitem)
|
||||
self.quirkList.sortItems()
|
||||
@QtCore.pyqtSlot()
|
||||
def addSuffixDialog(self):
|
||||
vdict = MultiTextDialog("ENTER SUFFIX", self, {"label": "Value:", "inputname": "value"}).getText()
|
||||
vdict["type"] = "suffix"
|
||||
quirk = pesterQuirk(vdict)
|
||||
item = PesterQuirkItem(quirk, self.quirkList)
|
||||
self.quirkList.addItem(item)
|
||||
self.quirkList.sortItems()
|
||||
@QtCore.pyqtSlot()
|
||||
def addSimpleReplaceDialog(self):
|
||||
vdict = MultiTextDialog("REPLACE", self, {"label": "Replace:", "inputname": "from"}, {"label": "With:", "inputname": "to"}).getText()
|
||||
vdict["type"] = "replace"
|
||||
quirk = pesterQuirk(vdict)
|
||||
item = PesterQuirkItem(quirk, self.quirkList)
|
||||
self.quirkList.addItem(item)
|
||||
self.quirkList.sortItems()
|
||||
@QtCore.pyqtSlot()
|
||||
def addRegexpDialog(self):
|
||||
vdict = MultiTextDialog("REGEXP REPLACE", self, {"label": "Regexp:", "inputname": "from"}, {"label": "Replace With:", "inputname": "to"}).getText()
|
||||
vdict["type"] = "regexp"
|
||||
quirk = pesterQuirk(vdict)
|
||||
item = PesterQuirkItem(quirk, self.quirkList)
|
||||
self.quirkList.addItem(item)
|
||||
self.quirkList.sortItems()
|
||||
|
||||
class PesterChooseTheme(QtGui.QDialog):
|
||||
def __init__(self, config, theme, parent):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.config = config
|
||||
self.theme = theme
|
||||
self.parent = parent
|
||||
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
||||
self.setWindowTitle("Pick a theme")
|
||||
|
||||
instructions = QtGui.QLabel("Pick a theme:")
|
||||
|
||||
avail_themes = config.availableThemes()
|
||||
self.themeBox = QtGui.QComboBox(self)
|
||||
for (i, t) in enumerate(avail_themes):
|
||||
self.themeBox.addItem(t)
|
||||
if t == theme.name:
|
||||
self.themeBox.setCurrentIndex(i)
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('accept()'))
|
||||
self.cancel = QtGui.QPushButton("CANCEL", self)
|
||||
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('reject()'))
|
||||
layout_ok = QtGui.QHBoxLayout()
|
||||
layout_ok.addWidget(self.cancel)
|
||||
layout_ok.addWidget(self.ok)
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
layout_0.addWidget(instructions)
|
||||
layout_0.addWidget(self.themeBox)
|
||||
layout_0.addLayout(layout_ok)
|
||||
|
||||
self.setLayout(layout_0)
|
||||
|
||||
self.connect(self, QtCore.SIGNAL('accepted()'),
|
||||
parent, QtCore.SLOT('themeSelected()'))
|
||||
self.connect(self, QtCore.SIGNAL('rejected()'),
|
||||
parent, QtCore.SLOT('closeTheme()'))
|
||||
|
||||
class PesterChooseProfile(QtGui.QDialog):
|
||||
def __init__(self, userprofile, config, theme, parent, collision=None):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.userprofile = userprofile
|
||||
self.theme = theme
|
||||
self.config = config
|
||||
self.parent = parent
|
||||
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
||||
|
||||
self.chumHandle = QtGui.QLineEdit(self)
|
||||
self.chumHandle.setMinimumWidth(200)
|
||||
self.chumHandleLabel = QtGui.QLabel(self.theme["main/mychumhandle/label/text"], self)
|
||||
self.chumColorButton = QtGui.QPushButton(self)
|
||||
self.chumColorButton.resize(50, 20)
|
||||
self.chumColorButton.setStyleSheet("background: %s" % (userprofile.chat.colorhtml()))
|
||||
self.chumcolor = userprofile.chat.color
|
||||
self.connect(self.chumColorButton, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('openColorDialog()'))
|
||||
layout_1 = QtGui.QHBoxLayout()
|
||||
layout_1.addWidget(self.chumHandleLabel)
|
||||
layout_1.addWidget(self.chumHandle)
|
||||
layout_1.addWidget(self.chumColorButton)
|
||||
|
||||
# available profiles?
|
||||
avail_profiles = self.config.availableProfiles()
|
||||
if avail_profiles:
|
||||
self.profileBox = QtGui.QComboBox(self)
|
||||
self.profileBox.addItem("Choose a profile...")
|
||||
for p in avail_profiles:
|
||||
self.profileBox.addItem(p.chat.handle)
|
||||
else:
|
||||
self.profileBox = None
|
||||
|
||||
self.defaultcheck = QtGui.QCheckBox(self)
|
||||
self.defaultlabel = QtGui.QLabel("Set This Profile As Default", self)
|
||||
layout_2 = QtGui.QHBoxLayout()
|
||||
layout_2.addWidget(self.defaultlabel)
|
||||
layout_2.addWidget(self.defaultcheck)
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('validateProfile()'))
|
||||
self.cancel = QtGui.QPushButton("CANCEL", self)
|
||||
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('reject()'))
|
||||
layout_ok = QtGui.QHBoxLayout()
|
||||
layout_ok.addWidget(self.cancel)
|
||||
layout_ok.addWidget(self.ok)
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
if collision:
|
||||
collision_warning = QtGui.QLabel("%s is taken already! Pick a new profile." % (collision))
|
||||
layout_0.addWidget(collision_warning)
|
||||
layout_0.addLayout(layout_1)
|
||||
if avail_profiles:
|
||||
profileLabel = QtGui.QLabel("Or choose an existing profile:", self)
|
||||
layout_0.addWidget(profileLabel)
|
||||
layout_0.addWidget(self.profileBox)
|
||||
layout_0.addLayout(layout_ok)
|
||||
layout_0.addLayout(layout_2)
|
||||
self.errorMsg = QtGui.QLabel(self)
|
||||
self.errorMsg.setStyleSheet("color:red;")
|
||||
layout_0.addWidget(self.errorMsg)
|
||||
self.setLayout(layout_0)
|
||||
|
||||
self.connect(self, QtCore.SIGNAL('accepted()'),
|
||||
parent, QtCore.SLOT('profileSelected()'))
|
||||
self.connect(self, QtCore.SIGNAL('rejected()'),
|
||||
parent, QtCore.SLOT('closeProfile()'))
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def openColorDialog(self):
|
||||
self.colorDialog = QtGui.QColorDialog(self)
|
||||
color = self.colorDialog.getColor(initial=self.userprofile.chat.color)
|
||||
self.chumColorButton.setStyleSheet("background: %s" % color.name())
|
||||
self.chumcolor = color
|
||||
self.colorDialog = None
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def validateProfile(self):
|
||||
if not self.profileBox or self.profileBox.currentIndex() == 0:
|
||||
handle = unicode(self.chumHandle.text())
|
||||
if not PesterProfile.checkLength(handle):
|
||||
self.errorMsg.setText("PROFILE HANDLE IS TOO LONG")
|
||||
return
|
||||
if not PesterProfile.checkValid(handle):
|
||||
self.errorMsg.setText("NOT A VALID CHUMTAG")
|
||||
return
|
||||
self.accept()
|
||||
|
||||
class PesterOptions(QtGui.QDialog):
|
||||
def __init__(self, config, theme, parent):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setModal(False)
|
||||
self.config = config
|
||||
self.theme = theme
|
||||
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
||||
|
||||
self.tabcheck = QtGui.QCheckBox(self)
|
||||
if self.config.tabs():
|
||||
self.tabcheck.setChecked(True)
|
||||
self.tablabel = QtGui.QLabel("Tabbed Conversations", self)
|
||||
layout_1 = QtGui.QHBoxLayout()
|
||||
layout_1.addWidget(self.tablabel)
|
||||
layout_1.addWidget(self.tabcheck)
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('accept()'))
|
||||
self.cancel = QtGui.QPushButton("CANCEL", self)
|
||||
self.connect(self.cancel, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('reject()'))
|
||||
layout_2 = QtGui.QHBoxLayout()
|
||||
layout_2.addWidget(self.cancel)
|
||||
layout_2.addWidget(self.ok)
|
||||
|
||||
layout_0 = QtGui.QVBoxLayout()
|
||||
layout_0.addLayout(layout_1)
|
||||
layout_0.addLayout(layout_2)
|
||||
|
||||
self.setLayout(layout_0)
|
||||
|
||||
class PesterUserlist(QtGui.QDialog):
|
||||
def __init__(self, config, theme, parent):
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.setModal(False)
|
||||
self.config = config
|
||||
self.theme = theme
|
||||
self.setStyleSheet(self.theme["main/defaultwindow/style"])
|
||||
self.resize([200, 600])
|
||||
|
||||
self.label = QtGui.QLabel("USERLIST")
|
||||
self.userarea = RightClickList(self)
|
||||
self.userarea.setStyleSheet(self.theme["main/chums/style"])
|
||||
|
||||
self.ok = QtGui.QPushButton("OK", self)
|
||||
self.ok.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
self, QtCore.SLOT('accept()'))
|
||||
|
||||
layout_0 = QVBoxLayout()
|
||||
layout.addWidget(self.label)
|
||||
layout.addWidget(self.userarea)
|
||||
layout.addWidget(self.ok)
|
||||
|
||||
self.setLayout(layout)
|
BIN
pestermenus.pyc
Normal file
BIN
pestermenus.pyc
Normal file
Binary file not shown.
|
@ -30,7 +30,7 @@
|
|||
"switch": "Trolltag",
|
||||
"theme": "Theme",
|
||||
"color": "Hemospectrum",
|
||||
"block": "Trollslum",
|
||||
"block": "Chumpdump",
|
||||
"quirks": "Annoying"},
|
||||
"rclickchumlist": {"pester": "Troll",
|
||||
"removechum": "Trash",
|
||||
|
@ -91,7 +91,7 @@
|
|||
"trollslum": {
|
||||
"style": "background: rgb(190, 19, 4); font-family: 'Arial'",
|
||||
"size": [175, 461],
|
||||
"label": { "text": "TROLLSLUM",
|
||||
"label": { "text": "Chumpdump",
|
||||
"style": "color: rgba(0, 0, 0, 100%) ;font:bold; font-family: 'Arial';border: 0px;" },
|
||||
"chumroll": {"style": "border: 0px; background-color: white; padding: 5px; font-family: 'Arial';selection-background-color:rgb(200,200,200); " }
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue