Files
pay/guis/mobile/CalendarTextButton.qml
T

71 lines
2.3 KiB
QML
Raw Permalink Normal View History

2025-08-03 20:35:31 +02:00
/*
* This file is part of the Flowee project
* Copyright (C) 2025-2026 Tom Zander <tom@flowee.org>
2025-08-03 20:35:31 +02:00
*
* 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 "../Flowee" as Flowee
Flow {
id: root
property date date;
property date selectedDate;
property alias text: mainLabel.text
spacing: 6
Flowee.Label {
id: mainLabel
height: Math.max(50, contentHeight + 10)
verticalAlignment: Text.AlignVCenter
MouseArea {
width: root.width + 10
height: parent.height
x: -5
onClicked: dateTimeDialog.start()
}
}
Flowee.Label {
text: {
var d = root.date
if (isNaN(d))
return qsTr("None")
return Pay.formatDate(d)
}
height: Math.max(50, contentHeight + 10)
verticalAlignment: Text.AlignVCenter
2025-09-05 17:29:11 +02:00
2025-08-03 20:35:31 +02:00
Flowee.Dialog {
id: dateTimeDialog
property var selectedDate: null;
function start() {
selectedDate = root.date
open();
}
2025-09-05 17:29:11 +02:00
2025-08-03 20:35:31 +02:00
contentComponent: CalendarWidget {
onSelectedChanged: dateTimeDialog.selectedDate = selected;
oldCutoff: { // To avoid selecting a date in the past
let today = new Date() // today.
return new Date(today.getFullYear(), today.getMonth() -1 , today.getDay() + 2);
}
2025-08-03 20:35:31 +02:00
onVisibleChanged: {
if (visible)
selected = dateTimeDialog.selectedDate
}
}
onAccepted: root.selectedDate = selectedDate
}
}
}