Files
pay/guis/mobile/CalendarWidget.qml
T
2026-03-14 21:14:42 +01:00

84 lines
2.4 KiB
QML

/*
* This file is part of the Flowee project
* Copyright (C) 2025 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick
import QtQuick.Controls.Basic as QQC2
import "../Flowee" as Flowee
Item {
id: root
property date selected: new Date()
property alias oldCutoff: mini.oldCutoff
width: implicitWidth
height: implicitHeight
implicitWidth: mini.implicitWidth * mini.scale
implicitHeight: mini.implicitHeight * mini.scale
MiniCalendarWidget {
id: mini
y: 5
scale: 2
month: {
if (isNaN(root.selected))
root.selected = new Date()
var s = root.selected
return new Date(s.getFullYear(), s.getMonth(), 1)
}
transformOrigin: Item.Top
x: (parent.width - width) / 2
monthFormat: "MMMM yyyy"
highlights: {
var day = []
if (root.selected.getFullYear() == month.getFullYear()
&& root.selected.getMonth() == month.getMonth()) {
day.push(root.selected.getDate())
}
return day
}
onSelectedChanged: {
if (selected !== 0) {
var m = month
root.selected = new Date(m.getFullYear(), m.getMonth(), selected)
}
}
onMonthChanged: selected = 0
}
Flowee.Label {
text: "<"
y: 10
x: 15
MouseArea {
anchors.fill: parent
anchors.margins: -8
onClicked: mini.month.setMonth(mini.month.getMonth() - 1)
}
}
Flowee.Label {
text: ">"
x: parent.width - width - 15
y: 10
MouseArea {
anchors.fill: parent
anchors.margins: -8
onClicked: mini.month.setMonth(mini.month.getMonth() + 1)
}
}
}