Implemented importing of playlists via the menubar.

This commit is contained in:
The Wobbler 2025-02-28 18:02:37 +01:00
parent 37f1ea3ff8
commit 5c7f4c4ef7
3 changed files with 32 additions and 2 deletions

View file

@ -30,11 +30,16 @@ class GUI:
elif self.app.settings.window_size is not None:
self.window.resize(*self.app.settings.window_size)
self.audio_file_selector = QFileDialog(self.window, "Select Audio File")
self.audio_file_selector = QFileDialog(self.window, "Select Audio Files")
self.audio_file_selector.setFileMode(QFileDialog.FileMode.ExistingFiles)
self.audio_file_selector.setNameFilters(["Audio Files (*.flac *.wav *.mp3 *.ogg *.opus)", "Any (*)"])
self.audio_file_selector.setViewMode(QFileDialog.ViewMode.List)
self.playlist_file_selector = QFileDialog(self.window, "Select Playlist")
self.playlist_file_selector.setFileMode(QFileDialog.FileMode.ExistingFile)
self.playlist_file_selector.setNameFilters(["Playlists (*.wbz.m3u *.m3u)", "Any (*)"])
self.playlist_file_selector.setViewMode(QFileDialog.ViewMode.List)
self.connect()
self.window.show()
@ -76,6 +81,10 @@ class GUI:
if self.audio_file_selector.exec():
return self.audio_file_selector.selectedFiles()
def select_playlist_file(self):
if self.playlist_file_selector.exec():
return self.playlist_file_selector.selectedFiles()[0]
def open_tracks(self):
files = self.select_audio_files()
@ -85,3 +94,9 @@ class GUI:
def import_tracks(self):
self.open_tracks() # placeholder
def import_playlist(self):
playlist_path = self.select_playlist_file()
if playlist_path is not None and not playlist_path == "":
self.app.library.import_playlist(playlist_path)

View file

@ -112,3 +112,12 @@ class Library:
playlist.load()
def import_playlist(self, playlist_path: str):
playlist = Playlist(self.app, "Temporary Playlist", playlist_path)
self.replace_temporary_playlist(playlist)
self.load_playlist_views()
playlist.load()

View file

@ -27,7 +27,12 @@ class MainWindow(QMainWindow):
self.menu_bar.addMenu(self.file_menu)
self.open_track_action = self.file_menu.addAction("&Open Tracks")
self.import_track_action = self.file_menu.addAction("&Import Track")
self.import_track_action = self.file_menu.addAction("&Import Tracks")
self.playlist_menu = QMenu("&Playlist", self.menu_bar)
self.menu_bar.addMenu(self.playlist_menu)
self.import_playlist_action = self.playlist_menu.addAction("&Import Playlists")
self.edit_menu = QMenu("&Edit", self.menu_bar)
self.menu_bar.addMenu(self.edit_menu)
@ -57,4 +62,5 @@ class MainWindow(QMainWindow):
self.processes_action.triggered.connect(self.process_dock.show)
self.open_track_action.triggered.connect(self.gui.open_tracks)
self.import_track_action.triggered.connect(self.gui.import_tracks)
self.import_playlist_action.triggered.connect(self.gui.import_playlist)