UI/UX polish: Tools menu, clickable timeline, live drag-seek, drag-and-drop load
- Clap detection moved from inline buttons to a Tools menu, plain labels (no more '(whole file)' / '(from cursor)' parentheticals) -- status messages moved to the window's status bar since the dedicated label widget went away with the button row. - ClickableSlider subclass: clicking anywhere along the seek track jumps straight there instead of QSlider's default page-by-a-step behavior; reposition-then-delegate-to-super keeps native drag behavior intact. - Dragging now seeks live via sliderMoved instead of waiting for sliderReleased. - PlayerWidget accepts drag-and-drop of a local file to load it. Verified with real Qt events (QMouseEvent clicks, a QDropEvent, a real mouse click via xdotool opening the Tools menu on an actual running window) rather than just calling the underlying methods directly.
This commit is contained in:
+15
-1
@@ -9,7 +9,7 @@ import time
|
||||
|
||||
import mpv
|
||||
from PyQt6.QtWidgets import QWidget
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6.QtCore import Qt, pyqtSignal
|
||||
|
||||
|
||||
class PlayerWidget(QWidget):
|
||||
@@ -20,10 +20,13 @@ class PlayerWidget(QWidget):
|
||||
this exists instead of a QMediaPlayer/HTML5-video-style backend.
|
||||
"""
|
||||
|
||||
fileDropped = pyqtSignal(str)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_DontCreateNativeAncestors)
|
||||
self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
# QApplication resets LC_NUMERIC to the system locale on construction,
|
||||
# which undoes python-mpv's own import-time fix and makes libmpv abort
|
||||
@@ -108,3 +111,14 @@ class PlayerWidget(QWidget):
|
||||
|
||||
def shutdown(self):
|
||||
self.mpv.terminate()
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
if event.mimeData().hasUrls() and any(u.isLocalFile() for u in event.mimeData().urls()):
|
||||
event.acceptProposedAction()
|
||||
|
||||
def dropEvent(self, event):
|
||||
for url in event.mimeData().urls():
|
||||
if url.isLocalFile():
|
||||
self.fileDropped.emit(url.toLocalFile())
|
||||
event.acceptProposedAction()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user