Add option for merge lists and fix saving overlay options in settings window
This commit is contained in:
parent
bada694fd4
commit
6c3b63abd9
@ -262,7 +262,7 @@ class AutoTagMatchWindow(QtWidgets.QDialog):
|
||||
return
|
||||
|
||||
QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor))
|
||||
md.overlay(ct_md, self.config.internal__source_data_overlay)
|
||||
md.overlay(ct_md, self.config.internal__source_data_overlay, self.config.internal__overlay_merge_lists)
|
||||
for style in self._styles:
|
||||
success = ca.write_metadata(md, style)
|
||||
QtWidgets.QApplication.restoreOverrideCursor()
|
||||
|
@ -253,13 +253,13 @@ class CLI:
|
||||
if ca.has_metadata(style):
|
||||
try:
|
||||
t_md = ca.read_metadata(style)
|
||||
md.overlay(t_md, self.config.internal__load_data_overlay)
|
||||
md.overlay(t_md, self.config.internal__load_data_overlay, self.config.internal__overlay_merge_lists)
|
||||
break
|
||||
except Exception as e:
|
||||
logger.error("Failed to load metadata for %s: %s", ca.path, e)
|
||||
|
||||
# finally, use explicit stuff (always 'overlay' mode)
|
||||
md.overlay(self.config.Runtime_Options__metadata, mode=merge.Mode.OVERLAY)
|
||||
md.overlay(self.config.Runtime_Options__metadata, mode=merge.Mode.OVERLAY, merge_lists=True)
|
||||
|
||||
return md
|
||||
|
||||
|
@ -189,6 +189,13 @@ def register_runtime(parser: settngs.Manager) -> None:
|
||||
help="How to overlay new metadata from a data source (CV, Metron, GCD, etc.) on to the current",
|
||||
file=False,
|
||||
)
|
||||
parser.add_setting(
|
||||
"--overlay-merge-lists",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
default="",
|
||||
help="When overlaying, merge or replace lists (genres, characters, etc.)",
|
||||
file=False,
|
||||
)
|
||||
parser.add_setting(
|
||||
"--overwrite",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
|
@ -28,6 +28,7 @@ def internal(parser: settngs.Manager) -> None:
|
||||
parser.add_setting("load_data_style", default=["cbi"], cmdline=False)
|
||||
parser.add_setting("load_data_overlay", default=merge.Mode.OVERLAY, cmdline=False, type=merge.Mode)
|
||||
parser.add_setting("source_data_overlay", default=merge.Mode.OVERLAY, cmdline=False, type=merge.Mode)
|
||||
parser.add_setting("overlay_merge_lists", default=True, cmdline=False, action=argparse.BooleanOptionalAction)
|
||||
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)
|
||||
|
@ -39,6 +39,7 @@ class SettngsNS(settngs.TypedNS):
|
||||
Runtime_Options__type_read: list[str]
|
||||
Runtime_Options__read_style_overlay: comicapi.merge.Mode
|
||||
Runtime_Options__source_overlay: comicapi.merge.Mode
|
||||
Runtime_Options__overlay_merge_lists: bool
|
||||
Runtime_Options__overwrite: bool
|
||||
Runtime_Options__no_gui: bool
|
||||
Runtime_Options__files: list[str]
|
||||
@ -48,6 +49,7 @@ class SettngsNS(settngs.TypedNS):
|
||||
internal__load_data_style: list[str]
|
||||
internal__load_data_overlay: comicapi.merge.Mode
|
||||
internal__source_data_overlay: comicapi.merge.Mode
|
||||
internal__overlay_merge_lists: bool
|
||||
internal__last_opened_folder: str
|
||||
internal__window_width: int
|
||||
internal__window_height: int
|
||||
|
@ -436,6 +436,7 @@ class SettingsWindow(QtWidgets.QDialog):
|
||||
self.cbxOverlaySource.setCurrentIndex(
|
||||
self.cbxOverlaySource.findData(self.config[0].internal__source_data_overlay.value)
|
||||
)
|
||||
self.cbxOverlayMergeLists.setChecked(self.config[0].internal__overlay_merge_lists)
|
||||
self.cbxShortMetadataNames.setChecked(self.config[0].Metadata_Options__use_short_metadata_names)
|
||||
self.cbxDisableCR.setChecked(self.config[0].Metadata_Options__disable_cr)
|
||||
|
||||
@ -561,8 +562,9 @@ class SettingsWindow(QtWidgets.QDialog):
|
||||
self.cbxApplyCBLTransformOnBatchOperation.isChecked()
|
||||
)
|
||||
|
||||
self.config[0].internal__load_data_overlay = merge.Mode[self.cbxOverlayReadStyle.currentData()]
|
||||
self.config[0].internal__source_data_overlay = merge.Mode[self.cbxOverlaySource.currentData()]
|
||||
self.config[0].internal__load_data_overlay = merge.Mode[self.cbxOverlayReadStyle.currentData().upper()]
|
||||
self.config[0].internal__source_data_overlay = merge.Mode[self.cbxOverlaySource.currentData().upper()]
|
||||
self.config[0].internal__overlay_merge_lists = self.cbxOverlayMergeLists.isChecked()
|
||||
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():
|
||||
|
@ -31,6 +31,7 @@ import natsort
|
||||
import settngs
|
||||
from PyQt5 import QtCore, QtGui, QtNetwork, QtWidgets, uic
|
||||
|
||||
import comicapi.merge
|
||||
import comictaggerlib.ui
|
||||
from comicapi import utils
|
||||
from comicapi.comicarchive import ComicArchive, metadata_styles
|
||||
@ -222,6 +223,8 @@ class TaggerWindow(QtWidgets.QMainWindow):
|
||||
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
|
||||
if isinstance(config[0].Runtime_Options__overlay_merge_lists, bool):
|
||||
config[0].internal__overlay_merge_lists = config[0].Runtime_Options__overlay_merge_lists
|
||||
|
||||
for style in config[0].internal__save_data_style:
|
||||
if style not in metadata_styles:
|
||||
@ -1050,7 +1053,7 @@ class TaggerWindow(QtWidgets.QMainWindow):
|
||||
self.config[0].Filename_Parsing__allow_issue_start_with_letter,
|
||||
self.config[0].Filename_Parsing__protofolius_issue_number_scheme,
|
||||
)
|
||||
self.metadata.overlay(new_metadata)
|
||||
self.metadata.overlay(new_metadata, mode=comicapi.merge.Mode.OVERLAY, merge_lists=False)
|
||||
self.metadata_to_form()
|
||||
|
||||
def use_filename_split(self) -> None:
|
||||
@ -2205,7 +2208,11 @@ class TaggerWindow(QtWidgets.QMainWindow):
|
||||
try:
|
||||
for style in load_data_styles:
|
||||
metadata = ca.read_metadata(style)
|
||||
md.overlay(metadata)
|
||||
md.overlay(
|
||||
metadata,
|
||||
mode=self.config[0].internal__load_data_overlay,
|
||||
merge_lists=self.config[0].internal__overlay_merge_lists,
|
||||
)
|
||||
except Exception as e:
|
||||
error = e
|
||||
|
||||
|
@ -867,6 +867,13 @@ Example:
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="cbxOverlayMergeLists">
|
||||
<property name="text">
|
||||
<string>Merge Lists</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user