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
This commit is contained in:
Jaime van Kessel 2018-12-12 11:09:58 +01:00
parent 95f70a75d8
commit 5fd0f2b5f6
2 changed files with 11 additions and 7 deletions

View file

@ -1,7 +1,7 @@
import QtQuick 2.2 import QtQuick 2.7
import QtQuick.Controls 2.0 import QtQuick.Controls 2.1
import UM 1.0 as UM import UM 1.0 as UM
import Cura 1.1 as Cura
Item Item
{ {
id: ratingWidget id: ratingWidget
@ -11,6 +11,7 @@ Item
property string packageId: "" property string packageId: ""
property int userRating: 0 property int userRating: 0
property bool canRate: false
signal rated(int rating) signal rated(int rating)
@ -20,7 +21,7 @@ Item
{ {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: ratingWidget.enabled hoverEnabled: ratingWidget.canRate
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
onExited: onExited:
{ {
@ -40,12 +41,15 @@ Item
hoverEnabled: true hoverEnabled: true
onHoveredChanged: onHoveredChanged:
{ {
if(hovered) if(hovered && ratingWidget.canRate)
{ {
indexHovered = index 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: property bool isStarFilled:
{ {
// If the entire widget is hovered, override the actual rating. // 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 // Unfilled stars should always have the default color. Only filled stars should change on hover
color: color:
{ {
if(!enabled) if(!ratingWidget.canRate)
{ {
return "#5a5a5a" return "#5a5a5a"
} }

View file

@ -135,7 +135,7 @@ Item
visible: details.type == "plugin" visible: details.type == "plugin"
packageId: details.id packageId: details.id
userRating: details.user_rating userRating: details.user_rating
enabled: toolbox.isInstalled(details.id) && Cura.API.account.isLoggedIn canRate: toolbox.isInstalled(details.id) && Cura.API.account.isLoggedIn
onRated: onRated:
{ {