Warning, /maui/mauikit/src/controls.5/GridItemTemplate.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 2.15 0021 import QtQuick.Layouts 1.3 0022 import QtQuick.Controls 2.15 0023 0024 import org.mauikit.controls 1.3 as Maui 0025 0026 /** 0027 * GridItemTemplate 0028 * A template with a icon or image and a bottom label.. 0029 * 0030 * 0031 * 0032 * 0033 * 0034 * 0035 */ 0036 Item 0037 { 0038 id: control 0039 focus: true 0040 property alias spacing: _layout.spacing 0041 0042 implicitHeight: _layout.implicitHeight 0043 0044 /** 0045 * content : data 0046 */ 0047 default property alias content: _layout.data 0048 0049 /** 0050 * text1 : string 0051 */ 0052 property alias text1 : _label1.text 0053 0054 /** 0055 * label1 : Label 0056 */ 0057 property alias label1 : _label1 0058 0059 /** 0060 * label1 : Label 0061 */ 0062 property alias label2 : _label2 0063 0064 /** 0065 * iconItem : Item 0066 */ 0067 property alias iconItem : _iconLoader.item 0068 0069 /** 0070 * iconItemContainer : Item 0071 */ 0072 property alias iconContainer : _iconLoader 0073 0074 /** 0075 * iconVisible : bool 0076 */ 0077 property alias iconVisible : _iconLoader.visible 0078 0079 /** 0080 * labelSizeHint : int 0081 */ 0082 property alias labelSizeHint : _labelsContainer.labelSizeHint 0083 0084 /** 0085 * iconSizeHint : int 0086 */ 0087 property int iconSizeHint : Maui.Style.iconSizes.big 0088 property int imageSizeHint : -1 0089 0090 /** 0091 * imageSource : string 0092 */ 0093 property string imageSource 0094 0095 /** 0096 * iconSource : string 0097 */ 0098 property string iconSource 0099 0100 /** 0101 * isCurrentItem : bool 0102 */ 0103 property bool isCurrentItem: false 0104 0105 /** 0106 * labelsVisible : bool 0107 */ 0108 property bool labelsVisible: true 0109 0110 /** 0111 * fillMode : Image.fillMode 0112 */ 0113 property int fillMode : Image.PreserveAspectCrop 0114 0115 /** 0116 * maskRadius : int 0117 */ 0118 property int maskRadius: 0 0119 0120 0121 property int imageWidth : -1 0122 0123 property int imageHeight: -1 0124 0125 property bool smooth : false 0126 0127 property bool isMask : iconSizeHint <= Maui.Style.iconSizes.small 0128 0129 property bool hovered: false 0130 0131 property bool autoTransform: false 0132 0133 property bool highlighted: false 0134 0135 property int alignment: Qt.AlignHCenter 0136 /** 0137 * iconComponent : Component 0138 */ 0139 property Component iconComponent : _iconComponent 0140 0141 Component 0142 { 0143 id: _iconComponent 0144 0145 Maui.IconItem 0146 { 0147 iconSource: control.iconSource 0148 imageSource: control.imageSource 0149 0150 highlighted: control.isCurrentItem || control.highlighted 0151 hovered: control.hovered 0152 smooth: control.smooth 0153 iconSizeHint: control.iconSizeHint 0154 imageSizeHint: control.imageSizeHint 0155 0156 fillMode: control.fillMode 0157 maskRadius: control.maskRadius 0158 0159 imageWidth: control.imageWidth 0160 imageHeight: control.imageHeight 0161 0162 isMask: control.isMask 0163 image.autoTransform: control.autoTransform 0164 0165 alignment: control.alignment 0166 0167 } 0168 } 0169 0170 ColumnLayout 0171 { 0172 id: _layout 0173 anchors.fill: parent 0174 spacing: Maui.Style.space.medium 0175 0176 Loader 0177 { 0178 id: _iconLoader 0179 0180 Layout.fillWidth: true 0181 Layout.fillHeight: true 0182 0183 asynchronous: true 0184 active: visible 0185 sourceComponent: control.iconComponent 0186 0187 Behavior on scale 0188 { 0189 NumberAnimation 0190 { 0191 duration: Maui.Style.units.longDuration 0192 easing.type: Easing.OutBack 0193 } 0194 } 0195 } 0196 0197 Item 0198 { 0199 id: _labelsContainer 0200 property int labelSizeHint: Math.min(64, _labels.implicitHeight) 0201 visible: control.labelsVisible && ( _label1.text || _label2.text) 0202 0203 Layout.preferredHeight: labelSizeHint 0204 Layout.fillWidth: true 0205 Layout.maximumHeight: control.height* 0.9 0206 Layout.minimumHeight: labelSizeHint 0207 0208 ColumnLayout 0209 { 0210 id: _labels 0211 anchors.fill: parent 0212 spacing: Maui.Style.space.tiny 0213 0214 Label 0215 { 0216 id: _label1 0217 visible: text && text.length 0218 0219 horizontalAlignment: control.alignment 0220 verticalAlignment: Qt.AlignVCenter 0221 0222 Layout.fillWidth: true 0223 Layout.fillHeight: true 0224 Layout.alignment: Qt.AlignCenter 0225 0226 elide: Qt.ElideRight 0227 wrapMode: Text.Wrap 0228 color: control.isCurrentItem || control.highlighted? control.Maui.Theme.highlightedTextColor : control.Maui.Theme.textColor 0229 } 0230 0231 Label 0232 { 0233 id: _label2 0234 visible: text.length 0235 0236 horizontalAlignment: control.alignment 0237 verticalAlignment: Qt.AlignVCenter 0238 0239 Layout.fillWidth: visible 0240 Layout.fillHeight: true 0241 Layout.alignment: Qt.AlignCenter 0242 0243 elide: Qt.ElideRight 0244 wrapMode: Text.NoWrap 0245 color: control.isCurrentItem || control.highlighted? control.Maui.Theme.highlightedTextColor : control.Maui.Theme.textColor 0246 opacity: control.isCurrentItem ? 0.8 : 0.6 0247 } 0248 } 0249 } 0250 } 0251 }