Warning, /maui/mauikit/src/controls.5/ListItemTemplate.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.14
0021 import QtQuick.Layouts 1.3
0022 import QtQuick.Controls 2.14
0023
0024 import org.mauikit.controls 1.3 as Maui
0025
0026 /**
0027 * ListItemTemplate
0028 * A global sidebar for the application window that can be collapsed.
0029 *
0030 *
0031 *
0032 *
0033 *
0034 *
0035 */
0036 Item
0037 {
0038 id: control
0039 /**
0040 * content : data
0041 */
0042 default property alias content: _layout.data
0043
0044 implicitHeight: _layout.implicitHeight
0045
0046 property alias spacing: _layout.spacing
0047
0048 /**
0049 * text1 : string
0050 */
0051 property alias text1 : _label1.text
0052
0053 /**
0054 * text2 : string
0055 */
0056 property alias text2 : _label2.text
0057
0058 /**
0059 * text3 : string
0060 */
0061 property alias text3 : _label3.text
0062
0063 /**
0064 * text4 : string
0065 */
0066 property alias text4 : _label4.text
0067
0068 /**
0069 * label1 : Label
0070 */
0071 property alias label1 : _label1
0072
0073 /**
0074 * label2 : Label
0075 */
0076 property alias label2 : _label2
0077
0078 /**
0079 * label3 : Label
0080 */
0081 property alias label3 : _label3
0082
0083 /**
0084 * label4 : Label
0085 */
0086 property alias label4 : _label4
0087
0088 /**
0089 * iconItemContainer : Item
0090 */
0091 property alias iconContainer : _iconLoader
0092
0093 /**
0094 * iconItem : Item
0095 */
0096 property alias iconItem : _iconLoader.item
0097
0098 /**
0099 * iconVisible : bool
0100 */
0101 property alias iconVisible : _iconLoader.visible
0102
0103 /**
0104 * leftLabels : ColumnLayout
0105 */
0106 property alias leftLabels : _leftLabels
0107
0108 /**
0109 * rightLabels : ColumnLayout
0110 */
0111 property alias rightLabels : _rightLabels
0112
0113
0114 /**
0115 * layout : RowLayout
0116 */
0117 property alias layout : _layout
0118
0119 /**
0120 * iconSizeHint : int
0121 */
0122 property int iconSizeHint : Maui.Style.iconSizes.big
0123 property int imageSizeHint : -1
0124 property int headerSizeHint : -1
0125
0126 /**
0127 * imageSource : string
0128 */
0129 property string imageSource
0130
0131 /**
0132 * iconSource : string
0133 */
0134 property string iconSource
0135
0136 /**
0137 * isCurrentItem : bool
0138 */
0139 property bool isCurrentItem: false
0140
0141 /**
0142 * labelsVisible : bool
0143 */
0144 property bool labelsVisible: true
0145
0146
0147 /**
0148 * fillMode : Image.fillMode
0149 */
0150 property int fillMode : Image.PreserveAspectFit
0151
0152 /**
0153 * maskRadius : int
0154 */
0155 property int maskRadius: 0
0156
0157
0158 /**
0159 * iconComponent : Component
0160 */
0161 property Component iconComponent : _iconComponent
0162
0163 property bool isMask : iconSizeHint <= Maui.Style.iconSizes.small
0164 property bool hovered: false
0165
0166 property bool highlighted: false
0167
0168 Component
0169 {
0170 id: _iconComponent
0171
0172 Maui.IconItem
0173 {
0174 iconSource: control.iconSource
0175 imageSource: control.imageSource
0176
0177 highlighted: control.isCurrentItem || control.highlighted
0178 hovered: control.hovered
0179
0180 iconSizeHint: control.iconSizeHint
0181 imageSizeHint: control.imageSizeHint
0182
0183 fillMode: control.fillMode
0184 maskRadius: control.maskRadius
0185
0186 isMask: control.isMask
0187 }
0188 }
0189
0190 RowLayout
0191 {
0192 id: _layout
0193 anchors.fill: parent
0194 spacing: Maui.Style.space.medium
0195
0196 readonly property color labelColor: control.isCurrentItem || control.highlighted? Maui.Theme.highlightedTextColor : Maui.Theme.textColor
0197
0198 Loader
0199 {
0200 id: _iconLoader
0201
0202 asynchronous: true
0203
0204 visible: (control.width > Maui.Style.units.gridUnit * 10) && (control.iconSource.length > 0 || control.imageSource.length > 0)
0205
0206 active: visible
0207
0208 Layout.alignment: Qt.AlignCenter
0209 Layout.fillWidth: !control.labelsVisible
0210 Layout.fillHeight: true
0211 Layout.preferredWidth: Math.max(implicitWidth, control.headerSizeHint)
0212 Layout.preferredHeight: Math.max(implicitHeight, control.headerSizeHint)
0213
0214 sourceComponent: control.iconComponent
0215 }
0216
0217
0218 ColumnLayout
0219 {
0220 id: _leftLabels
0221 clip: true
0222 visible: control.labelsVisible
0223
0224 Layout.fillHeight: true
0225 Layout.fillWidth: true
0226
0227 spacing: 0
0228
0229 Label
0230 {
0231 id: _label1
0232 visible: text.length
0233
0234 Layout.fillWidth: true
0235 Layout.fillHeight: true
0236
0237 verticalAlignment: _label2.visible ? Qt.AlignBottom : Qt.AlignVCenter
0238
0239 elide: Text.ElideRight
0240 // wrapMode: _label2.visible ? Text.NoWrap : Text.Wrap
0241 wrapMode: Text.NoWrap
0242 textFormat: Text.PlainText
0243 color: _layout.labelColor
0244 }
0245
0246 Label
0247 {
0248 id: _label2
0249 visible: text.length
0250
0251 Layout.fillWidth: true
0252 Layout.fillHeight: true
0253 verticalAlignment: _label1.visible ? Qt.AlignTop : Qt.AlignVCenter
0254
0255 elide: Text.ElideRight
0256 // wrapMode: Text.Wrap
0257 wrapMode: Text.NoWrap
0258 textFormat: Text.PlainText
0259 color: _layout.labelColor
0260 opacity: control.isCurrentItem ? 0.8 : 0.6
0261 }
0262 }
0263
0264 ColumnLayout
0265 {
0266 id: _rightLabels
0267 clip: true
0268 // visible: (control.width > Maui.Style.units.gridUnit * 15) && control.labelsVisible
0269
0270 Layout.fillHeight: true
0271 Layout.fillWidth: true
0272 Layout.maximumWidth: control.width/2
0273 Layout.preferredWidth: implicitWidth
0274 Layout.minimumWidth: 0
0275 spacing: _leftLabels.spacing
0276
0277 Label
0278 {
0279 id: _label3
0280 visible: text.length > 0
0281
0282 Layout.fillHeight: true
0283 Layout.fillWidth: true
0284
0285 Layout.alignment: Qt.AlignRight
0286
0287 horizontalAlignment: Qt.AlignRight
0288 verticalAlignment: _label4.visible ? Qt.AlignBottom : Qt.AlignVCenter
0289
0290 font.pointSize: Maui.Style.fontSizes.tiny
0291
0292 wrapMode: Text.NoWrap
0293 elide: Text.ElideMiddle
0294 textFormat: Text.PlainText
0295 color: _layout.labelColor
0296 opacity: control.isCurrentItem ? 0.8 : 0.6
0297 }
0298
0299 Label
0300 {
0301 id: _label4
0302 visible: text.length > 0
0303
0304 Layout.fillHeight: true
0305 Layout.fillWidth: true
0306
0307 Layout.alignment: Qt.AlignRight
0308 horizontalAlignment: Qt.AlignRight
0309 verticalAlignment: _label3.visible ? Qt.AlignTop : Qt.AlignVCenter
0310
0311 font.pointSize: Maui.Style.fontSizes.tiny
0312
0313 wrapMode: Text.NoWrap
0314 elide: Text.ElideMiddle
0315 textFormat: Text.PlainText
0316 color: _layout.labelColor
0317 opacity: control.isCurrentItem ? 0.8 : 0.6
0318 }
0319 }
0320 }
0321 }