43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
|
#!/usr/bin/python3
|
||
|
|
||
|
from PyQt6.QtWidgets import QTabWidget, QTreeWidgetItem
|
||
|
from player.playlist import Playlist
|
||
|
from ui.library_dock import LibraryDock
|
||
|
from ui.playlist import PlaylistView
|
||
|
|
||
|
|
||
|
class Library:
|
||
|
"""
|
||
|
Class that manages and syncs the library and library gui dock widgets.
|
||
|
"""
|
||
|
|
||
|
def __init__(self, app):
|
||
|
self.app = app
|
||
|
|
||
|
self.main_library_dock = LibraryDock()
|
||
|
self.library_docks = [self.main_library_dock]
|
||
|
|
||
|
self.temporary_playlist = Playlist(self.app, "Temporary Playlist")
|
||
|
self.playlists = [self.temporary_playlist]
|
||
|
|
||
|
def create_playlist_views(self):
|
||
|
for library_dock in self.library_docks:
|
||
|
playlist_tabs: QTabWidget = library_dock.library.playlist_tabs
|
||
|
|
||
|
playlist_tabs.playlists = {}
|
||
|
|
||
|
for playlist in self.playlists:
|
||
|
playlist_view = self.create_playlist_view(playlist)
|
||
|
playlist_tabs.playlists[playlist.title] = playlist_view
|
||
|
playlist_tabs.addTab(playlist_view, playlist.title)
|
||
|
|
||
|
def create_playlist_view(self, playlist: Playlist):
|
||
|
view = PlaylistView()
|
||
|
|
||
|
for track in playlist.tracks:
|
||
|
track_item = QTreeWidgetItem(view)
|
||
|
track_item.setText(1, track.title)
|
||
|
|
||
|
return view
|
||
|
|