Plasma-framework

Highlight.qml
1/*
2 SPDX-FileCopyrightText: 2011 Daker Fernandes Pinheiro <dakerfp@gmail.com>
3 SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
4 SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9import QtQuick
10import org.kde.ksvg as KSvg
11import org.kde.kirigami as Kirigami
12
13/**
14 * @brief Highlight for a list or grid item.
15 *
16 * Highlight provides the highlight used to indicate the active
17 * item in a model view. It is typically used in conjunction with
18 * the @sa QtQuick.ListView::highlight or the
19 * @sa QtQuick.GridView::highlight properties.
20 *
21 * Provides built-in animation of Behavior on opacity Easing.OutQuad for a
22 * duration of 50ms (defined in Kirigami.Units.veryShortDuration).
23 *
24 * @code{.qml}
25 * import QtQuick
26 * import org.kde.plasma.extras as PlasmaExtras
27 *
28 * ListView {
29 * highlightFollowsCurrentItem: true
30 * highlight: PlasmaExtras.Highlight { }
31 * highlightMoveDuration: 0
32 * highlightResizeDuration: 0
33 * currentIndex: -1
34 * }
35 *
36 * @endcode
37 *
38 * @inherit QtQuick.Item
39 */
40Item {
41 id: highlight
42
43 /**
44 * This property holds whether the control is hovered.
45 *
46 * This is set automatically when used in a ListView and GridView.
47 */
48 property bool hovered: ListView.view !== null || GridView.view !== null
50 /**
51 * This property holds whether the highlight has a pressed appearance.
52 */
53 property bool pressed: false
54
55 /**
56 * This property holds the margin hints used by the background.
57 *
58 * @property int marginHints
59 */
60 property alias marginHints: background.margins
62 /**
63 * This property holds whether the item is active. True by default. Set it to
64 * false to visually mark an item that's in the "current item" or "selected"
65 * state but is not currently being hovered.
66 */
67 property bool active: true
68
69 width: ListView.view?.width ?? undefined
70
71 KSvg.FrameSvgItem {
72 id: background
73
74 anchors.fill: parent
75
76 opacity: highlight.active ? 1 : 0.6
77
78 imagePath: "widgets/viewitem"
79 prefix: {
80 if (highlight.pressed) {
81 return highlight.hovered ? 'selected+hover' : 'selected';
82 }
83
84 return highlight.hovered ? 'hover' : 'normal';
85 }
86
87 Behavior on opacity {
88 enabled: Kirigami.Units.veryShortDuration > 0
89 NumberAnimation {
90 duration: Kirigami.Units.veryShortDuration
91 easing.type: Easing.OutQuad
92 }
93 }
94 }
95}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 10 2024 11:48:21 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.