try: from PyQt6 import QtGui, QtWidgets except ImportError: print("PyQt5 fallback (generic.py)") from PyQt5 import QtGui, QtWidgets from datetime import timedelta class mysteryTime(timedelta): def __sub__(self, other): return self def __eq__(self, other): return isinstance(other, mysteryTime) def __neq__(self, other): return not isinstance(other, mysteryTime) class CaseInsensitiveDict(dict): def __setitem__(self, key, value): super().__setitem__(key.lower(), value) def __getitem__(self, key): return super().__getitem__(key.lower()) def __contains__(self, key): return super().__contains__(key.lower()) def __delitem__(self, key): super().__delitem__(key.lower()) class PesterList(list): def __init__(self, l): self.extend(l) class PesterIcon(QtGui.QIcon): def __init__(self, *x): super().__init__(x[0]) if isinstance(x[0], str): self.icon_pixmap = QtGui.QPixmap(x[0]) else: self.icon_pixmap = None def realsize(self): if self.icon_pixmap: return self.icon_pixmap.size() else: try: return self.availableSizes()[0] except IndexError: return None class RightClickList(QtWidgets.QListWidget): def contextMenuEvent(self, event): # fuckin Qt <--- I feel that 5: self.moveupdate = 0 self.update() def mousePressEvent(self, event): # Assuming everything is supported, we only need this function to call "self.windowHandle().startSystemMove()". # If not supported, startSystemMove() returns False and the legacy code runs anyway. try: if not self.windowHandle().startSystemMove(): if event.button() == 1: self.moving = event.globalPos() - self.pos() except AttributeError as e: print("PyQt <= 5.14?") print(e) if event.button() == 1: self.moving = event.globalPos() - self.pos() def mouseReleaseEvent(self, event): if event.button() == 1: self.update() self.moving = None class WMButton(QtWidgets.QPushButton): def __init__(self, icon, parent=None): super().__init__(icon, "", parent) self.setIconSize(icon.realsize()) self.resize(icon.realsize()) self.setFlat(True) self.setStyleSheet("QPushButton { padding: 0px; }") self.setAutoDefault(False)