Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/SwitchDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org> 0003 SPDX-FileCopyrightText: 2017 The Qt Company Ltd. 0004 0005 SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later 0006 */ 0007 0008 0009 import QtQuick 0010 import QtQuick.Layouts 0011 import QtQuick.Templates as T 0012 import org.kde.kirigami as Kirigami 0013 import org.kde.desktop.private as Private 0014 0015 T.SwitchDelegate { 0016 id: controlRoot 0017 0018 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, 0019 implicitContentWidth + leftPadding + rightPadding) 0020 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, 0021 implicitContentHeight + topPadding + bottomPadding, 0022 implicitIndicatorHeight + topPadding + bottomPadding) 0023 0024 hoverEnabled: true 0025 0026 spacing: Kirigami.Units.smallSpacing 0027 padding: Kirigami.Settings.tabletMode ? Kirigami.Units.largeSpacing : Kirigami.Units.mediumSpacing 0028 horizontalPadding: Kirigami.Units.smallSpacing * 2 0029 leftPadding: !mirrored ? horizontalPadding + implicitIndicatorWidth + spacing : horizontalPadding 0030 rightPadding: mirrored ? horizontalPadding + implicitIndicatorWidth + spacing : horizontalPadding 0031 0032 icon.width: Kirigami.Units.iconSizes.smallMedium 0033 icon.height: Kirigami.Units.iconSizes.smallMedium 0034 0035 T.ToolTip.visible: (Kirigami.Settings.tabletMode ? down : hovered) && (contentItem.truncated ?? false) 0036 T.ToolTip.text: text 0037 T.ToolTip.delay: Kirigami.Units.toolTipDelay 0038 0039 contentItem: RowLayout { 0040 LayoutMirroring.enabled: controlRoot.mirrored 0041 spacing: controlRoot.spacing 0042 0043 property alias truncated: textLabel.truncated 0044 0045 Kirigami.Icon { 0046 Layout.alignment: Qt.AlignVCenter 0047 visible: controlRoot.icon.name !== "" || controlRoot.icon.source.toString() !== "" 0048 source: controlRoot.icon.name !== "" ? controlRoot.icon.name : controlRoot.icon.source 0049 Layout.preferredHeight: controlRoot.icon.height 0050 Layout.preferredWidth: controlRoot.icon.width 0051 } 0052 0053 Label { 0054 id: textLabel 0055 0056 text: controlRoot.text 0057 font: controlRoot.font 0058 color: (controlRoot.pressed && !controlRoot.checked && !controlRoot.sectionDelegate) ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor 0059 elide: Text.ElideRight 0060 visible: controlRoot.text 0061 horizontalAlignment: Text.AlignLeft 0062 verticalAlignment: Text.AlignVCenter 0063 } 0064 } 0065 0066 indicator: Private.SwitchIndicator { 0067 x: !controlRoot.mirrored ? controlRoot.horizontalPadding : controlRoot.width - width - controlRoot.horizontalPadding 0068 y: controlRoot.topPadding + (controlRoot.availableHeight - height) / 2 0069 control: controlRoot 0070 } 0071 0072 background: Private.DefaultListItemBackground { 0073 control: controlRoot 0074 } 0075 }