mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-19 20:59:11 +08:00
Merge pull request #4072 from Ultimaker/CURA-5536_installed_check
CURA-5536 Use an icon indicating when a package is installed
This commit is contained in:
commit
92da6e0ce3
8
plugins/Toolbox/resources/images/installed_check.svg
Normal file
8
plugins/Toolbox/resources/images/installed_check.svg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="Layer_3" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||||
|
<path d="M0,512h512V0L0,512z M440.4,318.3L331.2,431.6c-1.4,1.4-2.7,2-4.8,2c-2,0-3.4-0.7-4.8-2l-53.3-57.3l-1.4-2
|
||||||
|
c-1.4-1.4-2-3.4-2-4.8c0-1.4,0.7-3.4,2-4.8l9.6-9.6c2.7-2.7,6.8-2.7,9.6,0l0.7,0.7l37.6,40.2c1.4,1.4,3.4,1.4,4.8,0l91.4-94.9h0.7
|
||||||
|
c2.7-2.7,6.8-2.7,9.6,0l9.5,9.6C443.1,311.5,443.1,315.6,440.4,318.3z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 667 B |
@ -9,6 +9,8 @@ import UM 1.1 as UM
|
|||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
|
property int packageCount: toolbox.viewCategory == "material" ? toolbox.getTotalNumberOfPackagesByAuthor(model.id) : 1
|
||||||
|
property int installedPackages: toolbox.viewCategory == "material" ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0)
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
||||||
Rectangle
|
Rectangle
|
||||||
@ -40,6 +42,21 @@ Item
|
|||||||
source: model.icon_url || "../images/logobot.svg"
|
source: model.icon_url || "../images/logobot.svg"
|
||||||
mipmap: true
|
mipmap: true
|
||||||
}
|
}
|
||||||
|
UM.RecolorImage
|
||||||
|
{
|
||||||
|
width: (parent.width * 0.4) | 0
|
||||||
|
height: (parent.height * 0.4) | 0
|
||||||
|
anchors
|
||||||
|
{
|
||||||
|
bottom: parent.bottom
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
sourceSize.width: width
|
||||||
|
sourceSize.height: height
|
||||||
|
visible: installedPackages != 0
|
||||||
|
color: (installedPackages == packageCount) ? UM.Theme.getColor("primary") : UM.Theme.getColor("border")
|
||||||
|
source: "../images/installed_check.svg"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Column
|
Column
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,8 @@ import UM 1.1 as UM
|
|||||||
|
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
|
property int packageCount: toolbox.viewCategory == "material" ? toolbox.getTotalNumberOfPackagesByAuthor(model.id) : 1
|
||||||
|
property int installedPackages: toolbox.viewCategory == "material" ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0)
|
||||||
id: tileBase
|
id: tileBase
|
||||||
width: UM.Theme.getSize("toolbox_thumbnail_large").width + (2 * UM.Theme.getSize("default_lining").width)
|
width: UM.Theme.getSize("toolbox_thumbnail_large").width + (2 * UM.Theme.getSize("default_lining").width)
|
||||||
height: thumbnail.height + packageNameBackground.height + (2 * UM.Theme.getSize("default_lining").width)
|
height: thumbnail.height + packageNameBackground.height + (2 * UM.Theme.getSize("default_lining").width)
|
||||||
@ -36,6 +38,22 @@ Rectangle
|
|||||||
source: model.icon_url || "../images/logobot.svg"
|
source: model.icon_url || "../images/logobot.svg"
|
||||||
mipmap: true
|
mipmap: true
|
||||||
}
|
}
|
||||||
|
UM.RecolorImage
|
||||||
|
{
|
||||||
|
width: (parent.width * 0.3) | 0
|
||||||
|
height: (parent.height * 0.3) | 0
|
||||||
|
anchors
|
||||||
|
{
|
||||||
|
bottom: parent.bottom
|
||||||
|
right: parent.right
|
||||||
|
bottomMargin: UM.Theme.getSize("default_lining").width
|
||||||
|
}
|
||||||
|
sourceSize.width: width
|
||||||
|
sourceSize.height: height
|
||||||
|
visible: installedPackages != 0
|
||||||
|
color: (installedPackages == packageCount) ? UM.Theme.getColor("primary") : UM.Theme.getColor("border")
|
||||||
|
source: "../images/installed_check.svg"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Rectangle
|
Rectangle
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ class AuthorsModel(ListModel):
|
|||||||
"package_count": author["package_count"] if "package_count" in author else 0,
|
"package_count": author["package_count"] if "package_count" in author else 0,
|
||||||
"package_types": author["package_types"] if "package_types" in author else [],
|
"package_types": author["package_types"] if "package_types" in author else [],
|
||||||
"icon_url": author["icon_url"] if "icon_url" in author else None,
|
"icon_url": author["icon_url"] if "icon_url" in author else None,
|
||||||
"description": "Material and quality profiles from {author_name}".format( author_name = author["display_name"])
|
"description": "Material and quality profiles from {author_name}".format(author_name = author["display_name"])
|
||||||
})
|
})
|
||||||
|
|
||||||
# Filter on all the key-word arguments.
|
# Filter on all the key-word arguments.
|
||||||
|
@ -228,6 +228,7 @@ class Toolbox(QObject, Extension):
|
|||||||
self._makeRequestByType("authors")
|
self._makeRequestByType("authors")
|
||||||
self._makeRequestByType("plugins_showcase")
|
self._makeRequestByType("plugins_showcase")
|
||||||
self._makeRequestByType("materials_showcase")
|
self._makeRequestByType("materials_showcase")
|
||||||
|
self._makeRequestByType("materials_available")
|
||||||
|
|
||||||
# Gather installed packages:
|
# Gather installed packages:
|
||||||
self._updateInstalledModels()
|
self._updateInstalledModels()
|
||||||
@ -501,6 +502,22 @@ class Toolbox(QObject, Extension):
|
|||||||
def isInstalled(self, package_id: str) -> bool:
|
def isInstalled(self, package_id: str) -> bool:
|
||||||
return self._package_manager.isPackageInstalled(package_id)
|
return self._package_manager.isPackageInstalled(package_id)
|
||||||
|
|
||||||
|
@pyqtSlot(str, result = int)
|
||||||
|
def getNumberOfInstalledPackagesByAuthor(self, author_id: str) -> int:
|
||||||
|
count = 0
|
||||||
|
for package in self._metadata["materials_installed"]:
|
||||||
|
if package["author"]["author_id"] == author_id:
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
|
@pyqtSlot(str, result = int)
|
||||||
|
def getTotalNumberOfPackagesByAuthor(self, author_id: str) -> int:
|
||||||
|
count = 0
|
||||||
|
for package in self._metadata["materials_available"]:
|
||||||
|
if package["author"]["author_id"] == author_id:
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
@pyqtSlot(str, result = bool)
|
@pyqtSlot(str, result = bool)
|
||||||
def isEnabled(self, package_id: str) -> bool:
|
def isEnabled(self, package_id: str) -> bool:
|
||||||
if package_id in self._plugin_registry.getActivePlugins():
|
if package_id in self._plugin_registry.getActivePlugins():
|
||||||
@ -722,27 +739,27 @@ class Toolbox(QObject, Extension):
|
|||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
def authorsModel(self) -> AuthorsModel:
|
def authorsModel(self) -> AuthorsModel:
|
||||||
return self._models["authors"]
|
return cast(AuthorsModel, self._models["authors"])
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
def packagesModel(self) -> PackagesModel:
|
def packagesModel(self) -> PackagesModel:
|
||||||
return self._models["packages"]
|
return cast(PackagesModel, self._models["packages"])
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
def pluginsShowcaseModel(self) -> PackagesModel:
|
def pluginsShowcaseModel(self) -> PackagesModel:
|
||||||
return self._models["plugins_showcase"]
|
return cast(PackagesModel, self._models["plugins_showcase"])
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
def pluginsInstalledModel(self) -> PackagesModel:
|
def pluginsInstalledModel(self) -> PackagesModel:
|
||||||
return self._models["plugins_installed"]
|
return cast(PackagesModel, self._models["plugins_installed"])
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
def materialsShowcaseModel(self) -> PackagesModel:
|
def materialsShowcaseModel(self) -> AuthorsModel:
|
||||||
return self._models["materials_showcase"]
|
return cast(AuthorsModel, self._models["materials_showcase"])
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = metadataChanged)
|
@pyqtProperty(QObject, notify = metadataChanged)
|
||||||
def materialsInstalledModel(self) -> PackagesModel:
|
def materialsInstalledModel(self) -> PackagesModel:
|
||||||
return self._models["materials_installed"]
|
return cast(PackagesModel, self._models["materials_installed"])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user