Warning, /maui/nomad-style/MenuItem.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright 2017 Marco Martin <mart@kde.org>
0003  * Copyright 2017 The Qt Company Ltd.
0004  *
0005  * GNU Lesser General Public License Usage
0006  * Alternatively, this file may be used under the terms of the GNU Lesser
0007  * General Public License version 3 as published by the Free Software
0008  * Foundation and appearing in the file LICENSE.LGPLv3 included in the
0009  * packaging of this file. Please review the following information to
0010  * ensure the GNU Lesser General Public License version 3 requirements
0011  * will be met: https://www.gnu.org/licenses/lgpl.html.
0012  *
0013  * GNU General Public License Usage
0014  * Alternatively, this file may be used under the terms of the GNU
0015  * General Public License version 2.0 or later as published by the Free
0016  * Software Foundation and appearing in the file LICENSE.GPL included in
0017  * the packaging of this file. Please review the following information to
0018  * ensure the GNU General Public License version 2.0 requirements will be
0019  * met: http://www.gnu.org/licenses/gpl-2.0.html.
0020  */
0021 
0022 
0023 import QtQuick 2.6
0024 import QtQuick.Layouts 1.2
0025 import QtQuick.Templates 2.3 as T
0026 import org.kde.kirigami 2.2 as Kirigami
0027 
0028 T.MenuItem {
0029     id: controlRoot
0030 
0031     implicitWidth: Math.max(background ? background.implicitWidth : 0,
0032                             contentItem.implicitWidth + leftPadding + rightPadding)
0033     implicitHeight: Math.max(background ? background.implicitHeight : 0,
0034                              Math.max(contentItem.implicitHeight,
0035                                       indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
0036     baselineOffset: contentItem.y + contentItem.baselineOffset
0037 
0038     Layout.fillWidth: true
0039     padding: Kirigami.Settings.isMobile ? Kirigami.Units.largeSpacing : Kirigami.Units.smallSpacing
0040     hoverEnabled: true
0041 
0042     contentItem: Label {
0043         leftPadding: !controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0
0044         rightPadding: controlRoot.mirrored ? (controlRoot.indicator ? controlRoot.indicator.width : 0) + controlRoot.spacing : 0
0045 
0046         text: controlRoot.text
0047         font: controlRoot.font
0048         color: controlRoot.hovered && !controlRoot.pressed ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
0049         elide: Text.ElideRight
0050         visible: controlRoot.text
0051         horizontalAlignment: Text.AlignLeft
0052         verticalAlignment: Text.AlignVCenter
0053     }
0054 
0055     indicator: CheckIndicator {
0056         x: controlRoot.mirrored ? controlRoot.width - width - controlRoot.rightPadding : controlRoot.leftPadding
0057         y: controlRoot.topPadding + (controlRoot.availableHeight - height) / 2
0058 
0059         visible: controlRoot.checkable
0060         on: controlRoot.checked
0061         control: controlRoot
0062     }
0063 
0064     background: Item {
0065         anchors.fill: parent
0066         implicitWidth: Kirigami.Units.gridUnit * 8
0067 
0068         Rectangle {
0069             anchors.fill: parent
0070             color: Kirigami.Theme.highlightColor
0071             opacity: controlRoot.hovered && !controlRoot.pressed ? 1 : 0
0072             Behavior on opacity { NumberAnimation { duration: 150 } }
0073         }
0074     }
0075 }