[Timeline] send move request signal when user clicks onto the scene
This commit is contained in:
parent
30741be200
commit
e3b26c3da4
@ -23,6 +23,7 @@ class DetectionSceneSignals(QObject):
|
||||
class DetectionTimelineSignals(QObject):
|
||||
windowMoved = Signal()
|
||||
manualMove = Signal()
|
||||
moveRequest = Signal(float)
|
||||
|
||||
class DetectionSignals(QObject):
|
||||
hover = Signal((int, QPointF))
|
||||
|
@ -65,6 +65,7 @@ class Window(QGraphicsRectItem):
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
self.setCursor(Qt.ClosedHandCursor)
|
||||
# print(event.pos())
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
@ -121,6 +122,7 @@ class DetectionTimeline(QWidget):
|
||||
self._scene = QGraphicsScene(QRectF(0, 0, self._total_width, 85.))
|
||||
self._scene.setBackgroundBrush(self._bg_brush)
|
||||
self._scene.addItem(self._window)
|
||||
self._scene.mousePressEvent = self.on_sceneMousePress
|
||||
|
||||
self._view = QGraphicsView()
|
||||
# self._view.setRenderHints(QPainter.RenderHint.Antialiasing | QPainter.RenderHint.SmoothPixmapTransform)
|
||||
@ -159,6 +161,14 @@ class DetectionTimeline(QWidget):
|
||||
# self.setMaximumHeight(100)
|
||||
# self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed)
|
||||
|
||||
def on_sceneMousePress(self, event):
|
||||
scene_pos = event.scenePos()
|
||||
relpos = scene_pos.x() / self._total_width
|
||||
relpos = 0 if relpos < 0.0 else relpos
|
||||
relpos = 2000/self._total_width if scene_pos.x() > self._total_width else relpos
|
||||
self.signals.moveRequest.emit(relpos)
|
||||
logging.debug("Timeline: Scene clicked at position: %.2f, %.2f --> rel x-pos %.3f", scene_pos.x(), scene_pos.y(), relpos)
|
||||
|
||||
def clear(self):
|
||||
for i in self._scene.items():
|
||||
if isinstance(i, (QGraphicsLineItem, QGraphicsEllipseItem)):
|
||||
|
Loading…
Reference in New Issue
Block a user