diff --git a/comictaggerlib/autotagmatchwindow.py b/comictaggerlib/autotagmatchwindow.py index 163f597..a0cf9f6 100644 --- a/comictaggerlib/autotagmatchwindow.py +++ b/comictaggerlib/autotagmatchwindow.py @@ -262,7 +262,7 @@ class AutoTagMatchWindow(QtWidgets.QDialog): return QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor)) - md.overlay(ct_md, self.config.Metadata_Options__source_overlay) + md.overlay(ct_md, self.config.internal__source_data_overlay) for style in self._styles: success = ca.write_metadata(md, style) QtWidgets.QApplication.restoreOverrideCursor() diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py index 13dc94a..b299304 100644 --- a/comictaggerlib/cli.py +++ b/comictaggerlib/cli.py @@ -253,7 +253,7 @@ class CLI: if ca.has_metadata(style): try: t_md = ca.read_metadata(style) - md.overlay(t_md, self.config.Metadata_Options__read_style_overlay) + md.overlay(t_md, self.config.internal__load_data_overlay) break except Exception as e: logger.error("Failed to load metadata for %s: %s", ca.path, e) diff --git a/comictaggerlib/ctsettings/commandline.py b/comictaggerlib/ctsettings/commandline.py index 3884718..8d8a04c 100644 --- a/comictaggerlib/ctsettings/commandline.py +++ b/comictaggerlib/ctsettings/commandline.py @@ -27,7 +27,7 @@ import settngs from comicapi import utils from comicapi.comicarchive import metadata_styles -from comicapi.genericmetadata import GenericMetadata +from comicapi.genericmetadata import GenericMetadata, OverlayMode from comictaggerlib import ctversion from comictaggerlib.ctsettings.settngs_namespace import SettngsNS as ct_ns from comictaggerlib.ctsettings.types import ( @@ -177,6 +177,18 @@ def register_runtime(parser: settngs.Manager) -> None: help="""Specify the type of tags to read.\nUse commas for multiple types.\nSee --list-plugins for the available types.\nThe tag use will be 'overlayed' in order:\ne.g. '-t cbl,cr' with no CBL tags, CR will be used if they exist and CR will overwrite any shared CBL tags.\n\n""", file=False, ) + parser.add_setting( + "--read-style-overlay", + type=OverlayMode, + help="How to overlay new metadata on the current for enabled read styles (CR, CBL, etc.)", + file=False, + ) + parser.add_setting( + "--source-overlay", + type=OverlayMode, + help="How to overlay new metadata from a data source (CV, Metron, GCD, etc.) on to the current", + file=False, + ) parser.add_setting( "--overwrite", action=argparse.BooleanOptionalAction, diff --git a/comictaggerlib/ctsettings/file.py b/comictaggerlib/ctsettings/file.py index 6f67c98..756f1be 100644 --- a/comictaggerlib/ctsettings/file.py +++ b/comictaggerlib/ctsettings/file.py @@ -27,6 +27,8 @@ def internal(parser: settngs.Manager) -> None: parser.add_setting("install_id", default=uuid.uuid4().hex, cmdline=False) parser.add_setting("save_data_style", default=["cbi"], cmdline=False) parser.add_setting("load_data_style", default=["cbi"], cmdline=False) + parser.add_setting("load_data_overlay", default=OverlayMode.overlay, cmdline=False, type=OverlayMode) + parser.add_setting("source_data_overlay", default=OverlayMode.overlay, cmdline=False, type=OverlayMode) parser.add_setting("last_opened_folder", default="", cmdline=False) parser.add_setting("window_width", default=0, cmdline=False) parser.add_setting("window_height", default=0, cmdline=False) diff --git a/comictaggerlib/ctsettings/settngs_namespace.py b/comictaggerlib/ctsettings/settngs_namespace.py index 089ff84..ec29382 100644 --- a/comictaggerlib/ctsettings/settngs_namespace.py +++ b/comictaggerlib/ctsettings/settngs_namespace.py @@ -37,6 +37,8 @@ class SettngsNS(settngs.TypedNS): Runtime_Options__json: bool Runtime_Options__type_modify: list[str] Runtime_Options__type_read: list[str] + Runtime_Options__read_style_overlay: OverlayMode + Runtime_Options__source_overlay: OverlayMode Runtime_Options__overwrite: bool Runtime_Options__no_gui: bool Runtime_Options__files: list[str] @@ -44,6 +46,8 @@ class SettngsNS(settngs.TypedNS): internal__install_id: str internal__save_data_style: list[str] internal__load_data_style: list[str] + internal__load_data_overlay: OverlayMode + internal__source_data_overlay: OverlayMode internal__last_opened_folder: str internal__window_width: int internal__window_height: int @@ -202,7 +206,6 @@ class Metadata_Options(typing.TypedDict): cbl_copy_weblink_to_comments: bool cbl_apply_transform_on_import: bool cbl_apply_transform_on_bulk_operation: bool - metadata_overlay: OverlayMode use_short_metadata_names: bool disable_cr: bool diff --git a/comictaggerlib/settingswindow.py b/comictaggerlib/settingswindow.py index 5cd9bf7..0b60b15 100644 --- a/comictaggerlib/settingswindow.py +++ b/comictaggerlib/settingswindow.py @@ -433,10 +433,10 @@ class SettingsWindow(QtWidgets.QDialog): self.config[0].Metadata_Options__cbl_apply_transform_on_bulk_operation ) self.cbxOverlayReadStyle.setCurrentIndex( - self.cbxOverlayReadStyle.findData(self.config[0].Metadata_Options__read_style_overlay.value) + self.cbxOverlayReadStyle.findData(self.config[0].internal__load_data_overlay.value) ) self.cbxOverlaySource.setCurrentIndex( - self.cbxOverlaySource.findData(self.config[0].Metadata_Options__source_overlay.value) + self.cbxOverlaySource.findData(self.config[0].internal__source_data_overlay.value) ) self.cbxShortMetadataNames.setChecked(self.config[0].Metadata_Options__use_short_metadata_names) self.cbxDisableCR.setChecked(self.config[0].Metadata_Options__disable_cr) @@ -570,8 +570,8 @@ class SettingsWindow(QtWidgets.QDialog): self.cbxApplyCBLTransformOnBatchOperation.isChecked() ) - self.config[0].Metadata_Options__read_style_overlay = OverlayMode[self.cbxOverlayReadStyle.currentData()] - self.config[0].Metadata_Options__source_overlay = OverlayMode[self.cbxOverlaySource.currentData()] + self.config[0].internal__load_data_overlay = OverlayMode[self.cbxOverlayReadStyle.currentData()] + self.config[0].internal__source_data_overlay = OverlayMode[self.cbxOverlaySource.currentData()] self.config[0].Metadata_Options__disable_cr = self.cbxDisableCR.isChecked() # Update metadata style names if required if self.config[0].Metadata_Options__use_short_metadata_names != self.cbxShortMetadataNames.isChecked(): diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index 7651552..a69044a 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -217,6 +217,12 @@ class TaggerWindow(QtWidgets.QMainWindow): if config[0].Runtime_Options__type_read: config[0].internal__load_data_style = config[0].Runtime_Options__type_read + # Respect command line overlay settings + if config[0].Runtime_Options__read_style_overlay: + config[0].internal__load_data_overlay = config[0].Runtime_Options__read_style_overlay + if config[0].Runtime_Options__source_overlay: + config[0].internal__source_data_overlay = config[0].Runtime_Options__source_overlay + for style in config[0].internal__save_data_style: if style not in metadata_styles: config[0].internal__save_data_style.remove(style)