switched from qsettings to json added editng of actors
This commit is contained in:
parent
b04fbfb5bc
commit
df27b622a0
141 changed files with 4402 additions and 5068 deletions
37
src/items/poweritem.cpp
Normal file
37
src/items/poweritem.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "poweritem.h"
|
||||
#include <QProcess>
|
||||
#include <QApplication>
|
||||
|
||||
PowerItem::PowerItem(SensorStore* sensors, QApplication* a, uint32_t itemIdIn, QString name, uint8_t value, QObject* parent): Item(sensors, itemIdIn, name, value, parent), a_(a)
|
||||
{
|
||||
stateChanged(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 0));
|
||||
setValue(true);
|
||||
}
|
||||
|
||||
void PowerItem::setValue(uint8_t value)
|
||||
{
|
||||
Item::setValue(value);
|
||||
if(!value)
|
||||
{
|
||||
QTimer::singleShot(5000, this, &PowerItem::timeout);
|
||||
stateChanged(Sensor(Sensor::TYPE_SHUTDOWN_IMMINENT, 0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
void PowerItem::timeout()
|
||||
{
|
||||
QProcess::startDetached("syncoff");
|
||||
a_->exit(0);
|
||||
}
|
||||
|
||||
void PowerItem::store(QJsonObject& json)
|
||||
{
|
||||
json["Type"] = "Power";
|
||||
Item::store(json);
|
||||
}
|
||||
|
||||
void PowerItem::store(QString subsecton, QSettings* settings)
|
||||
{
|
||||
settings->setValue(subsecton + "Type", "Power");
|
||||
Item::store(subsecton, settings);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue