diff --git a/comictaggerlib/ctsettings/file.py b/comictaggerlib/ctsettings/file.py index 3d780f5..7fd8140 100644 --- a/comictaggerlib/ctsettings/file.py +++ b/comictaggerlib/ctsettings/file.py @@ -46,6 +46,43 @@ def identifier(parser: settngs.Manager) -> None: action=AppendAction, help="When enabled filters the listed publishers from all search results", ) + parser.add_setting("--series-match-search-thresh", default=90, type=int) + parser.add_setting( + "--clear-metadata", + default=True, + help="Clears all existing metadata during import, default is to merges metadata.\nMay be used in conjunction with -o, -f and -m.\n\n", + dest="clear_metadata_on_import", + action=argparse.BooleanOptionalAction, + ) + parser.add_setting( + "-a", + "--auto-imprint", + action=argparse.BooleanOptionalAction, + default=False, + help="Enables the auto imprint functionality.\ne.g. if the publisher is set to 'vertigo' it\nwill be updated to 'DC Comics' and the imprint\nproperty will be set to 'Vertigo'.\n\n", + ) + + parser.add_setting( + "--sort-series-by-year", default=True, action=argparse.BooleanOptionalAction, help="Sorts series by year" + ) + parser.add_setting( + "--exact-series-matches-first", + default=True, + action=argparse.BooleanOptionalAction, + help="Puts series that are an exact match at the top of the list", + ) + parser.add_setting( + "--always-use-publisher-filter", + default=False, + action=argparse.BooleanOptionalAction, + help="Enables the publisher filter", + ) + parser.add_setting( + "--clear-form-before-populating", + default=False, + action=argparse.BooleanOptionalAction, + help="Clears all existing metadata when applying metadata from comic source", + ) def dialog(parser: settngs.Manager) -> None: @@ -86,43 +123,6 @@ def filename(parser: settngs.Manager) -> None: def talker(parser: settngs.Manager) -> None: # General settings for talkers parser.add_setting("--source", default="comicvine", help="Use a specified source by source ID") - parser.add_setting("--series-match-search-thresh", default=90, type=int) - parser.add_setting( - "--clear-metadata", - default=True, - help="Clears all existing metadata during import, default is to merges metadata.\nMay be used in conjunction with -o, -f and -m.\n\n", - dest="clear_metadata_on_import", - action=argparse.BooleanOptionalAction, - ) - parser.add_setting( - "-a", - "--auto-imprint", - action=argparse.BooleanOptionalAction, - default=False, - help="Enables the auto imprint functionality.\ne.g. if the publisher is set to 'vertigo' it\nwill be updated to 'DC Comics' and the imprint\nproperty will be set to 'Vertigo'.\n\n", - ) - - parser.add_setting( - "--sort-series-by-year", default=True, action=argparse.BooleanOptionalAction, help="Sorts series by year" - ) - parser.add_setting( - "--exact-series-matches-first", - default=True, - action=argparse.BooleanOptionalAction, - help="Puts series that are an exact match at the top of the list", - ) - parser.add_setting( - "--always-use-publisher-filter", - default=False, - action=argparse.BooleanOptionalAction, - help="Enables the publisher filter", - ) - parser.add_setting( - "--clear-form-before-populating", - default=False, - action=argparse.BooleanOptionalAction, - help="Clears all existing metadata when applying metadata from comic source", - ) def cbl(parser: settngs.Manager) -> None: diff --git a/comictaggerlib/settingswindow.py b/comictaggerlib/settingswindow.py index 40b288a..a5558cf 100644 --- a/comictaggerlib/settingswindow.py +++ b/comictaggerlib/settingswindow.py @@ -306,7 +306,7 @@ class SettingsWindow(QtWidgets.QDialog): else: self.leRarExePath.setEnabled(False) self.sbNameMatchIdentifyThresh.setValue(self.config[0].identifier_series_match_identify_thresh) - self.sbNameMatchSearchThresh.setValue(self.config[0].talker_series_match_search_thresh) + self.sbNameMatchSearchThresh.setValue(self.config[0].identifier_series_match_search_thresh) self.tePublisherFilter.setPlainText("\n".join(self.config[0].identifier_publisher_filter)) self.cbxCheckForNewVersion.setChecked(self.config[0].general_check_for_new_version) @@ -317,10 +317,10 @@ class SettingsWindow(QtWidgets.QDialog): self.cbxRemovePublisher.setChecked(self.config[0].filename_remove_publisher) self.switch_parser() - self.cbxClearFormBeforePopulating.setChecked(self.config[0].talker_clear_form_before_populating) - self.cbxUseFilter.setChecked(self.config[0].talker_always_use_publisher_filter) - self.cbxSortByYear.setChecked(self.config[0].talker_sort_series_by_year) - self.cbxExactMatches.setChecked(self.config[0].talker_exact_series_matches_first) + self.cbxClearFormBeforePopulating.setChecked(self.config[0].identifier_clear_form_before_populating) + self.cbxUseFilter.setChecked(self.config[0].identifier_always_use_publisher_filter) + self.cbxSortByYear.setChecked(self.config[0].identifier_sort_series_by_year) + self.cbxExactMatches.setChecked(self.config[0].identifier_exact_series_matches_first) self.cbxAssumeLoneCreditIsPrimary.setChecked(self.config[0].cbl_assume_lone_credit_is_primary) self.cbxCopyCharactersToTags.setChecked(self.config[0].cbl_copy_characters_to_tags) @@ -352,9 +352,6 @@ class SettingsWindow(QtWidgets.QDialog): # Set talker values comictaggerlib.ui.talkeruigenerator.settings_to_talker_form(self.sources, self.config) - # Select active source in dropdown - self.cobxInfoSource.setCurrentIndex(self.cobxInfoSource.findData(self.config[0].talker_source)) - self.connect_signals() def get_replacements(self) -> Replacements: @@ -424,7 +421,7 @@ class SettingsWindow(QtWidgets.QDialog): self.config[0].general_check_for_new_version = self.cbxCheckForNewVersion.isChecked() self.config[0].identifier_series_match_identify_thresh = self.sbNameMatchIdentifyThresh.value() - self.config[0].talker_series_match_search_thresh = self.sbNameMatchSearchThresh.value() + self.config[0].identifier_series_match_search_thresh = self.sbNameMatchSearchThresh.value() self.config[0].identifier_publisher_filter = [ x.strip() for x in str(self.tePublisherFilter.toPlainText()).splitlines() if x.strip() ] @@ -434,12 +431,10 @@ class SettingsWindow(QtWidgets.QDialog): self.config[0].filename_remove_fcbd = self.cbxRemoveFCBD.isChecked() self.config[0].filename_remove_publisher = self.cbxRemovePublisher.isChecked() - self.config[0].talker_clear_form_before_populating = self.cbxClearFormBeforePopulating.isChecked() - self.config[0].talker_always_use_publisher_filter = self.cbxUseFilter.isChecked() - self.config[0].talker_sort_series_by_year = self.cbxSortByYear.isChecked() - self.config[0].talker_exact_series_matches_first = self.cbxExactMatches.isChecked() - - self.config[0].talker_source = str(self.cobxInfoSource.itemData(self.cobxInfoSource.currentIndex())) + self.config[0].identifier_clear_form_before_populating = self.cbxClearFormBeforePopulating.isChecked() + self.config[0].identifier_always_use_publisher_filter = self.cbxUseFilter.isChecked() + self.config[0].identifier_sort_series_by_year = self.cbxSortByYear.isChecked() + self.config[0].identifier_exact_series_matches_first = self.cbxExactMatches.isChecked() self.config[0].cbl_assume_lone_credit_is_primary = self.cbxAssumeLoneCreditIsPrimary.isChecked() self.config[0].cbl_copy_characters_to_tags = self.cbxCopyCharactersToTags.isChecked() @@ -471,6 +466,9 @@ class SettingsWindow(QtWidgets.QDialog): widget_value = widget.text().strip() elif isinstance(widget, QtWidgets.QCheckBox): widget_value = widget.isChecked() + # The talker source dropdown + elif isinstance(widget, QtWidgets.QComboBox): + widget_value = widget.itemData(widget.currentIndex()) setattr(self.config[0], name, widget_value) diff --git a/comictaggerlib/ui/settingswindow.ui b/comictaggerlib/ui/settingswindow.ui index 7607a7e..c1485c9 100644 --- a/comictaggerlib/ui/settingswindow.ui +++ b/comictaggerlib/ui/settingswindow.ui @@ -136,24 +136,14 @@ Searching - - - - <html><head/><body><p>These settings are for the automatic issue identifier which searches online for matches. </p><p>Hover the mouse over an entry field for more info.</p></body></html> - - - true - - - - - + + Qt::Horizontal - + QFormLayout::AllNonFixedFieldsGrow @@ -252,6 +242,44 @@ + + + + <html><head/><body><p>These settings are for the automatic issue identifier which searches online for matches. </p><p>Hover the mouse over an entry field for more info.</p></body></html> + + + true + + + + + + + Qt::Horizontal + + + + + + + Initially show Series Name exact matches first + + + + + + + Initially sort Series search results by Starting Year instead of No. Issues + + + + + + + Clear Form Before Importing Comic Vine data + + + @@ -313,154 +341,13 @@ Comic Sources - - - - - 0 - 0 - - - - Qt::Horizontal - - - - 0 + -1 - - - General - - - - - 10 - 70 - 650 - 22 - - - - Use Series Start Date as Volume - - - - - - 10 - 90 - 666 - 22 - - - - Clear Form Before Importing Comic Vine data - - - - - - 10 - 130 - 666 - 22 - - - - Initially sort Series search results by Starting Year instead of No. Issues - - - - - - 10 - 150 - 666 - 22 - - - - Initially show Series Name exact matches first - - - - - - 5 - 120 - 648 - 3 - - - - - 0 - 0 - - - - Qt::Horizontal - - - - - - 190 - 13 - 301 - 32 - - - - - - - 15 - 13 - 171 - 32 - - - - Select Information Source: - - - - - - 5 - 60 - 648 - 3 - - - - Qt::Horizontal - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/comictaggerlib/ui/talkeruigenerator.py b/comictaggerlib/ui/talkeruigenerator.py index edc9e4b..3a5c236 100644 --- a/comictaggerlib/ui/talkeruigenerator.py +++ b/comictaggerlib/ui/talkeruigenerator.py @@ -142,7 +142,11 @@ def settings_to_talker_form(sources: dict[str, QtWidgets.QWidget], config: settn value_type = type(value) try: if value_type is str: - widget.setText(value) + # Special case for general dropdown box + if name == "talker_source": + widget.setCurrentIndex(widget.findData(config[0].talker_source)) + else: + widget.setText(value) if value_type is int or value_type is float: widget.setValue(value) if value_type is bool: @@ -161,15 +165,28 @@ def generate_source_option_tabs( """ sources: dict = {} - cobxInfoSource = tabs.findChildren(QtWidgets.QComboBox, "cobxInfoSource")[0] + # Use a dict to make a var name from var + source_info = {} + + # Add General tab + source_info["general"] = {"tab": QtWidgets.QWidget(), "widgets": {}} + general_layout = QtWidgets.QGridLayout() + lbl_info = QtWidgets.QLabel("Information Source:") + cbx_info = QtWidgets.QComboBox() + general_layout.addWidget(lbl_info, 0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) + general_layout.addWidget(cbx_info, 0, 1, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) + vspacer = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) + general_layout.addItem(vspacer, 1, 0) + source_info["general"]["widgets"]["talker_source"] = cbx_info + + source_info["general"]["tab"].setLayout(general_layout) + tabs.addTab(source_info["general"]["tab"], "General") # Add source sub tabs to Comic Sources tab for talker_id, talker_obj in talkers.items(): # Add source to general tab dropdown list - cobxInfoSource.addItem(talker_obj.name, talker_id) + source_info["general"]["widgets"]["talker_source"].addItem(talker_obj.name, talker_id) - # Use a dict to make a var name from var - source_info = {} tab_name = talker_id source_info[tab_name] = {"tab": QtWidgets.QWidget(), "widgets": {}} layout_grid = QtWidgets.QGridLayout()