2026-10-12 16:30:00 +08:00
|
|
|
#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());
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-12 17:03:20 +08:00
|
|
|
captureDevice = s.value(QStringLiteral("captureDevice")).toString();
|
|
|
|
|
|
2026-10-12 16:30:00 +08:00
|
|
|
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();
|
2026-10-12 17:36:43 +08:00
|
|
|
|
|
|
|
|
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();
|
2026-10-12 16:30:00 +08:00
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-12 17:03:20 +08:00
|
|
|
s.setValue(QStringLiteral("captureDevice"), captureDevice);
|
2026-10-12 16:30:00 +08:00
|
|
|
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);
|
2026-10-12 17:36:43 +08:00
|
|
|
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);
|
2026-10-12 16:30:00 +08:00
|
|
|
s.endGroup();
|
|
|
|
|
s.sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace lc
|