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:
authorJelle Spijker <spijker.jelle@gmail.com>2021-10-18 16:35:17 +0300
committerJelle Spijker <spijker.jelle@gmail.com>2021-10-18 16:37:06 +0300
commit666880ad20a97e601ed7132912db39f932e51199 (patch)
treec58941169786ac936eedb1b808f2e9f3370c2202 /cura/API
parent629f695ef780ea50c6e86cc18868fd5db528cad8 (diff)
Only show certain App Switcher icons when account has DF access
Added a dictionary where additional user rights can be set. A plugin such as the DigitalFactory can update this dictionary if certain account rights change. The `account.additionalRights` is intended to allow us some flexibility, without breaking the API in the future. The Application Switcher now queries the additional account rights, which is updated by the DF plugin to only show `My printers`, `Digital Library` and `Print jobs` when the user has access to the DF. Contributes to CURA-8624
Diffstat (limited to 'cura/API')
-rw-r--r--cura/API/Account.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/cura/API/Account.py b/cura/API/Account.py
index a85e2c64c5..ab45c4a4be 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, Callable
+from typing import Any, Optional, Dict, TYPE_CHECKING, Callable
from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty, QTimer, Q_ENUMS
@@ -46,6 +46,9 @@ class Account(QObject):
loginStateChanged = pyqtSignal(bool)
"""Signal emitted when user logged in or out"""
+ additionalRightsChanged = pyqtSignal("QVariantMap")
+ """Signal emitted when a users additional rights change"""
+
accessTokenChanged = pyqtSignal()
syncRequested = pyqtSignal()
"""Sync services may connect to this signal to receive sync triggers.
@@ -70,6 +73,7 @@ class Account(QObject):
self._error_message = None # type: Optional[Message]
self._logged_in = False
+ self._additional_rights: Dict[str, Any] = {}
self._sync_state = SyncState.IDLE
self._manual_sync_enabled = False
self._update_packages_enabled = False
@@ -301,3 +305,14 @@ class Account(QObject):
return # Nothing to do, user isn't logged in.
self._authorization_service.deleteAuthData()
+
+ def updateAdditionalRight(self, **kwargs) -> None:
+ """Update the additional rights of the account.
+ The argument(s) are the rights that need to be set"""
+ self._additional_rights.update(kwargs)
+ self.additionalRightsChanged.emit(self._additional_rights)
+
+ @pyqtProperty("QVariantMap", notify = additionalRightsChanged)
+ def additionalRights(self) -> Dict[str, Any]:
+ """A dictionary which can be queried for additional account rights."""
+ return self._additional_rights