Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SmoothScrollDelegate from scroll_bar.py #837

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 19 additions & 5 deletions qfluentwidgets/components/widgets/scroll_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,19 +502,33 @@ def __init__(self, parent: QAbstractScrollArea, useAni=False):

def eventFilter(self, obj, e: QEvent):
if e.type() == QEvent.Type.Wheel:
if e.angleDelta().y() != 0:
verticalScrollBar = self.parent().verticalScrollBar()
horizontalScrollBar = self.parent().horizontalScrollBar()

# Check if the vertical scroll is at its limit
verticalAtEnd = (e.angleDelta().y() < 0 and verticalScrollBar.value() == verticalScrollBar.maximum()) or \
(e.angleDelta().y() > 0 and verticalScrollBar.value() == verticalScrollBar.minimum())

# Check if the horizontal scroll is at its limit
horizontalAtEnd = (e.angleDelta().x() < 0 and horizontalScrollBar.value() ==
horizontalScrollBar.maximum()) or \
(e.angleDelta().x() > 0 and horizontalScrollBar.value() == horizontalScrollBar.minimum())
if e.angleDelta().y() != 0 and not verticalAtEnd:
if not self.useAni:
self.verticalSmoothScroll.wheelEvent(e)
else:
self.vScrollBar.scrollValue(-e.angleDelta().y())
else:
e.setAccepted(True)
return True
elif e.angleDelta().x() != 0 and not horizontalAtEnd:
if not self.useAni:
self.horizonSmoothScroll.wheelEvent(e)
else:
self.hScrollBar.scrollValue(-e.angleDelta().x())

e.setAccepted(True)
return True
e.setAccepted(True)
return True
elif verticalAtEnd or horizontalAtEnd:
return False # Continue propagation of the event

return super().eventFilter(obj, e)

Expand Down