forked from Wobbl/Wobuzz
36 lines
940 B
Python
36 lines
940 B
Python
|
#!/usr/bin/python3
|
||
|
|
||
|
from PyQt6.QtGui import QDragEnterEvent
|
||
|
from PyQt6.QtWidgets import QTabBar
|
||
|
|
||
|
|
||
|
class PlaylistTabBar(QTabBar):
|
||
|
def __init__(self, parent=None):
|
||
|
super().__init__(parent)
|
||
|
|
||
|
self.tab_widget = parent
|
||
|
self.app = parent.library.app
|
||
|
|
||
|
self.setAcceptDrops(True)
|
||
|
|
||
|
self.tabBarClicked.connect(self.on_click)
|
||
|
self.tabBarDoubleClicked.connect(self.on_doubleclick)
|
||
|
|
||
|
def dragEnterEvent(self, event: QDragEnterEvent):
|
||
|
index = self.tabAt(event.position().toPoint())
|
||
|
|
||
|
self.tab_widget.setCurrentIndex(index)
|
||
|
|
||
|
def on_click(self, index):
|
||
|
playlist_view = self.tab_widget.widget(index)
|
||
|
playlist = playlist_view.playlist
|
||
|
|
||
|
self.app.gui.clicked_playlist = playlist
|
||
|
|
||
|
def on_doubleclick(self, index):
|
||
|
playlist_view = self.tab_widget.widget(index)
|
||
|
playlist = playlist_view.playlist
|
||
|
|
||
|
self.app.player.start_playlist(playlist)
|
||
|
|