Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, parent, **options):
icon = PesterIcon(options["icon"])
QtWidgets.QPushButton.__init__(self, icon, options["text"], parent)
self.setIconSize(icon.realsize())
self.setFlat(True)
self.resize(*options["size"])
self.move(*options["loc"])
self.unselectedSheet = options["style"]
self.selectedSheet = options["selected"]
self.setStyleSheet(self.unselectedSheet)
self.mainwindow = parent
self.mood = Mood(options["mood"])
def setSelected(self, selected):
def initTheme(self, theme):
self.resize(*theme["memos/size"])
self.setStyleSheet("QFrame#%s { %s }" % (self.channel, theme["memos/style"]))
self.setWindowIcon(PesterIcon(theme["memos/memoicon"]))
t = Template(theme["memos/label/text"])
if self.mainwindow.advanced and hasattr(self, 'modes'):
self.channelLabel.setText(t.safe_substitute(channel=self.channel) + "(%s)" % (self.modes))
else:
self.channelLabel.setText(t.safe_substitute(channel=self.channel))
self.channelLabel.setStyleSheet(theme["memos/label/style"])
self.channelLabel.setAlignment(self.aligndict["h"][theme["memos/label/align/h"]] | self.aligndict["v"][theme["memos/label/align/v"]])
self.channelLabel.setMaximumHeight(theme["memos/label/maxheight"])
self.channelLabel.setMinimumHeight(theme["memos/label/minheight"])
self.userlist.optionsMenu.setStyleSheet(theme["main/defaultwindow/style"])
scrolls = "width: 12px; height: 12px; border: 0; padding: 0;"
if "main/chums/scrollbar" in theme:
self.userlist.setStyleSheet("QListWidget { %s } QScrollBar { %s } QScrollBar::handle { %s } QScrollBar::add-line { %s } QScrollBar::sub-line { %s } QScrollBar:up-arrow { %s } QScrollBar:down-arrow { %s }" % (theme["memos/userlist/style"], theme["main/chums/scrollbar/style"] + scrolls, theme["main/chums/scrollbar/handle"], theme["main/chums/scrollbar/downarrow"], theme["main/chums/scrollbar/uparrow"], theme["main/chums/scrollbar/uarrowstyle"], theme["main/chums/scrollbar/darrowstyle"] ))
elif "convo/scrollbar" in theme:
self.helpAction = QtWidgets.QAction(self.theme["main/menus/help/help"], self, triggered=self.launchHelp)
self.botAction = QtWidgets.QAction(self.theme["main/menus/help/calsprite"], self, triggered=self.loadCalsprite)
self.nickServAction = QtWidgets.QAction(self.theme["main/menus/help/nickserv"], self, triggered=self.loadNickServ)
self.chanServAction = QtWidgets.QAction(self.theme["main/menus/help/chanserv"], self, triggered=self.loadChanServ)
self.aboutAction = QtWidgets.QAction(self.theme["main/menus/help/about"], self, triggered=self.aboutPesterchum)
self.reportBugAction = QtWidgets.QAction("REPORT BUG", self, triggered=self.reportBug)
helpmenu = self.menu.addMenu(self.theme["main/menus/help/_name"])
self.helpmenu = helpmenu
self.helpmenu.addAction(self.helpAction)
self.helpmenu.addAction(self.botAction)
self.helpmenu.addAction(self.chanServAction)
self.helpmenu.addAction(self.nickServAction)
self.helpmenu.addAction(self.aboutAction)
self.helpmenu.addAction(self.reportBugAction)
self.closeButton = WMButton(PesterIcon(self.theme["main/close/image"]), self)
self.setButtonAction(self.closeButton, self.config.closeAction(), -1)
self.miniButton = WMButton(PesterIcon(self.theme["main/minimize/image"]), self)
self.setButtonAction(self.miniButton, self.config.minimizeAction(), -1)
self.namesdb = CaseInsensitiveDict()
self.chumdb = PesterProfileDB()
chums = [PesterProfile(c, chumdb=self.chumdb) for c in set(self.config.chums())]
self.chumList = chumArea(chums, self)
self.chumList.itemActivated.connect(self.pesterSelectedChum)
self.chumList.removeChumSignal.connect(self.removeChum)
self.chumList.blockChumSignal.connect(self.blockChum)
self.addChumButton = QtWidgets.QPushButton(self.theme["main/addchum/text"], self, clicked=self.addChumWindow)
self.pesterButton = QtWidgets.QPushButton(self.theme["main/pester/text"], self, clicked=self.pesterSelectedChum)
self.blockButton = QtWidgets.QPushButton(self.theme["main/block/text"], self, clicked=self.blockSelectedChum)
def initTheme(self, theme):
self.resize(*theme["main/size"])
self.setWindowIcon(PesterIcon(theme["main/icon"]))
self.setWindowTitle(theme["main/windowtitle"])
self.setStyleSheet("QFrame#main { %s }" % (theme["main/style"]))
self.backgroundImage = QtGui.QPixmap(theme["main/background-image"])
self.backgroundMask = self.backgroundImage.mask()
self.setMask(self.backgroundMask)
self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " % (theme["main/menubar/style"], theme["main/menu/menuitem"]) + "QMenu { background: transparent; %s } QMenu::item::selected { %s } QMenu::item::disabled { %s }" % (theme["main/menu/style"], theme["main/menu/selected"], theme["main/menu/disabled"]))
newcloseicon = PesterIcon(theme["main/close/image"])
self.closeButton.setIcon(newcloseicon)
self.closeButton.setIconSize(newcloseicon.realsize())
self.closeButton.resize(newcloseicon.realsize())
self.closeButton.move(*theme["main/close/loc"])
newminiicon = PesterIcon(theme["main/minimize/image"])
self.miniButton.setIcon(newminiicon)
self.miniButton.setIconSize(newminiicon.realsize())
self.miniButton.resize(newminiicon.realsize())
self.miniButton.move(*theme["main/minimize/loc"])
# menus
self.menu.move(*theme["main/menu/loc"])
self.talk.setText(theme["main/menus/client/talk"])
self.logv.setText(theme["main/menus/client/logviewer"])
self.grps.setText(theme["main/menus/client/addgroup"])
self.rand.setText(self.theme["main/menus/client/randen"])
self.opts.setText(theme["main/menus/client/options"])
self.exitaction.setText(theme["main/menus/client/exit"])
self.userlistaction.setText(theme["main/menus/client/userlist"])
self.memoaction.setText(theme["main/menus/client/memos"])
self.importaction.setText(theme["main/menus/client/import"])
self.idleaction.setText(theme["main/menus/client/idle"])
def iconCrap(self, c, down=True):
for m in (self.umodes if down else reversed(self.umodes)):
if eval("c."+m):
if m == "box":
icon = PesterIcon("smilies/box.png")
else:
icon = PesterIcon(self.mainwindow.theme["memos/"+m+"/icon"])
c.setIcon(icon)
return
icon = QtGui.QIcon()
c.setIcon(icon)
def icon(self, theme):
try:
f = theme["main/chums/moods"][self.name()]["icon"]
except KeyError:
return PesterIcon(theme["main/chums/moods/chummy/icon"])
return PesterIcon(f)
if self.tabconvo:
self.tabconvo.changeTheme(theme)
if self.tabmemo:
self.tabmemo.changeTheme(theme)
for c in self.convos.values():
c.changeTheme(theme)
for m in self.memos.values():
m.changeTheme(theme)
if hasattr(self, 'trollslum') and self.trollslum:
self.trollslum.changeTheme(theme)
if hasattr(self, 'allusers') and self.allusers:
self.allusers.changeTheme(theme)
if self.config.ghostchum():
self.theme["main"]["icon"] = "themes/pesterchum/pesterdunk.png"
self.theme["main"]["newmsgicon"] = "themes/pesterchum/ghostchum.png"
self.setWindowIcon(PesterIcon(self.theme["main/icon"]))
# system tray icon
self.updateSystemTray()
def initTheme(self, theme):
self.resize(*theme["main/size"])
self.setWindowIcon(PesterIcon(theme["main/icon"]))
self.setWindowTitle(theme["main/windowtitle"])
self.setStyleSheet("QFrame#main { %s }" % (theme["main/style"]))
self.backgroundImage = QtGui.QPixmap(theme["main/background-image"])
self.backgroundMask = self.backgroundImage.mask()
self.setMask(self.backgroundMask)
self.menu.setStyleSheet("QMenuBar { background: transparent; %s } QMenuBar::item { background: transparent; %s } " % (theme["main/menubar/style"], theme["main/menu/menuitem"]) + "QMenu { background: transparent; %s } QMenu::item::selected { %s } QMenu::item::disabled { %s }" % (theme["main/menu/style"], theme["main/menu/selected"], theme["main/menu/disabled"]))
newcloseicon = PesterIcon(theme["main/close/image"])
self.closeButton.setIcon(newcloseicon)
self.closeButton.setIconSize(newcloseicon.realsize())
self.closeButton.resize(newcloseicon.realsize())
self.closeButton.move(*theme["main/close/loc"])
newminiicon = PesterIcon(theme["main/minimize/image"])
self.miniButton.setIcon(newminiicon)
self.miniButton.setIconSize(newminiicon.realsize())
self.miniButton.resize(newminiicon.realsize())
self.miniButton.move(*theme["main/minimize/loc"])