From 6b57ee099d05e44d24b224f0327a541b519edb46 Mon Sep 17 00:00:00 2001 From: Yuvi9587 <114073886+Yuvi9587@users.noreply.github.com> Date: Sun, 13 Jul 2025 21:45:30 -0700 Subject: [PATCH] Commit --- src/core/workers.py | 16 +++++---- src/ui/dialogs/MoreOptionsDialog.py | 2 +- src/ui/main_window.py | 50 ++++------------------------- 3 files changed, 17 insertions(+), 51 deletions(-) diff --git a/src/core/workers.py b/src/core/workers.py index 599a583..bc93876 100644 --- a/src/core/workers.py +++ b/src/core/workers.py @@ -893,6 +893,7 @@ class PostProcessorWorker: total_downloaded_this_post =0 total_skipped_this_post =0 history_data_for_this_post =None + temp_filepath_for_return = None parsed_api_url =urlparse (self .api_url_input ) referer_url =f"https://{parsed_api_url .netloc }/" @@ -1297,10 +1298,12 @@ class PostProcessorWorker: with open(temp_filepath, 'w', encoding='utf-8') as f: json.dump(content_data, f, indent=2) self.logger(f" Saved temporary text for '{post_title}' for single PDF compilation.") - return 0, 0, [], [], [], None, temp_filepath + self._emit_signal('worker_finished', (0, 0, [], [], [], None, temp_filepath)) # <--- CHANGE THIS + return (0, 0, [], [], [], None, temp_filepath) except Exception as e: self.logger(f" ❌ Failed to write temporary file for single PDF: {e}") - return 0, 0, [], [], [], None, None + self._emit_signal('worker_finished', (0, 0, [], [], [], [], None)) + return (0, 0, [], [], [], [], None) # --- Logic for Individual File Saving --- else: @@ -1747,12 +1750,8 @@ class PostProcessorWorker: permanent_failures_this_post, history_data_for_this_post, None) # The 7th item is None because we already saved the temp file - # In Single PDF mode, the 7th item is the temp file path we created. - if self.single_pdf_mode and os.path.exists(temp_filepath): - result_tuple = (0, 0, [], [], [], None, temp_filepath) - self._emit_signal('worker_finished', result_tuple) - return # The method now returns nothing. + return result_tuple class DownloadThread (QThread ): progress_signal =pyqtSignal (str ) @@ -1932,11 +1931,13 @@ class DownloadThread (QThread ): # Initialize the shared counter to the next number, protected by a thread lock self.manga_date_file_counter_ref = [highest_num + 1, threading.Lock()] self.logger(f"ℹ️ [Thread] Manga Date Mode: Initialized date-based counter at {self.manga_date_file_counter_ref[0]}.") + pass if self.manga_mode_active and self.manga_filename_style == STYLE_POST_TITLE_GLOBAL_NUMBERING and not self.extract_links_only and self.manga_global_file_counter_ref is None: # Initialize the shared counter at 1, protected by a thread lock self.manga_global_file_counter_ref = [1, threading.Lock()] self.logger(f"ℹ️ [Thread] Manga Title+GlobalNum Mode: Initialized global counter at {self.manga_global_file_counter_ref[0]}.") + pass worker_signals_obj = PostProcessorSignals() try: @@ -2084,6 +2085,7 @@ class DownloadThread (QThread ): # Emit the final signal with all collected results self.finished_signal.emit(grand_total_downloaded_files, grand_total_skipped_files, self.isInterruptionRequested(), grand_list_of_kept_original_filenames) + def receive_add_character_result (self ,result ): with QMutexLocker (self .prompt_mutex ): self ._add_character_response =result diff --git a/src/ui/dialogs/MoreOptionsDialog.py b/src/ui/dialogs/MoreOptionsDialog.py index b9d4e68..1f1ec5d 100644 --- a/src/ui/dialogs/MoreOptionsDialog.py +++ b/src/ui/dialogs/MoreOptionsDialog.py @@ -22,7 +22,7 @@ class MoreOptionsDialog(QDialog): layout.addWidget(self.description_label) self.radio_button_group = QButtonGroup(self) self.radio_content = QRadioButton("Description/Content") - self.radio_comments = QRadioButton("Comments (Not Working)") + self.radio_comments = QRadioButton("Comments") self.radio_button_group.addButton(self.radio_content) self.radio_button_group.addButton(self.radio_comments) layout.addWidget(self.radio_content) diff --git a/src/ui/main_window.py b/src/ui/main_window.py index 1936877..930462d 100644 --- a/src/ui/main_window.py +++ b/src/ui/main_window.py @@ -2683,26 +2683,17 @@ class DownloaderApp (QWidget ): format_display = f" ({self.text_export_format.upper()})" if self.single_pdf_setting: format_display = " (Single PDF)" - # Store original multithreading state before unchecking - self._original_multithreading_state = self.use_multithreading_checkbox.isChecked() if hasattr(self, 'use_multithreading_checkbox') else False - + # --- NEW: Disable checkboxes if Single PDF is active --- if hasattr(self, 'use_multithreading_checkbox'): - self.use_multithreading_checkbox.setChecked(False) # Explicitly UNCHECK IT - self.use_multithreading_checkbox.setEnabled(False) # Disable the checkbox - self.thread_count_input.setEnabled(False) # Disable thread count input - self.thread_count_label.setEnabled(False) # Disable thread count label - self.log_signal.emit("ℹ️ Multithreading disabled for text-only mode to ensure sequential processing and proper PDF compilation.") + self.use_multithreading_checkbox.setChecked(False) + self.use_multithreading_checkbox.setEnabled(False) if hasattr(self, 'use_subfolders_checkbox'): self.use_subfolders_checkbox.setChecked(False) self.use_subfolders_checkbox.setEnabled(False) else: - # Re-enable based on its original state if it wasn't a single PDF request - if hasattr(self, 'use_multithreading_checkbox'): - self.use_multithreading_checkbox.setEnabled(True) - # Call the handler to update its text and thread count input state - self._handle_multithreading_toggle(self.use_multithreading_checkbox.isChecked()) - if hasattr(self, 'use_subfolders_checkbox'): - self.use_subfolders_checkbox.setEnabled(True) + # --- NEW: Re-enable checkboxes if Single PDF is not active --- + if hasattr(self, 'use_multithreading_checkbox'): self.use_multithreading_checkbox.setEnabled(True) + if hasattr(self, 'use_subfolders_checkbox'): self.use_subfolders_checkbox.setEnabled(True) self.radio_more.setText(f"{scope_text}{format_display}") @@ -2712,33 +2703,6 @@ class DownloaderApp (QWidget ): else: self.log_signal.emit("ℹ️ 'More' filter selection cancelled. Reverting to 'All'.") self.radio_all.setChecked(True) - # Restore original multithreading state if the dialog was cancelled and we revert to 'All' - if hasattr(self, 'use_multithreading_checkbox'): - self.use_multithreading_checkbox.setEnabled(True) - # Restore previous checked state of multithreading checkbox - if hasattr(self, '_original_multithreading_state'): - self.use_multithreading_checkbox.setChecked(self._original_multithreading_state) - del self._original_multithreading_state # Clean up the stored state - self.thread_count_input.setEnabled(True) - self.thread_count_label.setEnabled(True) - self._handle_multithreading_toggle(self.use_multithreading_checkbox.isChecked()) - if hasattr(self, 'use_subfolders_checkbox'): - self.use_subfolders_checkbox.setEnabled(True) - # If a button other than "More" is selected, reset the UI or ensure multithreading is re-enabled. - elif button != self.radio_more and checked: - self.radio_more.setText("More") - self.more_filter_scope = None - self.single_pdf_setting = False # Reset the setting - # Re-enable the checkboxes - if hasattr(self, 'use_multithreading_checkbox'): - self.use_multithreading_checkbox.setEnabled(True) - # Restore previous checked state if it exists - if hasattr(self, '_original_multithreading_state'): - self.use_multithreading_checkbox.setChecked(self._original_multithreading_state) - del self._original_multithreading_state # Clean up - self._handle_multithreading_toggle(self.use_multithreading_checkbox.isChecked()) - if hasattr(self, 'use_subfolders_checkbox'): - self.use_subfolders_checkbox.setEnabled(True) def delete_selected_character (self ): global KNOWN_NAMES @@ -3828,7 +3792,7 @@ class DownloaderApp (QWidget ): 'manga_global_file_counter_ref','manga_date_prefix', 'manga_mode_active','unwanted_keywords','manga_filename_style','scan_content_for_images', 'allow_multipart_download','use_cookie','cookie_text','app_base_dir','selected_cookie_file','override_output_dir','project_root_dir', - 'text_only_scope', 'text_export_format', + 'text_only_scope', 'single_pdf_mode' ] args_template ['skip_current_file_flag']=None