diff --git a/cura/API/Account.py b/cura/API/Account.py index 00afe9e528..06125d4819 100644 --- a/cura/API/Account.py +++ b/cura/API/Account.py @@ -23,6 +23,7 @@ class SyncState: SYNCING = 0 SUCCESS = 1 ERROR = 2 + IDLE = 3 ## The account API provides a version-proof bridge to use Ultimaker Accounts @@ -59,7 +60,7 @@ class Account(QObject): self._error_message = None # type: Optional[Message] self._logged_in = False - self._sync_state = SyncState.SUCCESS + self._sync_state = SyncState.IDLE self._manual_sync_enabled = False self._last_sync_str = "-" @@ -116,11 +117,13 @@ class Account(QObject): if any(val == SyncState.SYNCING for val in self._sync_services.values()): self._sync_state = SyncState.SYNCING + self._setManualSyncEnabled(False) elif any(val == SyncState.ERROR for val in self._sync_services.values()): self._sync_state = SyncState.ERROR self._setManualSyncEnabled(True) else: self._sync_state = SyncState.SUCCESS + self._setManualSyncEnabled(False) if self._sync_state != prev_state: self.syncStateChanged.emit(self._sync_state) @@ -238,8 +241,10 @@ class Account(QObject): self._sync() @pyqtSlot() - def popupClosed(self) -> None: + def popupOpened(self) -> None: self._setManualSyncEnabled(True) + self._sync_state = SyncState.IDLE + self.syncStateChanged.emit(self._sync_state) @pyqtSlot() def logout(self) -> None: diff --git a/resources/qml/Account/AccountWidget.qml b/resources/qml/Account/AccountWidget.qml index 00ac954f22..eed711e745 100644 --- a/resources/qml/Account/AccountWidget.qml +++ b/resources/qml/Account/AccountWidget.qml @@ -112,8 +112,8 @@ Item if (popup.opened) { popup.close() - Cura.API.account.popupClosed() } else { + Cura.API.account.popupOpened() popup.open() } } @@ -127,6 +127,7 @@ Item x: parent.width - width closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent + onOpened: Cura.API.account.popupOpened() opacity: opened ? 1 : 0 Behavior on opacity { NumberAnimation { duration: 100 } } diff --git a/resources/qml/Account/SyncState.qml b/resources/qml/Account/SyncState.qml index eb71e81ecc..98e5991b5a 100644 --- a/resources/qml/Account/SyncState.qml +++ b/resources/qml/Account/SyncState.qml @@ -19,7 +19,7 @@ Row // sync state icon + message width: 20 * screenScaleFactor height: width - source: UM.Theme.getIcon("update") + source: Cura.API.account.manualSyncEnabled ? UM.Theme.getIcon("update") : UM.Theme.getIcon("checked") color: palette.text RotationAnimator @@ -54,6 +54,7 @@ Row // sync state icon + message color: UM.Theme.getColor("text") font: UM.Theme.getFont("medium") renderType: Text.NativeRendering + visible: !Cura.API.account.manualSyncEnabled } Label @@ -80,7 +81,9 @@ Row // sync state icon + message signal syncStateChanged(string newState) onSyncStateChanged: { - if(newState == Cura.AccountSyncState.SYNCING){ + if(newState == Cura.AccountSyncState.IDLE){ + icon.source = UM.Theme.getIcon("update") + } else if(newState == Cura.AccountSyncState.SYNCING){ icon.source = UM.Theme.getIcon("update") stateLabel.text = catalog.i18nc("@label", "Checking...") } else if (newState == Cura.AccountSyncState.SUCCESS) {