mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-06 21:44:01 -06:00
Only show the manual sync button after the account popup was closed
CURA-7290
This commit is contained in:
parent
72657f15be
commit
f78fa884c1
3 changed files with 42 additions and 16 deletions
|
@ -50,6 +50,7 @@ class Account(QObject):
|
|||
"""
|
||||
lastSyncDateTimeChanged = pyqtSignal()
|
||||
syncStateChanged = pyqtSignal(int) # because SyncState is an int Enum
|
||||
manualSyncEnabledChanged = pyqtSignal(bool)
|
||||
|
||||
def __init__(self, application: "CuraApplication", parent = None) -> None:
|
||||
super().__init__(parent)
|
||||
|
@ -59,6 +60,7 @@ class Account(QObject):
|
|||
self._error_message = None # type: Optional[Message]
|
||||
self._logged_in = False
|
||||
self._sync_state = SyncState.SUCCESS
|
||||
self._manual_sync_enabled = False
|
||||
self._last_sync_str = "-"
|
||||
|
||||
self._callback_port = 32118
|
||||
|
@ -157,11 +159,25 @@ class Account(QObject):
|
|||
self._logged_in = logged_in
|
||||
self.loginStateChanged.emit(logged_in)
|
||||
if logged_in:
|
||||
self.sync()
|
||||
self._sync()
|
||||
else:
|
||||
if self._update_timer.isActive():
|
||||
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()
|
||||
def login(self) -> None:
|
||||
if self._logged_in:
|
||||
|
@ -200,20 +216,23 @@ class Account(QObject):
|
|||
def lastSyncDateTime(self) -> str:
|
||||
return self._last_sync_str
|
||||
|
||||
@pyqtProperty(bool, notify=manualSyncEnabledChanged)
|
||||
def manualSyncEnabled(self) -> bool:
|
||||
return self._manual_sync_enabled
|
||||
|
||||
@pyqtSlot()
|
||||
def sync(self) -> None:
|
||||
"""Signals all sync services to start syncing
|
||||
@pyqtSlot(bool)
|
||||
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
|
||||
sync is currently running, a sync will be requested.
|
||||
"""
|
||||
self._sync()
|
||||
|
||||
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()
|
||||
def popupClosed(self):
|
||||
self._manual_sync_enabled = True
|
||||
self.manualSyncEnabledChanged.emit(self._manual_sync_enabled)
|
||||
|
||||
@pyqtSlot()
|
||||
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
|
||||
|
|
|
@ -63,11 +63,12 @@ Row // sync state icon + message
|
|||
color: UM.Theme.getColor("secondary_button_text")
|
||||
font: UM.Theme.getFont("medium")
|
||||
renderType: Text.NativeRendering
|
||||
visible: Cura.API.account.manualSyncEnabled
|
||||
|
||||
MouseArea
|
||||
{
|
||||
anchors.fill: parent
|
||||
onClicked: Cura.API.account.sync()
|
||||
onClicked: Cura.API.account.sync(true)
|
||||
hoverEnabled: true
|
||||
onEntered: accountSyncButton.font.underline = true
|
||||
onExited: accountSyncButton.font.underline = false
|
||||
|
@ -93,10 +94,8 @@ Row // sync state icon + message
|
|||
|
||||
if(newState == Cura.AccountSyncState.SYNCING){
|
||||
updateAnimator.running = true
|
||||
accountSyncButton.visible = false
|
||||
} else {
|
||||
updateAnimator.running = false
|
||||
accountSyncButton.visible = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue