mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 10:03:26 -08:00
[Client+Server] Auto deck sync with change polling
This commit is contained in:
parent
7390c89827
commit
5026e9a956
18 changed files with 448 additions and 18 deletions
|
|
@ -25,6 +25,7 @@ bool DeckSyncSidecar::load()
|
|||
{
|
||||
recordMap.clear();
|
||||
mode = MODE_LINKED;
|
||||
lastSyncSecs = 0;
|
||||
|
||||
QFile file(filePath);
|
||||
if (!file.exists()) {
|
||||
|
|
@ -39,6 +40,7 @@ bool DeckSyncSidecar::load()
|
|||
}
|
||||
const QJsonValue modeValue = document.object().value("mode");
|
||||
mode = modeValue.isString() ? modeValue.toString() : MODE_LINKED;
|
||||
lastSyncSecs = static_cast<qint64>(document.object().value("lastSync").toDouble());
|
||||
const QJsonObject records = document.object().value("records").toObject();
|
||||
for (auto it = records.begin(); it != records.end(); ++it) {
|
||||
if (!it.value().isObject()) {
|
||||
|
|
@ -70,6 +72,7 @@ bool DeckSyncSidecar::save() const
|
|||
QJsonObject root;
|
||||
root.insert("version", SIDECAR_FORMAT_VERSION);
|
||||
root.insert("mode", mode);
|
||||
root.insert("lastSync", static_cast<double>(lastSyncSecs));
|
||||
root.insert("records", records);
|
||||
|
||||
QDir().mkpath(QFileInfo(filePath).absolutePath());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue