you can now add countdowns to the list
This commit is contained in:
parent
f1dfd94f06
commit
f241ad0f09
1 changed files with 76 additions and 28 deletions
|
@ -3,23 +3,38 @@ import QtQuick.Controls 2.15 as Controls
|
|||
import QtQuick.Layouts 1.15
|
||||
import org.kde.kirigami 2.20 as Kirigami
|
||||
|
||||
|
||||
|
||||
|
||||
Kirigami.ApplicationWindow {
|
||||
id: root
|
||||
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 {
|
||||
id: kountdownModel
|
||||
ListElement {
|
||||
name: "Meow"
|
||||
description: "Meowy!"
|
||||
date: 420
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: kountdownDelegate
|
||||
Kirigami.AbstractCard {
|
||||
contentItem: Item {
|
||||
|
||||
GridLayout {
|
||||
id: delegateLayout
|
||||
anchors {
|
||||
|
@ -34,7 +49,7 @@ Kirigami.ApplicationWindow {
|
|||
Kirigami.Heading {
|
||||
Layout.fillHeight: true
|
||||
level: 1
|
||||
text: (date < 100000) ? date : i18n("%1 days", Math.round((date-Date.now()/86400000)))
|
||||
text: getDate(date)
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
|
@ -61,39 +76,72 @@ Kirigami.ApplicationWindow {
|
|||
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 {
|
||||
title: i18nc("@title", "Kountdown")
|
||||
title: i18nc("@title", "Meowdown")
|
||||
|
||||
actions.main: Kirigami.Action {
|
||||
id: addAction
|
||||
icon.name: "list-add"
|
||||
text: i18nc("@action:button", "add meowdown")
|
||||
onTriggered: addSheet.open()
|
||||
}
|
||||
|
||||
Kirigami.CardsListView {
|
||||
id: cardsView
|
||||
model: kountdownModel
|
||||
delegate: kountdownDelegate
|
||||
}
|
||||
actions.main: Kirigami.Action {
|
||||
id: addAction
|
||||
icon.name: "list-add"
|
||||
text: i18nc("@action:button", "Add meowdown")
|
||||
onTriggered: kountdownModel.append({
|
||||
name: "Meowy",
|
||||
description: "you just added a meowdown",
|
||||
date: 21
|
||||
})
|
||||
}
|
||||
}
|
||||
globalDrawer: Kirigami.GlobalDrawer {
|
||||
isMenu: true
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
text: i18n("Quit")
|
||||
icon.name: "gtk-quit"
|
||||
shortcut: StandardKey.Quit
|
||||
onTriggered: Qt.quit()
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue