Files
pay/guis/mobile/CalendarWidget.qml
T

84 lines
2.4 KiB
QML
Raw Permalink Normal View History

2025-07-03 22:51:45 +02:00
/*
* 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()
2025-08-03 20:35:31 +02:00
property alias oldCutoff: mini.oldCutoff
2025-07-03 22:51:45 +02:00
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))
2026-03-14 21:14:42 +01:00
root.selected = new Date()
var s = root.selected
return new Date(s.getFullYear(), s.getMonth(), 1)
2025-07-03 22:51:45 +02:00
}
2025-08-03 20:35:31 +02:00
transformOrigin: Item.Top
2025-07-03 22:51:45 +02:00
x: (parent.width - width) / 2
monthFormat: "MMMM yyyy"
highlights: {
2026-03-14 21:14:42 +01:00
var day = []
2025-07-03 22:51:45 +02:00
if (root.selected.getFullYear() == month.getFullYear()
&& root.selected.getMonth() == month.getMonth()) {
2026-03-14 21:14:42 +01:00
day.push(root.selected.getDate())
2025-07-03 22:51:45 +02:00
}
2026-03-14 21:14:42 +01:00
return day
2025-07-03 22:51:45 +02:00
}
onSelectedChanged: {
if (selected !== 0) {
2026-03-14 21:14:42 +01:00
var m = month
root.selected = new Date(m.getFullYear(), m.getMonth(), selected)
2025-07-03 22:51:45 +02:00
}
}
2026-03-14 21:14:42 +01:00
onMonthChanged: selected = 0
2025-07-03 22:51:45 +02:00
}
Flowee.Label {
text: "<"
y: 10
x: 15
2025-07-03 22:51:45 +02:00
MouseArea {
anchors.fill: parent
anchors.margins: -8
2026-03-14 21:14:42 +01:00
onClicked: mini.month.setMonth(mini.month.getMonth() - 1)
2025-07-03 22:51:45 +02:00
}
}
Flowee.Label {
text: ">"
x: parent.width - width - 15
2025-07-03 22:51:45 +02:00
y: 10
MouseArea {
anchors.fill: parent
anchors.margins: -8
2026-03-14 21:14:42 +01:00
onClicked: mini.month.setMonth(mini.month.getMonth() + 1)
2025-07-03 22:51:45 +02:00
}
}
}