forked from Wobbl/Wobuzz
Implemented loading of tracks via the window's top menubar.
This commit is contained in:
parent
66ee7d5af6
commit
a9f07f0716
8 changed files with 73 additions and 28 deletions
|
@ -36,6 +36,7 @@ class Playlist:
|
|||
self.current_track: Track | None = None
|
||||
self.views = {} # dict of id(LibraryDock): PlaylistView
|
||||
self.loaded = False
|
||||
self.loading = False
|
||||
|
||||
self.path = os.path.expanduser(
|
||||
f"{app.settings.library_path}/playlists/{self.title.replace(" ", "_")}.wbz.m3u"
|
||||
|
@ -78,9 +79,11 @@ class Playlist:
|
|||
loading_thread.start()
|
||||
|
||||
def loading_thread(self):
|
||||
if self.loaded:
|
||||
if self.loaded or self.loading:
|
||||
return
|
||||
|
||||
self.loading = True
|
||||
|
||||
if self.load_from is None: # if the playlist is in the library
|
||||
self.load_from_wbz(self.path)
|
||||
|
||||
|
@ -90,6 +93,8 @@ class Playlist:
|
|||
elif isinstance(self.load_from, list): # if it's created from tracks
|
||||
self.load_from_paths(self.load_from)
|
||||
|
||||
self.loading = False
|
||||
|
||||
for dock_id in self.views: # enable drag and drop on every view
|
||||
view = self.views[dock_id]
|
||||
|
||||
|
@ -297,13 +302,16 @@ class Playlist:
|
|||
if os.path.exists(self.path):
|
||||
os.remove(self.path)
|
||||
|
||||
self.app.utils.unique_names.remove(self.title)
|
||||
self.app.library.playlists.remove(self)
|
||||
|
||||
if self.app.player.current_playlist == self: # stop if this is the current playlist
|
||||
self.app.player.stop()
|
||||
self.app.player.current_playlist = None
|
||||
|
||||
for view in self.views.values(): # close views (and PyQt automatically closes the corresponding tabs)
|
||||
view.deleteLater()
|
||||
|
||||
self.app.utils.unique_names.remove(self.title)
|
||||
self.app.library.playlists.remove(self)
|
||||
|
||||
def append_track(self, track):
|
||||
for dock_id in self.views:
|
||||
view = self.views[dock_id]
|
||||
|
@ -316,3 +324,4 @@ class Playlist:
|
|||
|
||||
if len(self.tracks) > 1:
|
||||
return self.tracks[-2]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue