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
This commit is contained in:
2026-02-14 18:55:17 +02:00
parent 37fc8aac58
commit 65d7cf9d58

View File

@@ -6,11 +6,32 @@ Dialog {
width: 300 width: 300
height: 300 height: 300
id: dateRangeRootDialog
required property date currentDate required property date currentDate
required property SystemPalette calendarActivePalette; required property SystemPalette calendarActivePalette;
required property color disabledTextColor; required property color disabledTextColor;
enum ViewMode
{
DAY = 0,
MONTH = 1,
YEAR = 2
}
property int viewMode: Qt.enumStringToValue(DateRangeSelector.ViewMode, "DAY")
property date beginDate;
property date endDate;
Flickable
{
onMovementStarted: console.log("Flick started")
onMovementEnded: console.log("Flick ended")
anchors.fill: parent
contentHeight: myGridLayout.height
GridLayout { GridLayout {
id: myGridLayout
columns: 1 columns: 1
Label Label
@@ -20,6 +41,7 @@ Dialog {
} }
DayOfWeekRow { DayOfWeekRow {
visible: dateRangeRootDialog.viewMode === Qt.enumStringToValue(DateRangeSelector.ViewMode, "DAY")
locale: grid.locale locale: grid.locale
Layout.fillWidth: true Layout.fillWidth: true
} }
@@ -28,7 +50,7 @@ Dialog {
{ {
id: grid id: grid
month: Calendar.January month: currentDate.getMonth()
year: currentDate.getFullYear() year: currentDate.getFullYear()
locale: Qt.locale("en_US") locale: Qt.locale("en_US")
@@ -39,14 +61,8 @@ Dialog {
border.width: 3 border.width: 3
width: 30 width: 30
height: 20 height: 20
color: calendarActivePalette.base
MouseArea {
anchors.fill: parent
onClicked: {
if (model.day === 11)
console.log(model.day)
}
}
Text { Text {
anchors.centerIn: parent anchors.centerIn: parent
@@ -62,10 +78,25 @@ Dialog {
property date currentlySelectedDate: currentDate; property date currentlySelectedDate: currentDate;
} }
Row
{
Button
{
text: "Month"
}
Button
{
text: "Year"
}
}
}
} }
function getMyDate() function getMyDate()
{ {
return Qt.formatDateTime(currentDate, "MMM yyyy"); return Qt.formatDateTime(currentDate, "MMM yyyy");
} }
standardButtons: Dialog.Ok | Dialog.Cancel
} }