feat: Implementiere visuelle Zeitleiste mit Playhead im Track-Bereich
Co-authored-by: aider (ollama/qwen2.5-coder:14b) <aider@aider.chat>
This commit is contained in:
1 parent
f565975150
commit
b40a3d3eca
1 file changed
+48
-12
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from PyQt6.QtWidgets import QApplication, QMainWindow, QMenuBar, QMenu, QWidget, QVBoxLayout, QPushButton, QHBoxLayout
|
||||
from PyQt6.QtGui import QAction
|
||||
from PyQt6.QtCore import Qt
|
||||
from PyQt6.QtWidgets import QApplication, QMainWindow, QMenuBar, QMenu, QWidget, QVBoxLayout, QPushButton, QHBoxLayout, QGraphicsView, QGraphicsScene, QGraphicsLineItem
|
||||
from PyQt6.QtGui import QAction, QPen
|
||||
from PyQt6.QtCore import Qt, QTimer
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
@@ -38,18 +38,54 @@ class MainWindow(QMainWindow):
|
||||
button_layout = QHBoxLayout()
|
||||
layout.addLayout(button_layout)
|
||||
|
||||
play_button = QPushButton("Play", self)
|
||||
play_button.setStyleSheet("background-color: #007acc; color: white; padding: 10px 20px; border-radius: 5px;")
|
||||
button_layout.addWidget(play_button)
|
||||
self.play_button = QPushButton("Play", self)
|
||||
self.play_button.setStyleSheet("background-color: #007acc; color: white; padding: 10px 20px; border-radius: 5px;")
|
||||
button_layout.addWidget(self.play_button)
|
||||
self.play_button.clicked.connect(self.toggle_play)
|
||||
|
||||
pause_button = QPushButton("Pause", self)
|
||||
pause_button.setStyleSheet("background-color: #ff5722; color: white; padding: 10px 20px; border-radius: 5px;")
|
||||
button_layout.addWidget(pause_button)
|
||||
self.pause_button = QPushButton("Pause", self)
|
||||
self.pause_button.setStyleSheet("background-color: #ff5722; color: white; padding: 10px 20px; border-radius: 5px;")
|
||||
button_layout.addWidget(self.pause_button)
|
||||
self.pause_button.clicked.connect(self.pause)
|
||||
|
||||
# Arbeitsbereich für Audio-Spuren (Platzhalter)
|
||||
track_area = QWidget(self)
|
||||
track_area.setStyleSheet("background-color: #222222; border: 1px solid #333333;")
|
||||
layout.addWidget(track_area)
|
||||
self.track_area = QGraphicsView(self)
|
||||
self.track_area.setStyleSheet("background-color: #222222; border: 1px solid #333333;")
|
||||
layout.addWidget(self.track_area)
|
||||
|
||||
self.scene = QGraphicsScene(self)
|
||||
self.track_area.setScene(self.scene)
|
||||
|
||||
self.timeline_length = 1000 # Länge der Timeline in Pixeln
|
||||
self.scene.addLine(0, 0, self.timeline_length, 0, QPen(Qt.GlobalColor.white))
|
||||
|
||||
self.playhead = QGraphicsLineItem(0, -5, 0, 5)
|
||||
self.playhead.setPen(QPen(Qt.GlobalColor.red, 2))
|
||||
self.scene.addItem(self.playhead)
|
||||
|
||||
self.timer = QTimer(self)
|
||||
self.timer.timeout.connect(self.move_playhead)
|
||||
self.timer_interval = 10 # Intervall in Millisekunden
|
||||
self.timer.setInterval(self.timer_interval)
|
||||
|
||||
def toggle_play(self):
|
||||
if self.timer.isActive():
|
||||
self.pause()
|
||||
else:
|
||||
self.play()
|
||||
|
||||
def play(self):
|
||||
self.timer.start()
|
||||
|
||||
def pause(self):
|
||||
self.timer.stop()
|
||||
|
||||
def move_playhead(self):
|
||||
current_x = self.playhead.line().p1().x()
|
||||
if current_x < self.timeline_length:
|
||||
self.playhead.setLine(current_x + 1, -5, current_x + 1, 5)
|
||||
else:
|
||||
self.pause()
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
Reference in new issue
Block a user