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 不是死设置(它存的 是拖动后的位置),保留。
This commit is contained in:
1 parent
6c04071bb5
commit
898763eb74
12 files changed
+141
-26
No files matched your search
+21
-12
@@ -50,12 +50,13 @@ QIcon makeTrayIcon()
|
||||
return QIcon(pm);
|
||||
}
|
||||
|
||||
// 把设置应用到字幕窗(字号/不透明度/行数/位置)
|
||||
// 把设置应用到字幕窗(字号/不透明度/行数/位置/灰色尾部)
|
||||
void applyAppearance(lc::CaptionWindow & window, const lc::AppSettings & cfg)
|
||||
{
|
||||
window.setPanelOpacity(cfg.opacityPercent);
|
||||
window.setTextFontSize(cfg.fontSize);
|
||||
window.setLineCounts(cfg.collapsedLines, cfg.expandedLines);
|
||||
window.setShowTail(cfg.showUnstableTail);
|
||||
if (cfg.hasWindowPos) window.move(cfg.windowPos);
|
||||
}
|
||||
|
||||
@@ -193,7 +194,8 @@ int main(int argc, char ** argv)
|
||||
applyAppearance(window, cfg);
|
||||
// 语言 pill:流式模型不提供语言识别,就显示设置里选的语言
|
||||
if (!cfg.language.isEmpty()) {
|
||||
window.setLanguage(QString::fromStdString(lc::languageDisplayName(cfg.language.toStdString())));
|
||||
window.setLanguage(
|
||||
QString::fromStdString(lc::languageDisplayNameFromCode(cfg.language.toStdString())));
|
||||
}
|
||||
|
||||
// 注意声明顺序:asr 必须在 live 之前声明,
|
||||
@@ -259,24 +261,31 @@ int main(int argc, char ** argv)
|
||||
QString activeKey = backendKeyOf(cfg);
|
||||
|
||||
const auto openSettings = [&] {
|
||||
// 后端相关项变化时:先把语言标签跟设置对齐(流式模型没有自动检测结果来更新它),
|
||||
// 再重启识别后端。
|
||||
const auto applyBackend = [&]() -> bool {
|
||||
if (backendKeyOf(cfg) == activeKey) return true;
|
||||
window.setLanguage(cfg.language.isEmpty()
|
||||
? QString()
|
||||
: QString::fromStdString(
|
||||
lc::languageDisplayNameFromCode(cfg.language.toStdString())));
|
||||
if (!startTranscriber()) return false;
|
||||
activeKey = backendKeyOf(cfg);
|
||||
return true;
|
||||
};
|
||||
|
||||
lc::SettingsDialog dlg(false);
|
||||
QObject::connect(&dlg, &lc::SettingsDialog::settingsApplied, &window, [&] {
|
||||
lc::models::ModelStore::setRootOverride(cfg.modelDir);
|
||||
applyAppearance(window, cfg); // 透明度/字号等立刻可见
|
||||
if (backendKeyOf(cfg) != activeKey) {
|
||||
if (startTranscriber()) activeKey = backendKeyOf(cfg);
|
||||
}
|
||||
applyBackend();
|
||||
});
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
lc::models::ModelStore::setRootOverride(cfg.modelDir);
|
||||
applyAppearance(window, cfg);
|
||||
if (backendKeyOf(cfg) != activeKey) {
|
||||
if (!startTranscriber()) {
|
||||
QMessageBox::warning(&window, QObject::tr("启动失败"),
|
||||
QObject::tr("模型加载失败,请检查设置。"));
|
||||
} else {
|
||||
activeKey = backendKeyOf(cfg);
|
||||
}
|
||||
if (!applyBackend()) {
|
||||
QMessageBox::warning(&window, QObject::tr("启动失败"),
|
||||
QObject::tr("模型加载失败,请检查设置。"));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user