diff --git a/gui/translation_tab.py b/gui/translation_tab.py index caa0e41..f91761a 100644 --- a/gui/translation_tab.py +++ b/gui/translation_tab.py @@ -30,6 +30,12 @@ from PyQt5.QtGui import QFont from gui.log_viewer import LogViewer +def _strip_ansi(text): + if not isinstance(text, str) or not text: + return text + return re.sub(r"\x1b\[[0-?]*[ -/]*[@-~]", "", text) + + def create_section_header(title): """Create a clean section header without boxes.""" label = QLabel(title) @@ -1697,7 +1703,26 @@ class TranslationTab(QWidget): item['label'].setText(f"{current}/{total}") item['label'].setStyleSheet("color: #007acc; font-weight: bold;") - def mark_file_complete(self, filename, success=True, error_message=None): + def _apply_success_status_icon(self, item, completion_kind="normal"): + """Green checkmark for every successful row; tooltips explain skip / idle when relevant.""" + try: + item["status_label"].setText("✓") + item["status_label"].setStyleSheet( + "color: #4ec9b0; font-weight: bold; font-size: 11px;" + ) + if completion_kind == "skip": + reason = (item.get("_skip_reason") or "").strip() + tip = f"Skipped: {reason}" if reason else "Whole file skipped (paths/fonts only)." + elif completion_kind == "idle": + tip = "No translatable lines (non-dialogue content only)." + else: + tip = "" + item["status_label"].setToolTip(tip) + item["status_label"].setVisible(True) + except Exception: + pass + + def mark_file_complete(self, filename, success=True, error_message=None, completion_kind="normal"): """Mark a file as complete or failed.""" if filename in self.file_progress_items: item = self.file_progress_items[filename] @@ -1709,13 +1734,7 @@ class TranslationTab(QWidget): item['tokens_label'].setVisible(True) item['cost_label'].setVisible(True) item['time_label'].setVisible(True) - # Show compact status in the middle column - try: - item['status_label'].setText("✓") - item['status_label'].setStyleSheet("color: #4ec9b0; font-weight: bold; font-size: 11px;") - item['status_label'].setVisible(True) - except Exception: - pass + self._apply_success_status_icon(item, completion_kind) try: item['progress_bar'].setVisible(False) except Exception: @@ -1728,13 +1747,11 @@ class TranslationTab(QWidget): pass else: # No parsed results available - show status in status_label + self._apply_success_status_icon(item, completion_kind) try: - item['status_label'].setText("✓") - item['status_label'].setStyleSheet("color: #4ec9b0; font-weight: bold; font-size: 11px;") - item['status_label'].setVisible(True) + item['progress_bar'].setVisible(False) except Exception: pass - item['progress_bar'].setValue(item['progress_bar'].maximum()) try: item['label'].setText("") item['label'].setStyleSheet("color: #888888; font-size: 11px;") @@ -2007,32 +2024,67 @@ class TranslationTab(QWidget): except Exception: pass try: - pattern = r'^\W*(?P[^:]+):.*?\[Input:\s*(?P\d+)\].*?\[Output:\s*(?P\d+)\].*?\[Cost:\s*\$(?P[\d\.]+)\].*?\[(?P