Core: Cleanup in ListItemDelegate::paint

Do some stuff only if animationProgress < 1.

Change-Id: Ib864cae64e8454ea7ad71f872d572a72d4e0c893
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Alessandro Portale
2022-01-20 15:55:25 +01:00
parent 8b63dfccc6
commit 3740f04dd0

View File

@@ -412,10 +412,13 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
}
constexpr float hoverAnimationDuration = 260;
animationProgress = m_startTime.elapsed() / hoverAnimationDuration;
static const QEasingCurve animationCurve(QEasingCurve::OutCubic);
offset = animationCurve.valueForProgress(animationProgress) * shiftY;
if (offset < shiftY)
if (animationProgress < 1) {
static const QEasingCurve animationCurve(QEasingCurve::OutCubic);
offset = animationCurve.valueForProgress(animationProgress) * shiftY;
QTimer::singleShot(10, this, &ListItemDelegate::goon);
} else {
offset = shiftY;
}
} else if (index == m_previousIndex) {
m_previousIndex = QModelIndex();
}