Warning, /plasma/plasma-desktop/applets/kickoff/package/contents/ui/KickoffListDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2011 Martin *Gräßlin <mgraesslin@kde.org>
0003     SPDX-FileCopyrightText: 2012 Gregor Taetzner <gregor@freenet.de>
0004     SPDX-FileCopyrightText: 2014 Sebastian Kügler <sebas@kde.org>
0005     SPDX-FileCopyrightText: 2015-2018 Eike Hein <hein@kde.org>
0006     SPDX-FileCopyrightText: 2021 Mikel Johnson <mikel5764@gmail.com>
0007     SPDX-FileCopyrightText: 2021 Noah Davis <noahadvs@gmail.com>
0008     SPDX-FileCopyrightText: 2022 Nate Graham <nate@kde.org>
0009 
0010     SPDX-License-Identifier: GPL-2.0-or-later
0011  */
0012 import QtQuick 2.15
0013 import QtQml 2.15
0014 import QtQuick.Layouts 1.15
0015 import org.kde.ksvg 1.0 as KSvg
0016 import org.kde.plasma.components 3.0 as PC3
0017 import org.kde.kirigami 2.20 as Kirigami
0018 import org.kde.plasma.plasmoid 2.0
0019 
0020 AbstractKickoffItemDelegate {
0021     id: root
0022 
0023     property bool compact: Kirigami.Settings.tabletMode ? false : Plasmoid.configuration.compactMode
0024 
0025     leftPadding: KickoffSingleton.listItemMetrics.margins.left
0026     + (mirrored ? KickoffSingleton.fontMetrics.descent : 0)
0027     rightPadding: KickoffSingleton.listItemMetrics.margins.right
0028     + (!mirrored ? KickoffSingleton.fontMetrics.descent : 0)
0029     // Otherwise it's *too* compact :)
0030     topPadding: compact ? Kirigami.Units.mediumSpacing : Kirigami.Units.smallSpacing
0031     bottomPadding: compact ? Kirigami.Units.mediumSpacing : Kirigami.Units.smallSpacing
0032 
0033     icon.width: compact || root.isCategoryListItem ? Kirigami.Units.iconSizes.smallMedium : Kirigami.Units.iconSizes.medium
0034     icon.height: compact || root.isCategoryListItem ? Kirigami.Units.iconSizes.smallMedium : Kirigami.Units.iconSizes.medium
0035 
0036     labelTruncated: label.truncated
0037     descriptionTruncated: descriptionLabel.truncated
0038     descriptionVisible: descriptionLabel.visible
0039 
0040     dragIconItem: icon
0041 
0042     contentItem: RowLayout {
0043         id: row
0044         spacing: KickoffSingleton.listItemMetrics.margins.left * 2
0045 
0046         Kirigami.Icon {
0047             id: icon
0048             implicitWidth: root.icon.width
0049             implicitHeight: root.icon.height
0050             Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
0051 
0052             animated: false
0053             selected: root.iconAndLabelsShouldlookSelected
0054             source: root.decoration || root.icon.name || root.icon.source
0055         }
0056 
0057         GridLayout {
0058             id: gridLayout
0059 
0060             readonly property color textColor: root.iconAndLabelsShouldlookSelected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
0061 
0062             Layout.fillWidth: true
0063 
0064             rows: root.compact ? 1 : 2
0065             columns: root.compact ? 2 : 1
0066             rowSpacing: 0
0067             columnSpacing: Kirigami.Units.largeSpacing
0068 
0069             PC3.Label {
0070                 id: label
0071                 Layout.fillWidth: !descriptionLabel.visible
0072                 Layout.maximumWidth: root.width - root.leftPadding - root.rightPadding - icon.width - row.spacing
0073                 Layout.preferredHeight: {
0074                     if (root.isCategoryListItem) {
0075                         return root.compact ? implicitHeight : Math.round(implicitHeight * 1.5);
0076                     }
0077                     if (!root.compact && !descriptionLabel.visible) {
0078                         return implicitHeight + descriptionLabel.implicitHeight
0079                     }
0080                     return implicitHeight;
0081                 }
0082                 text: root.text
0083                 textFormat: Text.PlainText
0084                 elide: Text.ElideRight
0085                 verticalAlignment: Text.AlignVCenter
0086                 maximumLineCount: 1
0087                 color: gridLayout.textColor
0088             }
0089 
0090             PC3.Label {
0091                 id: descriptionLabel
0092                 Layout.fillWidth: true
0093                 // Don't want to show descriptions for apps in the category list, because
0094                 // there's not enough room for them with the category list item height
0095                 visible: text.length > 0 && text !== root.text && !root.isCategoryListItem
0096                 enabled: false
0097                 text: root.description
0098                 textFormat: Text.PlainText
0099                 font: Kirigami.Theme.smallFont
0100                 elide: Text.ElideRight
0101                 verticalAlignment: Text.AlignVCenter
0102                 horizontalAlignment: root.compact ? Text.AlignRight : Text.AlignLeft
0103                 maximumLineCount: 1
0104                 color: gridLayout.textColor
0105             }
0106         }
0107     }
0108 
0109     Loader {
0110         id: separatorLoader
0111 
0112         anchors.left: root.left
0113         anchors.right: root.right
0114         anchors.verticalCenter: root.verticalCenter
0115 
0116         active: root.isSeparator
0117 
0118         asynchronous: false
0119         sourceComponent: KSvg.SvgItem {
0120             width: parent.width
0121             height: KickoffSingleton.lineSvg.horLineHeight
0122 
0123             svg: KickoffSingleton.lineSvg
0124             elementId: "horizontal-line"
0125         }
0126     }
0127 }