mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 16:27:51 -06:00
Add update timer to intentCategory model
This commit is contained in:
parent
f090b5898e
commit
93e97c5dce
1 changed files with 10 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
#Copyright (c) 2019 Ultimaker B.V.
|
#Copyright (c) 2019 Ultimaker B.V.
|
||||||
#Cura is released under the terms of the LGPLv3 or higher.
|
#Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt, QTimer
|
||||||
import collections
|
import collections
|
||||||
from typing import TYPE_CHECKING, Optional, Dict
|
from typing import TYPE_CHECKING, Optional, Dict
|
||||||
|
|
||||||
|
@ -69,6 +69,11 @@ class IntentCategoryModel(ListModel):
|
||||||
extruder_manager = application.getExtruderManager()
|
extruder_manager = application.getExtruderManager()
|
||||||
extruder_manager.extrudersChanged.connect(self.update)
|
extruder_manager.extrudersChanged.connect(self.update)
|
||||||
|
|
||||||
|
self._update_timer = QTimer()
|
||||||
|
self._update_timer.setInterval(500)
|
||||||
|
self._update_timer.setSingleShot(True)
|
||||||
|
self._update_timer.timeout.connect(self._update)
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
## Updates the list of intents if an intent profile was added or removed.
|
## Updates the list of intents if an intent profile was added or removed.
|
||||||
|
@ -76,8 +81,11 @@ class IntentCategoryModel(ListModel):
|
||||||
if container.getMetaDataEntry("type") == "intent":
|
if container.getMetaDataEntry("type") == "intent":
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
self._update_timer.start()
|
||||||
|
|
||||||
## Updates the list of intents.
|
## Updates the list of intents.
|
||||||
def update(self) -> None:
|
def _update(self) -> None:
|
||||||
available_categories = IntentManager.getInstance().currentAvailableIntentCategories()
|
available_categories = IntentManager.getInstance().currentAvailableIntentCategories()
|
||||||
result = []
|
result = []
|
||||||
for category in available_categories:
|
for category in available_categories:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue