mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 18:19:15 +08:00
Only show the manual sync button after the account popup was closed
CURA-7290
This commit is contained in:
parent
72657f15be
commit
f78fa884c1
@ -50,6 +50,7 @@ class Account(QObject):
|
|||||||
"""
|
"""
|
||||||
lastSyncDateTimeChanged = pyqtSignal()
|
lastSyncDateTimeChanged = pyqtSignal()
|
||||||
syncStateChanged = pyqtSignal(int) # because SyncState is an int Enum
|
syncStateChanged = pyqtSignal(int) # because SyncState is an int Enum
|
||||||
|
manualSyncEnabledChanged = pyqtSignal(bool)
|
||||||
|
|
||||||
def __init__(self, application: "CuraApplication", parent = None) -> None:
|
def __init__(self, application: "CuraApplication", parent = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -59,6 +60,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._sync_state = SyncState.SUCCESS
|
self._sync_state = SyncState.SUCCESS
|
||||||
|
self._manual_sync_enabled = False
|
||||||
self._last_sync_str = "-"
|
self._last_sync_str = "-"
|
||||||
|
|
||||||
self._callback_port = 32118
|
self._callback_port = 32118
|
||||||
@ -157,11 +159,25 @@ class Account(QObject):
|
|||||||
self._logged_in = logged_in
|
self._logged_in = logged_in
|
||||||
self.loginStateChanged.emit(logged_in)
|
self.loginStateChanged.emit(logged_in)
|
||||||
if logged_in:
|
if logged_in:
|
||||||
self.sync()
|
self._sync()
|
||||||
else:
|
else:
|
||||||
if self._update_timer.isActive():
|
if self._update_timer.isActive():
|
||||||
self._update_timer.stop()
|
self._update_timer.stop()
|
||||||
|
|
||||||
|
def _sync(self) -> None:
|
||||||
|
"""Signals all sync services to start syncing
|
||||||
|
|
||||||
|
This can be considered a forced sync: even when a
|
||||||
|
sync is currently running, a sync will be requested.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if self._update_timer.isActive():
|
||||||
|
self._update_timer.stop()
|
||||||
|
elif self._sync_state == SyncState.SYNCING:
|
||||||
|
Logger.warning("Starting a new sync while previous sync was not completed\n{}", str(self._sync_services))
|
||||||
|
|
||||||
|
self.syncRequested.emit()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def login(self) -> None:
|
def login(self) -> None:
|
||||||
if self._logged_in:
|
if self._logged_in:
|
||||||
@ -200,20 +216,23 @@ class Account(QObject):
|
|||||||
def lastSyncDateTime(self) -> str:
|
def lastSyncDateTime(self) -> str:
|
||||||
return self._last_sync_str
|
return self._last_sync_str
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify=manualSyncEnabledChanged)
|
||||||
|
def manualSyncEnabled(self) -> bool:
|
||||||
|
return self._manual_sync_enabled
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def sync(self) -> None:
|
@pyqtSlot(bool)
|
||||||
"""Signals all sync services to start syncing
|
def sync(self, user_initiated=False):
|
||||||
|
if user_initiated:
|
||||||
|
self._manual_sync_enabled = False
|
||||||
|
self.manualSyncEnabledChanged.emit(self._manual_sync_enabled)
|
||||||
|
|
||||||
This can be considered a forced sync: even when a
|
self._sync()
|
||||||
sync is currently running, a sync will be requested.
|
|
||||||
"""
|
|
||||||
|
|
||||||
if self._update_timer.isActive():
|
@pyqtSlot()
|
||||||
self._update_timer.stop()
|
def popupClosed(self):
|
||||||
elif self._sync_state == SyncState.SYNCING:
|
self._manual_sync_enabled = True
|
||||||
Logger.warning("Starting a new sync while previous sync was not completed\n{}", str(self._sync_services))
|
self.manualSyncEnabledChanged.emit(self._manual_sync_enabled)
|
||||||
|
|
||||||
self.syncRequested.emit()
|
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def logout(self) -> None:
|
def logout(self) -> None:
|
||||||
|
@ -108,7 +108,15 @@ Item
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: popup.opened ? popup.close() : popup.open()
|
onClicked: {
|
||||||
|
if (popup.opened)
|
||||||
|
{
|
||||||
|
popup.close()
|
||||||
|
Cura.API.account.popupClosed()
|
||||||
|
} else {
|
||||||
|
popup.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Popup
|
Popup
|
||||||
|
@ -63,11 +63,12 @@ Row // sync state icon + message
|
|||||||
color: UM.Theme.getColor("secondary_button_text")
|
color: UM.Theme.getColor("secondary_button_text")
|
||||||
font: UM.Theme.getFont("medium")
|
font: UM.Theme.getFont("medium")
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
|
visible: Cura.API.account.manualSyncEnabled
|
||||||
|
|
||||||
MouseArea
|
MouseArea
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: Cura.API.account.sync()
|
onClicked: Cura.API.account.sync(true)
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
onEntered: accountSyncButton.font.underline = true
|
onEntered: accountSyncButton.font.underline = true
|
||||||
onExited: accountSyncButton.font.underline = false
|
onExited: accountSyncButton.font.underline = false
|
||||||
@ -93,10 +94,8 @@ Row // sync state icon + message
|
|||||||
|
|
||||||
if(newState == Cura.AccountSyncState.SYNCING){
|
if(newState == Cura.AccountSyncState.SYNCING){
|
||||||
updateAnimator.running = true
|
updateAnimator.running = true
|
||||||
accountSyncButton.visible = false
|
|
||||||
} else {
|
} else {
|
||||||
updateAnimator.running = false
|
updateAnimator.running = false
|
||||||
accountSyncButton.visible = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user