From aad00d77d3dd58d55fcf5735a35c76fab2ce89fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sun, 17 Apr 2016 21:49:54 +0200 Subject: [PATCH] Implemented InfoRating interaction and value. --- YACReaderLibrary/qml/ComicInfo.qml | 2 ++ YACReaderLibrary/qml/InfoRating.qml | 29 ++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/YACReaderLibrary/qml/ComicInfo.qml b/YACReaderLibrary/qml/ComicInfo.qml index 48291cef..f1f48084 100644 --- a/YACReaderLibrary/qml/ComicInfo.qml +++ b/YACReaderLibrary/qml/ComicInfo.qml @@ -105,6 +105,7 @@ Rectangle { InfoRating { Layout.alignment: Qt.AlignTop Layout.rightMargin: 30 + rating: comicInfo.rating } visible: mainContainer.compact @@ -146,6 +147,7 @@ Rectangle { InfoRating { Layout.alignment: Qt.AlignTop Layout.rightMargin: 30 + rating: comicInfo.rating } } } diff --git a/YACReaderLibrary/qml/InfoRating.qml b/YACReaderLibrary/qml/InfoRating.qml index 9e730195..9a2e5e76 100644 --- a/YACReaderLibrary/qml/InfoRating.qml +++ b/YACReaderLibrary/qml/InfoRating.qml @@ -3,13 +3,17 @@ import QtQuick 2.6 import QtGraphicalEffects 1.0 Row { - spacing: 6 + spacing: 0 + property int rating : 0 + property int mouseIndex : 0 + + signal ratingChangedByUser(int rating) Repeater { id: rating_compact model: 5 Item { - width: 20 + width: 25 height: 20 Image { @@ -20,8 +24,27 @@ Row { ColorOverlay { anchors.fill: star source: star - color: index <= 2 ? "#ffffff" : "#1c1c1c" + color: index < (mouseIndex > 0 ? mouseIndex : rating) ? "#ffffff" : "#1c1c1c" + } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + + onPositionChanged: { + mouseIndex = index + 1; + } + + onClicked: { + ratingChangedByUser(mouseIndex); + } + + onExited: { + mouseIndex = 0; + } } } } + + }