feat(gui): drive everything from settings, add tray and in-app download
The GUI no longer needs command line arguments: on first run it opens a settings dialog that lists the registry, downloads models in-app (mirror base, HTTP proxy, resume), and picks the active model. The caption window gains a tray icon (show/hide, settings, quit); its close button hides to the tray so the window can always be brought back, and the language pill opens the settings. Appearance (font, opacity, line counts, position) is persisted. CLI flags remain for automated testing and override settings. GUI 不再依赖命令行参数:首次启动打开设置对话框,可在应用内下载模型 (下载源/代理/断点续传)、选择当前模型与识别语言;字幕窗增加托盘(显示 隐藏/设置/退出),关闭按钮改为隐藏到托盘以免关掉后无法再打开,语言标签 点击进设置;字号/透明度/行数/位置都会持久化。命令行参数保留作自动化测试。
This commit is contained in:
1 parent
b37b9eb779
commit
a7a6f3e6b6
15 files changed
+1175
-90
No files matched your search
@@ -106,6 +106,48 @@ inline void addBackendOptions(QCommandLineParser & p)
|
||||
p.addOption(makeOption("language", "语言提示,多语言模型用(zh / en / ja …);留空=自动", "lang"));
|
||||
}
|
||||
|
||||
// 按注册表里的模型直接构造后端(GUI 用;不依赖任何命令行参数)
|
||||
inline std::unique_ptr<IAsr> makeAsrForModel(const models::ModelInfo & m,
|
||||
const QString & language,
|
||||
int threads, bool verbose,
|
||||
std::string * err)
|
||||
{
|
||||
QStringList missing;
|
||||
if (!models::ModelStore::isInstalled(m, &missing)) {
|
||||
if (err) {
|
||||
*err = "模型未安装,缺失: " + missing.join(QStringLiteral(", ")).toStdString();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (m.backend == models::Backend::LlamaCpp) {
|
||||
AsrOptions o;
|
||||
o.modelPath = m.filePath(QStringLiteral("model")).toStdString();
|
||||
o.mmprojPath = m.filePath(QStringLiteral("mmproj")).toStdString();
|
||||
o.threads = threads;
|
||||
o.verbose = verbose;
|
||||
auto a = std::make_unique<Qwen3Asr>();
|
||||
if (!a->load(o, err)) return nullptr;
|
||||
return a;
|
||||
}
|
||||
|
||||
#if defined(LC_HAVE_SHERPA)
|
||||
SherpaAsr::Options o;
|
||||
o.encoder = m.filePath(QStringLiteral("encoder")).toStdString();
|
||||
o.decoder = m.filePath(QStringLiteral("decoder")).toStdString();
|
||||
o.joiner = m.filePath(QStringLiteral("joiner")).toStdString();
|
||||
o.tokens = m.filePath(QStringLiteral("tokens")).toStdString();
|
||||
o.threads = 1; // 这类模型单线程最快
|
||||
if (m.languages.size() > 1 && !language.isEmpty()) o.language = language.toStdString();
|
||||
auto a = std::make_unique<SherpaAsr>();
|
||||
if (!a->load(o, err)) return nullptr;
|
||||
return a;
|
||||
#else
|
||||
if (err) *err = "编译时未找到 sherpa-onnx";
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 按命令行选择并加载后端;失败时返回 nullptr 并把原因写进 err
|
||||
inline std::unique_ptr<IAsr> makeAsr(const QCommandLineParser & p,
|
||||
const AsrOptions & asrOpt, std::string * err)
|
||||
|
||||
Reference in new issue
Block a user