class MetadataOptionsPage(OptionsPage): NAME = "metadata" TITLE = N_("Metadata") PARENT = None SORT_ORDER = 20 ACTIVE = True options = [ TextOption("setting", "va_name", u"Various Artists"), TextOption("setting", "nat_name", u"[non-album tracks]"), BoolOption("setting", "translate_artist_names", False), BoolOption("setting", "release_ars", True), BoolOption("setting", "track_ars", False), BoolOption("setting", "folksonomy_tags", False), BoolOption("setting", "convert_punctuation", False), BoolOption("setting", "standardize_tracks", False), BoolOption("setting", "standardize_releases", False), BoolOption("setting", "standardize_artists", False), ] def __init__(self, parent=None): super(MetadataOptionsPage, self).__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.connect(self.ui.va_name_default, QtCore.SIGNAL("clicked()"), self.set_va_name_default) self.connect(self.ui.nat_name_default, QtCore.SIGNAL("clicked()"), self.set_nat_name_default) def load(self): self.ui.translate_artist_names.setChecked(self.config.setting["translate_artist_names"]) self.ui.convert_punctuation.setChecked(self.config.setting["convert_punctuation"]) self.ui.release_ars.setChecked(self.config.setting["release_ars"]) self.ui.track_ars.setChecked(self.config.setting["track_ars"]) self.ui.folksonomy_tags.setChecked(self.config.setting["folksonomy_tags"]) self.ui.va_name.setText(self.config.setting["va_name"]) self.ui.nat_name.setText(self.config.setting["nat_name"]) self.ui.standardize_tracks.setChecked(self.config.setting["standardize_tracks"]) self.ui.standardize_releases.setChecked(self.config.setting["standardize_releases"]) self.ui.standardize_artists.setChecked(self.config.setting["standardize_artists"]) def save(self): self.config.setting["translate_artist_names"] = self.ui.translate_artist_names.isChecked() self.config.setting["convert_punctuation"] = self.ui.convert_punctuation.isChecked() self.config.setting["release_ars"] = self.ui.release_ars.isChecked() self.config.setting["track_ars"] = self.ui.track_ars.isChecked() self.config.setting["folksonomy_tags"] = self.ui.folksonomy_tags.isChecked() self.config.setting["va_name"] = self.ui.va_name.text() self.config.setting["nat_name"] = self.ui.nat_name.text() self.config.setting["standardize_tracks"] = self.ui.standardize_tracks.isChecked() self.config.setting["standardize_releases"] = self.ui.standardize_releases.isChecked() self.config.setting["standardize_artists"] = self.ui.standardize_artists.isChecked() def set_va_name_default(self): self.ui.va_name.setText(self.options[0].default) self.ui.va_name.setCursorPosition(0) def set_nat_name_default(self): self.ui.nat_name.setText(self.options[1].default) self.ui.nat_name.setCursorPosition(0)
def __init__(self, parent=None): super(MetadataOptionsPage, self).__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.connect(self.ui.va_name_default, QtCore.SIGNAL("clicked()"), self.set_va_name_default) self.connect(self.ui.nat_name_default, QtCore.SIGNAL("clicked()"), self.set_nat_name_default)
def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.ui.va_name_default.clicked.connect(self.set_va_name_default) self.ui.nat_name_default.clicked.connect(self.set_nat_name_default) self.ui.select_locales.clicked.connect(self.open_locale_selector) self.ui.select_scripts.clicked.connect(self.open_script_selector) self.ui.translate_artist_names.stateChanged.connect(self.set_enabled_states) self.ui.translate_artist_names_script_exception.stateChanged.connect(self.set_enabled_states)
class MetadataOptionsPage(OptionsPage): NAME = "metadata" TITLE = N_("Metadata") PARENT = None SORT_ORDER = 20 ACTIVE = True options = [ config.TextOption("setting", "va_name", u"Various Artists"), config.TextOption("setting", "nat_name", u"[non-album tracks]"), config.TextOption("setting", "artist_locale", u"en"), config.BoolOption("setting", "translate_artist_names", False), config.BoolOption("setting", "release_ars", True), config.BoolOption("setting", "track_ars", False), config.BoolOption("setting", "folksonomy_tags", False), config.BoolOption("setting", "convert_punctuation", True), config.BoolOption("setting", "standardize_artists", False), ] def __init__(self, parent=None): super(MetadataOptionsPage, self).__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.ui.va_name_default.clicked.connect(self.set_va_name_default) self.ui.nat_name_default.clicked.connect(self.set_nat_name_default) def load(self): self.ui.translate_artist_names.setChecked( config.setting["translate_artist_names"]) combo_box = self.ui.artist_locale locales = sorted(ALIAS_LOCALES.keys()) for i, loc in enumerate(locales): name = ALIAS_LOCALES[loc] if "_" in loc: name = " " + name combo_box.addItem(name, loc) if loc == config.setting["artist_locale"]: combo_box.setCurrentIndex(i) self.ui.convert_punctuation.setChecked( config.setting["convert_punctuation"]) self.ui.release_ars.setChecked(config.setting["release_ars"]) self.ui.track_ars.setChecked(config.setting["track_ars"]) self.ui.folksonomy_tags.setChecked(config.setting["folksonomy_tags"]) self.ui.va_name.setText(config.setting["va_name"]) self.ui.nat_name.setText(config.setting["nat_name"]) self.ui.standardize_artists.setChecked( config.setting["standardize_artists"]) def save(self): config.setting[ "translate_artist_names"] = self.ui.translate_artist_names.isChecked( ) config.setting["artist_locale"] = self.ui.artist_locale.itemData( self.ui.artist_locale.currentIndex()) config.setting[ "convert_punctuation"] = self.ui.convert_punctuation.isChecked() config.setting["release_ars"] = self.ui.release_ars.isChecked() config.setting["track_ars"] = self.ui.track_ars.isChecked() config.setting["folksonomy_tags"] = self.ui.folksonomy_tags.isChecked() config.setting["va_name"] = self.ui.va_name.text() nat_name = unicode(self.ui.nat_name.text()) if nat_name != config.setting["nat_name"]: config.setting["nat_name"] = nat_name self.tagger.nats.update() config.setting[ "standardize_artists"] = self.ui.standardize_artists.isChecked() def set_va_name_default(self): self.ui.va_name.setText(self.options[0].default) self.ui.va_name.setCursorPosition(0) def set_nat_name_default(self): self.ui.nat_name.setText(self.options[1].default) self.ui.nat_name.setCursorPosition(0)
def __init__(self, parent=None): super(MetadataOptionsPage, self).__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.ui.va_name_default.clicked.connect(self.set_va_name_default) self.ui.nat_name_default.clicked.connect(self.set_nat_name_default)
class MetadataOptionsPage(OptionsPage): NAME = "metadata" TITLE = N_("Metadata") PARENT = None SORT_ORDER = 20 ACTIVE = True options = [ config.TextOption("setting", "va_name", u"Various Artists"), config.TextOption("setting", "nat_name", u"[non-album tracks]"), config.TextOption("setting", "artist_locale", u"en"), config.BoolOption("setting", "translate_artist_names", False), config.BoolOption("setting", "release_ars", True), config.BoolOption("setting", "track_ars", False), config.BoolOption("setting", "folksonomy_tags", False), config.BoolOption("setting", "convert_punctuation", True), config.BoolOption("setting", "standardize_artists", False), ] def __init__(self, parent=None): super(MetadataOptionsPage, self).__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.ui.va_name_default.clicked.connect(self.set_va_name_default) self.ui.nat_name_default.clicked.connect(self.set_nat_name_default) def load(self): self.ui.translate_artist_names.setChecked(config.setting["translate_artist_names"]) combo_box = self.ui.artist_locale locales = ALIAS_LOCALES.keys() locales.sort() for i, loc in enumerate(locales): name = ALIAS_LOCALES[loc] if "_" in loc: name = " " + name combo_box.addItem(name, loc) if loc == config.setting["artist_locale"]: combo_box.setCurrentIndex(i) self.ui.convert_punctuation.setChecked(config.setting["convert_punctuation"]) self.ui.release_ars.setChecked(config.setting["release_ars"]) self.ui.track_ars.setChecked(config.setting["track_ars"]) self.ui.folksonomy_tags.setChecked(config.setting["folksonomy_tags"]) self.ui.va_name.setText(config.setting["va_name"]) self.ui.nat_name.setText(config.setting["nat_name"]) self.ui.standardize_artists.setChecked(config.setting["standardize_artists"]) def save(self): config.setting["translate_artist_names"] = self.ui.translate_artist_names.isChecked() config.setting["artist_locale"] = self.ui.artist_locale.itemData(self.ui.artist_locale.currentIndex()) config.setting["convert_punctuation"] = self.ui.convert_punctuation.isChecked() config.setting["release_ars"] = self.ui.release_ars.isChecked() config.setting["track_ars"] = self.ui.track_ars.isChecked() config.setting["folksonomy_tags"] = self.ui.folksonomy_tags.isChecked() config.setting["va_name"] = self.ui.va_name.text() nat_name = unicode(self.ui.nat_name.text()) if nat_name != config.setting["nat_name"]: config.setting["nat_name"] = nat_name self.tagger.nats.update() config.setting["standardize_artists"] = self.ui.standardize_artists.isChecked() def set_va_name_default(self): self.ui.va_name.setText(self.options[0].default) self.ui.va_name.setCursorPosition(0) def set_nat_name_default(self): self.ui.nat_name.setText(self.options[1].default) self.ui.nat_name.setCursorPosition(0)
def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.ui.va_name_default.clicked.connect(self.set_va_name_default) self.ui.nat_name_default.clicked.connect(self.set_nat_name_default)
class MetadataOptionsPage(OptionsPage): NAME = "metadata" TITLE = N_("Metadata") PARENT = None SORT_ORDER = 20 ACTIVE = True options = [ config.TextOption("setting", "va_name", "Various Artists"), config.TextOption("setting", "nat_name", "[non-album tracks]"), config.TextOption("setting", "artist_locale", "en"), config.BoolOption("setting", "translate_artist_names", False), config.BoolOption("setting", "release_ars", True), config.BoolOption("setting", "track_ars", False), config.BoolOption("setting", "convert_punctuation", True), config.BoolOption("setting", "standardize_artists", False), config.BoolOption("setting", "standardize_instruments", True), ] def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.ui.va_name_default.clicked.connect(self.set_va_name_default) self.ui.nat_name_default.clicked.connect(self.set_nat_name_default) def load(self): self.ui.translate_artist_names.setChecked( config.setting["translate_artist_names"]) combo_box = self.ui.artist_locale current_locale = config.setting["artist_locale"] for i, (locale, name, level) in enumerate(iter_sorted_locales(ALIAS_LOCALES)): label = " " * level + name combo_box.addItem(label, locale) if locale == current_locale: combo_box.setCurrentIndex(i) self.ui.convert_punctuation.setChecked( config.setting["convert_punctuation"]) self.ui.release_ars.setChecked(config.setting["release_ars"]) self.ui.track_ars.setChecked(config.setting["track_ars"]) self.ui.va_name.setText(config.setting["va_name"]) self.ui.nat_name.setText(config.setting["nat_name"]) self.ui.standardize_artists.setChecked( config.setting["standardize_artists"]) self.ui.standardize_instruments.setChecked( config.setting["standardize_instruments"]) def save(self): config.setting[ "translate_artist_names"] = self.ui.translate_artist_names.isChecked( ) config.setting["artist_locale"] = self.ui.artist_locale.itemData( self.ui.artist_locale.currentIndex()) config.setting[ "convert_punctuation"] = self.ui.convert_punctuation.isChecked() config.setting["release_ars"] = self.ui.release_ars.isChecked() config.setting["track_ars"] = self.ui.track_ars.isChecked() config.setting["va_name"] = self.ui.va_name.text() nat_name = self.ui.nat_name.text() if nat_name != config.setting["nat_name"]: config.setting["nat_name"] = nat_name if self.tagger.nats is not None: self.tagger.nats.update() config.setting[ "standardize_artists"] = self.ui.standardize_artists.isChecked() config.setting[ "standardize_instruments"] = self.ui.standardize_instruments.isChecked( ) def set_va_name_default(self): self.ui.va_name.setText(self.options[0].default) self.ui.va_name.setCursorPosition(0) def set_nat_name_default(self): self.ui.nat_name.setText(self.options[1].default) self.ui.nat_name.setCursorPosition(0)
class MetadataOptionsPage(OptionsPage): NAME = "metadata" TITLE = N_("Metadata") PARENT = None SORT_ORDER = 20 ACTIVE = True HELP_URL = '/config/options_metadata.html' options = [ TextOption("setting", "va_name", "Various Artists"), TextOption("setting", "nat_name", "[non-album tracks]"), ListOption("setting", "artist_locales", ["en"]), BoolOption("setting", "translate_artist_names", False), BoolOption("setting", "translate_artist_names_script_exception", False), ListOption("setting", "script_exceptions", []), BoolOption("setting", "release_ars", True), BoolOption("setting", "track_ars", False), BoolOption("setting", "convert_punctuation", False), BoolOption("setting", "standardize_artists", False), BoolOption("setting", "standardize_instruments", True), BoolOption("setting", "guess_tracknumber_and_title", True), ] def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.ui.va_name_default.clicked.connect(self.set_va_name_default) self.ui.nat_name_default.clicked.connect(self.set_nat_name_default) self.ui.select_locales.clicked.connect(self.open_locale_selector) self.ui.select_scripts.clicked.connect(self.open_script_selector) self.ui.translate_artist_names.stateChanged.connect( self.set_enabled_states) self.ui.translate_artist_names_script_exception.stateChanged.connect( self.set_enabled_states) def load(self): config = get_config() self.ui.translate_artist_names.setChecked( config.setting["translate_artist_names"]) self.current_locales = config.setting["artist_locales"] self.make_locales_text() self.current_scripts = config.setting["script_exceptions"] self.make_scripts_text() self.ui.translate_artist_names_script_exception.setChecked( config.setting["translate_artist_names_script_exception"]) self.ui.convert_punctuation.setChecked( config.setting["convert_punctuation"]) self.ui.release_ars.setChecked(config.setting["release_ars"]) self.ui.track_ars.setChecked(config.setting["track_ars"]) self.ui.va_name.setText(config.setting["va_name"]) self.ui.nat_name.setText(config.setting["nat_name"]) self.ui.standardize_artists.setChecked( config.setting["standardize_artists"]) self.ui.standardize_instruments.setChecked( config.setting["standardize_instruments"]) self.ui.guess_tracknumber_and_title.setChecked( config.setting["guess_tracknumber_and_title"]) self.set_enabled_states() def make_locales_text(self): def translated_locales(): for locale in self.current_locales: yield _(ALIAS_LOCALES[locale]) self.ui.selected_locales.setText('; '.join(translated_locales())) def make_scripts_text(self): def translated_scripts(): for script in self.current_scripts: yield ScriptExceptionSelector.make_label(script[0], script[1]) self.ui.selected_scripts.setText('; '.join(translated_scripts())) def save(self): config = get_config() config.setting[ "translate_artist_names"] = self.ui.translate_artist_names.isChecked( ) config.setting["artist_locales"] = self.current_locales config.setting[ "translate_artist_names_script_exception"] = self.ui.translate_artist_names_script_exception.isChecked( ) config.setting["script_exceptions"] = self.current_scripts config.setting[ "convert_punctuation"] = self.ui.convert_punctuation.isChecked() config.setting["release_ars"] = self.ui.release_ars.isChecked() config.setting["track_ars"] = self.ui.track_ars.isChecked() config.setting["va_name"] = self.ui.va_name.text() nat_name = self.ui.nat_name.text() if nat_name != config.setting["nat_name"]: config.setting["nat_name"] = nat_name if self.tagger.nats is not None: self.tagger.nats.update() config.setting[ "standardize_artists"] = self.ui.standardize_artists.isChecked() config.setting[ "standardize_instruments"] = self.ui.standardize_instruments.isChecked( ) config.setting[ "guess_tracknumber_and_title"] = self.ui.guess_tracknumber_and_title.isChecked( ) def set_va_name_default(self): self.ui.va_name.setText(self.options[0].default) self.ui.va_name.setCursorPosition(0) def set_nat_name_default(self): self.ui.nat_name.setText(self.options[1].default) self.ui.nat_name.setCursorPosition(0) def set_enabled_states(self): translate_checked = self.ui.translate_artist_names.isChecked() translate_exception_checked = self.ui.translate_artist_names_script_exception.isChecked( ) self.ui.select_locales.setEnabled(translate_checked) self.ui.selected_locales.setEnabled(translate_checked) self.ui.translate_artist_names_script_exception.setEnabled( translate_checked) select_scripts_enabled = translate_checked and translate_exception_checked self.ui.selected_scripts.setEnabled(select_scripts_enabled) self.ui.select_scripts.setEnabled(select_scripts_enabled) def open_locale_selector(self): dialog = MultiLocaleSelector(self) dialog.show() def open_script_selector(self): dialog = ScriptExceptionSelector(self) dialog.show()
class MetadataOptionsPage(OptionsPage): NAME = "metadata" TITLE = N_("Metadata") PARENT = None SORT_ORDER = 20 ACTIVE = True HELP_URL = '/config/options_metadata.html' options = [ TextOption("setting", "va_name", "Various Artists"), TextOption("setting", "nat_name", "[non-album tracks]"), ListOption("setting", "artist_locales", ["en"]), BoolOption("setting", "translate_artist_names", False), BoolOption("setting", "translate_artist_names_script_exception", False), ListOption("setting", "artist_script_exceptions", []), IntOption("setting", "artist_script_exception_weighting", 0), BoolOption("setting", "release_ars", True), BoolOption("setting", "track_ars", False), BoolOption("setting", "convert_punctuation", True), BoolOption("setting", "standardize_artists", False), BoolOption("setting", "standardize_instruments", True), BoolOption("setting", "guess_tracknumber_and_title", True), ] def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_MetadataOptionsPage() self.ui.setupUi(self) self.ui.va_name_default.clicked.connect(self.set_va_name_default) self.ui.nat_name_default.clicked.connect(self.set_nat_name_default) self.ui.select_locales.clicked.connect(self.open_locale_selector) self.ui.translate_artist_names.stateChanged.connect( self.set_enabled_states) self.ui.translate_artist_names_script_exception.stateChanged.connect( self.set_enabled_states) def load(self): config = get_config() self.ui.translate_artist_names.setChecked( config.setting["translate_artist_names"]) self.current_locales = config.setting["artist_locales"] self.make_locales_text() self.ui.translate_artist_names_script_exception.setChecked( config.setting["translate_artist_names_script_exception"]) self.ui.ignore_tx_scripts.clear() for script_id in SCRIPTS: enabled = script_id in config.setting["artist_script_exceptions"] item = QtWidgets.QListWidgetItem(_(SCRIPTS[script_id])) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setData(QtCore.Qt.UserRole, script_id) item.setCheckState( QtCore.Qt.Checked if enabled else QtCore.Qt.Unchecked) self.ui.ignore_tx_scripts.addItem(item) self.ui.minimum_weighting.setValue( config.setting["artist_script_exception_weighting"]) self.ui.convert_punctuation.setChecked( config.setting["convert_punctuation"]) self.ui.release_ars.setChecked(config.setting["release_ars"]) self.ui.track_ars.setChecked(config.setting["track_ars"]) self.ui.va_name.setText(config.setting["va_name"]) self.ui.nat_name.setText(config.setting["nat_name"]) self.ui.standardize_artists.setChecked( config.setting["standardize_artists"]) self.ui.standardize_instruments.setChecked( config.setting["standardize_instruments"]) self.ui.guess_tracknumber_and_title.setChecked( config.setting["guess_tracknumber_and_title"]) self.set_enabled_states() def make_locales_text(self): def translated_locales(): for locale in self.current_locales: yield _(ALIAS_LOCALES[locale]) self.ui.selected_locales.setText('; '.join(translated_locales())) def save(self): config = get_config() config.setting[ "translate_artist_names"] = self.ui.translate_artist_names.isChecked( ) config.setting["artist_locales"] = self.current_locales config.setting[ "translate_artist_names_script_exception"] = self.ui.translate_artist_names_script_exception.isChecked( ) script_exceptions = [] for idx in range(self.ui.ignore_tx_scripts.count()): item = self.ui.ignore_tx_scripts.item(idx) if item.checkState() == QtCore.Qt.Checked: script_exceptions.append(item.data(QtCore.Qt.UserRole)) config.setting["artist_script_exceptions"] = script_exceptions config.setting["artist_script_exception_weighting"] = min( 100, max(0, self.ui.minimum_weighting.value())) config.setting[ "convert_punctuation"] = self.ui.convert_punctuation.isChecked() config.setting["release_ars"] = self.ui.release_ars.isChecked() config.setting["track_ars"] = self.ui.track_ars.isChecked() config.setting["va_name"] = self.ui.va_name.text() nat_name = self.ui.nat_name.text() if nat_name != config.setting["nat_name"]: config.setting["nat_name"] = nat_name if self.tagger.nats is not None: self.tagger.nats.update() config.setting[ "standardize_artists"] = self.ui.standardize_artists.isChecked() config.setting[ "standardize_instruments"] = self.ui.standardize_instruments.isChecked( ) config.setting[ "guess_tracknumber_and_title"] = self.ui.guess_tracknumber_and_title.isChecked( ) def set_va_name_default(self): self.ui.va_name.setText(self.options[0].default) self.ui.va_name.setCursorPosition(0) def set_nat_name_default(self): self.ui.nat_name.setText(self.options[1].default) self.ui.nat_name.setCursorPosition(0) def set_enabled_states(self): translate_checked = self.ui.translate_artist_names.isChecked() translate_exception_checked = self.ui.translate_artist_names_script_exception.isChecked( ) self.ui.select_locales.setEnabled(translate_checked) self.ui.selected_locales.setEnabled(translate_checked) self.ui.translate_artist_names_script_exception.setEnabled( translate_checked) self.ui.ignore_script_frame.setEnabled(translate_checked and translate_exception_checked) def open_locale_selector(self): dialog = MultiLocaleSelector(self) dialog.show()