Fix defaults for replace_single_newlines variable

This commit is contained in:
Deniz Şafak
2025-11-28 23:25:02 +03:00
parent 7ee40d6aca
commit 4e678c7e13
6 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -390,7 +390,7 @@ class HandlerDialog(QDialog):
from abogen.utils import load_config
cfg = load_config()
replace_single_newlines = cfg.get("replace_single_newlines", False)
replace_single_newlines = cfg.get("replace_single_newlines", True)
cache_key = (self.book_path, mod_time, self.file_type, replace_single_newlines)
+1 -1
View File
@@ -2042,7 +2042,7 @@ class ConversionThread(QThread):
return
# Process text and timing
replace_nl = getattr(self, "replace_single_newlines", False)
replace_nl = getattr(self, "replace_single_newlines", True)
processed_text = text.replace("\n", " ") if replace_nl else text
use_gaps = getattr(self, "use_silent_gaps", False)
next_start = (
+2 -2
View File
@@ -1912,7 +1912,7 @@ class abogen(QWidget):
and queued_item.output_folder == item_queue.output_folder
and queued_item.subtitle_mode == item_queue.subtitle_mode
and queued_item.output_format == item_queue.output_format
and getattr(queued_item, "replace_single_newlines", False)
and getattr(queued_item, "replace_single_newlines", True)
== item_queue.replace_single_newlines
and getattr(queued_item, "save_base_path", None)
== item_queue.save_base_path
@@ -1977,7 +1977,7 @@ class abogen(QWidget):
self.selected_format = queued_item.output_format
self.char_count = queued_item.total_char_count
self.replace_single_newlines = getattr(
queued_item, "replace_single_newlines", False
queued_item, "replace_single_newlines", True
)
self.use_silent_gaps = getattr(queued_item, "use_silent_gaps", False)
# Restore the original file path for save location
+4 -4
View File
@@ -302,7 +302,7 @@ class QueueManager(QDialog):
f"<b>Subtitle Mode:</b> {getattr(item, 'subtitle_mode', '')}<br>"
f"<b>Output Format:</b> {getattr(item, 'output_format', '')}<br>"
f"<b>Characters:</b> {getattr(item, 'total_char_count', '')}<br>"
f"<b>Replace Single Newlines:</b> {getattr(item, 'replace_single_newlines', False)}<br>"
f"<b>Replace Single Newlines:</b> {getattr(item, 'replace_single_newlines', True)}<br>"
f"<b>Use Silent Gaps:</b> {getattr(item, 'use_silent_gaps', False)}<br>"
f"<b>Speed Method:</b> {getattr(item, 'subtitle_speed_method', 'tts')}"
)
@@ -415,7 +415,7 @@ class QueueManager(QDialog):
attrs["total_char_count"] = getattr(parent, "char_count", "")
# replace_single_newlines
attrs["replace_single_newlines"] = getattr(
parent, "replace_single_newlines", False
parent, "replace_single_newlines", True
)
# use_silent_gaps
attrs["use_silent_gaps"] = getattr(parent, "use_silent_gaps", False)
@@ -501,8 +501,8 @@ class QueueManager(QDialog):
== getattr(item, "output_format", None)
and getattr(queued_item, "total_char_count", None)
== getattr(item, "total_char_count", None)
and getattr(queued_item, "replace_single_newlines", False)
== getattr(item, "replace_single_newlines", False)
and getattr(queued_item, "replace_single_newlines", True)
== getattr(item, "replace_single_newlines", True)
and getattr(queued_item, "use_silent_gaps", False)
== getattr(item, "use_silent_gaps", False)
and getattr(queued_item, "subtitle_speed_method", "tts")
+1 -1
View File
@@ -13,7 +13,7 @@ class QueuedItem:
subtitle_mode: str
output_format: str
total_char_count: int
replace_single_newlines: bool = False
replace_single_newlines: bool = True
use_silent_gaps: bool = False
subtitle_speed_method: str = "tts"
save_base_path: str = None
+1 -1
View File
@@ -133,7 +133,7 @@ _sleep_procs = {"Darwin": None, "Linux": None} # Store sleep prevention process
def clean_text(text, *args, **kwargs):
# Load replace_single_newlines from config
cfg = load_config()
replace_single_newlines = cfg.get("replace_single_newlines", False)
replace_single_newlines = cfg.get("replace_single_newlines", True)
# Collapse all whitespace (excluding newlines) into single spaces per line and trim edges
# Use pre-compiled pattern for better performance
lines = [_WHITESPACE_PATTERN.sub(" ", line).strip() for line in text.splitlines()]