mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Add Account sync last update datetime
CURA-7290
This commit is contained in:
parent
0aed6d3731
commit
acf36d1e42
2 changed files with 26 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2018 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 datetime import datetime
|
||||||
from typing import Optional, Dict, TYPE_CHECKING
|
from typing import Optional, Dict, TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty
|
from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty
|
||||||
|
@ -33,6 +34,7 @@ class Account(QObject):
|
||||||
cloudPrintersDetectedChanged = pyqtSignal(bool)
|
cloudPrintersDetectedChanged = pyqtSignal(bool)
|
||||||
isSyncingChanged = pyqtSignal(bool)
|
isSyncingChanged = pyqtSignal(bool)
|
||||||
manualSyncRequested = pyqtSignal()
|
manualSyncRequested = pyqtSignal()
|
||||||
|
lastSyncDateTimeChanged = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, application: "CuraApplication", parent = None) -> None:
|
def __init__(self, application: "CuraApplication", parent = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
@ -41,6 +43,7 @@ class Account(QObject):
|
||||||
|
|
||||||
self._error_message = None # type: Optional[Message]
|
self._error_message = None # type: Optional[Message]
|
||||||
self._logged_in = False
|
self._logged_in = False
|
||||||
|
self._last_sync_str = "-"
|
||||||
|
|
||||||
self._callback_port = 32118
|
self._callback_port = 32118
|
||||||
self._oauth_root = UltimakerCloudAuthentication.CuraCloudAccountAPIRoot
|
self._oauth_root = UltimakerCloudAuthentication.CuraCloudAccountAPIRoot
|
||||||
|
@ -66,6 +69,7 @@ class Account(QObject):
|
||||||
self._authorization_service.onAuthenticationError.connect(self._onLoginStateChanged)
|
self._authorization_service.onAuthenticationError.connect(self._onLoginStateChanged)
|
||||||
self._authorization_service.accessTokenChanged.connect(self._onAccessTokenChanged)
|
self._authorization_service.accessTokenChanged.connect(self._onAccessTokenChanged)
|
||||||
self._authorization_service.loadAuthDataFromPreferences()
|
self._authorization_service.loadAuthDataFromPreferences()
|
||||||
|
self.isSyncingChanged.connect(self._onIsSyncingChanged)
|
||||||
|
|
||||||
def _onAccessTokenChanged(self):
|
def _onAccessTokenChanged(self):
|
||||||
self.accessTokenChanged.emit()
|
self.accessTokenChanged.emit()
|
||||||
|
@ -131,6 +135,17 @@ class Account(QObject):
|
||||||
return None
|
return None
|
||||||
return user_profile.__dict__
|
return user_profile.__dict__
|
||||||
|
|
||||||
|
def _onIsSyncingChanged(self, active: bool):
|
||||||
|
Logger.info("active: {}", active)
|
||||||
|
if not active:
|
||||||
|
# finished
|
||||||
|
self._last_sync_str = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
|
||||||
|
self.lastSyncDateTimeChanged.emit()
|
||||||
|
|
||||||
|
@pyqtProperty(str, notify=lastSyncDateTimeChanged)
|
||||||
|
def lastSyncDateTime(self) -> str:
|
||||||
|
return self._last_sync_str
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def sync(self) -> None:
|
def sync(self) -> None:
|
||||||
"""Checks for new cloud printers"""
|
"""Checks for new cloud printers"""
|
||||||
|
|
|
@ -101,6 +101,17 @@ Column
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
id: lastSyncLabel
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
renderType: Text.NativeRendering
|
||||||
|
text: catalog.i18nc("@label The argument is a timestamp", "Last update: %1").arg(Cura.API.account.lastSyncDateTime)
|
||||||
|
font: UM.Theme.getFont("default")
|
||||||
|
color: UM.Theme.getColor("text_medium")
|
||||||
|
}
|
||||||
|
|
||||||
Cura.SecondaryButton
|
Cura.SecondaryButton
|
||||||
{
|
{
|
||||||
id: accountButton
|
id: accountButton
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue