From 084e94d6ae407782c3ffd70865a7a6835145f122 Mon Sep 17 00:00:00 2001 From: LianWan Wen <2094941626@qq.com> Date: Tue, 10 Nov 2026 15:44:43 +0800 Subject: [PATCH 1/2] feat: explain detector tradeoffs beside the CUDA toggle --- assets/i18n/en.json | 2 ++ assets/i18n/ja.json | 2 ++ comic_translate_desktop/ui/main_window.py | 33 +++++++++++++++++++---- comic_translate_desktop/ui/theme.py | 3 +++ scripts/review_ui.py | 7 +++-- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/assets/i18n/en.json b/assets/i18n/en.json index b51b037..919980e 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -1,5 +1,7 @@ { "CUDA 加速": "CUDA", + "检测器与修补说明": "Detector and repair comparison", + "CUDA 快速检测器在 GPU 上检测更快,能用笔画像素限定擦除范围。日漫样本中文字框覆盖较少,漏检处可能留字。\n\n轻量双图检测器在 CPU 上检测更快,日漫样本中文字框覆盖更全。它靠文字框和文字行定位,复杂底纹或描边仍可能漏擦。\n\n两套方案共用背景修补流程,主要区别在于擦除范围。": "The fast CUDA detector runs faster on GPU and identifies stroke pixels to guide erasing. It covered fewer text regions in the Japanese manga sample, so missed text may remain.\n\nThe lightweight dual detector runs faster on CPU and covered more text regions in the sample. It uses text boxes and lines, so it can miss strokes on textured backgrounds or in outlined text.\n\nBoth detectors use the same background repair process. They mainly differ in what gets erased.", "下次任务生效。自动检测模式会按 CUDA 是否可用选择模型。": "Applies to the next job. Auto detection selects a model based on CUDA availability.", "CUDA 设置未保存": "CUDA setting not saved", "CUDA 设置未保存:{_0}": "Could not save the CUDA setting: {_0}", diff --git a/assets/i18n/ja.json b/assets/i18n/ja.json index 6923df4..3b91239 100644 --- a/assets/i18n/ja.json +++ b/assets/i18n/ja.json @@ -1,5 +1,7 @@ { "CUDA 加速": "CUDA 加速", + "检测器与修补说明": "検出器と修復の違い", + "CUDA 快速检测器在 GPU 上检测更快,能用笔画像素限定擦除范围。日漫样本中文字框覆盖较少,漏检处可能留字。\n\n轻量双图检测器在 CPU 上检测更快,日漫样本中文字框覆盖更全。它靠文字框和文字行定位,复杂底纹或描边仍可能漏擦。\n\n两套方案共用背景修补流程,主要区别在于擦除范围。": "高速 CUDA 検出器は GPU での検出が速く、文字の画素を使って消去範囲を絞ります。日本の漫画サンプルでは文字領域のカバー率が低く、検出漏れの文字が残ることがあります。\n\n軽量の二段階検出器は CPU での検出が速く、サンプルではより多くの文字領域をカバーしました。文字枠と行で位置を特定するため、複雑な背景や縁取り文字では一部が残ることがあります。\n\n背景の修復処理は共通で、主な違いは文字を消去する範囲です。", "下次任务生效。自动检测模式会按 CUDA 是否可用选择模型。": "次回の処理から適用されます。自動検出では CUDA の利用可否に応じてモデルを選びます。", "CUDA 设置未保存": "CUDA 設定は未保存", "CUDA 设置未保存:{_0}": "CUDA 設定を保存できませんでした:{_0}", diff --git a/comic_translate_desktop/ui/main_window.py b/comic_translate_desktop/ui/main_window.py index 1cb3d6d..36f1369 100644 --- a/comic_translate_desktop/ui/main_window.py +++ b/comic_translate_desktop/ui/main_window.py @@ -1,6 +1,7 @@ from __future__ import annotations from ..i18n import tr, ui_language +from html import escape from pathlib import Path import json import random @@ -331,7 +332,7 @@ def _build_work_panel(self) -> QWidget: self._control_grid.setContentsMargins(0, 0, 0, 0) self._control_grid.setHorizontalSpacing(10) self._control_grid.setVerticalSpacing(4) - self._controls_inline = None + self._controls_mode = None self._language_controls = QWidget() control_row = QGridLayout(self._language_controls) self._language_grid = control_row @@ -378,7 +379,22 @@ def _build_work_panel(self) -> QWidget: self._cuda_toggle.setChecked(self.config['use_gpu']) self._cuda_toggle.setToolTip(tr('下次任务生效。自动检测模式会按 CUDA 是否可用选择模型。')) self._cuda_toggle.toggled.connect(self._toggle_cuda) - quick_layout.addWidget(self._cuda_toggle) + cuda_note = tr( + 'CUDA 快速检测器在 GPU 上检测更快,能用笔画像素限定擦除范围。日漫样本中文字框覆盖较少,漏检处可能留字。\n\n' + '轻量双图检测器在 CPU 上检测更快,日漫样本中文字框覆盖更全。它靠文字框和文字行定位,复杂底纹或描边仍可能漏擦。\n\n' + '两套方案共用背景修补流程,主要区别在于擦除范围。') + self._cuda_help = QLabel('?') + self._cuda_help.setObjectName('cudaHelp') + self._cuda_help.setFixedSize(18, 18) + self._cuda_help.setAlignment(Qt.AlignCenter) + self._cuda_help.setAccessibleName(tr('检测器与修补说明')) + self._cuda_help.setAccessibleDescription(cuda_note) + self._cuda_help.setToolTip('
' + '
'.join(escape(cuda_note).split('\n\n')) + '
') + cuda_layout = QHBoxLayout() + cuda_layout.setSpacing(4) + cuda_layout.addWidget(self._cuda_toggle) + cuda_layout.addWidget(self._cuda_help, 0, Qt.AlignVCenter) + quick_layout.addLayout(cuda_layout) quick_layout.addWidget(self._pref_toggle) control_row.setColumnStretch(5, 1) self._control_divider = QFrame() @@ -1368,7 +1384,8 @@ def _apply_compact_layout(self): self._settings_btn.setVisible(self.width() >= 960) self._logs_btn.setVisible(self.width() >= 960) inline = self.width() >= (1400 if ui_language() == 'en' else 1280 if ui_language() == 'ja' else 1180) - stacked = not inline and ui_language() != 'zh-CN' + controls_mode = 'inline' if inline else 'narrow' if self.width() < 880 else 'split' + stacked = controls_mode == 'split' and ui_language() != 'zh-CN' if stacked != self._language_stacked: self._language_stacked = stacked fields = (self._source_caption, self._source_language, self._language_arrow, @@ -1389,8 +1406,8 @@ def _apply_compact_layout(self): self._language_grid.addWidget(self._target_language, 0, 4) self._language_arrow.setVisible(True) self._language_grid.setColumnStretch(5, 1) - if inline != self._controls_inline: - self._controls_inline = inline + if controls_mode != self._controls_mode: + self._controls_mode = controls_mode for widget in (self._language_controls, self._output_controls, self._start_btn, self._quick_options, self._control_divider): self._control_grid.removeWidget(widget) @@ -1401,6 +1418,12 @@ def _apply_compact_layout(self): self._control_grid.addWidget(self._quick_options, 0, 3) self._control_grid.addWidget(self._start_btn, 0, 4) self._control_divider.setVisible(True) + elif controls_mode == 'narrow': + self._control_grid.addWidget(self._language_controls, 0, 0, 1, 5) + self._control_grid.addWidget(self._quick_options, 1, 0, 1, 3, Qt.AlignLeft) + self._control_grid.addWidget(self._start_btn, 1, 3, 1, 2, Qt.AlignRight) + self._control_grid.addWidget(self._output_controls, 2, 0, 1, 5) + self._control_divider.setVisible(False) else: self._control_grid.addWidget(self._language_controls, 0, 0, 1, 3) self._control_grid.addWidget(self._quick_options, 0, 3, 1, 2, Qt.AlignRight) diff --git a/comic_translate_desktop/ui/theme.py b/comic_translate_desktop/ui/theme.py index eb15c3a..be569ca 100644 --- a/comic_translate_desktop/ui/theme.py +++ b/comic_translate_desktop/ui/theme.py @@ -330,6 +330,9 @@ def refresh_themed_icons(): QFrame#controlCard QPushButton[role="primary"] { border-radius: 10px; min-height: 32px; } QFrame#optionDivider { background: @rule; border: none; margin: 6px 0; } QLabel#optionArrow { color: @secondary; padding: 0 2px; } +QLabel#cudaHelp { background: @muted; color: @secondary; border: 1px solid @rule; + border-radius: 9px; font-size: 11px; font-weight: 700; } +QLabel#cudaHelp:hover { color: @ink; border-color: @ruleStrong; } QComboBox QLineEdit#fontSearchEditor, QComboBox QLineEdit#fontSearchEditor:focus { padding: 0; min-height: 0; border: none; border-radius: 0; background: transparent; } QLineEdit#fontSearchEditor QToolButton { padding: 0; min-height: 0; min-width: 0; border: none; border-radius: 0; background: transparent; } QSpinBox::up-button, QSpinBox::down-button { width: 20px; border: none; background: transparent; } diff --git a/scripts/review_ui.py b/scripts/review_ui.py index e8d93c4..4dcaaab 100644 --- a/scripts/review_ui.py +++ b/scripts/review_ui.py @@ -85,6 +85,9 @@ def capture(name, page, buttons=()): QTest.qWait(80) for button in buttons: check_action(window, button) + if page is window.translate_tab: + for field in (window._source_language, window._target_language): + assert window._language_controls.rect().contains(field.geometry()) header_widgets = [widget for widget in (window._brand_title, window._nav_auto, window._nav_editor, window.status_pill, window._stop_btn, window._settings_btn, window._logs_btn, window._output_btn, window._issue_btn, window._more_btn) if widget.isVisible()] @@ -123,7 +126,7 @@ def review(): report['illustrations'].append(dict(file=asset, width=pixmap.width(), height=pixmap.height(), transparent=True)) capture('automatic', window.translate_tab, - (window._add_btn, window._cuda_toggle, window._start_btn)) + (window._add_btn, window._cuda_toggle, window._cuda_help, window._start_btn)) window._pref_toggle.setChecked(True) QTest.qWait(320) capture('automatic-preferences', window.translate_tab, @@ -301,7 +304,7 @@ def review(): for width, height in ((1024, 720), (960, 540), (820, 480)): window.resize(min(width, int(screen.width() * .94)), min(height, int(screen.height() * .94))) capture(f'automatic-{width}', window.translate_tab, - (window._add_btn, window._cuda_toggle, window._start_btn)) + (window._add_btn, window._cuda_toggle, window._cuda_help, window._start_btn)) settings._sections.setCurrentIndex(2) capture(f'settings-{width}', settings, (settings._save_btn,)) settings._sections.setCurrentIndex(3) From 4f868f705279e4cf1ab4f903151150141837c05c Mon Sep 17 00:00:00 2001 From: LianWan Wen <2094941626@qq.com> Date: Tue, 10 Nov 2026 15:44:44 +0800 Subject: [PATCH 2/2] docs: record the CUDA detector help tooltip --- docs/UI_UPGRADE_PLAN_2026-11-06.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/UI_UPGRADE_PLAN_2026-11-06.md b/docs/UI_UPGRADE_PLAN_2026-11-06.md index b031070..ad66df8 100644 --- a/docs/UI_UPGRADE_PLAN_2026-11-06.md +++ b/docs/UI_UPGRADE_PLAN_2026-11-06.md @@ -29,6 +29,7 @@ - [x] 一键精修:自动处理页把上次任务的图片 / PDF 一次加入嵌字精修列表;翻译偏好展开改为高度动画,大窗口保留日志面板,去掉透明度效果与面板跳变 - [x] 精修框选填色:修复工具栏新增「填白 / 填黑」,把框选区域整块填成纯色并支持撤回,适配简单背景 - [x] 自动处理页新增 CUDA 开关,设置即时保存并在下一次任务生效;详细配置保留检测器的自动模式,窄窗保留模型浏览按钮,一键精修可跳过无效文件。 +- [x] CUDA 开关旁新增悬停问号,说明两套检测器对擦字范围和速度的影响。 ---