From ce52d1970c4a22c0ad4d52709e18af13a8e9fcdc Mon Sep 17 00:00:00 2001 From: Fries Date: Mon, 26 Jun 2023 21:40:26 -0700 Subject: [PATCH] add more to the HelloWorld Kirigami app this time, theres cards! --- src/KirigamiHelloWorld/ui/main.qml | 72 +++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/src/KirigamiHelloWorld/ui/main.qml b/src/KirigamiHelloWorld/ui/main.qml index 7505745..395c15d 100644 --- a/src/KirigamiHelloWorld/ui/main.qml +++ b/src/KirigamiHelloWorld/ui/main.qml @@ -5,12 +5,74 @@ import org.kde.kirigami 2.20 as Kirigami Kirigami.ApplicationWindow { id: root - title: i18nc("@title:window", "HelloWorld") - pageStack.initialPage: Kirigami.Page { - Controls.Label { - anchors.centerIn: parent - text: i18n("Meow!") + + ListModel { + id: kountdownModel + ListElement { + name: "Meow" + description: "Meowy!" + date: 420 + } + } + + Component { + id: kountdownDelegate + Kirigami.AbstractCard { + contentItem: Item { + implicitWidth: delegateLayout.implicitWidth + implicitHeight: delegateLayout.implicitHeight + GridLayout { + id: delegateLayout + anchors { + left: parent.left + top: parent.top + right: parent.right + } + rowSpacing: Kirigami.Units.largeSpacing + columnSpacing: Kirigami.Units.largeSpacing + columns: root.wideScreen ? 4 : 2 + + Kirigami.Heading { + Layout.fillHeight: true + level: 1 + text: (date < 100000) ? date : i18n("%1 days", Math.round((date-Date.now()/86400000))) + } + + ColumnLayout { + Kirigami.Heading { + Layout.fillWidth: true + level: 2 + text: name + } + Kirigami.Separator { + Layout.fillWidth: true + visible: description.length > 0 + } + Controls.Label { + Layout.fillWidth: true + wrapMode: Text.WordWrap + text: description + visible: description.length > 0 + } + } + + Controls.Button { + Layout.alignment: Qt.AlignRight + Layout.columnSpan: 2 + text: i18n("Edit") + } + } + } + } + } + + pageStack.initialPage: Kirigami.ScrollablePage { + title: i18nc("@title", "Kountdown") + Kirigami.CardsListView { + id: cardsView + model: kountdownModel + delegate: kountdownDelegate } } }