mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Some final tweaks and added missing documentation
Contributes to: CURA-8587
This commit is contained in:
parent
0fefe85fca
commit
f6966c25fb
7 changed files with 65 additions and 24 deletions
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2018 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from typing import Any, cast, Dict, List, Tuple, TYPE_CHECKING, Optional, Generator
|
from typing import Any, cast, Dict, List, Tuple, TYPE_CHECKING, Optional
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication # To find some resource types.
|
from cura.CuraApplication import CuraApplication # To find some resource types.
|
||||||
from cura.Settings.GlobalStack import GlobalStack
|
from cura.Settings.GlobalStack import GlobalStack
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# Copyright (c) 2021 Ultimaker B.V.
|
# Copyright (c) 2021 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from cura.UltimakerCloud import UltimakerCloudConstants
|
from cura.UltimakerCloud import UltimakerCloudConstants
|
||||||
from cura.ApplicationMetadata import CuraSDKVersion
|
from cura.ApplicationMetadata import CuraSDKVersion
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import os.path
|
import os.path
|
||||||
from PyQt5.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject
|
from PyQt5.QtCore import pyqtSlot, QObject
|
||||||
from PyQt5.QtQml import qmlRegisterType
|
from PyQt5.QtQml import qmlRegisterType
|
||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,12 @@ class PackageList(ListModel):
|
||||||
self.subscribeUserToPackage(package_id, str(package.sdk_version))
|
self.subscribeUserToPackage(package_id, str(package.sdk_version))
|
||||||
|
|
||||||
def download(self, package_id: str, url: str, update: bool = False) -> None:
|
def download(self, package_id: str, url: str, update: bool = False) -> None:
|
||||||
|
"""Initiate the download request
|
||||||
|
|
||||||
|
:param package_id: the package identification string
|
||||||
|
:param url: the URL from which the package needs to be obtained
|
||||||
|
:param update: A flag if this is download request is an update process
|
||||||
|
"""
|
||||||
|
|
||||||
def downloadFinished(reply: "QNetworkReply") -> None:
|
def downloadFinished(reply: "QNetworkReply") -> None:
|
||||||
self._downloadFinished(package_id, reply, update)
|
self._downloadFinished(package_id, reply, update)
|
||||||
|
@ -232,6 +238,11 @@ class PackageList(ListModel):
|
||||||
package.is_installing = False
|
package.is_installing = False
|
||||||
|
|
||||||
def subscribeUserToPackage(self, package_id: str, sdk_version: str) -> None:
|
def subscribeUserToPackage(self, package_id: str, sdk_version: str) -> None:
|
||||||
|
"""Subscribe the user (if logged in) to the package for a given SDK
|
||||||
|
|
||||||
|
:param package_id: the package identification string
|
||||||
|
:param sdk_version: the SDK version
|
||||||
|
"""
|
||||||
if self._account.isLoggedIn:
|
if self._account.isLoggedIn:
|
||||||
Logger.debug(f"Subscribing the user for package: {package_id}")
|
Logger.debug(f"Subscribing the user for package: {package_id}")
|
||||||
HttpRequestManager.getInstance().put(
|
HttpRequestManager.getInstance().put(
|
||||||
|
@ -241,6 +252,10 @@ class PackageList(ListModel):
|
||||||
)
|
)
|
||||||
|
|
||||||
def unsunscribeUserFromPackage(self, package_id: str) -> None:
|
def unsunscribeUserFromPackage(self, package_id: str) -> None:
|
||||||
|
"""Unsubscribe the user (if logged in) from the package
|
||||||
|
|
||||||
|
:param package_id: the package identification string
|
||||||
|
"""
|
||||||
if self._account.isLoggedIn:
|
if self._account.isLoggedIn:
|
||||||
Logger.debug(f"Unsubscribing the user for package: {package_id}")
|
Logger.debug(f"Unsubscribing the user for package: {package_id}")
|
||||||
HttpRequestManager.getInstance().delete(url = f"{USER_PACKAGES_URL}/{package_id}", scope = self._scope)
|
HttpRequestManager.getInstance().delete(url = f"{USER_PACKAGES_URL}/{package_id}", scope = self._scope)
|
||||||
|
@ -256,6 +271,10 @@ class PackageList(ListModel):
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def installPackage(self, package_id: str) -> None:
|
def installPackage(self, package_id: str) -> None:
|
||||||
|
"""Install a package from the Marketplace
|
||||||
|
|
||||||
|
:param package_id: the package identification string
|
||||||
|
"""
|
||||||
package = self.getPackageModel(package_id)
|
package = self.getPackageModel(package_id)
|
||||||
package.is_installing = True
|
package.is_installing = True
|
||||||
url = package.download_url
|
url = package.download_url
|
||||||
|
@ -264,6 +283,10 @@ class PackageList(ListModel):
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def uninstallPackage(self, package_id: str) -> None:
|
def uninstallPackage(self, package_id: str) -> None:
|
||||||
|
"""Uninstall a package from the Marketplace
|
||||||
|
|
||||||
|
:param package_id: the package identification string
|
||||||
|
"""
|
||||||
Logger.debug(f"Uninstalling {package_id}")
|
Logger.debug(f"Uninstalling {package_id}")
|
||||||
package = self.getPackageModel(package_id)
|
package = self.getPackageModel(package_id)
|
||||||
package.is_installing = True
|
package.is_installing = True
|
||||||
|
@ -274,6 +297,10 @@ class PackageList(ListModel):
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def updatePackage(self, package_id: str) -> None:
|
def updatePackage(self, package_id: str) -> None:
|
||||||
|
"""Update a package from the Marketplace
|
||||||
|
|
||||||
|
:param package_id: the package identification string
|
||||||
|
"""
|
||||||
package = self.getPackageModel(package_id)
|
package = self.getPackageModel(package_id)
|
||||||
package.is_updating = True
|
package.is_updating = True
|
||||||
self._manager.removePackage(package_id, force_add = True)
|
self._manager.removePackage(package_id, force_add = True)
|
||||||
|
@ -283,6 +310,10 @@ class PackageList(ListModel):
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def enablePackage(self, package_id: str) -> None:
|
def enablePackage(self, package_id: str) -> None:
|
||||||
|
"""Enable a package in the plugin registry
|
||||||
|
|
||||||
|
:param package_id: the package identification string
|
||||||
|
"""
|
||||||
package = self.getPackageModel(package_id)
|
package = self.getPackageModel(package_id)
|
||||||
package.is_enabling = True
|
package.is_enabling = True
|
||||||
Logger.debug(f"Enabling {package_id}")
|
Logger.debug(f"Enabling {package_id}")
|
||||||
|
@ -292,6 +323,10 @@ class PackageList(ListModel):
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def disablePackage(self, package_id: str) -> None:
|
def disablePackage(self, package_id: str) -> None:
|
||||||
|
"""Disable a package in the plugin registry
|
||||||
|
|
||||||
|
:param package_id: the package identification string
|
||||||
|
"""
|
||||||
package = self.getPackageModel(package_id)
|
package = self.getPackageModel(package_id)
|
||||||
package.is_enabling = True
|
package.is_enabling = True
|
||||||
Logger.debug(f"Disabling {package_id}")
|
Logger.debug(f"Disabling {package_id}")
|
||||||
|
|
|
@ -3,10 +3,9 @@
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtProperty, QObject, pyqtSignal
|
from PyQt5.QtCore import pyqtProperty, QObject, pyqtSignal
|
||||||
import re
|
import re
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry # To get names of materials we're compatible with.
|
from cura.Settings.CuraContainerRegistry import CuraContainerRegistry # To get names of materials we're compatible with.
|
||||||
from UM.Logger import Logger
|
|
||||||
from UM.i18n import i18nCatalog # To translate placeholder names if data is not present.
|
from UM.i18n import i18nCatalog # To translate placeholder names if data is not present.
|
||||||
|
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
@ -285,13 +284,10 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@pyqtProperty(str, notify = stateManageButtonChanged)
|
@pyqtProperty(str, notify = stateManageButtonChanged)
|
||||||
def stateManageEnableButton(self) -> str:
|
def stateManageEnableButton(self) -> str:
|
||||||
|
"""The state of the manage Enable Button of this package"""
|
||||||
if self._is_enabling:
|
if self._is_enabling:
|
||||||
return "busy"
|
return "busy"
|
||||||
if self._is_recently_managed:
|
if self._is_recently_managed or self._package_type == "material" or not self._is_installed:
|
||||||
return "hidden"
|
|
||||||
if self._package_type == "material":
|
|
||||||
return "hidden"
|
|
||||||
if not self._is_installed:
|
|
||||||
return "hidden"
|
return "hidden"
|
||||||
if self._is_installed and self._is_active:
|
if self._is_installed and self._is_active:
|
||||||
return "secondary"
|
return "secondary"
|
||||||
|
@ -299,6 +295,7 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_enabling(self) -> bool:
|
def is_enabling(self) -> bool:
|
||||||
|
"""Flag if the package is being enabled/disabled"""
|
||||||
return self._is_enabling
|
return self._is_enabling
|
||||||
|
|
||||||
@is_enabling.setter
|
@is_enabling.setter
|
||||||
|
@ -309,6 +306,7 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_active(self) -> bool:
|
def is_active(self) -> bool:
|
||||||
|
"""Flag if the package is currently active"""
|
||||||
return self._is_active
|
return self._is_active
|
||||||
|
|
||||||
@is_active.setter
|
@is_active.setter
|
||||||
|
@ -321,6 +319,7 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@pyqtProperty(str, notify = stateManageButtonChanged)
|
@pyqtProperty(str, notify = stateManageButtonChanged)
|
||||||
def stateManageInstallButton(self) -> str:
|
def stateManageInstallButton(self) -> str:
|
||||||
|
"""The state of the Manage Install package card"""
|
||||||
if self._is_installing:
|
if self._is_installing:
|
||||||
return "busy"
|
return "busy"
|
||||||
if self._is_recently_managed:
|
if self._is_recently_managed:
|
||||||
|
@ -335,6 +334,7 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_recently_managed(self) -> bool:
|
def is_recently_managed(self) -> bool:
|
||||||
|
"""Flag if the package has been recently managed by the user, either un-/installed updated etc"""
|
||||||
return self._is_recently_managed
|
return self._is_recently_managed
|
||||||
|
|
||||||
@is_recently_managed.setter
|
@is_recently_managed.setter
|
||||||
|
@ -345,6 +345,7 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_installing(self) -> bool:
|
def is_installing(self) -> bool:
|
||||||
|
"""Flag is we're currently installing"""
|
||||||
return self._is_installing
|
return self._is_installing
|
||||||
|
|
||||||
@is_installing.setter
|
@is_installing.setter
|
||||||
|
@ -355,6 +356,7 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def can_downgrade(self) -> bool:
|
def can_downgrade(self) -> bool:
|
||||||
|
"""Flag if the installed package can be downgraded to a bundled version"""
|
||||||
return self._can_downgrade
|
return self._can_downgrade
|
||||||
|
|
||||||
@can_downgrade.setter
|
@can_downgrade.setter
|
||||||
|
@ -367,6 +369,7 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@pyqtProperty(str, notify = stateManageButtonChanged)
|
@pyqtProperty(str, notify = stateManageButtonChanged)
|
||||||
def stateManageUpdateButton(self) -> str:
|
def stateManageUpdateButton(self) -> str:
|
||||||
|
"""The state of the manage Update button for this card """
|
||||||
if self._is_updating:
|
if self._is_updating:
|
||||||
return "busy"
|
return "busy"
|
||||||
if self._can_update:
|
if self._can_update:
|
||||||
|
@ -375,6 +378,7 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_updating(self) -> bool:
|
def is_updating(self) -> bool:
|
||||||
|
"""Flag indicating if the package is being updated"""
|
||||||
return self._is_updating
|
return self._is_updating
|
||||||
|
|
||||||
@is_updating.setter
|
@is_updating.setter
|
||||||
|
@ -385,6 +389,7 @@ class PackageModel(QObject):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def can_update(self) -> bool:
|
def can_update(self) -> bool:
|
||||||
|
"""Flag indicating if the package can be updated"""
|
||||||
return self._can_update
|
return self._can_update
|
||||||
|
|
||||||
@can_update.setter
|
@can_update.setter
|
||||||
|
|
|
@ -8,7 +8,7 @@ import QtQuick.Controls 2.3
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
import QtQuick.Controls.Styles 1.4
|
import QtQuick.Controls.Styles 1.4
|
||||||
|
|
||||||
import UM 1.1 as UM
|
import UM 1.6 as UM
|
||||||
import Cura 1.6 as Cura
|
import Cura 1.6 as Cura
|
||||||
|
|
||||||
UM.Dialog
|
UM.Dialog
|
||||||
|
@ -21,14 +21,15 @@ UM.Dialog
|
||||||
height: minimumHeight
|
height: minimumHeight
|
||||||
backgroundColor: UM.Theme.getColor("main_background")
|
backgroundColor: UM.Theme.getColor("main_background")
|
||||||
|
|
||||||
|
property variant catalog: UM.I18nCatalog { name: "cura" }
|
||||||
|
|
||||||
ColumnLayout
|
ColumnLayout
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: UM.Theme.getSize("thick_margin").height
|
spacing: UM.Theme.getSize("thick_margin").height
|
||||||
|
|
||||||
UM.I18nCatalog{id: catalog; name: "cura"}
|
Row
|
||||||
|
{
|
||||||
Row {
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
spacing: UM.Theme.getSize("default_margin").width
|
spacing: UM.Theme.getSize("default_margin").width
|
||||||
|
@ -36,6 +37,7 @@ UM.Dialog
|
||||||
|
|
||||||
UM.RecolorImage
|
UM.RecolorImage
|
||||||
{
|
{
|
||||||
|
id: icon
|
||||||
width: UM.Theme.getSize("marketplace_large_icon").width
|
width: UM.Theme.getSize("marketplace_large_icon").width
|
||||||
height: UM.Theme.getSize("marketplace_large_icon").height
|
height: UM.Theme.getSize("marketplace_large_icon").height
|
||||||
color: UM.Theme.getColor("text")
|
color: UM.Theme.getColor("text")
|
||||||
|
@ -53,12 +55,10 @@ UM.Dialog
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Cura.ScrollableTextArea
|
Cura.ScrollableTextArea
|
||||||
{
|
{
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
||||||
|
@ -73,7 +73,7 @@ UM.Dialog
|
||||||
Cura.PrimaryButton
|
Cura.PrimaryButton
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@button", "Accept")
|
text: catalog.i18nc("@button", "Accept")
|
||||||
onClicked: { handler.onLicenseAccepted(packageId) }
|
onClicked: handler.onLicenseAccepted(packageId)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -82,11 +82,11 @@ UM.Dialog
|
||||||
Cura.SecondaryButton
|
Cura.SecondaryButton
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@button", "Decline")
|
text: catalog.i18nc("@button", "Decline")
|
||||||
onClicked: { handler.onLicenseDeclined(packageId) }
|
onClicked: handler.onLicenseDeclined(packageId)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
onAccepted: { handler.onLicenseAccepted(packageId) }
|
onAccepted: handler.onLicenseAccepted(packageId)
|
||||||
onRejected: { handler.onLicenseDeclined(packageId) }
|
onRejected: handler.onLicenseDeclined(packageId)
|
||||||
onClosing: { handler.onLicenseDeclined(packageId) }
|
onClosing: handler.onLicenseDeclined(packageId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CloudApiClient:
|
||||||
def _subscribe(self, package_id: str) -> None:
|
def _subscribe(self, package_id: str) -> None:
|
||||||
"""You probably don't want to use this directly. All installed packages will be automatically subscribed."""
|
"""You probably don't want to use this directly. All installed packages will be automatically subscribed."""
|
||||||
|
|
||||||
Logger.debug("Subscribing to {}", package_id)
|
Logger.debug("Subscribing to using the Old Toolbox {}", package_id)
|
||||||
data = "{\"data\": {\"package_id\": \"%s\", \"sdk_version\": \"%s\"}}" % (package_id, CloudApiModel.sdk_version)
|
data = "{\"data\": {\"package_id\": \"%s\", \"sdk_version\": \"%s\"}}" % (package_id, CloudApiModel.sdk_version)
|
||||||
HttpRequestManager.getInstance().put(
|
HttpRequestManager.getInstance().put(
|
||||||
url = CloudApiModel.api_url_user_packages,
|
url = CloudApiModel.api_url_user_packages,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue