toast fix (referenced from original repo)

This commit is contained in:
BuildTools 2021-03-24 19:20:47 +01:00
parent 7a75d43f65
commit 0f1e15032b
2 changed files with 9 additions and 6 deletions

View file

@ -69,8 +69,8 @@ if vnum.find(".", vnum.find(".")+1) != -1:
minor = int(vnum[vnum.find(".")+1:vnum.find(".", vnum.find(".")+1)]) minor = int(vnum[vnum.find(".")+1:vnum.find(".", vnum.find(".")+1)])
else: else:
minor = int(vnum[vnum.find(".")+1:]) minor = int(vnum[vnum.find(".")+1:])
if not ((major > 4) or (major == 4 and minor >= 6)): if not ((major > 5) or (major == 5 and minor >= 0)):
print("ERROR: Pesterchum requires Qt version >= 4.6") print("ERROR: Pesterchum requires at least Qt version >= 5.0")
print("You currently have version " + vnum + ". Please upgrade Qt.") print("You currently have version " + vnum + ". Please upgrade Qt.")
exit() exit()

View file

@ -2,6 +2,7 @@ import inspect
import threading import threading
import time, os import time, os
import ostools import ostools
import logging
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
try: try:
@ -178,7 +179,9 @@ class ToastMachine(object):
class PesterToast(QtWidgets.QWidget, DefaultToast): class PesterToast(QtWidgets.QWidget, DefaultToast):
def __init__(self, machine, title, msg, icon, time=3000, parent=None): def __init__(self, machine, title, msg, icon, time=3000, parent=None):
QtWidgets.QWidget.__init__(self, parent) logging.info(isinstance(parent, QtWidgets.QWidget))
kwds = dict(machine=machine, title=title, msg=msg, icon=icon)
super().__init__(parent, **kwds)
self.machine = machine self.machine = machine
self.time = time self.time = time
@ -243,7 +246,7 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
o = QtWidgets.QApplication.desktop().screenGeometry(self).bottomRight() o = QtWidgets.QApplication.desktop().screenGeometry(self).bottomRight()
anim.setStartValue(p.y() - o.y()) anim.setStartValue(p.y() - o.y())
anim.setEndValue(100) anim.setEndValue(100)
anim.valueChanged[QVariant].connect(self.updateBottomLeftAnimation) anim.valueChanged[QtCore.QVariant].connect(self.updateBottomLeftAnimation)
self.byebye = False self.byebye = False
@ -266,7 +269,7 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def reverseTrigger(self): def reverseTrigger(self):
if self.time >= 0: if self.time >= 0:
QtCore.QTimer.singleShot(self.time, self, QtCore.SLOT('reverseStart()')) QtCore.QTimer.singleShot(self.time, self.reverseStart)
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def reverseStart(self): def reverseStart(self):
@ -283,7 +286,7 @@ class PesterToast(QtWidgets.QWidget, DefaultToast):
def updateBottomLeftAnimation(self, value): def updateBottomLeftAnimation(self, value):
p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight() p = QtWidgets.QApplication.desktop().availableGeometry(self).bottomRight()
val = float(self.height())/100 val = float(self.height())/100
self.move(p.x()-self.width(), p.y() - (value.toInt()[0] * val) +1) self.move(p.x()-self.width(), p.y() - (value * val) +1)
self.layout().setSpacing(0) self.layout().setSpacing(0)
QtWidgets.QWidget.show(self) QtWidgets.QWidget.show(self)