mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Read-Only Configuration-Database support (#1046)
This commit is contained in:
@@ -10,10 +10,10 @@
|
||||
|
||||
AuthManager *AuthManager::manager = nullptr;
|
||||
|
||||
AuthManager::AuthManager(QObject *parent)
|
||||
AuthManager::AuthManager(QObject *parent, bool readonlyMode)
|
||||
: QObject(parent)
|
||||
, _authTable(new AuthTable("", this))
|
||||
, _metaTable(new MetaTable(this))
|
||||
, _authTable(new AuthTable("", this, readonlyMode))
|
||||
, _metaTable(new MetaTable(this, readonlyMode))
|
||||
, _pendingRequests()
|
||||
, _authRequired(true)
|
||||
, _timer(new QTimer(this))
|
||||
|
@@ -39,10 +39,10 @@
|
||||
// Boblight
|
||||
#include <boblightserver/BoblightServer.h>
|
||||
|
||||
Hyperion::Hyperion(quint8 instance)
|
||||
Hyperion::Hyperion(quint8 instance, bool readonlyMode)
|
||||
: QObject()
|
||||
, _instIndex(instance)
|
||||
, _settingsManager(new SettingsManager(instance, this))
|
||||
, _settingsManager(new SettingsManager(instance, this, readonlyMode))
|
||||
, _componentRegister(this)
|
||||
, _ledString(hyperion::createLedString(getSetting(settings::LEDS).array(), hyperion::createColorOrder(getSetting(settings::DEVICE).object())))
|
||||
, _imageProcessor(new ImageProcessor(_ledString, this))
|
||||
@@ -54,6 +54,7 @@ Hyperion::Hyperion(quint8 instance)
|
||||
, _hwLedCount()
|
||||
, _ledGridSize(hyperion::getLedLayoutGridSize(getSetting(settings::LEDS).array()))
|
||||
, _ledBuffer(_ledString.leds().size(), ColorRgb::BLACK)
|
||||
, _readOnlyMode(readonlyMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -9,11 +9,12 @@
|
||||
|
||||
HyperionIManager* HyperionIManager::HIMinstance;
|
||||
|
||||
HyperionIManager::HyperionIManager(const QString& rootPath, QObject* parent)
|
||||
HyperionIManager::HyperionIManager(const QString& rootPath, QObject* parent, bool readonlyMode)
|
||||
: QObject(parent)
|
||||
, _log(Logger::getInstance("HYPERION"))
|
||||
, _instanceTable( new InstanceTable(rootPath, this) )
|
||||
, _instanceTable( new InstanceTable(rootPath, this, readonlyMode) )
|
||||
, _rootPath( rootPath )
|
||||
, _readonlyMode(readonlyMode)
|
||||
{
|
||||
HIMinstance = this;
|
||||
qRegisterMetaType<InstanceState>("InstanceState");
|
||||
@@ -75,7 +76,7 @@ bool HyperionIManager::startInstance(quint8 inst, bool block, QObject* caller, i
|
||||
{
|
||||
QThread* hyperionThread = new QThread();
|
||||
hyperionThread->setObjectName("HyperionThread");
|
||||
Hyperion* hyperion = new Hyperion(inst);
|
||||
Hyperion* hyperion = new Hyperion(inst, _readonlyMode);
|
||||
hyperion->moveToThread(hyperionThread);
|
||||
// setup thread management
|
||||
connect(hyperionThread, &QThread::started, hyperion, &Hyperion::start);
|
||||
|
@@ -14,11 +14,13 @@
|
||||
|
||||
QJsonObject SettingsManager::schemaJson;
|
||||
|
||||
SettingsManager::SettingsManager(quint8 instance, QObject* parent)
|
||||
SettingsManager::SettingsManager(quint8 instance, QObject* parent, bool readonlyMode)
|
||||
: QObject(parent)
|
||||
, _log(Logger::getInstance("SETTINGSMGR"))
|
||||
, _sTable(new SettingsTable(instance, this))
|
||||
, _readonlyMode(readonlyMode)
|
||||
{
|
||||
_sTable->setReadonlyMode(_readonlyMode);
|
||||
// get schema
|
||||
if(schemaJson.isEmpty())
|
||||
{
|
||||
@@ -152,18 +154,24 @@ bool SettingsManager::saveSettings(QJsonObject config, bool correct)
|
||||
}
|
||||
}
|
||||
|
||||
int rc = true;
|
||||
// compare database data with new data to emit/save changes accordingly
|
||||
for(const auto & key : keyList)
|
||||
{
|
||||
QString data = newValueList.takeFirst();
|
||||
if(_sTable->getSettingsRecordString(key) != data)
|
||||
{
|
||||
_sTable->createSettingsRecord(key, data);
|
||||
|
||||
emit settingsChanged(settings::stringToType(key), QJsonDocument::fromJson(data.toLocal8Bit()));
|
||||
if ( ! _sTable->createSettingsRecord(key, data) )
|
||||
{
|
||||
rc = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
emit settingsChanged(settings::stringToType(key), QJsonDocument::fromJson(data.toLocal8Bit()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
|
||||
|
Reference in New Issue
Block a user