Added system item support, support for RGBControlers with multiple item backends, and item settings widgets
This commit is contained in:
parent
a761eb4317
commit
5fb9ca7cc0
56 changed files with 635 additions and 210 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "mainobject.h"
|
||||
#include "items/messageitem.h"
|
||||
|
||||
MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const bool masterIn, QObject *parent) :
|
||||
QObject(parent),
|
||||
|
|
@ -9,6 +10,7 @@ MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const
|
|||
broadCast(ioMultiplexer.getIoDevice(), masterIn),
|
||||
settingsPath(settingsPathIn),
|
||||
sunSensorSource(49.884450, 8.650536),
|
||||
powerItem(new PowerItem),
|
||||
rgbItem(new RgbItem(µ, 5487422, "Rgb Lights")),
|
||||
auxItem(new AuxItem(µ, 5487421, "Desk Light"))
|
||||
|
||||
|
|
@ -27,10 +29,12 @@ MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const
|
|||
QObject::connect(µ, &Microcontroller::itemChanged, &items, &ItemStore::itemStateChanged);
|
||||
|
||||
//special items
|
||||
QObject::connect(&powerItem, &PowerItem::stateChanged, &globalSensors, &SensorStore::sensorGotState);
|
||||
powerItem.emmitSensor();
|
||||
QObject::connect(powerItem.get(), &PowerItem::stateChanged, &globalSensors, &SensorStore::sensorGotState);
|
||||
powerItem->emmitSensor();
|
||||
items.addItem(rgbItem);
|
||||
items.addItem(auxItem);
|
||||
MessageItem::broadCast = &broadCast;
|
||||
|
||||
|
||||
Relay::setMicrocontroller(µ);
|
||||
|
||||
|
|
@ -42,6 +46,7 @@ MainObject::MainObject(QIODevice* ioDevice, const QString& settingsPathIn, const
|
|||
else
|
||||
{
|
||||
broadCast.requestJson();
|
||||
broadCast.requestSensors();
|
||||
}
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
|
|
@ -62,12 +67,15 @@ MainObject::~MainObject()
|
|||
void MainObject::store(QJsonObject &json)
|
||||
{
|
||||
items.store(json);
|
||||
|
||||
QJsonObject powerObject;
|
||||
powerItem.store(powerObject);
|
||||
powerItem->store(powerObject);
|
||||
json.insert("Power", powerObject);
|
||||
QJsonDocument pwrDoc(powerObject);
|
||||
|
||||
QJsonObject ocupancyObject;
|
||||
ocupancySensor.store(ocupancyObject);
|
||||
json.insert("Ocupancy", ocupancyObject);
|
||||
json.insert("Power", powerObject);
|
||||
}
|
||||
|
||||
void MainObject::load(const QJsonObject& json)
|
||||
|
|
@ -75,11 +83,11 @@ void MainObject::load(const QJsonObject& json)
|
|||
items.clear();
|
||||
rgbItem->removeAllActors();
|
||||
auxItem->removeAllActors();
|
||||
powerItem.removeAllActors();
|
||||
powerItem->removeAllActors();
|
||||
items.addItem(rgbItem);
|
||||
items.addItem(auxItem);
|
||||
items.load(json);
|
||||
powerItem.load(json["Power"].toObject());
|
||||
powerItem->load(json["Power"].toObject());
|
||||
ocupancySensor.load(json["Ocupancy"].toObject());
|
||||
qDebug()<<"aray size: "<<json.isEmpty();
|
||||
if(json["Items"].toArray().size() >= 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue