diff --git a/src/contents/ui/TimeCombo.qml b/src/contents/ui/TimeCombo.qml index 0c731791fb2f6e81163898b3ae16d2a5196157f2..9995d62d251fcfd30f04e89cee18a83b62ddb282 100644 --- a/src/contents/ui/TimeCombo.qml +++ b/src/contents/ui/TimeCombo.qml @@ -33,7 +33,7 @@ QQC2.ComboBox { property alias timePicker: popupTimePicker editable: true - editText: activeFocus ? editText : DateUtils.adjustDateTimeToLocalTimeZone(dateTime, timeZoneOffset).toLocaleTimeString(Qt.locale(), "HH:mm") + editText: activeFocus && !popupTimePicker.visible ? editText : DateUtils.adjustDateTimeToLocalTimeZone(dateTime, timeZoneOffset).toLocaleTimeString(Qt.locale(), "HH:mm") inputMethodHints: Qt.ImhTime validator: activeFocus ? inputValidator : timeValidator @@ -42,7 +42,7 @@ QQC2.ComboBox { if(!isNaN(dateTime.getTime())) { popupTimePicker.setToTimeFromString(editText) } - if (acceptableInput && activeFocus) { // Need to check for activeFocus or on load the text gets reset to 00:00 + if (acceptableInput && activeFocus && !popupTimePicker.visible) { // Need to check for activeFocus or on load the text gets reset to 00:00 newTimeChosen(new Date(DateUtils.adjustDateTimeToLocalTimeZone(dateTime, timeZoneOffset).setHours(popupTimePicker.hours, popupTimePicker.minutes))); } } @@ -50,7 +50,7 @@ QQC2.ComboBox { popup: QQC2.Popup { id: timePopup width: parent.width - height: parent.width * 2 + height: parent.width * 1.5 y: parent.y + parent.height z: 1000 @@ -61,7 +61,8 @@ QQC2.ComboBox { Connections { target: root function onDateTimeChanged() { - popupTimePicker.setToTimeFromString(root.editText); + if(!popupTimePicker.visible) + popupTimePicker.setToTimeFromString(root.editText); } } diff --git a/src/contents/ui/TimePicker.qml b/src/contents/ui/TimePicker.qml index 4d91b24d7d93a1d1f7d9c8acff6a1fc54799a2c1..f14929335c9d594055ce23088272fb76f7d72ec6 100644 --- a/src/contents/ui/TimePicker.qml +++ b/src/contents/ui/TimePicker.qml @@ -59,6 +59,16 @@ Item { } } + function wheelHandler(parent, wheel) { + if(parent.currentIndex == parent.count - 1) { + wheel.angleDelta.y < 0 ? parent.currentIndex = 0 : parent.currentIndex -= 1; + } else if(parent.currentIndex == 0) { + wheel.angleDelta.y < 0 ? parent.currentIndex += 1 : parent.currentIndex = parent.count - 1; + } else { + wheel.angleDelta.y < 0 ? parent.currentIndex += 1 : parent.currentIndex -= 1; + } + } + GridLayout { anchors.fill: parent columns: timePicker.secondsPicker ? 5 : 3 @@ -111,8 +121,10 @@ Item { QQC2.Tumbler { id: hourView Layout.fillWidth: true + Layout.fillHeight: true Layout.row: 2 Layout.column: 0 + wrap: true model: 24 @@ -126,6 +138,11 @@ Item { opacity: hourView.currentIndex == thisIndex ? 1 : 0.7 text: modelData < 10 ? String(modelData).padStart(2, "0") : modelData } + + MouseArea { + anchors.fill: parent + onWheel: timePicker.wheelHandler(parent, wheel) + } } Kirigami.Heading { @@ -139,6 +156,7 @@ Item { QQC2.Tumbler { id: minuteView Layout.fillWidth: true + Layout.fillHeight: true wrap: true property int selectedIndex: 0 @@ -162,6 +180,11 @@ Item { opacity: minuteView.currentIndex == thisIndex ? 1 : 0.7 text: minuteToDisplay < 10 ? String(minuteToDisplay).padStart(2, "0") : minuteToDisplay } + + MouseArea { + anchors.fill: parent + onWheel: timePicker.wheelHandler(parent, wheel) + } } @@ -195,6 +218,11 @@ Item { opacity: secondsView.currentIndex == thisIndex ? 1 : 0.7 text: modelData < 10 ? String(modelData).padStart(2, "0") : modelData } + + MouseArea { + anchors.fill: parent + onWheel: timePicker.wheelHandler(parent, wheel) + } } QQC2.ToolButton {