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();
|
|
|
|
|
autoPickByLanguage = s.value(QStringLiteral("autoPickByLanguage"), false).toBool();
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
s.endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppSettings::save()
|
|
|
|
|
{
|
|
|
|
|
QSettings s;
|
|
|
|
|
s.beginGroup(QStringLiteral("app"));
|
|
|
|
|
s.setValue(QStringLiteral("modelId"), modelId);
|
|
|
|
|
s.setValue(QStringLiteral("language"), language);
|
|
|
|
|
s.setValue(QStringLiteral("autoPickByLanguage"), autoPickByLanguage);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
s.endGroup();
|
|
|
|
|
s.sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace lc
|