Make animation time instead of update dependant

CURA-6823
This commit is contained in:
Jaime van Kessel 2019-12-24 12:53:19 +01:00
parent d110d04c36
commit 41c953112a
No known key found for this signature in database
GPG Key ID: 3710727397403C91

View File

@ -9,6 +9,7 @@ from UM.Resources import Resources
from UM.Application import Application
from cura import ApplicationMetadata
import time
class CuraSplashScreen(QSplashScreen):
def __init__(self):
@ -34,15 +35,20 @@ class CuraSplashScreen(QSplashScreen):
self._change_timer.setSingleShot(False)
self._change_timer.timeout.connect(self.updateLoadingImage)
self._last_update_time = None
def show(self):
super().show()
self._last_update_time = time.time()
self._change_timer.start()
def updateLoadingImage(self):
if self._to_stop:
return
self._loading_image_rotation_angle -= 10
time_since_last_update = time.time() - self._last_update_time
self._last_update_time = time.time()
# Since we don't know how much time actually passed, check how many intervals of 50 we had.
self._loading_image_rotation_angle -= 10 * (time_since_last_update * 1000 / 50)
self.repaint()
# Override the mousePressEvent so the splashscreen doesn't disappear when clicked