Compare commits

..

2 Commits

Author SHA1 Message Date
858c72011a Changed "year" to "Years" 2026-02-14 18:56:27 +02:00
65d7cf9d58 Added Month and Year buttons
Rearranged the DateRangeSelector dialog layout to also include a "Month"
and "Year" view buttons, to make selecting a range of dates easier
2026-02-14 18:55:17 +02:00

View File

@@ -6,61 +6,90 @@ Dialog {
width: 300
height: 300
id: dateRangeRootDialog
required property date currentDate
required property SystemPalette calendarActivePalette;
required property color disabledTextColor;
GridLayout {
columns: 1
enum ViewMode
{
DAY = 0,
MONTH = 1,
YEAR = 2
}
Label
{
font.pixelSize: 22
text: getMyDate()
}
property int viewMode: Qt.enumStringToValue(DateRangeSelector.ViewMode, "DAY")
property date beginDate;
property date endDate;
DayOfWeekRow {
locale: grid.locale
Layout.fillWidth: true
}
Flickable
{
onMovementStarted: console.log("Flick started")
onMovementEnded: console.log("Flick ended")
anchors.fill: parent
contentHeight: myGridLayout.height
MonthGrid
{
GridLayout {
id: myGridLayout
columns: 1
id: grid
month: Calendar.January
year: currentDate.getFullYear()
locale: Qt.locale("en_US")
Layout.fillWidth: true
Layout.fillHeight: true
delegate: Rectangle {
border.color: model.day === currentDate.getDay() ? "green": "transparent"
border.width: 3
width: 30
height: 20
MouseArea {
anchors.fill: parent
onClicked: {
if (model.day === 11)
console.log(model.day)
}
}
Text {
anchors.centerIn: parent
font.pixelSize: 12
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: model.day
color: model.month === currentDate.getMonth() ? calendarActivePalette.text : disabledTextColor
}
required property var model
Label
{
font.pixelSize: 22
text: getMyDate()
}
property date currentlySelectedDate: currentDate;
DayOfWeekRow {
visible: dateRangeRootDialog.viewMode === Qt.enumStringToValue(DateRangeSelector.ViewMode, "DAY")
locale: grid.locale
Layout.fillWidth: true
}
MonthGrid
{
id: grid
month: currentDate.getMonth()
year: currentDate.getFullYear()
locale: Qt.locale("en_US")
Layout.fillWidth: true
Layout.fillHeight: true
delegate: Rectangle {
border.color: model.day === currentDate.getDay() ? "green": "transparent"
border.width: 3
width: 30
height: 20
color: calendarActivePalette.base
Text {
anchors.centerIn: parent
font.pixelSize: 12
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: model.day
color: model.month === currentDate.getMonth() ? calendarActivePalette.text : disabledTextColor
}
required property var model
}
property date currentlySelectedDate: currentDate;
}
Row
{
Button
{
text: "Months"
}
Button
{
text: "Years"
}
}
}
}
@@ -68,4 +97,6 @@ Dialog {
{
return Qt.formatDateTime(currentDate, "MMM yyyy");
}
standardButtons: Dialog.Ok | Dialog.Cancel
}