Fluid 1.3.0
Material Design for QtQuick and Qml
Loading...
Searching...
No Matches
CheckIndicator.qml
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
2// SPDX-FileCopyrightText: 2024-2025 hypengw <hypengwip@gmail.com>
3// SPDX-License-Identifier: MPL-2.0
4//
5// Originally based on code by hypengw, licensed under the MIT license.
6
7import QtQuick
8import QtQuick.Shapes
9import Fluid as MD
10import "../core/UiMetrics.js" as UiMetrics
11
23Item {
24 id: indicatorItem
25 Accessible.ignored: true
26
28 property Item control
29
31 property color color
32
34 property color backgroundColor
35
37 property color outlineColor
38
40 property real outlineWidth
41
42 implicitWidth: MD.Tokens.checkBox.containerSize + MD.Tokens.checkBox.containerPadding * 2
43 implicitHeight: MD.Tokens.checkBox.containerSize + MD.Tokens.checkBox.containerPadding * 2
44
45 Rectangle {
46 id: container
47
48 anchors.centerIn: parent
49 implicitWidth: MD.Tokens.checkBox.containerSize
50 implicitHeight: MD.Tokens.checkBox.containerSize
51 color: indicatorItem.backgroundColor
52 topLeftRadius: UiMetrics.resolveShapeRadius(MD.Tokens.checkBox.containerShape.topLeft,
53 width, height)
54 topRightRadius: UiMetrics.resolveShapeRadius(MD.Tokens.checkBox.containerShape.topRight,
55 width, height)
56 bottomLeftRadius: UiMetrics.resolveShapeRadius(
57 MD.Tokens.checkBox.containerShape.bottomLeft, width, height)
58 bottomRightRadius: UiMetrics.resolveShapeRadius(
59 MD.Tokens.checkBox.containerShape.bottomRight, width, height)
60 border.width: indicatorItem.outlineWidth
61 border.color: indicatorItem.outlineColor
62
63 Behavior on color {
64 ColorAnimation {
65 duration: MD.Tokens.motion.duration.short2
66 }
67 }
68
69 Behavior on border.color {
70 ColorAnimation {
71 duration: MD.Tokens.motion.duration.short2
72 }
73 }
74
75 Behavior on border.width {
76 NumberAnimation {
77 duration: MD.Tokens.motion.duration.short2
78 }
79 }
80
81 MD.Shape {
82 id: checkmark
83
84 anchors.fill: parent
85 visible: control.checkState !== Qt.Unchecked
86
87 transform: [
88 Translate {
89 x: -7
90 y: -7
91 }
92 ]
93
94 ShapePath {
95 objectName: "svg_path:checked"
96 strokeColor: "transparent"
97 fillRule: ShapePath.WindingFill
98 fillColor: control.checkState === Qt.Checked ? indicatorItem.color : "transparent"
99 pathHints: ShapePath.PathQuadratic | ShapePath.PathNonIntersecting | ShapePath.PathNonOverlappingControlPointTriangles
100
101 PathSvg {
102 path: "M 14 18.2 L 11.4 15.6 L 10 17 L 14 21 L 22 13 L 20.6 11.6 L 14 18.2 "
103 }
104 }
105
106 ShapePath {
107 objectName: "svg_path:partially_checked"
108 strokeColor: "transparent"
109 fillRule: ShapePath.WindingFill
110 fillColor: control.checkState === Qt.PartiallyChecked ? indicatorItem.color : "transparent"
111 pathHints: ShapePath.PathQuadratic | ShapePath.PathNonIntersecting | ShapePath.PathNonOverlappingControlPointTriangles
112
113 PathSvg {
114 path: "M 13.4 15 L 11 15 L 11 17 L 13.4 17 L 21 17 L 21 15 L 13.4 15 "
115 }
116 }
117 }
118 }
119}