From 8c31f51ee6030671af3dcf1dbc3058fce17810d2 Mon Sep 17 00:00:00 2001 From: Yari Polla Date: Sun, 12 Mar 2023 20:21:28 +0100 Subject: [PATCH] components/GridView: implement highlight component --- .../mobileshell/qml/components/GridView.qml | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/components/mobileshell/qml/components/GridView.qml b/components/mobileshell/qml/components/GridView.qml index 47fd3478..5d310b1d 100644 --- a/components/mobileshell/qml/components/GridView.qml +++ b/components/mobileshell/qml/components/GridView.qml @@ -1,9 +1,32 @@ // SPDX-FileCopyrightText: 2022 Devin Lin // SPDX-License-Identifier: GPL-2.0-or-later -import QtQuick 2.15 -import QtQuick.Controls 2.15 +import QtQuick +import QtQuick.Controls + +import org.kde.plasma.core as PlasmaCore +import org.kde.kirigami as Kirigami GridView { maximumFlickVelocity: 5000 + + highlightFollowsCurrentItem: true + highlight: highlightComponent + + onActiveFocusChanged: { + if (!activeFocus) { + currentIndex = -1; + } + } + + Component { + id: highlightComponent + Rectangle { + color: Kirigami.ColorUtils.tintWithAlpha(PlasmaCore.ColorScope.highlightColor, PlasmaCore.ColorScope.backgroundColor, 0.6) + radius: PlasmaCore.Units.smallSpacing + + Behavior on x { SpringAnimation { spring: 3; damping: 0.2 } } + Behavior on y { SpringAnimation { spring: 3; damping: 0.2 } } + } + } }