Warning, /maui/mauikit/src/controls.6/LabelDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   Copyright 2018 Camilo Higuita <milo.h@aol.com>
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 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
0021 import QtQuick.Controls
0022 
0023 import org.mauikit.controls 1.3 as Maui
0024 
0025 /** 
0026  * @inherit QtQuick.Controls.Control
0027  * @brief A basic MauiKit delegate for displaying a text label with an icon in a horizontal layout.
0028  * 
0029  * @warning This item is not interactive and is meant to be use as an information label. Not press events are handled.
0030  * For a similar interactive delegate checkout ListDelegate.
0031  * @see ListDelegate
0032  * 
0033  * <a href="https://doc.qt.io/qt-6/qml-qtquick-controls-itemdelegate.html">This controls inherits from QQC2 ItemDelegate, to checkout its inherited properties refer to the Qt Docs.</a>
0034  * 
0035  * @image html Misc/labeldelegate.png
0036  * 
0037  * @code
0038  * Column
0039  * {
0040  *    width: Math.min(600, parent.width)
0041  *    anchors.centerIn: parent
0042  * 
0043  *    Maui.LabelDelegate
0044  *    {
0045  *        width: parent.width
0046  *        text: "Hola!"
0047  *        icon.name: "love"
0048  *    }
0049  * 
0050  *    Maui.LabelDelegate
0051  *    {
0052  *        width: parent.width
0053  *        text: "Section Header"
0054  *        icon.name: "anchor"
0055  *        isSection: true
0056  *    }
0057  * 
0058  * 
0059  *    Maui.LabelDelegate
0060  *    {
0061  *        width: parent.width
0062  *        text: "Regular label thingy."
0063  *    }
0064  * 
0065  *    Maui.LabelDelegate
0066  *    {
0067  *        width: parent.width
0068  *        text: "Hola!"
0069  *        icon.name: "folder"
0070  *    }
0071  * }
0072  * @endcode
0073  * 
0074  * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/LabelDelegate.qml">You can find a more complete example at this link.</a>
0075  * 
0076  */
0077 Control
0078 {
0079     id: control
0080     
0081     implicitHeight: Maui.Style.rowHeight + topPadding + bottomPadding
0082     
0083     focusPolicy: Qt.NoFocus
0084     hoverEnabled: false
0085     
0086     padding: Maui.Style.defaultPadding
0087     spacing: Maui.Style.defaultSpacing
0088     
0089     /**
0090      * @brief Whether the label should be styled as a section header.
0091      * @see SectionHeader
0092      * By default this is set to `false`.
0093      */
0094     property bool isSection : false
0095     
0096     /**
0097      * @see IconLabel::label 
0098      */
0099     property alias label: _labelTxt.label
0100     
0101     /**
0102      * @see IconLabel::color
0103      */
0104     property alias color: _labelTxt.color
0105     
0106     /**
0107      * @brief The group icon properties, to set the icon name, source, and size.
0108      */
0109     property alias icon : _dummyButton.icon
0110     
0111     /**
0112      * @see IconLabel::text
0113      */
0114     property alias text : _labelTxt.text
0115     
0116     /**
0117      * @brief An alias to the IconLabel control handling the information.
0118      * @see IconLabel for properties.
0119      * @property IconLabel LabelDelegate::template
0120      */
0121     property alias template : _labelTxt
0122     
0123     background: Item{}
0124     
0125     AbstractButton
0126     {
0127         id: _dummyButton
0128         visible: false
0129         icon.height: Maui.Style.iconSize
0130         icon.width: Maui.Style.iconSize
0131         icon.color: control.color
0132     }
0133     
0134     contentItem: MouseArea
0135     {
0136         propagateComposedEvents: true
0137         preventStealing: false
0138         //        onPressed: mouse.accepted= false
0139         
0140         Maui.IconLabel
0141         {
0142             id: _labelTxt
0143             
0144             anchors.fill: parent
0145             
0146             display: ToolButton.TextBesideIcon
0147             icon: control.icon
0148             font: control.isSection ? Maui.Style.h2Font : Maui.Style.defaultFont
0149             
0150             alignment: Qt.AlignLeft
0151             
0152             text: control.text
0153             color: control.isCurrentListItem ? control.Maui.Theme.highlightedTextColor : control.Maui.Theme.textColor
0154         }
0155     }
0156 }