diff --git a/plugins/Toolbox/resources/qml/RatingWidget.qml b/plugins/Toolbox/resources/qml/RatingWidget.qml index b7d07835e8..f1499b61a7 100644 --- a/plugins/Toolbox/resources/qml/RatingWidget.qml +++ b/plugins/Toolbox/resources/qml/RatingWidget.qml @@ -19,6 +19,8 @@ Item property int userRating: 0 + signal rated(int rating) + width: contentRow.width height: contentRow.height MouseArea @@ -94,8 +96,9 @@ Item onClicked: { // Ensure that the local rating is updated (even though it's not on the server just yet) - _localRating = index + 1 - toolbox.ratePackage(ratingWidget.packageId, index + 1) + //_localRating = index + 1 + rated(index + 1) + } } } diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml index dd3f0a6c84..a503a9d519 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml @@ -177,6 +177,21 @@ Item numRatings: details.num_ratings userRating: details.user_rating 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