Removed some mechanic that is going to be reimplemented.

This commit is contained in:
The Wobbler 2025-02-03 17:53:35 +01:00
parent 67d353dcef
commit bedca22ca6
9 changed files with 24 additions and 28 deletions

View file

@ -11,8 +11,6 @@ class GUI:
self.dropped = [] self.dropped = []
self.clicked_playlist = self.app.library.temporary_playlist
self.window = MainWindow(app) self.window = MainWindow(app)
self.settings = self.window.settings self.settings = self.window.settings
self.track_control = self.window.track_control self.track_control = self.window.track_control

View file

@ -18,8 +18,7 @@ class Library:
self.main_library_dock = LibraryDock(self) self.main_library_dock = LibraryDock(self)
self.library_docks = [self.main_library_dock] self.library_docks = [self.main_library_dock]
self.temporary_playlist = Playlist(self.app, "Temporary Playlist") self.playlists = []
self.playlists = [self.temporary_playlist]
def load(self): def load(self):
path_playlists = os.path.expanduser(f"{self.app.settings.library_path}/playlists") path_playlists = os.path.expanduser(f"{self.app.settings.library_path}/playlists")
@ -37,12 +36,8 @@ class Library:
if file_name.endswith(".m3u"): if file_name.endswith(".m3u"):
path = f"{path_playlists}/{file_name}" path = f"{path_playlists}/{file_name}"
if file_name == "Temporary_Playlist.wbz.m3u": playlist = Playlist(self.app, file_name.replace("_", " ").split(".")[0])
playlist = self.temporary_playlist self.playlists.append(playlist)
else:
playlist = Playlist(self.app, file_name.replace("_", " ").split(".")[0])
self.playlists.append(playlist)
playlist.load_from_m3u(path) playlist.load_from_m3u(path)
@ -62,6 +57,9 @@ class Library:
for playlist in self.playlists: for playlist in self.playlists:
playlist.save() playlist.save()
if self.app.player.current_playlist is not None:
self.app.settings.latest_playlist = self.app.player.current_playlist.path
def new_playlist(self): def new_playlist(self):
playlist = Playlist(self.app, self.app.utils.unique_name("New Playlist")) playlist = Playlist(self.app, self.app.utils.unique_name("New Playlist"))
self.playlists.append(playlist) self.playlists.append(playlist)

View file

@ -19,8 +19,8 @@ class Wobuzz:
self.settings = load_dataclass_json(Settings, self.utils.settings_location, self, True, True) self.settings = load_dataclass_json(Settings, self.utils.settings_location, self, True, True)
self.settings.set_attribute_change_event(self.on_settings_change) self.settings.set_attribute_change_event(self.on_settings_change)
self.player = Player(self)
self.library = Library(self) self.library = Library(self)
self.player = Player(self)
self.gui = GUI(self) self.gui = GUI(self)
self.post_init() self.post_init()

View file

@ -18,7 +18,7 @@ class Player:
self.track_progress = TrackProgress(self.app) self.track_progress = TrackProgress(self.app)
self.history = Playlist(self.app, "History") self.history = Playlist(self.app, "History")
self.current_playlist = Playlist(self.app, "None") self.current_playlist = None
self.playing = False self.playing = False
self.paused = False self.paused = False
@ -134,7 +134,7 @@ class Player:
self.music_channel.stop() self.music_channel.stop()
self.track_progress.stop() self.track_progress.stop()
if not self.current_playlist.current_track is None: if self.current_playlist is not None and self.current_playlist.current_track is not None:
self.current_sound_duration = self.current_playlist.current_track.duration self.current_sound_duration = self.current_playlist.current_track.duration
self.playing = False self.playing = False

View file

@ -72,8 +72,6 @@ class Playlist:
if self.current_track is None and self.has_tracks(): if self.current_track is None and self.has_tracks():
self.current_track = self.tracks[0] self.current_track = self.tracks[0]
#self.app.player.history.append_track(self.current_track)
def load_from_wbz(self, path): def load_from_wbz(self, path):
pass pass

View file

@ -48,13 +48,14 @@ class Track:
If this track is the currently playing track, and it gets moved, this corrects the current playlist index. If this track is the currently playing track, and it gets moved, this corrects the current playlist index.
""" """
if self.app.player.current_playlist.current_track is self: if self.app.player.current_playlist is not None:
for item in self.items: if self.app.player.current_playlist.current_track is self:
if ( for item in self.items:
item.playlist in self.occurrences and if (
self.occurrences[item.playlist][id(item)] == self.app.player.current_playlist.current_track_index item.playlist in self.occurrences and
): self.occurrences[item.playlist][id(item)] == self.app.player.current_playlist.current_track_index
self.app.player.current_playlist.set_track(new_occurrences[item.playlist][id(item)]) ):
self.app.player.current_playlist.set_track(new_occurrences[item.playlist][id(item)])
def cache(self): def cache(self):
self.load_audio() self.load_audio()

View file

@ -30,5 +30,5 @@ class TrackProgress:
def stop(self): def stop(self):
self.timer.stop() self.timer.stop()
if not self.app.player.current_playlist.current_track is None: if self.app.player.current_playlist is not None and self.app.player.current_playlist.current_track is not None:
self.remaining_time = self.app.player.current_playlist.current_track.duration self.remaining_time = self.app.player.current_playlist.current_track.duration

View file

@ -8,5 +8,6 @@ class Settings:
window_size: tuple[int, int]=None window_size: tuple[int, int]=None
window_maximized: bool=False window_maximized: bool=False
library_path: str="~/.wobuzz" library_path: str="~/.wobuzz"
clear_track_cache: bool=True clear_track_cache: bool=True,
latest_playlist: str=None

View file

@ -80,12 +80,12 @@ class TrackControl(QToolBar):
elif self.app.player.playing: # playing elif self.app.player.playing: # playing
self.app.player.pause() self.app.player.pause()
elif self.app.player.current_playlist.has_tracks(): # stopped but tracks in the current playlist # stopped but tracks in the current playlist
elif self.app.player.current_playlist is not None and self.app.player.current_playlist.has_tracks():
self.app.player.start_playing() self.app.player.start_playing()
elif self.app.player.current_playlist.title == "None": elif self.app.player.current_playlist is None:
if self.app.gui.clicked_playlist.has_tracks(): pass #self.app.player.start_playlist(self.app.gui.clicked_playlist)
self.app.player.start_playlist(self.app.gui.clicked_playlist)
def on_playstate_update(self): def on_playstate_update(self):
if self.app.player.playing: if self.app.player.playing: