mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-06 13:34:01 -06:00
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
This commit is contained in:
parent
629f695ef7
commit
666880ad20
3 changed files with 31 additions and 14 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue