mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 03:35:57 +08:00
Put a change timer on the globalStacks model
This decreases the time that a first thing is shown on the main screen (as the creation of the global stack model doesn't block the UI anymore)
This commit is contained in:
parent
48ed9b6e20
commit
5118953373
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from UM.Qt.ListModel import ListModel
|
from UM.Qt.ListModel import ListModel
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtProperty, Qt, pyqtSignal
|
from PyQt5.QtCore import pyqtProperty, Qt, pyqtSignal, QTimer
|
||||||
|
|
||||||
from cura.PrinterOutputDevice import ConnectionType
|
from cura.PrinterOutputDevice import ConnectionType
|
||||||
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
|
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry
|
||||||
@ -26,18 +26,26 @@ class GlobalStacksModel(ListModel):
|
|||||||
self.addRoleName(self.MetaDataRole, "metadata")
|
self.addRoleName(self.MetaDataRole, "metadata")
|
||||||
self._container_stacks = []
|
self._container_stacks = []
|
||||||
|
|
||||||
|
self._change_timer = QTimer()
|
||||||
|
self._change_timer.setInterval(200)
|
||||||
|
self._change_timer.setSingleShot(True)
|
||||||
|
self._change_timer.timeout.connect(self._update)
|
||||||
|
|
||||||
# Listen to changes
|
# Listen to changes
|
||||||
CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged)
|
CuraContainerRegistry.getInstance().containerAdded.connect(self._onContainerChanged)
|
||||||
CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged)
|
CuraContainerRegistry.getInstance().containerMetaDataChanged.connect(self._onContainerChanged)
|
||||||
CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged)
|
CuraContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChanged)
|
||||||
self._filter_dict = {}
|
self._filter_dict = {}
|
||||||
self._update()
|
self._updateDelayed()
|
||||||
|
|
||||||
## Handler for container added/removed events from registry
|
## Handler for container added/removed events from registry
|
||||||
def _onContainerChanged(self, container):
|
def _onContainerChanged(self, container):
|
||||||
# We only need to update when the added / removed container GlobalStack
|
# We only need to update when the added / removed container GlobalStack
|
||||||
if isinstance(container, GlobalStack):
|
if isinstance(container, GlobalStack):
|
||||||
self._update()
|
self._updateDelayed()
|
||||||
|
|
||||||
|
def _updateDelayed(self):
|
||||||
|
self._change_timer.start()
|
||||||
|
|
||||||
def _update(self) -> None:
|
def _update(self) -> None:
|
||||||
items = []
|
items = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user