mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
Move isActive and timeRemaining logic from QML to Python
Contributes to CL-1153
This commit is contained in:
parent
36a86adc0f
commit
665e2d3060
1 changed files with 24 additions and 0 deletions
|
@ -125,10 +125,34 @@ class PrintJobOutputModel(QObject):
|
||||||
def timeElapsed(self):
|
def timeElapsed(self):
|
||||||
return self._time_elapsed
|
return self._time_elapsed
|
||||||
|
|
||||||
|
@pyqtProperty(int, notify = timeElapsedChanged)
|
||||||
|
def timeRemaining(self) -> int:
|
||||||
|
# Never get a negative time remaining
|
||||||
|
return max(self.timeTotal - self.timeElapsed, 0)
|
||||||
|
|
||||||
|
@pyqtProperty(float, notify = timeElapsedChanged)
|
||||||
|
def progress(self) -> float:
|
||||||
|
result = self.timeElapsed / self.timeTotal
|
||||||
|
if result > 1.0:
|
||||||
|
result = 1.0
|
||||||
|
return result
|
||||||
|
|
||||||
@pyqtProperty(str, notify=stateChanged)
|
@pyqtProperty(str, notify=stateChanged)
|
||||||
def state(self):
|
def state(self):
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify=stateChanged)
|
||||||
|
def isActive(self) -> bool:
|
||||||
|
inactiveStates = [
|
||||||
|
"pausing",
|
||||||
|
"paused",
|
||||||
|
"resuming",
|
||||||
|
"wait_cleanup"
|
||||||
|
]
|
||||||
|
if self.state in inactiveStates and self.timeRemaining > 0:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def updateTimeTotal(self, new_time_total):
|
def updateTimeTotal(self, new_time_total):
|
||||||
if self._time_total != new_time_total:
|
if self._time_total != new_time_total:
|
||||||
self._time_total = new_time_total
|
self._time_total = new_time_total
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue