mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 04:07:57 -06:00
Move the rating logic outside of the rating widget
That way it's easier to re-use the component if that's ever required. CURA-6013
This commit is contained in:
parent
04f3601c27
commit
098adc45ff
2 changed files with 20 additions and 2 deletions
|
@ -19,6 +19,8 @@ Item
|
||||||
|
|
||||||
property int userRating: 0
|
property int userRating: 0
|
||||||
|
|
||||||
|
signal rated(int rating)
|
||||||
|
|
||||||
width: contentRow.width
|
width: contentRow.width
|
||||||
height: contentRow.height
|
height: contentRow.height
|
||||||
MouseArea
|
MouseArea
|
||||||
|
@ -94,8 +96,9 @@ Item
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
// Ensure that the local rating is updated (even though it's not on the server just yet)
|
// Ensure that the local rating is updated (even though it's not on the server just yet)
|
||||||
_localRating = index + 1
|
//_localRating = index + 1
|
||||||
toolbox.ratePackage(ratingWidget.packageId, index + 1)
|
rated(index + 1)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,21 @@ Item
|
||||||
numRatings: details.num_ratings
|
numRatings: details.num_ratings
|
||||||
userRating: details.user_rating
|
userRating: details.user_rating
|
||||||
enabled: toolbox.isInstalled(details.id) && Cura.API.account.isLoggedIn
|
enabled: toolbox.isInstalled(details.id) && Cura.API.account.isLoggedIn
|
||||||
|
|
||||||
|
onRated:
|
||||||
|
{
|
||||||
|
toolbox.ratePackage(details.id, rating)
|
||||||
|
var index = toolbox.packagesModel.find("id", details.id)
|
||||||
|
if(index != -1)
|
||||||
|
{
|
||||||
|
// Found the package
|
||||||
|
toolbox.packagesModel.setProperty(index, "user_rating", rating)
|
||||||
|
toolbox.packagesModel.setProperty(index, "num_ratings", details.num_ratings + 1)
|
||||||
|
|
||||||
|
// Hack; This is because the current selection is an outdated copy, so we need to re-copy it.
|
||||||
|
base.selection = toolbox.packagesModel.getItem(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rectangle
|
Rectangle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue