forked from Wobbl/Wobuzz
39 lines
1,008 B
Python
39 lines
1,008 B
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.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)
|
|
|
|
def dragEnterEvent(self, event: QDragEnterEvent):
|
|
index = self.tabAt(event.position().toPoint())
|
|
|
|
self.tab_widget.setCurrentIndex(index)
|
|
|
|
def mouseDoubleClickEvent(self, event: QMouseEvent):
|
|
index = self.tabAt(event.position().toPoint())
|
|
|
|
playlist_view = self.tab_widget.widget(index)
|
|
playlist = playlist_view.playlist
|
|
|
|
self.app.player.current_playlist = playlist
|
|
|