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
116
wobuzz/ui/library/import_dialog.py
Normal file
116
wobuzz/ui/library/import_dialog.py
Normal file
|
@ -0,0 +1,116 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from PyQt6.QtWidgets import (
|
||||
QWidget,
|
||||
QLabel,
|
||||
QDialog,
|
||||
QCheckBox,
|
||||
QLineEdit,
|
||||
QDialogButtonBox,
|
||||
QButtonGroup,
|
||||
QRadioButton,
|
||||
QVBoxLayout,
|
||||
QHBoxLayout,
|
||||
QFormLayout,
|
||||
QSizePolicy,
|
||||
)
|
||||
from PyQt6.QtCore import Qt
|
||||
|
||||
from ..custom_widgets import GroupBox
|
||||
|
||||
|
||||
class ImportDialog(QDialog):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.setWindowTitle("Import")
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
self.setLayout(layout)
|
||||
|
||||
self.tagging_section = GroupBox("Metadata And Tagging", self)
|
||||
self.tagging_section.layout = QFormLayout(self.tagging_section)
|
||||
self.tagging_section.setLayout(self.tagging_section.layout)
|
||||
layout.addWidget(self.tagging_section)
|
||||
|
||||
self.tagging_section.overwrite_metadata = QCheckBox(
|
||||
"Set custom metadata for all tracks (Leave property blank to keep the metadata from the audio file.)",
|
||||
self.tagging_section
|
||||
)
|
||||
self.tagging_section.layout.addRow(self.tagging_section.overwrite_metadata)
|
||||
|
||||
self.tagging_section.artist = QLineEdit(self.tagging_section)
|
||||
self.tagging_section.layout.addRow(" Artist: ", self.tagging_section.artist)
|
||||
self.tagging_section.artist.setPlaceholderText("Keep track artist")
|
||||
|
||||
self.tagging_section.album = QLineEdit(self.tagging_section)
|
||||
self.tagging_section.layout.addRow(" Album: ", self.tagging_section.album)
|
||||
self.tagging_section.album.setPlaceholderText("Keep track album")
|
||||
|
||||
self.tagging_section.genre = QLineEdit(self.tagging_section)
|
||||
self.tagging_section.layout.addRow(" Genre: ", self.tagging_section.genre)
|
||||
self.tagging_section.genre.setPlaceholderText("Keep track genre")
|
||||
|
||||
self.file_section = GroupBox("File Structure", self)
|
||||
self.file_section.layout = QFormLayout(self.file_section)
|
||||
self.file_section.setLayout(self.file_section.layout)
|
||||
layout.addWidget(self.file_section)
|
||||
|
||||
self.file_section.copy_type_description = QLabel("How should the tracks get put into the Wobuzz library?")
|
||||
self.file_section.layout.addRow(self.file_section.copy_type_description)
|
||||
|
||||
self.file_section.copy_type = QButtonGroup(self.file_section)
|
||||
|
||||
self.file_section.copy_type_symlink = QRadioButton("Create symlinks", self.file_section)
|
||||
self.file_section.copy_type_symlink.setChecked(True)
|
||||
self.file_section.copy_type.addButton(self.file_section.copy_type_symlink)
|
||||
self.file_section.layout.addWidget(self.file_section.copy_type_symlink)
|
||||
|
||||
self.file_section.copy_type_copy = QRadioButton("Copy tracks", self.file_section)
|
||||
self.file_section.copy_type.addButton(self.file_section.copy_type_copy)
|
||||
self.file_section.layout.addWidget(self.file_section.copy_type_copy)
|
||||
|
||||
self.file_section.copy_type_move = QRadioButton("Move tracks", self.file_section)
|
||||
self.file_section.copy_type.addButton(self.file_section.copy_type_move)
|
||||
self.file_section.layout.addWidget(self.file_section.copy_type_move)
|
||||
|
||||
# add expanding widget so the GroupBoxes aren't vertically centered
|
||||
spacer_widget = QWidget(self)
|
||||
spacer_widget.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
|
||||
layout.addWidget(spacer_widget)
|
||||
|
||||
dialog_buttons = QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||
|
||||
self.dialog_buttons = QDialogButtonBox(dialog_buttons)
|
||||
layout.addWidget(self.dialog_buttons)
|
||||
|
||||
self.reset_inputs()
|
||||
|
||||
self.tagging_section.overwrite_metadata.stateChanged.connect(self.overwrite_state_changed)
|
||||
self.dialog_buttons.accepted.connect(self.accept)
|
||||
self.dialog_buttons.rejected.connect(self.reject)
|
||||
|
||||
def exec(self):
|
||||
self.reset_inputs()
|
||||
|
||||
return super().exec()
|
||||
|
||||
def overwrite_state_changed(self, state: int):
|
||||
overwrite = state == 2
|
||||
|
||||
self.tagging_section.artist.setEnabled(overwrite)
|
||||
self.tagging_section.album.setEnabled(overwrite)
|
||||
self.tagging_section.genre.setEnabled(overwrite)
|
||||
|
||||
self.tagging_section.layout.setRowVisible(self.tagging_section.artist, overwrite)
|
||||
self.tagging_section.layout.setRowVisible(self.tagging_section.album, overwrite)
|
||||
self.tagging_section.layout.setRowVisible(self.tagging_section.genre, overwrite)
|
||||
|
||||
def reset_inputs(self):
|
||||
self.overwrite_state_changed(0)
|
||||
|
||||
self.tagging_section.artist.setText("")
|
||||
self.tagging_section.album.setText("")
|
||||
self.tagging_section.genre.setText("")
|
||||
|
||||
self.file_section.copy_type_symlink.setChecked(True)
|
Loading…
Add table
Add a link
Reference in a new issue