Warning, /libraries/kirigami-addons/tests/DelegateApp.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 * Copyright 2022 Devin Lin <devin@kde.org>
0003 * SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005
0006 import QtQuick 2.15
0007 import QtQuick.Controls 2.15 as Controls
0008 import QtQuick.Layouts 1.2
0009 import QtQuick.Layouts 1.15
0010
0011 import org.kde.kirigami 2.20 as Kirigami
0012 import org.kde.kirigamiaddons.formcard as MobileForm
0013 import org.kde.kirigamiaddons.delegates 1.0 as Delegates
0014 import org.kde.kirigamiaddons.components 1.0 as Components
0015
0016 Kirigami.ApplicationWindow {
0017 id: appwindow
0018
0019 title: "Kirigami Addons Delegates Test"
0020
0021 width: Kirigami.Settings.isMobile ? 400 : 800
0022 height: Kirigami.Settings.isMobile ? 550 : 500
0023
0024 pageStack {
0025 defaultColumnWidth: Kirigami.Units.gridUnit * 35
0026 initialPage: welcomePageComponent
0027
0028 globalToolBar {
0029 style: Kirigami.ApplicationHeaderStyle.ToolBar;
0030 showNavigationButtons: Kirigami.ApplicationHeaderStyle.ShowBackButton;
0031 }
0032 }
0033
0034
0035 // Dummy implementation of ki18n
0036 function i18nd(context, text) {
0037 return text;
0038 }
0039
0040 function i18ndp(context, text1, text2, number) {
0041 return number === 1 ? text1 : text2;
0042 }
0043
0044 function i18ndc(context, text) {
0045 return text
0046 }
0047
0048 function i18nc(context, text) {
0049 return text;
0050 }
0051
0052 LayoutMirroring.enabled: false
0053
0054 Component {
0055 id: roundedItemDelegatePageComponent
0056
0057 Kirigami.ScrollablePage {
0058 title: "RoundedItemDelegate"
0059
0060 header: Components.Banner {
0061 text: "Hello"
0062 visible: true
0063 }
0064
0065 ListView {
0066 model: 50
0067 delegate: Delegates.RoundedItemDelegate {
0068 id: delegate
0069
0070 required property int modelData
0071
0072 icon.name: "kde"
0073 text: "Item " + modelData
0074 }
0075
0076 Components.DoubleFloatingButton {
0077 anchors {
0078 right: parent.right
0079 rightMargin: Kirigami.Units.largeSpacing
0080 bottom: parent.bottom
0081 bottomMargin: Kirigami.Units.largeSpacing
0082 }
0083
0084 leadingAction: Kirigami.Action {
0085 text: "Hello"
0086 icon.name: "list-add"
0087 }
0088
0089 trailingAction: Kirigami.Action {
0090 text: "Hello"
0091 icon.name: "list-add"
0092 }
0093 }
0094 }
0095 }
0096 }
0097
0098 Component {
0099 id: subtitleRoundedItemDelegatePageComponent
0100
0101 Kirigami.ScrollablePage {
0102 title: "RoundedItemDelegate with subtitle"
0103
0104 header: Components.Banner {
0105 title: "Hello"
0106 text: "Hello world"
0107 visible: true
0108 }
0109
0110 ListView {
0111 model: 50
0112
0113 delegate: Delegates.RoundedItemDelegate {
0114 id: delegate
0115
0116 required property int modelData
0117
0118 icon.name: "kde"
0119 text: "Item " + modelData
0120
0121 contentItem: Delegates.SubtitleContentItem {
0122 itemDelegate: delegate
0123 subtitle: "Subtitle " + delegate.modelData
0124 }
0125 }
0126
0127 Components.FloatingButton {
0128 anchors {
0129 right: parent.right
0130 rightMargin: Kirigami.Units.largeSpacing
0131 bottom: parent.bottom
0132 bottomMargin: Kirigami.Units.largeSpacing
0133 }
0134
0135 action: Kirigami.Action {
0136 text: "Hello"
0137 icon.name: "list-add"
0138 }
0139 }
0140 }
0141 }
0142 }
0143
0144 Component {
0145 id: indicatorItemDelegatePageComponent
0146
0147 Kirigami.ScrollablePage {
0148 title: "IndicatorItemDelegate"
0149
0150 ListView {
0151 id: listView
0152
0153 model: 50
0154 delegate: Delegates.IndicatorItemDelegate {
0155 id: delegate
0156
0157 required property int modelData
0158
0159 unread: Math.random() > 0.3
0160 icon.name: "kde"
0161 text: "Item " + modelData
0162 onClicked: {
0163 unread = false;
0164 listView.currentIndex = index;
0165 }
0166 }
0167 }
0168 }
0169 }
0170
0171 Component {
0172 id: subtitleIndicatorItemDelegatePageComponent
0173
0174 Kirigami.ScrollablePage {
0175 title: "IndicatorItemDelegate with subtitle"
0176
0177 ListView {
0178 id: listView
0179
0180 model: 50
0181 delegate: Delegates.IndicatorItemDelegate {
0182 id: delegate
0183
0184 required property int modelData
0185
0186 unread: Math.random() > 0.3
0187 icon.name: "kde"
0188 text: "Item " + modelData
0189 onClicked: {
0190 unread = false;
0191 listView.currentIndex = index;
0192 }
0193
0194 contentItem: Delegates.SubtitleContentItem {
0195 itemDelegate: delegate
0196 subtitle: "Subtitle " + delegate.modelData
0197 }
0198 }
0199 }
0200 }
0201 }
0202
0203 Component {
0204 id: welcomePageComponent
0205
0206 Kirigami.ScrollablePage {
0207 id: page
0208 title: "Mobile Form Layout"
0209
0210 leftPadding: 0
0211 rightPadding: 0
0212 topPadding: Kirigami.Units.gridUnit
0213 bottomPadding: Kirigami.Units.gridUnit
0214
0215 ColumnLayout {
0216 spacing: 0
0217
0218 // Form Grid
0219 MobileForm.FormGridContainer {
0220 id: container
0221
0222 Layout.fillWidth: true
0223
0224 infoCards: [
0225 MobileForm.FormGridContainer.InfoCard {
0226 title: "RoundedItemDelegate"
0227 action: Kirigami.Action {
0228 onTriggered: applicationWindow().pageStack.push(roundedItemDelegatePageComponent);
0229 }
0230 },
0231 MobileForm.FormGridContainer.InfoCard {
0232 title: "ReadIndicatorItemDelegate"
0233 action: Kirigami.Action {
0234 onTriggered: applicationWindow().pageStack.push(indicatorItemDelegatePageComponent);
0235 }
0236 },
0237 MobileForm.FormGridContainer.InfoCard {
0238 title: "RoundedItemDelegate with subtitle"
0239 action: Kirigami.Action {
0240 onTriggered: applicationWindow().pageStack.push(subtitleRoundedItemDelegatePageComponent);
0241 }
0242 },
0243 MobileForm.FormGridContainer.InfoCard {
0244 title: "ReadIndicatorItemDelegate with subtitle"
0245 action: Kirigami.Action {
0246 onTriggered: applicationWindow().pageStack.push(subtitleIndicatorItemDelegatePageComponent);
0247 }
0248 }
0249 ]
0250 }
0251 }
0252 }
0253 }
0254 }