MauiKit Controls

FlexSectionItem.qml
1/*
2 * Copyright 2018 Camilo Higuita <milo.h@aol.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as
6 * published by the Free Software Foundation; either version 2, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20import QtQuick
21import QtQuick.Layouts
22
23import org.mauikit.controls 1.3 as Maui
24
25/**
26 * @inherit FlexListItem
27 * @since org.mauikit.controls
28 * @brief An item used for holding information in a responsive layout.
29 * This control inherits from MauiKit FlexListItem, to checkout its inherited properties refer to the docs.
30 *
31 * @note There is also the SectionItem, which uses a static column layout for positioning its content.
32 * @see FlexSectionItem
33 *
34 * This control is a wrapper around the FlexListItem, with some added functionality.
35 *
36 * @image html Misc/flexsectionitem.png "Demo of a flex section being wrapped"
37 *
38 * @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.
39 *
40 * <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>
41 */
42Maui.FlexListItem
43{
44 id: control
45
46 padding: Maui.Style.defaultPadding
47 spacing: Maui.Style.space.small
48
49 Layout.fillWidth: true
50 hoverEnabled: !Maui.Handy.isMobile
51
52 /**
53 * @brief Whether the control should be styled as flat, as in not having a background or hover/pressed visual effect hints.
54 * By default this is set to `!Handy.isMobile`
55 * @see Handy::isMobile
56 */
57 property bool flat : !Maui.Handy.isMobile
58
59 /**
60 * @brief Whether the first children element from the `content` is checkable.
61 * If it is the the control will have a hover effct to hint about the item being checkable.
62 */
63 readonly property bool childCheckable : control.content.length === 1 && control.content[0].hasOwnProperty("checkable") ? control.content[0].checkable : false
64
65 background: Rectangle
66 {
67 color: control.enabled ? ( control.childCheckable && control.hovered ? Maui.Theme.hoverColor : (control.flat ? "transparent" : Maui.Theme.alternateBackgroundColor)) : "transparent"
68 radius: Maui.Style.radiusV
69
70 Behavior on color
71 {
72 enabled: !control.flat
73 Maui.ColorTransition{}
74 }
75 }
76
77 onClicked:
78 {
79 if(control.childCheckable)
80 {
81 control.content[0].toggled()
82 }
83 }
84}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.