Warning, /plasma/latte-dock/declarativeimports/components/ItemDelegate.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
0003
0004 SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006
0007 import QtQuick 2.5
0008 import QtQuick.Layouts 1.3
0009 import QtQuick.Templates 2.2 as T
0010 import org.kde.plasma.core 2.0 as PlasmaCore
0011
0012 import org.kde.latte.components 1.0 as LatteComponents
0013
0014 import "private" as Private
0015
0016 T.CheckDelegate {
0017 id: control
0018 implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
0019 implicitHeight: isSeparator ? 1 : Math.max(contentItem.implicitHeight, indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding
0020 hoverEnabled: !isSeparator
0021
0022 topPadding: margin
0023 bottomPadding: margin
0024 leftPadding: isSeparator ? 0 : margin
0025 rightPadding: isSeparator ? 0 : margin
0026 spacing: units.smallSpacing
0027
0028 property bool isSeparator: false
0029
0030 property bool blankSpaceForEmptyIcons: false
0031 property string icon
0032 property string iconToolTip
0033 property bool iconOnlyWhenHovered
0034 property string toolTip
0035
0036 property int textHorizontalAlignment: Text.AlignLeft
0037
0038 readonly property bool isHovered: hovered || iconMouseArea.containsMouse
0039 readonly property int margin: isSeparator ? 1 : 4
0040
0041 contentItem: RowLayout {
0042 Layout.leftMargin: control.mirrored && !isSeparator ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0
0043 Layout.rightMargin: !control.mirrored && !isSeparator ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0
0044 spacing: isSeparator ? 0 : units.smallSpacing
0045 enabled: control.enabled
0046
0047 Rectangle {
0048 Layout.minimumWidth: parent.height
0049 Layout.maximumWidth: parent.height
0050 Layout.minimumHeight: parent.height
0051 Layout.maximumHeight: parent.height
0052 visible: !isSeparator && icon && (!control.iconOnlyWhenHovered || (control.iconOnlyWhenHovered && control.isHovered))
0053 color: control.iconToolTip && iconMouseArea.containsMouse ? theme.highlightColor : "transparent"
0054
0055 PlasmaCore.IconItem {
0056 id: iconElement
0057 anchors.fill: parent
0058 colorGroup: PlasmaCore.Theme.ButtonColorGroup
0059 source: control.icon
0060 }
0061
0062 LatteComponents.ToolTip{
0063 parent: iconElement
0064 text: iconToolTip
0065 visible: iconMouseArea.containsMouse
0066 delay: 6 * units.longDuration
0067 }
0068
0069 MouseArea {
0070 id: iconMouseArea
0071 anchors.fill: parent
0072 hoverEnabled: true
0073 visible: control.iconToolTip
0074
0075 onClicked: control.ListView.view.iconClicked(index);
0076 }
0077 }
0078
0079 Rectangle {
0080 //blank space when no icon is shown
0081 Layout.minimumHeight: parent.height
0082 Layout.minimumWidth: parent.height
0083 visible: !isSeparator && control.blankSpaceForEmptyIcons && (!icon || (control.iconOnlyWhenHovered && !control.isHovered) )
0084 color: "transparent"
0085 }
0086
0087 Label {
0088 Layout.fillWidth: true
0089 text: control.text
0090 font: control.font
0091 color: theme.viewTextColor
0092 elide: Text.ElideRight
0093 visible: !isSeparator && control.text
0094 horizontalAlignment: control.textHorizontalAlignment
0095 verticalAlignment: Text.AlignVCenter
0096 }
0097
0098 Rectangle {
0099 width: parent.width
0100 height: 1
0101 color: theme.textColor
0102 opacity: 0.25
0103 visible: isSeparator
0104 }
0105 }
0106
0107 //background: Private.DefaultListItemBackground {}
0108 background: Rectangle {
0109 visible: isSeparator ? false : (control.ListView.view ? control.ListView.view.highlight === null : true)
0110 enabled: control.enabled
0111 opacity: {
0112 if (control.highlighted || control.pressed) {
0113 return 0.6;
0114 } else if (control.isHovered && !control.pressed) {
0115 return 0.3;
0116 }
0117
0118 return 0;
0119 }
0120
0121 color: theme.highlightColor
0122 }
0123 }