Made the double click working again.

This commit is contained in:
The Wobbler 2025-02-11 17:34:04 +01:00
parent 22ffd211df
commit 0879575882
3 changed files with 17 additions and 5 deletions

View file

@ -51,6 +51,7 @@ def main():
app.library.temporary_playlist = playlist
app.library.load_playlist_views()
sys.exit(app.qt_app.exec())

View file

@ -7,10 +7,15 @@ from .track import Track
class Playlist:
def __init__(self, app, title: str):
def __init__(self, app, title: str, load_from=None):
self.app = app
self.title = title # playlist title
# if the playlist is imported and not already in the library, this variable will contain the playlist path or
# track path from which the playlist will get imported
# if None, playlist should be already in the library and will be loaded from a .wbz.m3u
self.load_from = load_from
# add to unique names so if the playlist is loaded from disk,
# no other playlist can be created using the same name
self.app.utils.unique_names.append(self.title)
@ -48,9 +53,16 @@ class Playlist:
self.tracks = []
def load(self):
loading_thread = threading.Thread(target=self.load_from_m3u, args=(self.path,))
loading_thread = threading.Thread(target=self.loading_thread)
loading_thread.start()
def loading_thread(self):
if self.load_from is None: # if the playlist is in the library
self.load_from_wbz(self.path)
elif self.load_from is list:
pass
def load_from_m3u(self, path):
file = open(path, "r")
m3u = file.read()
@ -83,7 +95,7 @@ class Playlist:
self.loaded = True
def load_from_wbz(self, path):
pass
self.load_from_m3u(path) # placeholder
def has_tracks(self):
return len(self.tracks) > 0

View file

@ -42,8 +42,7 @@ class PlaylistTabBar(QTabBar):
playlist = playlist_view.playlist
if playlist.has_tracks(): # dont crash when playlist is empty
self.app.player.start_playlist(playlist)
self.app.player.start_playlist(playlist)
def contextMenuEvent(self, event: QContextMenuEvent, title=None):
# get title by self.tabAt() if the event is called from PyQt, else its executed from the tab title and getting