MauiKit Controls

CheckBoxItem.qml
1import QtQuick
2import org.mauikit.controls as Maui
3
4Item
5{
6 id: control
7
8 implicitHeight: Maui.Style.iconSize + 2
9 implicitWidth: implicitHeight
10
11 property bool checked : false
12 property bool checkable: false
13 property bool autoExclusive: false
14 property bool hovered: false
15 // signal toggled(bool state)
16
17 Rectangle
18 {
19 id: _rec
20 anchors.fill: parent
21 color: control.checked ? Maui.Theme.backgroundColor : Maui.Theme.backgroundColor
22 radius: control.autoExclusive ? height/2 : 4
23 border.color: control.checked ? Maui.Theme.highlightColor : Maui.ColorUtils.linearInterpolation(Maui.Theme.alternateBackgroundColor, Maui.Theme.textColor, 0.2)
24 border.width: 2
25
26 Maui.Icon
27 {
28 visible: opacity > 0
29
30 color: Maui.Theme.highlightColor
31
32 anchors.centerIn: parent
33
34 height: control.checked ? Math.round(parent.height*0.9) : 0
35 width: height
36
37 opacity: control.checked ? 1 : 0
38
39 isMask: true
40
41 source: "qrc:/assets/checkmark.svg"
42
43 Behavior on opacity
44 {
45 NumberAnimation
46 {
47 duration: Maui.Style.units.shortDuration
48 easing.type: Easing.InOutQuad
49 }
50 }
51
52 Behavior on color
53 {
54 Maui.ColorTransition{}
55 }
56 }
57
58 Behavior on color
59 {
60 Maui.ColorTransition{}
61 }
62 }
63
64 onCheckedChanged:
65 {
66 if(checked)
67 {
68 _checkAnimation.start()
69 }else
70 {
71 _uncheckAnimation.start()
72 }
73 }
74
75 NumberAnimation
76 {
77 id: _checkAnimation
78 target: control
79 property: "scale"
80 from: 1.3
81 to: 1
82 duration: Maui.Style.units.longDuration
83 easing.type: Easing.OutBack
84 }
85
86 NumberAnimation
87 {
88 id: _uncheckAnimation
89 target: control
90 property: "scale"
91 from: 0.7
92 to: 1
93 duration: Maui.Style.units.longDuration
94 easing.type: Easing.InBack
95 }
96}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.