Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/ItemDelegate.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     SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0005 
0006     SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later
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.ItemDelegate {
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 + (indicator ? implicitIndicatorWidth + spacing : 0) : horizontalPadding
0030     rightPadding: mirrored ? horizontalPadding + (indicator ? implicitIndicatorWidth + spacing : 0) : 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             selected: controlRoot.highlighted || controlRoot.down
0047             Layout.alignment: Qt.AlignVCenter
0048             visible: controlRoot.icon.name.length > 0 || controlRoot.icon.source.toString().length > 0
0049             source: controlRoot.icon.name.length > 0 ? controlRoot.icon.name : controlRoot.icon.source
0050             Layout.preferredHeight: controlRoot.icon.height
0051             Layout.preferredWidth: controlRoot.icon.width
0052         }
0053 
0054         Label {
0055             id: textLabel
0056 
0057             text: controlRoot.text
0058             font: controlRoot.font
0059             color: controlRoot.highlighted || controlRoot.down
0060                 ? Kirigami.Theme.highlightedTextColor
0061                 : (controlRoot.enabled ? Kirigami.Theme.textColor : Kirigami.Theme.disabledTextColor)
0062 
0063             elide: Text.ElideRight
0064             visible: controlRoot.text
0065             horizontalAlignment: Text.AlignLeft
0066             verticalAlignment: Text.AlignVCenter
0067             Layout.alignment: Qt.AlignLeft
0068             Layout.fillWidth: true
0069         }
0070     }
0071 
0072     background: Private.DefaultListItemBackground {
0073         control: controlRoot
0074     }
0075 }