diff options
author | Jaime van Kessel <nallath@gmail.com> | 2020-01-03 12:17:54 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2020-01-03 12:17:54 +0300 |
commit | 5da77472e7e3451e8494691799ef2fcee2203938 (patch) | |
tree | d94613264c564f4a17c1d8f0ec07926f46bc584e /cura/UI | |
parent | c261065d68b1b62c7188e255e0486487149ccc17 (diff) |
Add some timers to sceneChanged
Diffstat (limited to 'cura/UI')
-rw-r--r-- | cura/UI/PrintInformation.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/cura/UI/PrintInformation.py b/cura/UI/PrintInformation.py index e33ab13b69..c39314dc02 100644 --- a/cura/UI/PrintInformation.py +++ b/cura/UI/PrintInformation.py @@ -7,7 +7,7 @@ import os import unicodedata from typing import Dict, List, Optional, TYPE_CHECKING -from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty, pyqtSlot +from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty, pyqtSlot, QTimer from UM.Logger import Logger from UM.Qt.Duration import Duration @@ -47,7 +47,12 @@ class PrintInformation(QObject): if self._backend: self._backend.printDurationMessage.connect(self._onPrintDurationMessage) - self._application.getController().getScene().sceneChanged.connect(self._onSceneChanged) + self._application.getController().getScene().sceneChanged.connect(self._onSceneChangedDelayed) + + self._change_timer = QTimer() + self._change_timer.setInterval(100) + self._change_timer.setSingleShot(True) + self._change_timer.timeout.connect(self._onSceneChanged) self._is_user_specified_job_name = False self._base_name = "" @@ -418,12 +423,14 @@ class PrintInformation(QObject): self._onPrintDurationMessage(build_plate, temp_message, temp_material_amounts) - ## Listen to scene changes to check if we need to reset the print information - def _onSceneChanged(self, scene_node: SceneNode) -> None: + def _onSceneChangedDelayed(self, scene_node: SceneNode) -> None: # Ignore any changes that are not related to sliceable objects - if not isinstance(scene_node, SceneNode)\ - or not scene_node.callDecoration("isSliceable")\ + if not isinstance(scene_node, SceneNode) \ + or not scene_node.callDecoration("isSliceable") \ or not scene_node.callDecoration("getBuildPlateNumber") == self._active_build_plate: return + self._change_timer.start() + ## Listen to scene changes to check if we need to reset the print information + def _onSceneChanged(self) -> None: self.setToZeroPrintInformation(self._active_build_plate) |