Warning, /plasma/latte-dock/declarativeimports/components/ItemDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   Copyright 2016 Marco Martin <mart@kde.org>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU Library General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 
0020 import QtQuick 2.5
0021 import QtQuick.Layouts 1.3
0022 import QtQuick.Templates 2.2 as T
0023 import org.kde.plasma.core 2.0 as PlasmaCore
0024 
0025 import org.kde.latte.components 1.0 as LatteComponents
0026 
0027 import "private" as Private
0028 
0029 T.CheckDelegate {
0030     id: control
0031 
0032     implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
0033     implicitHeight: Math.max(contentItem.implicitHeight,
0034                              indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding
0035     hoverEnabled: true
0036 
0037     topPadding: margin
0038     bottomPadding: margin
0039     leftPadding: margin
0040     rightPadding: margin
0041     spacing: units.smallSpacing
0042 
0043     property bool blankSpaceForEmptyIcons: false
0044     property string icon
0045     property string iconToolTip
0046     property bool iconOnlyWhenHovered
0047 
0048     readonly property bool isHovered: hovered || iconMouseArea.containsMouse
0049     readonly property int margin: 4
0050 
0051     contentItem: RowLayout {
0052         Layout.leftMargin: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0
0053         Layout.rightMargin: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0
0054         spacing: units.smallSpacing
0055         enabled: control.enabled
0056 
0057         Rectangle {
0058             Layout.minimumWidth: parent.height
0059             Layout.maximumWidth: parent.height
0060             Layout.minimumHeight: parent.height
0061             Layout.maximumHeight: parent.height
0062             visible: icon && (!control.iconOnlyWhenHovered || (control.iconOnlyWhenHovered && control.isHovered))
0063             color: control.iconToolTip && iconMouseArea.containsMouse ? theme.highlightColor : "transparent"
0064 
0065             PlasmaCore.IconItem {
0066                 id: iconElement
0067                 anchors.fill: parent
0068                 colorGroup: PlasmaCore.Theme.ButtonColorGroup
0069                 source: control.icon
0070             }
0071 
0072             LatteComponents.ToolTip{
0073                 parent: iconElement
0074                 text: iconToolTip
0075                 visible: iconMouseArea.containsMouse
0076                 delay: 6 * units.longDuration
0077             }
0078 
0079             MouseArea {
0080                 id: iconMouseArea
0081                 anchors.fill: parent
0082                 hoverEnabled: true
0083                 visible: control.iconToolTip
0084 
0085                 onClicked: control.ListView.view.iconClicked(index);
0086             }
0087         }
0088 
0089         Rectangle {
0090             //blank space when no icon is shown
0091             Layout.minimumHeight: parent.height
0092             Layout.minimumWidth: parent.height
0093             visible: control.blankSpaceForEmptyIcons && (!icon || (control.iconOnlyWhenHovered && !control.isHovered) )
0094             color: "transparent"
0095         }
0096 
0097         Label {
0098             Layout.fillWidth: true
0099             text: control.text
0100             font: control.font
0101             color: theme.viewTextColor
0102             elide: Text.ElideRight
0103             visible: control.text
0104             horizontalAlignment: Text.AlignLeft
0105             verticalAlignment: Text.AlignVCenter
0106         }
0107     }
0108 
0109     //background: Private.DefaultListItemBackground {}
0110     background: Rectangle {
0111         visible: control.ListView.view ? control.ListView.view.highlight === null : true
0112         enabled: control.enabled
0113         opacity: {
0114             if (control.highlighted || control.pressed) {
0115                 return 0.6;
0116             } else if (control.isHovered && !control.pressed) {
0117                 return 0.3;
0118             }
0119 
0120             return 0;
0121         }
0122 
0123         color: theme.highlightColor
0124     }
0125 }