mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 10:13:42 +00:00
first commit
This commit is contained in:
commit
3e7d8b4b70
43 changed files with 2681 additions and 0 deletions
77
src/qml/DateField.qml
Normal file
77
src/qml/DateField.qml
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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: MiraiColorPalette.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')
|
||||
print('onClicked', formattedDate)
|
||||
newTodoDate.text = formattedDate
|
||||
datePicker.close()
|
||||
}
|
||||
onReset: {
|
||||
newTodoDate.text = ""
|
||||
datePicker.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue