Kirigami2

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

KDE's Doxygen guidelines are available online.