mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-29 15:25:02 +08:00
Made smallrating widget re-usable
Also added it to the details page CURA-6013
This commit is contained in:
parent
30057e2fcd
commit
7a5701b001
33
plugins/Toolbox/resources/qml/SmallRatingWidget.qml
Normal file
33
plugins/Toolbox/resources/qml/SmallRatingWidget.qml
Normal file
@ -0,0 +1,33 @@
|
||||
import QtQuick 2.3
|
||||
import QtQuick.Controls 1.4
|
||||
import UM 1.1 as UM
|
||||
import Cura 1.1 as Cura
|
||||
|
||||
|
||||
|
||||
Row
|
||||
{
|
||||
id: rating
|
||||
height: UM.Theme.getSize("rating_star").height
|
||||
visible: model.average_rating > 0 //Has a rating at all.
|
||||
spacing: UM.Theme.getSize("thick_lining").width
|
||||
|
||||
UM.RecolorImage
|
||||
{
|
||||
id: starIcon
|
||||
source: UM.Theme.getIcon("star_filled")
|
||||
color: model.user_rating == 0 ? "#5a5a5a" : UM.Theme.getColor("primary")
|
||||
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")
|
||||
}
|
||||
}
|
@ -57,16 +57,22 @@ Item
|
||||
top: thumbnail.top
|
||||
left: thumbnail.right
|
||||
leftMargin: UM.Theme.getSize("default_margin").width
|
||||
right: parent.right
|
||||
rightMargin: UM.Theme.getSize("wide_margin").width
|
||||
bottomMargin: UM.Theme.getSize("default_margin").height
|
||||
}
|
||||
text: details === null ? "" : (details.name || "")
|
||||
font: UM.Theme.getFont("large")
|
||||
color: UM.Theme.getColor("text")
|
||||
wrapMode: Text.WordWrap
|
||||
width: parent.width
|
||||
height: UM.Theme.getSize("toolbox_property_label").height
|
||||
width: properties.width + values.width
|
||||
height: contentHeight
|
||||
}
|
||||
|
||||
SmallRatingWidget
|
||||
{
|
||||
anchors.left: title.right
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||
anchors.verticalCenter: title.verticalCenter
|
||||
property var model: details
|
||||
}
|
||||
|
||||
Column
|
||||
@ -82,6 +88,12 @@ Item
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
Label
|
||||
{
|
||||
text: catalog.i18nc("@label", "Rating") + ":"
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: catalog.i18nc("@label", "Version") + ":"
|
||||
font: UM.Theme.getFont("default")
|
||||
@ -105,12 +117,6 @@ Item
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: catalog.i18nc("@label", "Rating") + ":"
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text_medium")
|
||||
}
|
||||
}
|
||||
Column
|
||||
{
|
||||
@ -124,50 +130,6 @@ Item
|
||||
}
|
||||
spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
|
||||
height: childrenRect.height
|
||||
Label
|
||||
{
|
||||
text: details === null ? "" : (details.version || catalog.i18nc("@label", "Unknown"))
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text:
|
||||
{
|
||||
if (details === null)
|
||||
{
|
||||
return ""
|
||||
}
|
||||
var date = new Date(details.last_updated)
|
||||
return date.toLocaleString(UM.Preferences.getValue("general/language"))
|
||||
}
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text:
|
||||
{
|
||||
if (details === null)
|
||||
{
|
||||
return ""
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<a href=\"" + details.website + "\">" + details.author_name + "</a>"
|
||||
}
|
||||
}
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
linkColor: UM.Theme.getColor("text_link")
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: details === null ? "" : (details.download_count || catalog.i18nc("@label", "Unknown"))
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
RatingWidget
|
||||
{
|
||||
id: rating
|
||||
@ -212,6 +174,50 @@ Item
|
||||
}
|
||||
}
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: details === null ? "" : (details.version || catalog.i18nc("@label", "Unknown"))
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text:
|
||||
{
|
||||
if (details === null)
|
||||
{
|
||||
return ""
|
||||
}
|
||||
var date = new Date(details.last_updated)
|
||||
return date.toLocaleString(UM.Preferences.getValue("general/language"))
|
||||
}
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
Label
|
||||
{
|
||||
text:
|
||||
{
|
||||
if (details === null)
|
||||
{
|
||||
return ""
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<a href=\"" + details.website + "\">" + details.author_name + "</a>"
|
||||
}
|
||||
}
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
linkColor: UM.Theme.getColor("text_link")
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: details === null ? "" : (details.download_count || catalog.i18nc("@label", "Unknown"))
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
}
|
||||
}
|
||||
Rectangle
|
||||
{
|
||||
|
@ -119,37 +119,15 @@ Item
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
maximumLineCount: 2
|
||||
}
|
||||
Row
|
||||
SmallRatingWidget
|
||||
{
|
||||
id: rating
|
||||
height: UM.Theme.getSize("rating_star").height
|
||||
visible: model.average_rating > 0 //Has a rating at all.
|
||||
spacing: UM.Theme.getSize("thick_lining").width
|
||||
anchors
|
||||
{
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
UM.RecolorImage
|
||||
{
|
||||
id: starIcon
|
||||
source: UM.Theme.getIcon("star_filled")
|
||||
color: model.user_rating == 0 ? "#5a5a5a" : UM.Theme.getColor("primary")
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user