Bug fixes

This commit is contained in:
2019-06-13 00:05:10 +02:00
parent 3cbe947408
commit f6aaebafc6
5 changed files with 20 additions and 5 deletions

View File

@ -36,7 +36,7 @@ MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const
items.addItem(rgbItem);
items.addItem(auxItem);
connect(&broadCast, &BroadCast::gotJson, this, &MainObject::load);
connect(&broadCast, &BroadCast::gotJson, this, &MainObject::recivedJson);
connect(&broadCast, &BroadCast::jsonRequested, this, &MainObject::sendJson);
if(master) load(getJsonObjectFromDisk(settingsPath));
@ -68,9 +68,11 @@ void MainObject::store(QJsonObject &json)
json.insert("Power", powerObject);
}
void MainObject::load(const QJsonObject json)
void MainObject::load(const QJsonObject& json)
{
items.clear();
rgbItem->removeAllActors();
auxItem->removeAllActors();
items.addItem(rgbItem);
items.addItem(auxItem);
items.load(json, &micro);
@ -78,13 +80,18 @@ void MainObject::load(const QJsonObject json)
qDebug()<<"aray size: "<<json.isEmpty();
if(json["Items"].toArray().size() >= 2)
{
rgbItem->load(json["Items"].toArray()[0].toObject());
auxItem->load(json["Items"].toArray()[1].toObject());
}
micro.requestState();
}
void MainObject::recivedJson(const QJsonObject json)
{
if(master)storeJsonObjectToDisk(json, settingsPath);
load(json);
}
void MainObject::sendJson()
{
QJsonObject json;