Introduce the Kotlin/Compose Android companion app and extend the TMDB proxy into a combo server that synchronizes the whole library as an encrypted snapshot, with all three components (Go server, Android, desktop) sharing one zero-knowledge crypto envelope and JSON schema. - server: add PostgreSQL-backed /sync/library (GET/PUT) with optimistic concurrency (revision + 409 on conflict); sync stays disabled unless DATABASE_URL is set. Add docker-compose with Postgres. - desktop: add libsodium CryptoEnvelope, LibrarySerializer and SyncClient; storage-mode and passphrase settings; a "Sync now" toolbar action with conflict resolution. - android: Room-backed library with local/cloud storage modes, encrypted sync client, and settings UI. The proxy server (URL + token) can be configured as a TMDB proxy even in local-only mode. Crypto is identical across platforms: Argon2id (libsodium crypto_pwhash, INTERACTIVE) + XChaCha20-Poly1305 in a versioned "UMTS" envelope, so a snapshot encrypted on one client decrypts on the other. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
129 lines
4 KiB
C++
129 lines
4 KiB
C++
#include "core/Settings.h"
|
|
|
|
namespace umt {
|
|
|
|
AppSettings::AppSettings(QObject *parent)
|
|
: QObject(parent)
|
|
, m_s(QStringLiteral("UMT"), QStringLiteral("UltimateMediaTracker"))
|
|
{
|
|
}
|
|
|
|
bool AppSettings::darkMode() const {
|
|
return m_s.value(QStringLiteral("theme/dark"), true).toBool();
|
|
}
|
|
void AppSettings::setDarkMode(bool on) {
|
|
if (darkMode() == on) return;
|
|
m_s.setValue(QStringLiteral("theme/dark"), on);
|
|
emit themeChanged();
|
|
}
|
|
|
|
QColor AppSettings::accentColor() const {
|
|
return QColor(m_s.value(QStringLiteral("theme/accent"),
|
|
QStringLiteral("#0a84ff")).toString());
|
|
}
|
|
void AppSettings::setAccentColor(const QColor &c) {
|
|
if (accentColor() == c) return;
|
|
m_s.setValue(QStringLiteral("theme/accent"), c.name());
|
|
emit accentChanged(c);
|
|
emit themeChanged();
|
|
}
|
|
|
|
QString AppSettings::preferredLanguage() const {
|
|
return m_s.value(QStringLiteral("locale/language"),
|
|
QStringLiteral("de")).toString();
|
|
}
|
|
void AppSettings::setPreferredLanguage(const QString &code) {
|
|
m_s.setValue(QStringLiteral("locale/language"), code);
|
|
}
|
|
|
|
QString AppSettings::tmdbMode() const {
|
|
return m_s.value(QStringLiteral("providers/tmdbMode"),
|
|
QStringLiteral("key")).toString();
|
|
}
|
|
void AppSettings::setTmdbMode(const QString &mode) {
|
|
m_s.setValue(QStringLiteral("providers/tmdbMode"), mode);
|
|
}
|
|
|
|
QString AppSettings::tmdbApiKey() const {
|
|
return m_s.value(QStringLiteral("providers/tmdbKey")).toString();
|
|
}
|
|
void AppSettings::setTmdbApiKey(const QString &key) {
|
|
m_s.setValue(QStringLiteral("providers/tmdbKey"), key);
|
|
}
|
|
|
|
QString AppSettings::proxyUrl() const {
|
|
return m_s.value(QStringLiteral("providers/proxyUrl")).toString();
|
|
}
|
|
void AppSettings::setProxyUrl(const QString &url) {
|
|
m_s.setValue(QStringLiteral("providers/proxyUrl"), url);
|
|
}
|
|
|
|
QString AppSettings::proxyToken() const {
|
|
return m_s.value(QStringLiteral("providers/proxyToken")).toString();
|
|
}
|
|
void AppSettings::setProxyToken(const QString &token) {
|
|
m_s.setValue(QStringLiteral("providers/proxyToken"), token);
|
|
}
|
|
|
|
QString AppSettings::rawgApiKey() const {
|
|
return m_s.value(QStringLiteral("providers/rawgKey")).toString();
|
|
}
|
|
void AppSettings::setRawgApiKey(const QString &key) {
|
|
m_s.setValue(QStringLiteral("providers/rawgKey"), key);
|
|
}
|
|
|
|
QString AppSettings::storageMode() const {
|
|
return m_s.value(QStringLiteral("sync/storageMode"),
|
|
QStringLiteral("local")).toString();
|
|
}
|
|
void AppSettings::setStorageMode(const QString &mode) {
|
|
m_s.setValue(QStringLiteral("sync/storageMode"), mode);
|
|
}
|
|
|
|
QString AppSettings::syncPassphrase() const {
|
|
return m_s.value(QStringLiteral("sync/passphrase")).toString();
|
|
}
|
|
void AppSettings::setSyncPassphrase(const QString &pass) {
|
|
m_s.setValue(QStringLiteral("sync/passphrase"), pass);
|
|
}
|
|
|
|
qlonglong AppSettings::syncRevision() const {
|
|
return m_s.value(QStringLiteral("sync/revision"), 0).toLongLong();
|
|
}
|
|
void AppSettings::setSyncRevision(qlonglong revision) {
|
|
m_s.setValue(QStringLiteral("sync/revision"), revision);
|
|
}
|
|
|
|
bool AppSettings::autoFetchCovers() const {
|
|
return m_s.value(QStringLiteral("providers/autoCovers"), true).toBool();
|
|
}
|
|
void AppSettings::setAutoFetchCovers(bool on) {
|
|
m_s.setValue(QStringLiteral("providers/autoCovers"), on);
|
|
}
|
|
|
|
int AppSettings::cardWidth() const {
|
|
return m_s.value(QStringLiteral("view/cardWidth"), 180).toInt();
|
|
}
|
|
void AppSettings::setCardWidth(int px) {
|
|
if (cardWidth() == px) return;
|
|
m_s.setValue(QStringLiteral("view/cardWidth"), px);
|
|
emit cardSizeChanged(px);
|
|
}
|
|
|
|
QString AppSettings::defaultView() const {
|
|
return m_s.value(QStringLiteral("view/default"),
|
|
QStringLiteral("grid")).toString();
|
|
}
|
|
void AppSettings::setDefaultView(const QString &v) {
|
|
m_s.setValue(QStringLiteral("view/default"), v);
|
|
}
|
|
|
|
QString AppSettings::sortMode() const {
|
|
return m_s.value(QStringLiteral("view/sort"),
|
|
QStringLiteral("dateAdded")).toString();
|
|
}
|
|
void AppSettings::setSortMode(const QString &v) {
|
|
m_s.setValue(QStringLiteral("view/sort"), v);
|
|
}
|
|
|
|
} // namespace umt
|