forked from Wobbl/Wobuzz
Added popup on import where the user can configure how the tracks get imported.
This commit is contained in:
parent
31b2e3bf41
commit
fd34476d00
12 changed files with 289 additions and 28 deletions
|
@ -1,6 +1,9 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from PyQt6.QtWidgets import QFileDialog
|
||||
from PyQt6.QtWidgets import QDialog, QFileDialog
|
||||
|
||||
from .library.import_dialog import ImportDialog
|
||||
from ..types import Types
|
||||
|
||||
|
||||
class Popups:
|
||||
|
@ -12,7 +15,7 @@ class Popups:
|
|||
|
||||
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.setNameFilters(["Audio Files (*.flac *.wav *.mp3 *.ogg *.opus *.m4a)", "Any (*)"])
|
||||
self.audio_file_selector.setViewMode(QFileDialog.ViewMode.List)
|
||||
|
||||
self.playlist_file_selector = QFileDialog(self.window, "Select Playlist")
|
||||
|
@ -20,6 +23,8 @@ class Popups:
|
|||
self.playlist_file_selector.setNameFilters(["Playlists (*.wbz.m3u *.m3u)", "Any (*)"])
|
||||
self.playlist_file_selector.setViewMode(QFileDialog.ViewMode.List)
|
||||
|
||||
self.import_dialog = ImportDialog()
|
||||
|
||||
self.window.open_track_action.triggered.connect(self.open_tracks)
|
||||
self.window.import_track_action.triggered.connect(self.import_tracks)
|
||||
self.window.open_playlist_action.triggered.connect(self.open_playlist)
|
||||
|
@ -39,11 +44,43 @@ class Popups:
|
|||
if files is not None and not files == []:
|
||||
self.app.library.open_tracks(files)
|
||||
|
||||
def get_import_options(self):
|
||||
import_options = Types.ImportOptions()
|
||||
|
||||
if self.import_dialog.tagging_section.overwrite_metadata.isChecked():
|
||||
artist = self.import_dialog.tagging_section.artist.text()
|
||||
album = self.import_dialog.tagging_section.album.text()
|
||||
genre = self.import_dialog.tagging_section.genre.text()
|
||||
|
||||
if not artist == "":
|
||||
import_options.artist = artist
|
||||
|
||||
if not album == "":
|
||||
import_options.album = album
|
||||
|
||||
if not genre == "":
|
||||
import_options.genre = genre
|
||||
|
||||
if self.import_dialog.file_section.copy_type_copy.isChecked():
|
||||
import_options.copy_type = Types.CopyType.copy
|
||||
|
||||
elif self.import_dialog.file_section.copy_type_move.isChecked():
|
||||
import_options.copy_type = Types.CopyType.move
|
||||
|
||||
return import_options
|
||||
|
||||
def import_tracks(self):
|
||||
files = self.select_audio_files()
|
||||
|
||||
if files is not None and not files == []:
|
||||
self.app.library.import_tracks(files)
|
||||
if files is None or files == []:
|
||||
return
|
||||
|
||||
if self.import_dialog.exec() == QDialog.rejected:
|
||||
return
|
||||
|
||||
import_options = self.get_import_options()
|
||||
|
||||
self.app.library.import_tracks(files, import_options)
|
||||
|
||||
def open_playlist(self):
|
||||
playlist_path = self.select_playlist_file()
|
||||
|
@ -54,5 +91,12 @@ class Popups:
|
|||
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)
|
||||
if playlist_path is None or playlist_path == "":
|
||||
return
|
||||
|
||||
if self.import_dialog.exec() == QDialog.rejected:
|
||||
return
|
||||
|
||||
import_options = self.get_import_options()
|
||||
|
||||
self.app.library.import_playlist(playlist_path, import_options)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue