Plasma-framework

CheckIndicator.qml
1/*
2 SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
3 SPDX-FileCopyrightText: 2022 ivan (@ratijas) tkachenko <me@ratijas.tk>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8import QtQuick
9import QtQuick.Templates as T
10
11import org.kde.ksvg as KSvg
12//NOTE: importing PlasmaCore is necessary in order to make KSvg load the current Plasma Theme
13import org.kde.plasma.core as PlasmaCore
14import org.kde.kirigami as Kirigami
15import "private" as Private
16
18 id: root
19
20 required property T.AbstractButton control
21
22 imagePath: "widgets/button"
23 prefix: "normal"
24 implicitWidth: Kirigami.Units.iconSizes.small
25 implicitHeight: Kirigami.Units.iconSizes.small
26 opacity: control.enabled ? 1 : 0.6
27
28 Private.ButtonShadow {
29 anchors.fill: parent
30 showShadow: !control.down
31 }
32
34 anchors.fill: parent
35 svg: KSvg.Svg {
36 id: checkmarkSvg
37 imagePath: "widgets/checkmarks"
38 }
39 elementId: "checkbox"
40 opacity: {
41 if (control instanceof T.CheckBox) {
42 switch (control.checkState) {
43 case Qt.Checked:
44 return 1;
45 case Qt.PartiallyChecked:
46 return 0.5;
47 default:
48 return 0;
49 }
50 } else {
51 return control.checked ? 1 : 0;
52 }
53 }
54 Behavior on opacity {
55 enabled: Kirigami.Units.longDuration > 0
56 NumberAnimation {
57 duration: Kirigami.Units.longDuration
58 easing.type: Easing.InOutQuad
59 }
60 }
61 }
62
63 Private.ButtonFocus {
64 anchors.fill: parent
65 showFocus: control.visualFocus && !control.down
66 }
67
68 Private.ButtonHover {
69 anchors.fill: parent
70 showHover: control.hovered
71 }
72}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.