Compare commits

..

No commits in common. "f241ad0f092207e0eed6a916c1c03e3002a38e04" and "ce52d1970c4a22c0ad4d52709e18af13a8e9fcdc" have entirely different histories.

View file

@ -3,38 +3,25 @@ import QtQuick.Controls 2.15 as Controls
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.20 as Kirigami import org.kde.kirigami 2.20 as Kirigami
Kirigami.ApplicationWindow { Kirigami.ApplicationWindow {
id: root id: root
title: i18nc("@title:window", "HelloWorld") title: i18nc("@title:window", "HelloWorld")
function getDate(date) {
return i18n("%1 days", Math.round((date-Date.now())/86400000))
}
globalDrawer: Kirigami.GlobalDrawer {
isMenu: true
actions: [
Kirigami.Action {
text: i18n("Quit")
icon.name: "gtk-quit"
shortcut: StandardKey.Quit
onTriggered: Qt.quit()
}
]
}
ListModel { ListModel {
id: kountdownModel id: kountdownModel
ListElement {
name: "Meow"
description: "Meowy!"
date: 420
}
} }
Component { Component {
id: kountdownDelegate id: kountdownDelegate
Kirigami.AbstractCard { Kirigami.AbstractCard {
contentItem: Item { contentItem: Item {
implicitWidth: delegateLayout.implicitWidth
implicitHeight: delegateLayout.implicitHeight
GridLayout { GridLayout {
id: delegateLayout id: delegateLayout
anchors { anchors {
@ -49,7 +36,7 @@ Kirigami.ApplicationWindow {
Kirigami.Heading { Kirigami.Heading {
Layout.fillHeight: true Layout.fillHeight: true
level: 1 level: 1
text: getDate(date) text: (date < 100000) ? date : i18n("%1 days", Math.round((date-Date.now()/86400000)))
} }
ColumnLayout { ColumnLayout {
@ -76,68 +63,12 @@ Kirigami.ApplicationWindow {
text: i18n("Edit") text: i18n("Edit")
} }
} }
implicitWidth: delegateLayout.implicitWidth
implicitHeight: delegateLayout.implicitHeight
}
}
}
Kirigami.OverlaySheet {
id: addSheet
header: Kirigami.Heading {
text: i18nc("@title:window", "Add meowdown")
}
Kirigami.FormLayout {
Controls.TextField {
id: nameField
Kirigami.FormData.label: i18nc("@label:textbox", "Name:")
placeholderText: i18n("Event Name (susquired)")
onAccepted: descriptionField.forceActiveFocus()
}
Controls.TextField {
id: descriptionField
Kirigami.FormData.label: i18nc("@label:textbox", "Description:")
placeholderText: i18n("Optional")
onAccepted: dateField.forceActiveFocus()
}
Controls.TextField {
id: dateField
Kirigami.FormData.label: i18nc("@label:textbox", "Date:")
placeholderText: i18n("YYYY-MM-DD")
inputMask: "0000-00-00"
}
Controls.Button {
id: doneButton
Layout.fillWidth: true
text: i18nc("@action:button", "Done")
enabled: nameField.text.length > 0
onClicked: {
kountdownModel.append({
name: nameField.text,
description: descriptionField.text,
date: Date.parse(dateField.text)
})
nameField.text = ""
descriptionField.text = ""
dateField.text = ""
addSheet.close()
}
} }
} }
} }
pageStack.initialPage: Kirigami.ScrollablePage { pageStack.initialPage: Kirigami.ScrollablePage {
title: i18nc("@title", "Meowdown") title: i18nc("@title", "Kountdown")
actions.main: Kirigami.Action {
id: addAction
icon.name: "list-add"
text: i18nc("@action:button", "add meowdown")
onTriggered: addSheet.open()
}
Kirigami.CardsListView { Kirigami.CardsListView {
id: cardsView id: cardsView
model: kountdownModel model: kountdownModel