From 5fd0f2b5f69e8f0597b4550a828a88da16eb8621 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 12 Dec 2018 11:09:58 +0100 Subject: [PATCH] Add tooltip to rating if the rating is disabled This makes it clearer what the user needs to do in order to rate (install package or login) CURA-6013 --- plugins/Toolbox/resources/qml/RatingWidget.qml | 16 ++++++++++------ .../Toolbox/resources/qml/ToolboxDetailPage.qml | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/Toolbox/resources/qml/RatingWidget.qml b/plugins/Toolbox/resources/qml/RatingWidget.qml index 355b99c0c4..9d9eb8bca8 100644 --- a/plugins/Toolbox/resources/qml/RatingWidget.qml +++ b/plugins/Toolbox/resources/qml/RatingWidget.qml @@ -1,7 +1,7 @@ -import QtQuick 2.2 -import QtQuick.Controls 2.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 @@ -11,6 +11,7 @@ Item property string packageId: "" property int userRating: 0 + property bool canRate: false signal rated(int rating) @@ -20,7 +21,7 @@ Item { id: mouseArea anchors.fill: parent - hoverEnabled: ratingWidget.enabled + hoverEnabled: ratingWidget.canRate acceptedButtons: Qt.NoButton onExited: { @@ -40,12 +41,15 @@ Item hoverEnabled: true onHoveredChanged: { - if(hovered) + 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. @@ -72,7 +76,7 @@ Item // Unfilled stars should always have the default color. Only filled stars should change on hover color: { - if(!enabled) + if(!ratingWidget.canRate) { return "#5a5a5a" } diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml index 1d977883f9..d0608be4de 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml @@ -135,7 +135,7 @@ Item visible: details.type == "plugin" packageId: details.id userRating: details.user_rating - enabled: toolbox.isInstalled(details.id) && Cura.API.account.isLoggedIn + canRate: toolbox.isInstalled(details.id) && Cura.API.account.isLoggedIn onRated: {