Warning, /maui/mauikit/src/controls.6/FlexSectionItem.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.Layouts
0022 
0023 import org.mauikit.controls 1.3 as Maui
0024 
0025 /**
0026  * @inherit FlexListItem
0027  * @since org.mauikit.controls
0028  * @brief An item used for holding information in a responsive layout.
0029  * This control inherits from MauiKit FlexListItem, to checkout its inherited properties refer to the docs.
0030  * 
0031  *  @note There is also the SectionItem, which uses a static column layout for positioning its content.
0032  * @see FlexSectionItem
0033  * 
0034  * This control is a wrapper around the FlexListItem, with some added functionality.
0035  * 
0036  * @image html Misc/flexsectionitem.png "Demo of a flex section being wrapped"
0037  * 
0038  * @note If the first and single child element of this control is `checkable`, then the state of such control will be toggled by clicking on the area of the FlexSectionItem.
0039  * 
0040  * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/FlexSectionItem.qml">You can find a more complete example at this link.</a> 
0041  */
0042 Maui.FlexListItem
0043 {
0044     id: control
0045     
0046     padding: Maui.Style.defaultPadding
0047     spacing: Maui.Style.space.small
0048     
0049     Layout.fillWidth: true
0050     hoverEnabled: !Maui.Handy.isMobile
0051     
0052     /**
0053      * @brief Whether the control should be styled as flat, as in not having a background or hover/pressed visual effect hints.
0054      * By default this is set to `!Handy.isMobile`
0055      * @see Handy::isMobile
0056      */
0057     property bool flat : !Maui.Handy.isMobile
0058     
0059     /**
0060      * @brief Whether the first children element from the `content` is checkable. 
0061      * If it is the the control will have a hover effct to hint about the item being checkable.
0062      */ 
0063     readonly property bool childCheckable : control.content.length === 1 && control.content[0].hasOwnProperty("checkable") ? control.content[0].checkable : false
0064     
0065     background: Rectangle
0066     {       
0067         color: control.enabled ? ( control.childCheckable && control.hovered ? Maui.Theme.hoverColor : (control.flat ? "transparent" : Maui.Theme.alternateBackgroundColor)) : "transparent"        
0068         radius: Maui.Style.radiusV   
0069         
0070         Behavior on color
0071         {
0072             enabled: !control.flat
0073             Maui.ColorTransition{}
0074         }
0075     }
0076     
0077     onClicked:
0078     {
0079         if(control.childCheckable)
0080         {
0081             control.content[0].toggled()
0082         }        
0083     }
0084 }