Libplasma

CheckDelegate.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
10import org.kde.kirigami as Kirigami
11import org.kde.ksvg as KSvg
12import "private" as Private
13
14T.CheckDelegate {
15 id: control
16
17 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
18 implicitContentWidth + leftPadding + rightPadding,
19 implicitIndicatorWidth + leftPadding + rightPadding)
20 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
21 implicitContentHeight + topPadding + bottomPadding,
22 implicitIndicatorHeight + topPadding + bottomPadding)
23
24 baselineOffset: contentItem.y + contentItem.baselineOffset
25 hoverEnabled: true
26
27 topPadding: (background as KSvg.FrameSvgItem)?.margins.top ?? undefined
28 leftPadding: (background as KSvg.FrameSvgItem)?.margins.left ?? undefined
29 rightPadding: (background as KSvg.FrameSvgItem)?.margins.right ?? undefined
30 bottomPadding: (background as KSvg.FrameSvgItem)?.margins.bottom ?? undefined
31
32 spacing: Kirigami.Units.smallSpacing
33
34 icon.width: Kirigami.Units.iconSizes.sizeForLabels
35 icon.height: Kirigami.Units.iconSizes.sizeForLabels
36
37 contentItem: Private.IconLabel {
38 readonly property int effectiveIndicatorWidth: control.indicator && control.indicator.visible && control.indicator.width > 0
39 ? control.indicator.width + control.spacing : 0
40
41 mirrored: control.mirrored
42 leftPadding: !control.mirrored ? 0 : effectiveIndicatorWidth
43 rightPadding: control.mirrored ? 0 : effectiveIndicatorWidth
44
45 font: control.font
46 alignment: Qt.AlignLeft
47 display: control.display
48 spacing: control.spacing
49 iconItem.implicitWidth: control.icon.width
50 iconItem.implicitHeight: control.icon.height
51 iconItem.source: control.icon.name || control.icon.source
52 label.text: control.text
53 }
54
55 indicator: CheckIndicator {
56 x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
57 y: control.topPadding + Math.round((control.availableHeight - height) / 2)
58
59 control: control
60 }
61
62 background: Private.DefaultListItemBackground {
63 control: control
64 }
65}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:54:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.