47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
#!/usr/bin/python3
|
|
from PyQt6.QtGui import QDragEnterEvent, QMouseEvent
|
|
from PyQt6.QtWidgets import QTabWidget, QTabBar
|
|
|
|
|
|
class PlaylistTabs(QTabWidget):
|
|
def __init__(self, library, parent=None):
|
|
self.library = library
|
|
|
|
super().__init__(parent)
|
|
|
|
self.setTabBar(PlaylistTabBar(self))
|
|
self.setDocumentMode(True)
|
|
|
|
self.setMovable(True)
|
|
self.setAcceptDrops(True)
|
|
|
|
|
|
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)
|
|
|