Warning, /frameworks/kirigami/tests/BasicListItemTest.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2021 Nate Graham <nate@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Layouts 1.15 0009 import QtQuick.Controls 2.15 as QQC2 0010 0011 import org.kde.kirigami 2.20 as Kirigami 0012 0013 Kirigami.ApplicationWindow { 0014 GridLayout { 0015 anchors.fill: parent 0016 anchors.margins: Kirigami.Units.gridUnit 0017 0018 rows: 3 0019 rowSpacing: Kirigami.Units.gridUnit 0020 columns: 3 0021 columnSpacing: Kirigami.Units.gridUnit 0022 0023 // Icon + Label 0024 ColumnLayout { 0025 Layout.fillWidth: true 0026 Layout.fillHeight: true 0027 0028 Kirigami.Heading { 0029 text: "Icon + Label" 0030 level: 3 0031 Layout.fillWidth: true 0032 wrapMode: Text.Wrap 0033 } 0034 QQC2.ScrollView { 0035 Layout.fillWidth: true 0036 Layout.fillHeight: true 0037 0038 Component.onCompleted: { 0039 if (background) { 0040 background.visible = true; 0041 } 0042 } 0043 ListView { 0044 model: 3 0045 delegate: Kirigami.BasicListItem { 0046 icon: "edit-bomb" 0047 text: "Boom!" 0048 } 0049 } 0050 } 0051 } 0052 0053 // Label + space reserved for icon 0054 ColumnLayout { 0055 Layout.fillWidth: true 0056 Layout.fillHeight: true 0057 0058 Kirigami.Heading { 0059 text: "Icon + Label + space reserved for icon" 0060 level: 3 0061 Layout.fillWidth: true 0062 wrapMode: Text.Wrap 0063 } 0064 QQC2.ScrollView { 0065 Layout.fillWidth: true 0066 Layout.fillHeight: true 0067 0068 Component.onCompleted: { 0069 if (background) { 0070 background.visible = true; 0071 } 0072 } 0073 ListView { 0074 model: 3 0075 delegate: Kirigami.BasicListItem { 0076 text: "Boom!" 0077 reserveSpaceForIcon: true 0078 } 0079 } 0080 } 0081 } 0082 0083 // Icon + Label + leading and trailing items 0084 ColumnLayout { 0085 Layout.fillWidth: true 0086 Layout.fillHeight: true 0087 0088 Kirigami.Heading { 0089 text: "Icon + Label + leading and trailing items" 0090 level: 3 0091 Layout.fillWidth: true 0092 wrapMode: Text.Wrap 0093 } 0094 QQC2.ScrollView { 0095 Layout.fillWidth: true 0096 Layout.fillHeight: true 0097 0098 Component.onCompleted: { 0099 if (background) { 0100 background.visible = true; 0101 } 0102 } 0103 ListView { 0104 model: 3 0105 delegate: Kirigami.BasicListItem { 0106 leading: Rectangle { 0107 radius: width * 0.5 0108 width: Kirigami.Units.largeSpacing 0109 height: Kirigami.Units.largeSpacing 0110 Kirigami.Theme.colorSet: Kirigami.Theme.View 0111 color: Kirigami.Theme.neutralTextColor 0112 } 0113 leadingFillVertically: false 0114 0115 icon: "edit-bomb" 0116 text: "Boom!" 0117 0118 trailing: QQC2.Button { 0119 text: "Defuse the bomb!" 0120 icon.name: "edit-delete" 0121 } 0122 } 0123 } 0124 } 0125 } 0126 0127 // Icon + Label + subtitle 0128 ColumnLayout { 0129 Layout.fillWidth: true 0130 Layout.fillHeight: true 0131 0132 Kirigami.Heading { 0133 text: "Icon + Label + subtitle" 0134 level: 3 0135 Layout.fillWidth: true 0136 wrapMode: Text.Wrap 0137 } 0138 QQC2.ScrollView { 0139 Layout.fillWidth: true 0140 Layout.fillHeight: true 0141 0142 Component.onCompleted: { 0143 if (background) { 0144 background.visible = true; 0145 } 0146 } 0147 ListView { 0148 model: 3 0149 delegate: Kirigami.BasicListItem { 0150 icon: "edit-bomb" 0151 text: "Boom!" 0152 subtitle: "smaller boom" 0153 } 0154 } 0155 } 0156 } 0157 0158 // Icon + Label + space reserved for subtitle 0159 ColumnLayout { 0160 Layout.fillWidth: true 0161 Layout.fillHeight: true 0162 0163 Kirigami.Heading { 0164 text: "Icon + Label + space reserved for subtitle" 0165 level: 3 0166 Layout.fillWidth: true 0167 wrapMode: Text.Wrap 0168 } 0169 QQC2.ScrollView { 0170 Layout.fillWidth: true 0171 Layout.fillHeight: true 0172 0173 Component.onCompleted: { 0174 if (background) { 0175 background.visible = true; 0176 } 0177 } 0178 ListView { 0179 model: 3 0180 delegate: Kirigami.BasicListItem { 0181 icon: "edit-bomb" 0182 text: "Boom!" 0183 reserveSpaceForSubtitle: true 0184 } 0185 } 0186 } 0187 } 0188 0189 // Icon + Label + subtitle + leading and trailing items 0190 ColumnLayout { 0191 Layout.fillWidth: true 0192 Layout.fillHeight: true 0193 0194 Kirigami.Heading { 0195 text: "Icon + Label + subtitle + leading and trailing items" 0196 level: 3 0197 Layout.fillWidth: true 0198 wrapMode: Text.Wrap 0199 } 0200 QQC2.ScrollView { 0201 Layout.fillWidth: true 0202 Layout.fillHeight: true 0203 0204 Component.onCompleted: { 0205 if (background) { 0206 background.visible = true; 0207 } 0208 } 0209 ListView { 0210 model: 3 0211 delegate: Kirigami.BasicListItem { 0212 leading: Rectangle { 0213 radius: width * 0.5 0214 width: Kirigami.Units.largeSpacing 0215 height: Kirigami.Units.largeSpacing 0216 Kirigami.Theme.colorSet: Kirigami.Theme.View 0217 color: Kirigami.Theme.neutralTextColor 0218 } 0219 leadingFillVertically: false 0220 0221 icon: "edit-bomb" 0222 text: "Boom!" 0223 subtitle: "smaller boom" 0224 0225 trailing: QQC2.Button { 0226 text: "Defuse the bomb!" 0227 icon.name: "edit-delete" 0228 } 0229 } 0230 } 0231 } 0232 } 0233 } 0234 }