From b8b6e8a51b22966c1c50cf557497240ac1681587 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 19 Aug 2022 16:31:22 +0200 Subject: [PATCH] Fix dateTime pickers on margings, missing rows of days and hide old days. --- .../modules/Common/Dialog/DateTimeDialog.qml | 4 +++- .../ui/modules/Common/Picker/DatePicker.qml | 13 +++++++++---- .../ui/modules/Common/Picker/TimePicker.qml | 19 ++++++++----------- .../ui/views/App/Dialog/NewConference.qml | 2 +- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/linphone-app/ui/modules/Common/Dialog/DateTimeDialog.qml b/linphone-app/ui/modules/Common/Dialog/DateTimeDialog.qml index e968b74a8..8ef173b1e 100644 --- a/linphone-app/ui/modules/Common/Dialog/DateTimeDialog.qml +++ b/linphone-app/ui/modules/Common/Dialog/DateTimeDialog.qml @@ -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 diff --git a/linphone-app/ui/modules/Common/Picker/DatePicker.qml b/linphone-app/ui/modules/Common/Picker/DatePicker.qml index b1e8891a3..fb9eb1b0d 100644 --- a/linphone-app/ui/modules/Common/Picker/DatePicker.qml +++ b/linphone-app/ui/modules/Common/Picker/DatePicker.qml @@ -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) diff --git a/linphone-app/ui/modules/Common/Picker/TimePicker.qml b/linphone-app/ui/modules/Common/Picker/TimePicker.qml index 3a11561ed..a76af1607 100644 --- a/linphone-app/ui/modules/Common/Picker/TimePicker.qml +++ b/linphone-app/ui/modules/Common/Picker/TimePicker.qml @@ -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 diff --git a/linphone-app/ui/views/App/Dialog/NewConference.qml b/linphone-app/ui/views/App/Dialog/NewConference.qml index 3eddad3c7..d9daced14 100644 --- a/linphone-app/ui/views/App/Dialog/NewConference.qml +++ b/linphone-app/ui/views/App/Dialog/NewConference.qml @@ -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)