feat(gui): add an Apply button for live preview of settings
Split applying settings from closing the dialog, so appearance changes (opacity, font size, line counts) can be previewed without dismissing it. The caption window now listens to settingsApplied and updates immediately; only model, language or capture-device changes restart the ASR backend. 设置对话框新增「应用」按钮:应用设置但不关闭对话框,方便实时预览(不透明度、 字号等立刻可见)。字幕窗改为监听 settingsApplied 即时更新;只有模型/识别语言/ 采集设备变化才重启识别后端,外观调整不会打断正在进行的转写。
This commit is contained in:
1 parent
0fa0bcb44a
commit
370c869ad0
4 files changed
+68
-19
No files matched your search
+35
-13
@@ -131,6 +131,16 @@ int main(int argc, char ** argv)
|
||||
if (b->text() == QObject::tr("确定")) { b->click(); break; }
|
||||
}
|
||||
}
|
||||
else if (autoclose == QLatin1String("apply")) { // 点「应用」,应保持打开
|
||||
for (auto * b : dlg.findChildren<QPushButton *>()) {
|
||||
if (b->text() == QObject::tr("应用")) { b->click(); break; }
|
||||
}
|
||||
QTimer::singleShot(400, &dlg, [&dlg] {
|
||||
std::fprintf(stderr, "点「应用」后对话框仍可见: %s\n",
|
||||
dlg.isVisible() ? "是 ✅" : "否 ❌");
|
||||
dlg.reject();
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -197,17 +207,35 @@ int main(int argc, char ** argv)
|
||||
qWarning("采集失败: %s", qUtf8Printable(m));
|
||||
});
|
||||
|
||||
// 语言 pill → 设置
|
||||
QObject::connect(&window, &lc::CaptionWindow::languageClicked, &window, [&] {
|
||||
// 后端相关项(模型/语言/采集设备)变化才需要重启;外观类改动即时生效
|
||||
const auto backendKey = [&cfg] {
|
||||
return cfg.modelId + QLatin1Char('|') + cfg.language + QLatin1Char('|') + cfg.captureDevice;
|
||||
};
|
||||
QString activeKey = backendKey();
|
||||
|
||||
const auto openSettings = [&] {
|
||||
lc::SettingsDialog dlg(false);
|
||||
QObject::connect(&dlg, &lc::SettingsDialog::settingsApplied, &window, [&] {
|
||||
applyAppearance(window, cfg); // 透明度/字号等立刻可见
|
||||
if (backendKey() != activeKey) {
|
||||
if (startTranscriber()) activeKey = backendKey();
|
||||
}
|
||||
});
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
applyAppearance(window, cfg);
|
||||
if (!startTranscriber()) {
|
||||
QMessageBox::warning(&window, QObject::tr("启动失败"),
|
||||
QObject::tr("模型加载失败,请检查设置。"));
|
||||
if (backendKey() != activeKey) {
|
||||
if (!startTranscriber()) {
|
||||
QMessageBox::warning(&window, QObject::tr("启动失败"),
|
||||
QObject::tr("模型加载失败,请检查设置。"));
|
||||
} else {
|
||||
activeKey = backendKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 语言 pill → 设置
|
||||
QObject::connect(&window, &lc::CaptionWindow::languageClicked, &window, openSettings);
|
||||
|
||||
// ---- 托盘 ----
|
||||
QSystemTrayIcon * tray = nullptr;
|
||||
@@ -224,13 +252,7 @@ int main(int argc, char ** argv)
|
||||
|
||||
QObject::connect(showAct, &QAction::triggered, &window,
|
||||
[&window] { window.setVisible(!window.isVisible()); });
|
||||
QObject::connect(setAct, &QAction::triggered, &window, [&] {
|
||||
lc::SettingsDialog dlg(false);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
applyAppearance(window, cfg);
|
||||
startTranscriber();
|
||||
}
|
||||
});
|
||||
QObject::connect(setAct, &QAction::triggered, &window, openSettings);
|
||||
QObject::connect(quitAct, &QAction::triggered, &app, &QApplication::quit);
|
||||
QObject::connect(tray, &QSystemTrayIcon::activated, &window,
|
||||
[&window](QSystemTrayIcon::ActivationReason r) {
|
||||
|
||||
Reference in new issue
Block a user