Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cura/API
diff options
context:
space:
mode:
authorNino van Hooff <ninovanhooff@gmail.com>2020-06-26 12:37:01 +0300
committerNino van Hooff <ninovanhooff@gmail.com>2020-06-26 12:37:01 +0300
commit4f1a18f1024c5bfc4cdef46a856ec4fe42011c71 (patch)
treefc125ada1020490666425ff4dcd4f555464dd2f7 /cura/API
parentf35ca0eb7dc98827ab654a97a462bc7f869b745b (diff)
Add Install Pending Updates button to Account popup
CURA-7473
Diffstat (limited to 'cura/API')
-rw-r--r--cura/API/Account.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/cura/API/Account.py b/cura/API/Account.py
index e190fe9b42..991a2ef967 100644
--- a/cura/API/Account.py
+++ b/cura/API/Account.py
@@ -1,7 +1,7 @@
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from datetime import datetime
-from typing import Optional, Dict, TYPE_CHECKING, Union
+from typing import Optional, Dict, TYPE_CHECKING, Callable
from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty, QTimer, Q_ENUMS
@@ -56,6 +56,7 @@ class Account(QObject):
lastSyncDateTimeChanged = pyqtSignal()
syncStateChanged = pyqtSignal(int) # because SyncState is an int Enum
manualSyncEnabledChanged = pyqtSignal(bool)
+ updatePackagesEnabledChanged = pyqtSignal(bool)
def __init__(self, application: "CuraApplication", parent = None) -> None:
super().__init__(parent)
@@ -66,6 +67,8 @@ class Account(QObject):
self._logged_in = False
self._sync_state = SyncState.IDLE
self._manual_sync_enabled = False
+ self._update_packages_enabled = False
+ self._update_packages_action = None # type: Callable
self._last_sync_str = "-"
self._callback_port = 32118
@@ -143,6 +146,18 @@ class Account(QObject):
if not self._update_timer.isActive():
self._update_timer.start()
+ def setUpdatePackagesAction(self, action: Callable):
+ """ Set the callback which will be invoked when the user clicks the update packages button
+
+ Should be invoked after your service sets the sync state to SYNCING and before setting the
+ sync state to SUCCESS.
+
+ Action will be reset to None when the next sync starts
+ """
+ self._update_packages_action = action
+ self._update_packages_enabled = True
+ self.updatePackagesEnabledChanged.emit(self._update_packages_enabled)
+
def _onAccessTokenChanged(self):
self.accessTokenChanged.emit()
@@ -185,6 +200,9 @@ class Account(QObject):
sync is currently running, a sync will be requested.
"""
+ self._update_packages_action = None
+ self._update_packages_enabled = False
+ self.updatePackagesEnabledChanged.emit(self._update_packages_enabled)
if self._update_timer.isActive():
self._update_timer.stop()
elif self._sync_state == SyncState.SYNCING:
@@ -251,6 +269,10 @@ class Account(QObject):
def manualSyncEnabled(self) -> bool:
return self._manual_sync_enabled
+ @pyqtProperty(bool, notify=updatePackagesEnabledChanged)
+ def updatePackagesEnabled(self) -> bool:
+ return self._update_packages_enabled
+
@pyqtSlot()
@pyqtSlot(bool)
def sync(self, user_initiated: bool = False) -> None:
@@ -260,10 +282,13 @@ class Account(QObject):
self._sync()
@pyqtSlot()
+ def update_packages(self):
+ if self._update_packages_action is not None:
+ self._update_packages_action()
+
+ @pyqtSlot()
def popupOpened(self) -> None:
self._setManualSyncEnabled(True)
- self._sync_state = SyncState.IDLE
- self.syncStateChanged.emit(self._sync_state)
@pyqtSlot()
def logout(self) -> None: