From 39dda0f16b057df966b4a3e07f16fa4c0be88207 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Fri, 2 Apr 2021 00:47:53 +0200 Subject: [PATCH] Check that rating position is to the right or left of the rectangle. Adapted from Clementine. Author: Jim Broadus --- src/widgets/ratingwidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/widgets/ratingwidget.cpp b/src/widgets/ratingwidget.cpp index fbb60ab31..37801e090 100644 --- a/src/widgets/ratingwidget.cpp +++ b/src/widgets/ratingwidget.cpp @@ -86,6 +86,10 @@ double RatingPainter::RatingForPos(const QPoint &pos, const QRect &rect) { const QRect contents = Contents(rect); const double raw = double(pos.x() - contents.left()) / contents.width(); + // Check if the position was to the right or left of the rectangle. + if (raw < 0) return 0; + if (raw > 1) return 1; + // Round to the nearest 0.1 return double(int(raw * kStarCount * 2 + 0.5)) / (kStarCount * 2);