Linux: Fix slow mouse wheel scrolling in Cover grid because of Qt bug

This commit is contained in:
Kovid Goyal 2017-06-27 12:07:07 +05:30
parent eddc49fa44
commit 5311b5155e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1020,13 +1020,13 @@ class GridView(QListView):
return super(GridView, self).selectionCommand(index, event) return super(GridView, self).selectionCommand(index, event)
def wheelEvent(self, ev): def wheelEvent(self, ev):
if ev.phase() not in (Qt.ScrollUpdate, 0): if ev.phase() not in (Qt.ScrollUpdate, Qt.NoScrollPhase):
# 0 is Qt.NoScrollPhase which is not yet available in PyQt
return return
number_of_pixels = ev.pixelDelta() number_of_pixels = ev.pixelDelta()
number_of_degrees = ev.angleDelta() / 8 number_of_degrees = ev.angleDelta() / 8.0
b = self.verticalScrollBar() b = self.verticalScrollBar()
if number_of_pixels.isNull(): if number_of_pixels.isNull() or islinux:
# pixelDelta() is broken on linux with wheel mice
dy = number_of_degrees.y() / 15.0 dy = number_of_degrees.y() / 15.0
# Scroll by approximately half a row # Scroll by approximately half a row
dy = int(math.ceil((dy) * b.singleStep() / 2.0)) dy = int(math.ceil((dy) * b.singleStep() / 2.0))