71 lines
2.3 KiB
QML
71 lines
2.3 KiB
QML
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (C) 2025-2026 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 "../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
|
|
|
|
Flowee.Dialog {
|
|
id: dateTimeDialog
|
|
property var selectedDate: null;
|
|
function start() {
|
|
selectedDate = root.date
|
|
open();
|
|
}
|
|
|
|
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);
|
|
}
|
|
onVisibleChanged: {
|
|
if (visible)
|
|
selected = dateTimeDialog.selectedDate
|
|
}
|
|
}
|
|
onAccepted: root.selectedDate = selectedDate
|
|
}
|
|
}
|
|
}
|