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 不是死设置(它存的 是拖动后的位置),保留。
97 lines
3.9 KiB
C++
97 lines
3.9 KiB
C++
#include "appsettings.h"
|
|
|
|
#include <QSettings>
|
|
|
|
namespace lc {
|
|
|
|
AppSettings & AppSettings::instance()
|
|
{
|
|
static AppSettings s;
|
|
return s;
|
|
}
|
|
|
|
void AppSettings::load()
|
|
{
|
|
QSettings s;
|
|
s.beginGroup(QStringLiteral("app"));
|
|
modelId = s.value(QStringLiteral("modelId")).toString();
|
|
language = s.value(QStringLiteral("language")).toString();
|
|
|
|
opacityPercent = s.value(QStringLiteral("opacity"), 84).toInt();
|
|
fontSize = s.value(QStringLiteral("fontSize"), 15).toInt();
|
|
showUnstableTail = s.value(QStringLiteral("showUnstableTail"), true).toBool();
|
|
collapsedLines = s.value(QStringLiteral("collapsedLines"), 2).toInt();
|
|
expandedLines = s.value(QStringLiteral("expandedLines"), 8).toInt();
|
|
|
|
hasWindowPos = s.contains(QStringLiteral("windowX"));
|
|
if (hasWindowPos) {
|
|
windowPos = QPoint(s.value(QStringLiteral("windowX")).toInt(),
|
|
s.value(QStringLiteral("windowY")).toInt());
|
|
}
|
|
|
|
captureDevice = s.value(QStringLiteral("captureDevice")).toString();
|
|
|
|
mirrorBase = s.value(QStringLiteral("mirrorBase"),
|
|
QStringLiteral("https://hf-mirror.com")).toString();
|
|
proxyMode = s.value(QStringLiteral("proxyMode"), 0).toInt();
|
|
proxyHost = s.value(QStringLiteral("proxyHost")).toString();
|
|
proxyPort = s.value(QStringLiteral("proxyPort"), 0).toInt();
|
|
proxyUser = s.value(QStringLiteral("proxyUser")).toString();
|
|
proxyPass = s.value(QStringLiteral("proxyPass")).toString();
|
|
|
|
chunkSec = s.value(QStringLiteral("chunkSec"), 0.0).toDouble();
|
|
threads = s.value(QStringLiteral("threads"), 8).toInt();
|
|
|
|
streamMode = s.value(QStringLiteral("streamMode"), QStringLiteral("incremental")).toString();
|
|
streamWindowSec = s.value(QStringLiteral("streamWindowSec"), 16.0).toDouble();
|
|
streamSegmentSec = s.value(QStringLiteral("streamSegmentSec"), 30.0).toDouble();
|
|
unfixedTokens = s.value(QStringLiteral("unfixedTokens"), 5).toInt();
|
|
unfixedChunks = s.value(QStringLiteral("unfixedChunks"), 2).toInt();
|
|
maxTokens = s.value(QStringLiteral("maxTokens"), 256).toInt();
|
|
verbose = s.value(QStringLiteral("verbose"), false).toBool();
|
|
modelDir = s.value(QStringLiteral("modelDir")).toString();
|
|
s.endGroup();
|
|
}
|
|
|
|
void AppSettings::save()
|
|
{
|
|
QSettings s;
|
|
s.beginGroup(QStringLiteral("app"));
|
|
s.setValue(QStringLiteral("modelId"), modelId);
|
|
s.setValue(QStringLiteral("language"), language);
|
|
|
|
s.setValue(QStringLiteral("opacity"), opacityPercent);
|
|
s.setValue(QStringLiteral("fontSize"), fontSize);
|
|
s.setValue(QStringLiteral("showUnstableTail"), showUnstableTail);
|
|
s.setValue(QStringLiteral("collapsedLines"), collapsedLines);
|
|
s.setValue(QStringLiteral("expandedLines"), expandedLines);
|
|
|
|
if (hasWindowPos) {
|
|
s.setValue(QStringLiteral("windowX"), windowPos.x());
|
|
s.setValue(QStringLiteral("windowY"), windowPos.y());
|
|
}
|
|
|
|
s.setValue(QStringLiteral("captureDevice"), captureDevice);
|
|
s.setValue(QStringLiteral("mirrorBase"), mirrorBase);
|
|
s.setValue(QStringLiteral("proxyMode"), proxyMode);
|
|
s.setValue(QStringLiteral("proxyHost"), proxyHost);
|
|
s.setValue(QStringLiteral("proxyPort"), proxyPort);
|
|
s.setValue(QStringLiteral("proxyUser"), proxyUser);
|
|
s.setValue(QStringLiteral("proxyPass"), proxyPass);
|
|
|
|
s.setValue(QStringLiteral("chunkSec"), chunkSec);
|
|
s.setValue(QStringLiteral("threads"), threads);
|
|
s.setValue(QStringLiteral("streamMode"), streamMode);
|
|
s.setValue(QStringLiteral("streamWindowSec"), streamWindowSec);
|
|
s.setValue(QStringLiteral("streamSegmentSec"), streamSegmentSec);
|
|
s.setValue(QStringLiteral("unfixedTokens"), unfixedTokens);
|
|
s.setValue(QStringLiteral("unfixedChunks"), unfixedChunks);
|
|
s.setValue(QStringLiteral("maxTokens"), maxTokens);
|
|
s.setValue(QStringLiteral("verbose"), verbose);
|
|
s.setValue(QStringLiteral("modelDir"), modelDir);
|
|
s.endGroup();
|
|
s.sync();
|
|
}
|
|
|
|
} // namespace lc
|