preview_pane: accumulate scroll delta for volume control
Hi-res scroll mice (e.g. G502) send many small angleDelta events per physical notch instead of one ±120. Without accumulation, each micro-event triggered a ±5 volume jump, making volume unusable on hi-res hardware. Now accumulates to ±120 boundaries before firing. behavior change
This commit is contained in:
parent
553734fe79
commit
ebaacb8a25
@ -51,6 +51,7 @@ class ImagePreview(QWidget):
|
|||||||
self._is_bookmarked = False # tracks bookmark state for the button submenu
|
self._is_bookmarked = False # tracks bookmark state for the button submenu
|
||||||
self._current_tags: dict[str, list[str]] = {}
|
self._current_tags: dict[str, list[str]] = {}
|
||||||
self._current_tag_list: list[str] = []
|
self._current_tag_list: list[str] = []
|
||||||
|
self._vol_scroll_accum = 0
|
||||||
|
|
||||||
layout = QVBoxLayout(self)
|
layout = QVBoxLayout(self)
|
||||||
layout.setContentsMargins(0, 0, 0, 0)
|
layout.setContentsMargins(0, 0, 0, 0)
|
||||||
@ -405,9 +406,11 @@ class ImagePreview(QWidget):
|
|||||||
self.navigate.emit(1)
|
self.navigate.emit(1)
|
||||||
return
|
return
|
||||||
if self._stack.currentIndex() == 1:
|
if self._stack.currentIndex() == 1:
|
||||||
delta = event.angleDelta().y()
|
self._vol_scroll_accum += event.angleDelta().y()
|
||||||
if delta:
|
steps = self._vol_scroll_accum // 120
|
||||||
vol = max(0, min(100, self._video_player.volume + (5 if delta > 0 else -5)))
|
if steps:
|
||||||
|
self._vol_scroll_accum -= steps * 120
|
||||||
|
vol = max(0, min(100, self._video_player.volume + 5 * steps))
|
||||||
self._video_player.volume = vol
|
self._video_player.volume = vol
|
||||||
else:
|
else:
|
||||||
super().wheelEvent(event)
|
super().wheelEvent(event)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user