mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Move _error_check_timer initialization to a separate function
This simplifies understanding the class __init__ function
This commit is contained in:
parent
a7b1052b27
commit
b13b7a892d
1 changed files with 14 additions and 6 deletions
|
@ -45,16 +45,12 @@ class MachineErrorChecker(QObject):
|
||||||
|
|
||||||
self._start_time = 0. # measure checking time
|
self._start_time = 0. # measure checking time
|
||||||
|
|
||||||
# This timer delays the starting of error check so we can react less frequently if the user is frequently
|
self._setCheckTimer()
|
||||||
# changing settings.
|
|
||||||
self._error_check_timer = QTimer(self)
|
|
||||||
self._error_check_timer.setInterval(100)
|
|
||||||
self._error_check_timer.setSingleShot(True)
|
|
||||||
|
|
||||||
self._keys_to_check = set() # type: Set[str]
|
self._keys_to_check = set() # type: Set[str]
|
||||||
|
|
||||||
self._num_keys_to_check_per_update = 10
|
self._num_keys_to_check_per_update = 10
|
||||||
|
|
||||||
def initialize(self) -> None:
|
def initialize(self) -> None:
|
||||||
self._error_check_timer.timeout.connect(self._rescheduleCheck)
|
self._error_check_timer.timeout.connect(self._rescheduleCheck)
|
||||||
|
|
||||||
|
@ -66,6 +62,18 @@ class MachineErrorChecker(QObject):
|
||||||
|
|
||||||
self._onMachineChanged()
|
self._onMachineChanged()
|
||||||
|
|
||||||
|
def _setCheckTimer(self) -> None:
|
||||||
|
"""A QTimer to regulate error check frequency
|
||||||
|
|
||||||
|
This timer delays the starting of error check
|
||||||
|
so we can react less frequently if the user is frequently
|
||||||
|
changing settings.
|
||||||
|
"""
|
||||||
|
|
||||||
|
self._error_check_timer = QTimer(self)
|
||||||
|
self._error_check_timer.setInterval(100)
|
||||||
|
self._error_check_timer.setSingleShot(True)
|
||||||
|
|
||||||
def _onMachineChanged(self) -> None:
|
def _onMachineChanged(self) -> None:
|
||||||
if self._global_stack:
|
if self._global_stack:
|
||||||
self._global_stack.propertyChanged.disconnect(self.startErrorCheckPropertyChanged)
|
self._global_stack.propertyChanged.disconnect(self.startErrorCheckPropertyChanged)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue