Files
live-caption/src/ui/settingsdialog.h
T
blumia 898763eb74 fix(gui): drop a dead setting, make the language list and tail toggle real
Three settings were only half-wired:

- autoPickByLanguage was saved but never read anywhere: delete it.
- showUnstableTail had a checkbox and a setter, but nothing ever called
  the setter, so the checkbox did nothing: apply it in applyAppearance
  and re-render from the cached text instead of blanking the caption.
- the language dropdown was hard-coded to auto/zh/en/ja while the registry
  declares up to 16 languages per model: build it from the selected
  model's own language list, with an ISO-code to display-name mapping
  (plus a unit test covering every code in the registry). The caption
  window's language pill now follows the setting too, instead of keeping
  whatever it showed at startup.

windowPos is not dead -- it stores the dragged window position -- so it stays.

三个「半死」设置:autoPickByLanguage 存了但从没被读取,直接删掉;showUnstableTail
有复选框也有 setter,但从来没人调用 setter(复选框点了没用),改为在 applyAppearance
里生效并用缓存文本重画;「识别语言」下拉原来硬编码 自动/中/英/日,而注册表里每个模型
声明了最多 16 种语言,改为按所选模型的语言动态生成,并补 ISO 码→显示名映射与单元测试。
字幕窗的语言标签也跟着设置走了(原来只在启动时读一次)。windowPos 不是死设置(它存的
是拖动后的位置),保留。
2026-10-12 17:48:21 +08:00

98 lines
3.0 KiB
C++

#pragma once
#include <QDialog>
class QComboBox;
class QCheckBox;
class QDoubleSpinBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QProgressBar;
class QPushButton;
class QSlider;
class QSpinBox;
class QTableWidget;
namespace lc {
namespace models { class ModelDownloader; }
// 设置对话框:模型管理(下载/删除/选择)、显示、窗口、下载源与代理、高级。
// GUI 用户完全靠它驱动,不再需要命令行参数。
class SettingsDialog : public QDialog {
Q_OBJECT
public:
explicit SettingsDialog(bool firstRun, QWidget * parent = nullptr);
~SettingsDialog() override;
Q_SIGNALS:
// 设置已变更且用户点了确定
void settingsApplied();
private:
QWidget * buildModelPage();
QWidget * buildDisplayPage();
QWidget * buildAdvancedPage();
void refreshModelTable();
void refreshActiveCombo();
void rebuildLanguageCombo(); // 按所选模型支持的语言重建语言下拉
void updateStreamGroupEnabled(); // 流式参数只在 llama 后端下可用
void onDownload();
void onVerify();
void onDelete();
void onOpenDir();
void applySettings(); // 读取控件 → 保存 → 发 settingsApplied(不关闭对话框)
void onAccept(); // 确定:applySettings + 关闭
void onApplyClicked(); // 应用:只 applySettings
bool ensureModelSelected();
QTableWidget * table_ = nullptr;
QComboBox * activeCombo_ = nullptr;
QComboBox * languageCombo_ = nullptr;
QComboBox * captureCombo_ = nullptr;
QPushButton * verifyBtn_ = nullptr;
QPushButton * downloadBtn_ = nullptr;
QPushButton * deleteBtn_ = nullptr;
QProgressBar * progress_ = nullptr;
QLabel * statusLabel_ = nullptr;
QLineEdit * mirrorEdit_ = nullptr;
QComboBox * proxyCombo_ = nullptr;
QLineEdit * proxyHost_ = nullptr;
QSpinBox * proxyPort_ = nullptr;
QLineEdit * proxyUser_ = nullptr;
QLineEdit * proxyPass_ = nullptr;
QSpinBox * fontSpin_ = nullptr;
QCheckBox * showTailCheck_ = nullptr;
QSpinBox * collapsedSpin_ = nullptr;
QSpinBox * expandedSpin_ = nullptr;
QSlider * opacitySlider_ = nullptr;
QLabel * opacityLabel_ = nullptr;
QDoubleSpinBox * chunkSpin_ = nullptr;
QSpinBox * threadsSpin_ = nullptr;
// 高级:流式参数(只影响 llama 后端)
QGroupBox * streamGroup_ = nullptr;
QLabel * streamNote_ = nullptr;
QComboBox * streamModeCombo_ = nullptr;
QDoubleSpinBox * windowSpin_ = nullptr;
QDoubleSpinBox * segmentSpin_ = nullptr;
QSpinBox * unfixedTokenSpin_ = nullptr;
QSpinBox * unfixedChunkSpin_ = nullptr;
QSpinBox * maxTokenSpin_ = nullptr;
// 高级:调试
QCheckBox * verboseCheck_ = nullptr;
QLineEdit * modelDirEdit_ = nullptr;
models::ModelDownloader * downloader_ = nullptr;
bool firstRun_ = false;
};
} // namespace lc