Skip to content

Commit

Permalink
Fixed Mouse Wheel moving video
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRetro2033 committed May 2, 2024
1 parent 8221aef commit 2e645a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 4 additions & 3 deletions tagstudio/src/qt/widgets/preview_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,10 @@ def update_widgets(self):
image = Image.fromarray(frame)
resolution = QSize(image.width, image.height)
self.preview_vid.play(filepath, resolution)
# elif extension in AUDIO_TYPES:
# self.preview_vid.show()
# self.preview_img.hide()
elif extension in AUDIO_TYPES:
self.preview_vid.hide()
self.preview_vid.stop( )
self.preview_img.show()
# resolution = QSize(512, 512)
# self.preview_vid.play(filepath, resolution)
# Stats for specific file types are displayed here.
Expand Down
16 changes: 11 additions & 5 deletions tagstudio/src/qt/widgets/video_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from PySide6.QtMultimedia import QMediaPlayer, QAudioOutput, QMediaDevices, QAudioFormat, QAudioDecoder
from PySide6.QtMultimediaWidgets import QGraphicsVideoItem
from PySide6.QtWidgets import QGraphicsView, QGraphicsScene
from PySide6.QtGui import QDragMoveEvent, QInputMethodEvent, QPainter, QPen, QColor, QBrush, QResizeEvent
from PySide6.QtGui import QDragMoveEvent, QInputMethodEvent, QPainter, QPen, QColor, QBrush, QResizeEvent, QWheelEvent
from PySide6.QtSvgWidgets import QSvgWidget

from src.core.ts_core import VIDEO_TYPES, AUDIO_TYPES
Expand Down Expand Up @@ -67,6 +67,8 @@ def __init__(self) -> None:
self.mute_button.move(self.width() - self.mute_button.size().width()/2, self.height() - self.mute_button.size().height()/2)
self.mute_button.hide()

self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)

def checkMediaStatus(self, media_status:QMediaPlayer.MediaStatus) -> None:
logging.info(media_status)
if media_status == QMediaPlayer.MediaStatus.EndOfMedia:
Expand Down Expand Up @@ -103,6 +105,10 @@ def updateControls(self) -> None:
self.play_pause.load('./tagstudio/resources/pause.svg')
else:
self.play_pause.load('./tagstudio/resources/play.svg')

def wheelEvent(self, event:QWheelEvent) -> None:
return

def eventFilter(self, obj:QObject, event:QEvent) -> bool:
#This chunk of code is for the video controls.
if obj == self.play_pause and event.type() == QEvent.Type.MouseButtonPress and event.button() == Qt.MouseButton.LeftButton:
Expand Down Expand Up @@ -144,8 +150,8 @@ def underMouse(self) -> bool:
self.play_pause.show()
self.mute_button.show()
self.keepControlsInPlace()
self.centerOn(self.video_preview)
self.scene().setSceneRect(QRect(0,0, self.video_preview.size().width()-1, self.video_preview.size().height()-1))
# rcontent = self.contentsRect()
# self.setSceneRect(0, 0, rcontent.width(), rcontent.height())
return super().underMouse()

def releaseMouse(self) -> None:
Expand Down Expand Up @@ -191,7 +197,6 @@ def play(self, filepath: str, resolution: QSize) -> None:
self.player.play()
else:
self.checkMediaStatus(QMediaPlayer.MediaStatus.EndOfMedia)

logging.info(f'Successfully stopped.')

def stop(self) -> None:
Expand All @@ -203,7 +208,8 @@ def resizeVideo(self, new_size : QSize,) -> None:
self.video_preview.setSize(new_size)
self.video_tint.setRect(0, 0, self.video_preview.size().width(), self.video_preview.size().height())
self.centerOn(self.video_preview)
self.scene().setSceneRect(QRect(0,0, new_size.width()-1, new_size.height()-1))

# self.setSceneRect(0, 0, rcontent.width(), rcontent.height())
self.keepControlsInPlace()

def keepControlsInPlace(self) -> None:
Expand Down

0 comments on commit 2e645a7

Please sign in to comment.