components/gridview: simplify component

This commit is contained in:
Yari Polla 2023-03-20 15:12:55 +01:00
parent 31eeaee2cd
commit 2da1bb150f

View file

@ -1,16 +1,15 @@
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org> // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
import QtQuick import QtQuick as QQ
import QtQuick.Controls
import org.kde.plasma.core as PlasmaCore import org.kde.plasma.extras as PlasmaExtras
import org.kde.kirigami as Kirigami
QQ.GridView {
id: root
GridView {
maximumFlickVelocity: 5000 maximumFlickVelocity: 5000
highlightFollowsCurrentItem: true
highlight: highlightComponent highlight: highlightComponent
/** These function are called when the user tries to move the highlight outside the allowed surface by using arrow keys. /** These function are called when the user tries to move the highlight outside the allowed surface by using arrow keys.
@ -21,7 +20,7 @@ GridView {
property var leftEdgeCallback: null property var leftEdgeCallback: null
property var rightEdgeCallback: null property var rightEdgeCallback: null
Keys.onPressed: event => { QQ.Keys.onPressed: event => {
if (!currentItem) { if (!currentItem) {
return; return;
} }
@ -70,14 +69,9 @@ GridView {
} }
} }
Component { QQ.Component {
id: highlightComponent 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 } } PlasmaExtras.Highlight {}
Behavior on y { SpringAnimation { spring: 3; damping: 0.2 } }
}
} }
} }