Made the Track Progress Slider clickable.
This commit is contained in:
parent
7844e15aa2
commit
19b6f4dcaa
4 changed files with 22 additions and 2 deletions
|
@ -5,7 +5,7 @@ from PyQt6.QtWidgets import QApplication
|
||||||
from utils import Utils
|
from utils import Utils
|
||||||
from player.player import Player
|
from player.player import Player
|
||||||
from gui import GUI
|
from gui import GUI
|
||||||
from gui_communication import GUICommunication
|
from gui_communication.gui_communication import GUICommunication
|
||||||
|
|
||||||
|
|
||||||
class Wobuzz:
|
class Wobuzz:
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
from PyQt6.QtCore import Qt
|
from PyQt6.QtCore import Qt
|
||||||
from PyQt6.QtGui import QIcon
|
from PyQt6.QtGui import QIcon
|
||||||
from PyQt6.QtWidgets import QToolBar, QLabel, QSlider
|
from PyQt6.QtWidgets import QToolBar, QLabel, QSlider
|
||||||
|
from .track_progress_slider import TrackProgressSlider
|
||||||
|
|
||||||
|
|
||||||
class TrackControl(QToolBar):
|
class TrackControl(QToolBar):
|
||||||
|
@ -24,7 +25,7 @@ class TrackControl(QToolBar):
|
||||||
self.progress_indicator = QLabel("0:00")
|
self.progress_indicator = QLabel("0:00")
|
||||||
self.addWidget(self.progress_indicator)
|
self.addWidget(self.progress_indicator)
|
||||||
|
|
||||||
self.track_progress_slider = QSlider(Qt.Orientation.Horizontal, self)
|
self.track_progress_slider = TrackProgressSlider(Qt.Orientation.Horizontal, self)
|
||||||
self.addWidget(self.track_progress_slider)
|
self.addWidget(self.track_progress_slider)
|
||||||
|
|
||||||
self.track_length_indicator = QLabel("0:00")
|
self.track_length_indicator = QLabel("0:00")
|
||||||
|
|
19
wobuzz/ui/track_progress_slider.py
Normal file
19
wobuzz/ui/track_progress_slider.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from PyQt6.QtCore import Qt
|
||||||
|
from PyQt6.QtGui import QMouseEvent
|
||||||
|
from PyQt6.QtWidgets import QSlider
|
||||||
|
|
||||||
|
|
||||||
|
class TrackProgressSlider(QSlider):
|
||||||
|
def mousePressEvent(self, event: QMouseEvent):
|
||||||
|
if event.button() == Qt.MouseButton.LeftButton:
|
||||||
|
event.accept()
|
||||||
|
|
||||||
|
x = event.pos().x()
|
||||||
|
|
||||||
|
value = self.maximum() * x // self.width()
|
||||||
|
self.setValue(value)
|
||||||
|
|
||||||
|
return super().mousePressEvent(event)
|
||||||
|
|
Loading…
Add table
Reference in a new issue