added the record of the scroll events

This commit is contained in:
Faraphel 2023-12-30 18:31:05 +01:00
parent 8664a7c7ba
commit 5eedc4896f

View file

@ -2,7 +2,7 @@ import time
from pathlib import Path from pathlib import Path
from typing import Optional, Any from typing import Optional, Any
from PyQt6.QtCore import Qt, QTimer, pyqtSignal, QUrl, QEvent, QObject from PyQt6.QtCore import Qt, QTimer, pyqtSignal, QUrl, QEvent, QObject, QPointF
from PyQt6.QtGui import QFont, QMouseEvent, QResizeEvent, QKeyEvent from PyQt6.QtGui import QFont, QMouseEvent, QResizeEvent, QKeyEvent
from PyQt6.QtWidgets import QLabel, QVBoxLayout, QSizePolicy from PyQt6.QtWidgets import QLabel, QVBoxLayout, QSizePolicy
@ -73,6 +73,9 @@ class WebMission(BaseSurvey):
self.timer_skip.setInterval(self.skip_time * 1000) self.timer_skip.setInterval(self.skip_time * 1000)
self.timer_skip.timeout.connect(self._on_time_skip) # NOQA: connect exist self.timer_skip.timeout.connect(self._on_time_skip) # NOQA: connect exist
# setup the events
self.browser.web.page().scrollPositionChanged.connect(self._on_scroll_position_changed)
@classmethod @classmethod
def from_dict(cls, data: dict[str, Any], signals: dict[str, pyqtSignal]) -> "WebMission": def from_dict(cls, data: dict[str, Any], signals: dict[str, pyqtSignal]) -> "WebMission":
return cls( return cls(
@ -86,11 +89,13 @@ class WebMission(BaseSurvey):
# events # events
def eventFilter(self, obj: QObject, event: QEvent) -> bool: def _on_scroll_position_changed(self, position: QPointF):
# TODO: scroll ? self._save_event(type="scroll", position=[position.x(), position.y()])
def eventFilter(self, obj: QObject, event: QEvent) -> bool:
if obj is self.browser.web.focusProxy() and not self._finished: if obj is self.browser.web.focusProxy() and not self._finished:
# if the object is the content of the web engine widget # if the object is the content of the web engine widget
match event.type(): match event.type():
case QEvent.Type.MouseMove: case QEvent.Type.MouseMove:
# if this is a mouse movement # if this is a mouse movement