Kirigami2

DefaultChipBackground.qml
1// SPDX-FileCopyrightText: 2022 Felipe Kinoshita <kinofhek@gmail.com>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4import QtQuick
5import org.kde.kirigami as Kirigami
6
7Rectangle {
8
9 /**
10 * @brief This property holds the chip's default background color.
11 */
12 property color defaultColor: Kirigami.Theme.backgroundColor
13
14 /**
15 * @brief This property holds the color of the Chip's background when it is being pressed.
16 * @see QtQuick.AbstractButton::down
17 */
18 property color pressedColor: Qt.rgba(Kirigami.Theme.highlightColor.r, Kirigami.Theme.highlightColor.g, Kirigami.Theme.highlightColor.b, 0.3)
19
20 /**
21 * @brief This property holds the color of the Chip's background when it is checked.
22 * @see QtQuick.AbstractButton::checked
23 */
24 property color checkedColor: Qt.rgba(Kirigami.Theme.highlightColor.r, Kirigami.Theme.highlightColor.g, Kirigami.Theme.highlightColor.b, 0.2)
25
26 /**
27 * @brief This property holds the chip's default border color.
28 */
29 property color defaultBorderColor: Kirigami.ColorUtils.linearInterpolation(Kirigami.Theme.backgroundColor, Kirigami.Theme.textColor, Kirigami.Theme.frameContrast)
30
31 /**
32 * @brief This property holds the color of the Chip's border when it is checked.
33 * @see QtQuick.AbstractButton::checked
34 */
35 property color checkedBorderColor: Qt.rgba(Kirigami.Theme.highlightColor.r, Kirigami.Theme.highlightColor.g, Kirigami.Theme.highlightColor.b, 0.9)
36
37 /**
38 * @brief This property holds the color of the Chip's border when it is being pressed.
39 * @see QtQuick.AbstractButton::down
40 */
41 property color pressedBorderColor: Qt.rgba(Kirigami.Theme.highlightColor.r, Kirigami.Theme.highlightColor.g, Kirigami.Theme.highlightColor.b, 0.7)
42
43 /**
44 * @brief This property holds the color of the Chip's border when it is hovered.
45 * @see QtQuick.Control::hovered
46 */
47 property color hoveredBorderColor: Kirigami.Theme.hoverColor
48
49 Kirigami.Theme.colorSet: Kirigami.Theme.Header
50 Kirigami.Theme.inherit: false
51
52 color: {
53 if (parent.down) {
54 return pressedColor
55 } else if (parent.checked) {
56 return checkedColor
57 } else {
58 return defaultColor
59 }
60 }
61 border.color: {
62 if (parent.down) {
63 return pressedBorderColor
64 } else if (parent.checked) {
65 return checkedBorderColor
66 } else if (parent.hovered) {
67 return hoveredBorderColor
68 } else {
69 return defaultBorderColor
70 }
71 }
72 border.width: 1
73 radius: Kirigami.Units.cornerRadius
74}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.