mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 01:33:19 +00:00
76 lines
1.5 KiB
QML
76 lines
1.5 KiB
QML
/*
|
|
* Mirai. Copyright (C) 2024 Vyn
|
|
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
|
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
|
*/
|
|
|
|
import QtQuick
|
|
import QtQuick.Window
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Mirai
|
|
|
|
Rectangle {
|
|
|
|
id: datePickerRoot
|
|
property alias text: newTodoDate.text
|
|
property alias textFieldComponent: newTodoDate
|
|
color: colorPalette.selected.fieldBackground
|
|
radius: 4
|
|
implicitHeight: 32
|
|
|
|
RowLayout {
|
|
anchors.fill: parent
|
|
|
|
AppIcon {
|
|
icon.source: "qrc:/qt/qml/Mirai/src/images/calendar.png"
|
|
Layout.preferredWidth: 32
|
|
Layout.preferredHeight: 32
|
|
}
|
|
|
|
AppLineEdit {
|
|
id: newTodoDate
|
|
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
readOnly: true
|
|
|
|
background: Rectangle {
|
|
color: "transparent"
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: {
|
|
datePicker.open()
|
|
}
|
|
}
|
|
}
|
|
|
|
Popup {
|
|
id: datePicker
|
|
implicitWidth: 300
|
|
implicitHeight: 300
|
|
x: datePickerRoot.x
|
|
y: datePickerRoot.y - 300 - 10
|
|
background: Rectangle {
|
|
color: colorPalette.selected.pane
|
|
border.color: colorPalette.selected.modalBorder
|
|
border.width: 2
|
|
}
|
|
DatePicker {
|
|
anchors.fill: parent
|
|
Component.onCompleted: set(new Date()) // today
|
|
onClicked: {
|
|
const formattedDate = Qt.formatDate(date, 'yyyy-MM-dd')
|
|
newTodoDate.text = formattedDate
|
|
datePicker.close()
|
|
}
|
|
onReset: {
|
|
newTodoDate.text = ""
|
|
datePicker.close()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|