forked from Wobbl/Wobuzz
Implemented playing of different playlist, but its buggy.
This commit is contained in:
parent
744d050bac
commit
2b1310990a
3 changed files with 23 additions and 7 deletions
|
@ -11,7 +11,7 @@ class Library(QToolBox):
|
|||
|
||||
self.library = library
|
||||
|
||||
self.playlist_tabs = PlaylistTabs()
|
||||
self.playlist_tabs = PlaylistTabs(library)
|
||||
|
||||
self.addItem(self.playlist_tabs, "Playlists")
|
||||
|
||||
|
|
|
@ -68,8 +68,6 @@ class PlaylistView(QTreeWidget):
|
|||
|
||||
self.itemDropped.emit(self, items)
|
||||
|
||||
self.on_user_sort()
|
||||
|
||||
else:
|
||||
items = self.app.gui.dropped
|
||||
|
||||
|
@ -78,6 +76,8 @@ class PlaylistView(QTreeWidget):
|
|||
for item in items:
|
||||
track = item.track
|
||||
|
||||
self.playlist.tracks.append(track)
|
||||
|
||||
track_item = TrackItem(track, i, self)
|
||||
|
||||
i += 1
|
||||
|
@ -86,6 +86,8 @@ class PlaylistView(QTreeWidget):
|
|||
|
||||
event.accept()
|
||||
|
||||
self.on_user_sort()
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
# store dragged items in gui.dropped, so the other playlist can receive it
|
||||
if event.source() == self:
|
||||
|
@ -106,6 +108,9 @@ class PlaylistView(QTreeWidget):
|
|||
i += 1
|
||||
|
||||
def on_track_activation(self, item, column):
|
||||
if not self.app.player.current_playlist == self.playlist:
|
||||
self.app.player.current_playlist = self.playlist
|
||||
|
||||
index = self.indexOfTopLevelItem(item)
|
||||
self.app.player.play_track_in_playlist(index)
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
#!/usr/bin/python3
|
||||
from PyQt6.QtGui import QDragEnterEvent
|
||||
from PyQt6.QtGui import QDragEnterEvent, QMouseEvent
|
||||
from PyQt6.QtWidgets import QTabWidget, QTabBar
|
||||
|
||||
|
||||
class PlaylistTabs(QTabWidget):
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, library, parent=None):
|
||||
self.library = library
|
||||
|
||||
super().__init__(parent)
|
||||
|
||||
self.setTabBar(PlaylistTabBar(self))
|
||||
|
@ -18,11 +20,20 @@ class PlaylistTabBar(QTabBar):
|
|||
super().__init__(parent)
|
||||
|
||||
self.tab_widget = parent
|
||||
self.app = parent.library.app
|
||||
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
def dragEnterEvent(self, event: QDragEnterEvent):
|
||||
tab = self.tabAt(event.position().toPoint())
|
||||
index = self.tabAt(event.position().toPoint())
|
||||
|
||||
self.tab_widget.setCurrentIndex(tab)
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue