mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Connect the manual sync button
CURA-7290
This commit is contained in:
parent
a6c0ee6c82
commit
0aed6d3731
2 changed files with 18 additions and 1 deletions
|
@ -31,6 +31,8 @@ class Account(QObject):
|
||||||
loginStateChanged = pyqtSignal(bool)
|
loginStateChanged = pyqtSignal(bool)
|
||||||
accessTokenChanged = pyqtSignal()
|
accessTokenChanged = pyqtSignal()
|
||||||
cloudPrintersDetectedChanged = pyqtSignal(bool)
|
cloudPrintersDetectedChanged = pyqtSignal(bool)
|
||||||
|
isSyncingChanged = pyqtSignal(bool)
|
||||||
|
manualSyncRequested = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, application: "CuraApplication", parent = None) -> None:
|
def __init__(self, application: "CuraApplication", parent = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
@ -133,7 +135,7 @@ class Account(QObject):
|
||||||
def sync(self) -> None:
|
def sync(self) -> None:
|
||||||
"""Checks for new cloud printers"""
|
"""Checks for new cloud printers"""
|
||||||
|
|
||||||
Logger.info("Starting account sync")
|
self.manualSyncRequested.emit()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def logout(self) -> None:
|
def logout(self) -> None:
|
||||||
|
|
|
@ -54,6 +54,8 @@ class CloudOutputDeviceManager:
|
||||||
# Ensure we don't start twice.
|
# Ensure we don't start twice.
|
||||||
self._running = False
|
self._running = False
|
||||||
|
|
||||||
|
self._syncing = False
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""Starts running the cloud output device manager, thus periodically requesting cloud data."""
|
"""Starts running the cloud output device manager, thus periodically requesting cloud data."""
|
||||||
|
|
||||||
|
@ -66,6 +68,8 @@ class CloudOutputDeviceManager:
|
||||||
self._update_timer.start()
|
self._update_timer.start()
|
||||||
self._getRemoteClusters()
|
self._getRemoteClusters()
|
||||||
|
|
||||||
|
self._account.manualSyncRequested.connect(self._getRemoteClusters)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
"""Stops running the cloud output device manager."""
|
"""Stops running the cloud output device manager."""
|
||||||
|
|
||||||
|
@ -92,6 +96,14 @@ class CloudOutputDeviceManager:
|
||||||
def _getRemoteClusters(self) -> None:
|
def _getRemoteClusters(self) -> None:
|
||||||
"""Gets all remote clusters from the API."""
|
"""Gets all remote clusters from the API."""
|
||||||
|
|
||||||
|
if self._syncing:
|
||||||
|
return
|
||||||
|
|
||||||
|
if self._update_timer.isActive():
|
||||||
|
self._update_timer.stop()
|
||||||
|
|
||||||
|
self._syncing = True
|
||||||
|
self._account.isSyncingChanged.emit(True)
|
||||||
self._api.getClusters(self._onGetRemoteClustersFinished)
|
self._api.getClusters(self._onGetRemoteClustersFinished)
|
||||||
|
|
||||||
def _onGetRemoteClustersFinished(self, clusters: List[CloudClusterResponse]) -> None:
|
def _onGetRemoteClustersFinished(self, clusters: List[CloudClusterResponse]) -> None:
|
||||||
|
@ -119,6 +131,9 @@ class CloudOutputDeviceManager:
|
||||||
if removed_device_keys:
|
if removed_device_keys:
|
||||||
# If the removed device was active we should connect to the new active device
|
# If the removed device was active we should connect to the new active device
|
||||||
self._connectToActiveMachine()
|
self._connectToActiveMachine()
|
||||||
|
|
||||||
|
self._syncing = False
|
||||||
|
self._account.isSyncingChanged.emit(False)
|
||||||
# Schedule a new update
|
# Schedule a new update
|
||||||
self._update_timer.start()
|
self._update_timer.start()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue