Browse Source

Remove rating packages/materials.

Online teams decided not to support ratings anymore, making this a rather useless feature in the upcoming release.

CURA-7606
Remco Burema 4 years ago
parent
commit
51a13675a5

+ 0 - 106
plugins/Toolbox/resources/qml/components/RatingWidget.qml

@@ -1,106 +0,0 @@
-import QtQuick 2.7
-import QtQuick.Controls 2.1
-import UM 1.0 as UM
-import Cura 1.1 as Cura
-Item
-{
-    id: ratingWidget
-
-    property real rating: 0
-    property int indexHovered: -1
-    property string packageId: ""
-
-    property int userRating: 0
-    property bool canRate: false
-
-    signal rated(int rating)
-
-    width: contentRow.width
-    height: contentRow.height
-    MouseArea
-    {
-        id: mouseArea
-        anchors.fill: parent
-        hoverEnabled: ratingWidget.canRate
-        acceptedButtons: Qt.NoButton
-        onExited:
-        {
-            if(ratingWidget.canRate)
-            {
-                ratingWidget.indexHovered = -1
-            }
-        }
-
-        Row
-        {
-            id: contentRow
-            height: childrenRect.height
-            Repeater
-            {
-                model: 5 // We need to get 5 stars
-                Button
-                {
-                    id: control
-                    hoverEnabled: true
-                    onHoveredChanged:
-                    {
-                        if(hovered && ratingWidget.canRate)
-                        {
-                            indexHovered = index
-                        }
-                    }
-
-                    ToolTip.visible: control.hovered  && !ratingWidget.canRate
-                    ToolTip.text: !Cura.API.account.isLoggedIn ? catalog.i18nc("@label", "You need to login first before you can rate"): catalog.i18nc("@label", "You need to install the package before you can rate")
-
-                    property bool isStarFilled:
-                    {
-                        // If the entire widget is hovered, override the actual rating.
-                        if(ratingWidget.indexHovered >= 0)
-                        {
-                            return indexHovered >= index
-                        }
-
-                        if(ratingWidget.userRating > 0)
-                        {
-                            return userRating >= index +1
-                        }
-
-                        return rating >= index + 1
-                    }
-
-                    contentItem: Item {}
-                    height: UM.Theme.getSize("rating_star").height
-                    width: UM.Theme.getSize("rating_star").width
-                    background: UM.RecolorImage
-                    {
-                        source: UM.Theme.getIcon(control.isStarFilled ? "star_filled" : "star_empty")
-                        sourceSize.width: width
-                        sourceSize.height: height
-
-                        // Unfilled stars should always have the default color. Only filled stars should change on hover
-                        color:
-                        {
-                            if(!ratingWidget.canRate)
-                            {
-                                return UM.Theme.getColor("rating_star")
-                            }
-                            if((ratingWidget.indexHovered >= 0 || ratingWidget.userRating > 0) && isStarFilled)
-                            {
-                                return UM.Theme.getColor("primary")
-                            }
-                            return UM.Theme.getColor("rating_star")
-                        }
-                    }
-                    onClicked:
-                    {
-                        if(ratingWidget.canRate)
-                        {
-                            rated(index + 1)  // Notify anyone who cares about this.
-                        }
-                    }
-                }
-            }
-        }
-    }
-}

+ 0 - 36
plugins/Toolbox/resources/qml/components/SmallRatingWidget.qml

@@ -1,36 +0,0 @@
-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
-    width: starIcon.width + spacing + numRatingsLabel.width
-    UM.RecolorImage
-    {
-        id: starIcon
-        source: UM.Theme.getIcon("star_filled")
-        color: model.user_rating == 0  ? UM.Theme.getColor("rating_star") : UM.Theme.getColor("primary")
-        height: UM.Theme.getSize("rating_star").height
-        width: UM.Theme.getSize("rating_star").width
-        sourceSize.height: height
-        sourceSize.width: width
-    }
-
-    Label
-    {
-        id: numRatingsLabel
-        text: model.average_rating != undefined ? model.average_rating.toFixed(1) + " (" + model.num_ratings + " " + catalog.i18nc("@label", "ratings") + ")": ""
-        verticalAlignment: Text.AlignVCenter
-        height: starIcon.height
-        width: contentWidth
-        anchors.verticalCenter: starIcon.verticalCenter
-        color: starIcon.color
-        font: UM.Theme.getFont("default")
-        renderType: Text.NativeRendering
-    }
-}

+ 1 - 11
plugins/Toolbox/resources/qml/components/ToolboxDownloadsGridTile.qml

@@ -117,19 +117,9 @@ Item
             color: UM.Theme.getColor("text")
             font: UM.Theme.getFont("default")
             anchors.top: name.bottom
-            anchors.bottom: rating.top
+            anchors.bottom: parent.bottom
             verticalAlignment: Text.AlignVCenter
             maximumLineCount: 2
         }
-        SmallRatingWidget
-        {
-            id: rating
-            anchors
-            {
-                bottom: parent.bottom
-                left: parent.left
-                right: parent.right
-            }
-        }
     }
 }

+ 1 - 8
plugins/Toolbox/resources/qml/components/ToolboxDownloadsShowcaseTile.qml

@@ -13,7 +13,7 @@ Rectangle
     property int installedPackages: toolbox.viewCategory == "material" ? toolbox.getNumberOfInstalledPackagesByAuthor(model.id) : (toolbox.isInstalled(model.id) ? 1 : 0)
     id: tileBase
     width: UM.Theme.getSize("toolbox_thumbnail_large").width + (2 * UM.Theme.getSize("default_lining").width)
-    height: thumbnail.height + packageName.height + rating.height + UM.Theme.getSize("default_margin").width
+    height: thumbnail.height + packageName.height + UM.Theme.getSize("default_margin").width
     border.width: UM.Theme.getSize("default_lining").width
     border.color: UM.Theme.getColor("lining")
     color: UM.Theme.getColor("main_background")
@@ -67,13 +67,6 @@ Rectangle
         source: "../../images/installed_check.svg"
     }
 
-    SmallRatingWidget
-    {
-        id: rating
-        anchors.bottom: parent.bottom
-        anchors.bottomMargin: UM.Theme.getSize("narrow_margin").height
-        anchors.horizontalCenter: parent.horizontalCenter
-    }
     Rectangle
     {
         id: bottomBorder

+ 0 - 58
plugins/Toolbox/resources/qml/pages/ToolboxDetailPage.qml

@@ -72,14 +72,6 @@ Item
             renderType: Text.NativeRendering
         }
 
-        SmallRatingWidget
-        {
-            anchors.left: title.right
-            anchors.leftMargin: UM.Theme.getSize("default_margin").width
-            anchors.verticalCenter: title.verticalCenter
-            property var model: details
-        }
-
         Column
         {
             id: properties
@@ -93,14 +85,6 @@ Item
             width: childrenRect.width
             height: childrenRect.height
             Label
-            {
-                text: catalog.i18nc("@label", "Your rating") + ":"
-                visible: details.type == "plugin"
-                font: UM.Theme.getFont("default")
-                color: UM.Theme.getColor("text_medium")
-                renderType: Text.NativeRendering
-            }
-            Label
             {
                 text: catalog.i18nc("@label", "Version") + ":"
                 font: UM.Theme.getFont("default")
@@ -141,48 +125,6 @@ Item
             }
             spacing: Math.floor(UM.Theme.getSize("narrow_margin").height)
             height: childrenRect.height
-            RatingWidget
-            {
-                id: rating
-                visible: details.type == "plugin"
-                packageId: details.id != undefined ? details.id: ""
-                userRating: details.user_rating != undefined ? details.user_rating: 0
-                canRate: toolbox.isInstalled(details.id) && Cura.API.account.isLoggedIn
-
-                onRated:
-                {
-                    toolbox.ratePackage(details.id, rating)
-                    // HACK: This is a far from optimal solution, but without major refactoring, this is the best we can
-                    // do. Since a rework of this is scheduled, it shouldn't live that long...
-                    var index = toolbox.pluginsAvailableModel.find("id", details.id)
-                    if(index != -1)
-                    {
-                        if(details.user_rating == 0)  // User never rated before.
-                        {
-                            toolbox.pluginsAvailableModel.setProperty(index, "num_ratings", details.num_ratings + 1)
-                        }
-
-                        toolbox.pluginsAvailableModel.setProperty(index, "user_rating", rating)
-
-
-                        // Hack; This is because the current selection is an outdated copy, so we need to re-copy it.
-                        base.selection = toolbox.pluginsAvailableModel.getItem(index)
-                        return
-                    }
-                    index = toolbox.pluginsShowcaseModel.find("id", details.id)
-                    if(index != -1)
-                    {
-                        if(details.user_rating == 0) // User never rated before.
-                        {
-                            toolbox.pluginsShowcaseModel.setProperty(index, "user_rating", rating)
-                        }
-                        toolbox.pluginsShowcaseModel.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.pluginsShowcaseModel.getItem(index)
-                    }
-                }
-            }
             Label
             {
                 text: details === null ? "" : (details.version || catalog.i18nc("@label", "Unknown"))

+ 0 - 7
plugins/Toolbox/src/Toolbox.py

@@ -151,13 +151,6 @@ class Toolbox(QObject, Extension):
         self._package_used_materials = []  # type: List[Tuple[GlobalStack, str, str]]
         self._package_used_qualities = []  # type: List[Tuple[GlobalStack, str, str]]
 
-    @pyqtSlot(str, int)
-    def ratePackage(self, package_id: str, rating: int) -> None:
-        url = "{base_url}/packages/{package_id}/ratings".format(base_url = CloudApiModel.api_url, package_id = package_id)
-        data = "{\"data\": {\"cura_version\": \"%s\", \"rating\": %i}}" % (Version(self._application.getVersion()), rating)
-
-        self._application.getHttpRequestManager().put(url, data = data.encode(), scope = self._json_scope)
-
     def getLicenseDialogPluginFileLocation(self) -> str:
         return self._license_dialog_plugin_file_location