Removed the rating from the download grid

It felt a bit weird to already have it in the grid layout

CURA-6013
This commit is contained in:
Jaime van Kessel 2018-12-07 17:28:42 +01:00
parent 50099ab753
commit e92bd01fb2
2 changed files with 67 additions and 47 deletions

View File

@ -16,44 +16,9 @@ Item
height: UM.Theme.getSize("toolbox_thumbnail_small").height height: UM.Theme.getSize("toolbox_thumbnail_small").height
Layout.alignment: Qt.AlignTop | Qt.AlignLeft Layout.alignment: Qt.AlignTop | Qt.AlignLeft
Rectangle
{
id: thumbnail
width: UM.Theme.getSize("toolbox_thumbnail_small").width
height: UM.Theme.getSize("toolbox_thumbnail_small").height
color: UM.Theme.getColor("main_background")
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining")
Image
{
anchors.centerIn: parent
width: UM.Theme.getSize("toolbox_thumbnail_small").width - UM.Theme.getSize("wide_margin").width
height: UM.Theme.getSize("toolbox_thumbnail_small").height - UM.Theme.getSize("wide_margin").width
fillMode: Image.PreserveAspectFit
source: model.icon_url || "../images/logobot.svg"
mipmap: true
}
UM.RecolorImage
{
width: (parent.width * 0.4) | 0
height: (parent.height * 0.4) | 0
anchors
{
bottom: parent.bottom
right: parent.right
}
sourceSize.height: height
visible: installedPackages != 0
color: (installedPackages == packageCount) ? UM.Theme.getColor("primary") : UM.Theme.getColor("border")
source: "../images/installed_check.svg"
}
MouseArea MouseArea
{ {
anchors.fill: thumbnail anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onEntered: thumbnail.border.color = UM.Theme.getColor("primary") onEntered: thumbnail.border.color = UM.Theme.getColor("primary")
onExited: thumbnail.border.color = UM.Theme.getColor("lining") onExited: thumbnail.border.color = UM.Theme.getColor("lining")
@ -86,6 +51,39 @@ Item
} }
} }
} }
Rectangle
{
id: thumbnail
width: UM.Theme.getSize("toolbox_thumbnail_small").width
height: UM.Theme.getSize("toolbox_thumbnail_small").height
color: UM.Theme.getColor("main_background")
border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining")
Image
{
anchors.centerIn: parent
width: UM.Theme.getSize("toolbox_thumbnail_small").width - UM.Theme.getSize("wide_margin").width
height: UM.Theme.getSize("toolbox_thumbnail_small").height - UM.Theme.getSize("wide_margin").width
fillMode: Image.PreserveAspectFit
source: model.icon_url || "../images/logobot.svg"
mipmap: true
}
UM.RecolorImage
{
width: (parent.width * 0.4) | 0
height: (parent.height * 0.4) | 0
anchors
{
bottom: parent.bottom
right: parent.right
}
sourceSize.height: height
visible: installedPackages != 0
color: (installedPackages == packageCount) ? UM.Theme.getColor("primary") : UM.Theme.getColor("border")
source: "../images/installed_check.svg"
}
} }
Item Item
{ {
@ -119,17 +117,39 @@ Item
anchors.top: name.bottom anchors.top: name.bottom
anchors.bottom: rating.top anchors.bottom: rating.top
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
maximumLineCount: 2
} }
RatingWidget Row
{ {
id: rating id: rating
visible: model.type == "plugin" height: UM.Theme.getSize("rating_star").height
packageId: model.id visible: model.average_rating > 0 //Has a rating at all.
rating: model.average_rating != undefined ? model.average_rating : 0 spacing: UM.Theme.getSize("thick_lining").width
numRatings: model.num_ratings != undefined ? model.num_ratings : 0 anchors
userRating: model.user_rating {
enabled: installedPackages != 0 && Cura.API.account.isLoggedIn bottom: parent.bottom
anchors.bottom: parent.bottom left: parent.left
right: parent.right
}
UM.RecolorImage
{
id: starIcon
source: UM.Theme.getIcon("star_filled")
color: "#5a5a5a"
height: UM.Theme.getSize("rating_star").height
width: UM.Theme.getSize("rating_star").width
}
Label
{
text: model.average_rating.toFixed(1) + " (" + model.num_ratings + " " + catalog.i18nc("@label", "ratings") + ")"
verticalAlignment: Text.AlignVCenter
height: starIcon.height
anchors.verticalCenter: starIcon.verticalCenter
color: starIcon.color
font: UM.Theme.getFont("small")
}
} }
} }
} }

View File

@ -105,7 +105,7 @@ class PackagesModel(ListModel):
"links": links_dict, "links": links_dict,
"website": package["website"] if "website" in package else None, "website": package["website"] if "website" in package else None,
"login_required": "login-required" in package.get("tags", []), "login_required": "login-required" in package.get("tags", []),
"average_rating": package.get("rating", {}).get("average", 0), "average_rating": float(package.get("rating", {}).get("average", 0)),
"num_ratings": package.get("rating", {}).get("count", 0), "num_ratings": package.get("rating", {}).get("count", 0),
"user_rating": package.get("rating", {}).get("user", 0) "user_rating": package.get("rating", {}).get("user", 0)
}) })