Allow changing the current month using mouse wheel
REVIEW: 120003
This commit is contained in:
parent
db601cf291
commit
8678630a82
@ -107,6 +107,8 @@ Item {
|
|||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: monthMouse
|
id: monthMouse
|
||||||
|
property int previousPixelDelta
|
||||||
|
|
||||||
width: monthHeading.paintedWidth
|
width: monthHeading.paintedWidth
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
@ -119,6 +121,29 @@ Item {
|
|||||||
}
|
}
|
||||||
menuLoader.item.open(0, height);
|
menuLoader.item.open(0, height);
|
||||||
}
|
}
|
||||||
|
onExited: previousPixelDelta = 0
|
||||||
|
onWheel: {
|
||||||
|
var delta = wheel.angleDelta.y || wheel.angleDelta.x
|
||||||
|
var pixelDelta = wheel.pixelDelta.y || wheel.pixelDelta.x
|
||||||
|
|
||||||
|
// For high-precision touchpad scrolling, we get a wheel event for basically every slightest
|
||||||
|
// finger movement. To prevent the view from suddenly ending up in the next century, we
|
||||||
|
// cumulate all the pixel deltas until they're larger than the label and then only change
|
||||||
|
// the month. Standard mouse wheel scrolling is unaffected since it's fine.
|
||||||
|
if (pixelDelta) {
|
||||||
|
if (Math.abs(previousPixelDelta) < monthMouse.height) {
|
||||||
|
previousPixelDelta += pixelDelta
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delta >= 15) {
|
||||||
|
calendarBackend.previousMonth()
|
||||||
|
} else if (delta <= -15) {
|
||||||
|
calendarBackend.nextMonth()
|
||||||
|
}
|
||||||
|
previousPixelDelta = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user