mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
migrate std::string to qstring + add sysinfo via json (#412)
* std::string -> qstring part 1 * more string migration * more string migration ... * ... * more qstring mogrations add sysinfo via json * remove unneccessary includes * integrate sysinfo into webui
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
// Stl includes
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
|
||||
@@ -60,13 +57,12 @@ LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig, const
|
||||
QString ss(config.toJson(QJsonDocument::Indented));
|
||||
Info(log, "configuration: %s ", ss.toUtf8().constData());
|
||||
|
||||
std::string type = deviceConfig["type"].toString("UNSPECIFIED").toStdString();
|
||||
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
|
||||
QString type = deviceConfig["type"].toString("UNSPECIFIED").toLower();
|
||||
|
||||
// set amount of led to leddevice
|
||||
LedDevice::setLedCount(ledCount);
|
||||
|
||||
#define REGISTER(className) LedDevice::addToDeviceMap(QString(#className).toLower().toStdString(), LedDevice##className::construct);
|
||||
#define REGISTER(className) LedDevice::addToDeviceMap(QString(#className).toLower(), LedDevice##className::construct);
|
||||
// rs232 devices
|
||||
REGISTER(Adalight);
|
||||
REGISTER(Sedu);
|
||||
@@ -126,21 +122,21 @@ LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig, const
|
||||
{
|
||||
device = dev.second(deviceConfig);
|
||||
LedDevice::setActiveDevice(dev.first);
|
||||
Info(log,"LedDevice '%s' configured.", dev.first.c_str());
|
||||
Info(log,"LedDevice '%s' configured.", QSTRING_CSTR(dev.first));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (device == nullptr)
|
||||
{
|
||||
Error(log, "Dummy device used, because configured device '%s' is unknown", type.c_str() );
|
||||
Error(log, "Dummy device used, because configured device '%s' is unknown", QSTRING_CSTR(type) );
|
||||
throw std::runtime_error("unknown device");
|
||||
}
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
|
||||
Error(log, "Dummy device used, because configured device '%s' throws error '%s'", type.c_str(), e.what());
|
||||
Error(log, "Dummy device used, because configured device '%s' throws error '%s'", QSTRING_CSTR(type), e.what());
|
||||
const QJsonObject dummyDeviceConfig;
|
||||
device = LedDeviceFile::construct(QJsonObject());
|
||||
}
|
||||
|
Reference in New Issue
Block a user