Fix dateTime pickers on margings, missing rows of days and hide old days.

This commit is contained in:
Julien Wadel 2022-08-19 16:31:22 +02:00
parent b648fc03be
commit b8b6e8a51b
4 changed files with 21 additions and 17 deletions

View file

@ -12,9 +12,11 @@ import Utils 1.0
DialogPlus {
id: mainItem
height: 550
height: timePicker.visible ? 575 : 500
width: 500
property alias hideOldDates: datePicker.hideOldDates
property alias showDatePicker : datePicker.visible
property alias showTimePicker: timePicker.visible

View file

@ -9,6 +9,7 @@ Item{
id: mainItem
property bool allYears : false // if false : years from today
property alias selectedDate: monthList.selectedDate
property bool hideOldDates : false
signal clicked(date date);
@ -17,6 +18,8 @@ Item{
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 5
height: 30
Layout.alignment: Qt.AlignCenter
ActionButton{
@ -47,6 +50,8 @@ Item{
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: 10
cacheBuffer:0
property int maxYears: 5 // Max years to be requested.
@ -93,7 +98,7 @@ Item{
property real cellMinSize: Math.min(cellHeight, cellWidth)
columns: 7 // days
rows: 7
rows: 8
Repeater {
model: grid.columns * grid.rows // 49 cells per month
@ -132,10 +137,10 @@ Item{
if(cellItem.day < 0)
// Magic date to set day names in this order : 'S', 'M', 'T', 'W', 'T', 'F', 'S' in Locale
return new Date(1,3,index).toLocaleString(Qt.locale(), 'ddd')[0]
else if(new Date(year, month, cellItem.date).getMonth() == month)
else if(new Date(year, month, cellItem.date).getMonth() == month && (!hideOldDates || new Date(year, month, cellItem.date+1) >= new Date())) // new Date use time too
return cellItem.date
else
return ''
return '-'
}
}
}
@ -144,7 +149,7 @@ Item{
id: mouseArea
anchors.fill: parent
enabled: text.text && cellItem.day >= 0
enabled: text.text && text.text != '-' && cellItem.day >= 0
onClicked: {
monthList.selectedDate = new Date(year, month, cellItem.date)

View file

@ -66,7 +66,6 @@ Item{
text: index
color: currentItem ? TimePickerStyle.selectedItemColor : TimePickerStyle.unselectedItemColor
}
MouseArea {
anchors.fill: parent
onClicked: mainItem.selectedTime = mainItem.getDate(parent.text, undefined)
@ -77,15 +76,15 @@ Item{
id: outPath
property int yStep: middleMinSize * Math.cos(2 * Math.PI / outer.count)
startX: mainItem.centerPosition
startY: mainItem.centerPosition - outPath.yStep
startX: mainItem.centerPosition+10
startY: mainItem.centerPosition - outPath.yStep
PathArc {
x: mainItem.centerPosition; y: mainItem.centerPosition + outPath.yStep
x: mainItem.centerPosition+10; y: mainItem.centerPosition + outPath.yStep
radiusX: 110; radiusY: 110
useLargeArc: false
}
PathArc {
x: mainItem.centerPosition; y: mainItem.centerPosition - outPath.yStep
x: mainItem.centerPosition+10; y: mainItem.centerPosition - outPath.yStep
radiusX: 110; radiusY: 110
useLargeArc: false
}
@ -136,14 +135,14 @@ Item{
path: Path {
id: innerPath
property int yStep: (middleMinSize - 30 ) * Math.cos(2 * Math.PI / inner.count)
startX: mainItem.centerPosition; startY: mainItem.centerPosition - innerPath.yStep
startX: mainItem.centerPosition+10; startY: mainItem.centerPosition - innerPath.yStep
PathArc {
x: mainItem.centerPosition; y: mainItem.centerPosition + innerPath.yStep
x: mainItem.centerPosition+10; y: mainItem.centerPosition + innerPath.yStep
radiusX: 40; radiusY: 40
useLargeArc: false
}
PathArc {
x: mainItem.centerPosition; y: mainItem.centerPosition - innerPath.yStep
x: mainItem.centerPosition+10; y: mainItem.centerPosition - innerPath.yStep
radiusX: 40; radiusY: 40
useLargeArc: false
}
@ -152,9 +151,7 @@ Item{
RowLayout {
id: selectedTimeArea
property int cBinding: centerPosition // remove binding loop
onCBindingChanged: Qt.callLater(function(){x = centerPosition - width/2; y= centerPosition - height/2})// To avoid binding loops
anchors.centerIn: parent
Text {
id: h
font.pointSize: Units.dp * 12

View file

@ -308,7 +308,7 @@ DialogPlus {
MouseArea{
anchors.fill: parent
onClicked: {
window.attachVirtualWindow(Utils.buildCommonDialogUri('DateTimeDialog'), {showDatePicker:true, selectedDate: new Date(dateField.getDate())}
window.attachVirtualWindow(Utils.buildCommonDialogUri('DateTimeDialog'), {hideOldDates:true, showDatePicker:true, selectedDate: new Date(dateField.getDate())}
, function (status) {
if(status){
dateField.setDate(status.selectedDate)