more work
This commit is contained in:
parent
294cff0fb3
commit
93c91d71bd
57
guh-control/basicconfiguration.cpp
Normal file
57
guh-control/basicconfiguration.cpp
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#include "basicconfiguration.h"
|
||||||
|
|
||||||
|
#include "jsonrpc/jsonrpcclient.h"
|
||||||
|
|
||||||
|
BasicConfiguration::BasicConfiguration(JsonRpcClient* client, QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_client(client)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BasicConfiguration::debugServerEnabled() const
|
||||||
|
{
|
||||||
|
return m_debugServerEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicConfiguration::setDebugServerEnabled(bool debugServerEnabled)
|
||||||
|
{
|
||||||
|
QVariantMap params;
|
||||||
|
params.insert("enabled", debugServerEnabled);
|
||||||
|
m_client->sendCommand("Configuration.SetDebugServerEnabled", params, this, "setDebugServerEnabledResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString BasicConfiguration::serverName() const
|
||||||
|
{
|
||||||
|
return m_serverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicConfiguration::setServerName(const QString &serverName)
|
||||||
|
{
|
||||||
|
QVariantMap params;
|
||||||
|
params.insert("serverName", serverName);
|
||||||
|
m_client->sendCommand("Configuration.SetServerName", params, this, "setServerNameResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicConfiguration::init()
|
||||||
|
{
|
||||||
|
m_client->sendCommand("Configuration.GetConfigurations", this, "getConfigurationsResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicConfiguration::getConfigurationsResponse(const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
qDebug() << "have config reply" << params;
|
||||||
|
QVariantMap basicConfig = params.value("params").toMap().value("basicConfiguration").toMap();
|
||||||
|
m_debugServerEnabled = basicConfig.value("debugServerEnabled").toBool();
|
||||||
|
m_serverName = basicConfig.value("serverName").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicConfiguration::setDebugServerEnabledResponse(const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
qDebug() << "Debug server set:" << params;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BasicConfiguration::setServerNameResponse(const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
qDebug() << "Server name set:" << params;
|
||||||
|
}
|
||||||
39
guh-control/basicconfiguration.h
Normal file
39
guh-control/basicconfiguration.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef BASICCONFIGURATION_H
|
||||||
|
#define BASICCONFIGURATION_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class JsonRpcClient;
|
||||||
|
|
||||||
|
class BasicConfiguration : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool debugServerEnabled READ debugServerEnabled WRITE setDebugServerEnabled NOTIFY debugServerEnabledChanged)
|
||||||
|
Q_PROPERTY(QString serverName READ serverName WRITE setServerName NOTIFY serverNameChanged)
|
||||||
|
public:
|
||||||
|
explicit BasicConfiguration(JsonRpcClient* client, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
bool debugServerEnabled() const;
|
||||||
|
void setDebugServerEnabled(bool debugServerEnabled);
|
||||||
|
|
||||||
|
QString serverName() const;
|
||||||
|
void setServerName(const QString &serverName);
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_INVOKABLE void getConfigurationsResponse(const QVariantMap ¶ms);
|
||||||
|
Q_INVOKABLE void setDebugServerEnabledResponse(const QVariantMap ¶ms);
|
||||||
|
Q_INVOKABLE void setServerNameResponse(const QVariantMap ¶ms);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void debugServerEnabledChanged();
|
||||||
|
void serverNameChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
JsonRpcClient* m_client = nullptr;
|
||||||
|
bool m_debugServerEnabled = false;
|
||||||
|
QString m_serverName;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BASICCONFIGURATION_H
|
||||||
@ -151,6 +151,35 @@ void DeviceManager::getPluginsResponse(const QVariantMap ¶ms)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_jsonClient->sendCommand("Devices.GetSupportedVendors", this, "getVendorsResponse");
|
m_jsonClient->sendCommand("Devices.GetSupportedVendors", this, "getVendorsResponse");
|
||||||
|
|
||||||
|
if (m_plugins->count() > 0) {
|
||||||
|
m_currentGetConfigIndex = 0;
|
||||||
|
QVariantMap configRequestParams;
|
||||||
|
configRequestParams.insert("pluginId", m_plugins->get(m_currentGetConfigIndex)->pluginId());
|
||||||
|
m_jsonClient->sendCommand("Devices.GetPluginConfiguration", configRequestParams, this, "getPluginConfigResponse");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceManager::getPluginConfigResponse(const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
qDebug() << "plugin config response" << params;
|
||||||
|
Plugin *p = m_plugins->get(m_currentGetConfigIndex);
|
||||||
|
if (!p) {
|
||||||
|
qDebug() << "Received a plugin config for a plugin we don't know";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QVariantList pluginParams = params.value("params").toMap().value("configuration").toList();
|
||||||
|
foreach (const QVariant ¶mVariant, pluginParams) {
|
||||||
|
Param* param = JsonTypes::unpackParam(paramVariant.toMap(), p->params());
|
||||||
|
p->params()->addParam(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentGetConfigIndex++;
|
||||||
|
if (m_plugins->count() > m_currentGetConfigIndex) {
|
||||||
|
QVariantMap configRequestParams;
|
||||||
|
configRequestParams.insert("pluginId", m_plugins->get(m_currentGetConfigIndex)->pluginId());
|
||||||
|
m_jsonClient->sendCommand("Devices.GetPluginConfiguration", configRequestParams, this, "getPluginConfigResponse");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::getConfiguredDevicesResponse(const QVariantMap ¶ms)
|
void DeviceManager::getConfiguredDevicesResponse(const QVariantMap ¶ms)
|
||||||
@ -221,6 +250,29 @@ void DeviceManager::confirmPairingResponse(const QVariantMap ¶ms)
|
|||||||
emit confirmPairingReply(params.value("params").toMap());
|
emit confirmPairingReply(params.value("params").toMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceManager::setPluginConfigResponse(const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
qDebug() << "set plugin config respionse" << params;
|
||||||
|
emit savePluginConfigReply(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceManager::savePluginConfig(const QUuid &pluginId)
|
||||||
|
{
|
||||||
|
Plugin *p = m_plugins->getPlugin(pluginId);
|
||||||
|
if (!p) {
|
||||||
|
qWarning()<< "Error: can't find plugin with id" << pluginId;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QVariantMap params;
|
||||||
|
params.insert("pluginId", pluginId);
|
||||||
|
QVariantList pluginParams;
|
||||||
|
for (int i = 0; i < p->params()->rowCount(); i++) {
|
||||||
|
pluginParams.append(JsonTypes::packParam(p->params()->get(i)));
|
||||||
|
}
|
||||||
|
params.insert("configuration", pluginParams);
|
||||||
|
m_jsonClient->sendCommand("Devices.SetPluginConfiguration", params, this, "setPluginConfigResponse");
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceManager::addDiscoveredDevice(const QUuid &deviceClassId, const QUuid &deviceDescriptorId, const QString &name)
|
void DeviceManager::addDiscoveredDevice(const QUuid &deviceClassId, const QUuid &deviceDescriptorId, const QString &name)
|
||||||
{
|
{
|
||||||
qDebug() << "JsonRpc: add discovered device " << deviceClassId.toString();
|
qDebug() << "JsonRpc: add discovered device " << deviceClassId.toString();
|
||||||
|
|||||||
@ -63,17 +63,23 @@ private:
|
|||||||
Q_INVOKABLE void getVendorsResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void getVendorsResponse(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void getSupportedDevicesResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void getSupportedDevicesResponse(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void getPluginsResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void getPluginsResponse(const QVariantMap ¶ms);
|
||||||
|
Q_INVOKABLE void getPluginConfigResponse(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void getConfiguredDevicesResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void getConfiguredDevicesResponse(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void addDeviceResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void addDeviceResponse(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void removeDeviceResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void removeDeviceResponse(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void pairDeviceResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void pairDeviceResponse(const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void confirmPairingResponse(const QVariantMap ¶ms);
|
Q_INVOKABLE void confirmPairingResponse(const QVariantMap ¶ms);
|
||||||
|
Q_INVOKABLE void setPluginConfigResponse(const QVariantMap ¶ms);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void savePluginConfig(const QUuid &pluginId);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pairDeviceReply(const QVariantMap ¶ms);
|
void pairDeviceReply(const QVariantMap ¶ms);
|
||||||
void confirmPairingReply(const QVariantMap ¶ms);
|
void confirmPairingReply(const QVariantMap ¶ms);
|
||||||
void addDeviceReply(const QVariantMap ¶ms);
|
void addDeviceReply(const QVariantMap ¶ms);
|
||||||
void removeDeviceReply(const QVariantMap ¶ms);
|
void removeDeviceReply(const QVariantMap ¶ms);
|
||||||
|
void savePluginConfigReply(const QVariantMap ¶ms);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vendors *m_vendors;
|
Vendors *m_vendors;
|
||||||
@ -81,6 +87,8 @@ private:
|
|||||||
Devices *m_devices;
|
Devices *m_devices;
|
||||||
DeviceClasses *m_deviceClasses;
|
DeviceClasses *m_deviceClasses;
|
||||||
|
|
||||||
|
int m_currentGetConfigIndex = 0;
|
||||||
|
|
||||||
JsonRpcClient *m_jsonClient = nullptr;
|
JsonRpcClient *m_jsonClient = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
#include "tcpsocketinterface.h"
|
#include "tcpsocketinterface.h"
|
||||||
#include "rulemanager.h"
|
#include "rulemanager.h"
|
||||||
#include "logmanager.h"
|
#include "logmanager.h"
|
||||||
|
#include "basicconfiguration.h"
|
||||||
|
|
||||||
Engine* Engine::s_instance = 0;
|
Engine* Engine::s_instance = 0;
|
||||||
|
|
||||||
@ -62,6 +63,11 @@ LogManager *Engine::logManager() const
|
|||||||
return m_logManager;
|
return m_logManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BasicConfiguration *Engine::basicConfiguration() const
|
||||||
|
{
|
||||||
|
return m_basicConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
GuhConnection *Engine::connection() const
|
GuhConnection *Engine::connection() const
|
||||||
{
|
{
|
||||||
return m_connection;
|
return m_connection;
|
||||||
@ -73,7 +79,8 @@ Engine::Engine(QObject *parent) :
|
|||||||
m_jsonRpcClient(new JsonRpcClient(m_connection, this)),
|
m_jsonRpcClient(new JsonRpcClient(m_connection, this)),
|
||||||
m_deviceManager(new DeviceManager(m_jsonRpcClient, this)),
|
m_deviceManager(new DeviceManager(m_jsonRpcClient, this)),
|
||||||
m_ruleManager(new RuleManager(m_jsonRpcClient, this)),
|
m_ruleManager(new RuleManager(m_jsonRpcClient, this)),
|
||||||
m_logManager(new LogManager(m_jsonRpcClient, this))
|
m_logManager(new LogManager(m_jsonRpcClient, this)),
|
||||||
|
m_basicConfiguration(new BasicConfiguration(m_jsonRpcClient, this))
|
||||||
{
|
{
|
||||||
connect(m_jsonRpcClient, &JsonRpcClient::connectedChanged, this, &Engine::onConnectedChanged);
|
connect(m_jsonRpcClient, &JsonRpcClient::connectedChanged, this, &Engine::onConnectedChanged);
|
||||||
connect(m_jsonRpcClient, &JsonRpcClient::authenticationRequiredChanged, this, &Engine::onConnectedChanged);
|
connect(m_jsonRpcClient, &JsonRpcClient::authenticationRequiredChanged, this, &Engine::onConnectedChanged);
|
||||||
@ -88,6 +95,7 @@ void Engine::onConnectedChanged()
|
|||||||
if (!m_jsonRpcClient->initialSetupRequired() && !m_jsonRpcClient->authenticationRequired()) {
|
if (!m_jsonRpcClient->initialSetupRequired() && !m_jsonRpcClient->authenticationRequired()) {
|
||||||
m_deviceManager->init();
|
m_deviceManager->init();
|
||||||
m_ruleManager->init();
|
m_ruleManager->init();
|
||||||
|
m_basicConfiguration->init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,14 +31,16 @@
|
|||||||
|
|
||||||
class RuleManager;
|
class RuleManager;
|
||||||
class LogManager;
|
class LogManager;
|
||||||
|
class BasicConfiguration;
|
||||||
|
|
||||||
class Engine : public QObject
|
class Engine : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(GuhConnection *connection READ connection CONSTANT)
|
Q_PROPERTY(GuhConnection* connection READ connection CONSTANT)
|
||||||
Q_PROPERTY(DeviceManager *deviceManager READ deviceManager CONSTANT)
|
Q_PROPERTY(DeviceManager* deviceManager READ deviceManager CONSTANT)
|
||||||
Q_PROPERTY(RuleManager *ruleManager READ ruleManager CONSTANT)
|
Q_PROPERTY(RuleManager* ruleManager READ ruleManager CONSTANT)
|
||||||
Q_PROPERTY(JsonRpcClient *jsonRpcClient READ jsonRpcClient CONSTANT)
|
Q_PROPERTY(JsonRpcClient* jsonRpcClient READ jsonRpcClient CONSTANT)
|
||||||
|
Q_PROPERTY(BasicConfiguration* basicConfiguration READ basicConfiguration CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Engine *instance();
|
static Engine *instance();
|
||||||
@ -52,6 +54,7 @@ public:
|
|||||||
RuleManager *ruleManager() const;
|
RuleManager *ruleManager() const;
|
||||||
JsonRpcClient *jsonRpcClient() const;
|
JsonRpcClient *jsonRpcClient() const;
|
||||||
LogManager *logManager() const;
|
LogManager *logManager() const;
|
||||||
|
BasicConfiguration* basicConfiguration() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Engine(QObject *parent = 0);
|
explicit Engine(QObject *parent = 0);
|
||||||
@ -62,6 +65,7 @@ private:
|
|||||||
DeviceManager *m_deviceManager;
|
DeviceManager *m_deviceManager;
|
||||||
RuleManager *m_ruleManager;
|
RuleManager *m_ruleManager;
|
||||||
LogManager *m_logManager;
|
LogManager *m_logManager;
|
||||||
|
BasicConfiguration *m_basicConfiguration;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onConnectedChanged();
|
void onConnectedChanged();
|
||||||
|
|||||||
@ -36,7 +36,8 @@ HEADERS += engine.h \
|
|||||||
models/logsmodel.h \
|
models/logsmodel.h \
|
||||||
models/valuelogsproxymodel.h \
|
models/valuelogsproxymodel.h \
|
||||||
discovery/guhdiscovery.h \
|
discovery/guhdiscovery.h \
|
||||||
logmanager.h
|
logmanager.h \
|
||||||
|
basicconfiguration.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
@ -68,7 +69,8 @@ SOURCES += main.cpp \
|
|||||||
models/logsmodel.cpp \
|
models/logsmodel.cpp \
|
||||||
models/valuelogsproxymodel.cpp \
|
models/valuelogsproxymodel.cpp \
|
||||||
discovery/guhdiscovery.cpp \
|
discovery/guhdiscovery.cpp \
|
||||||
logmanager.cpp
|
logmanager.cpp \
|
||||||
|
basicconfiguration.cpp
|
||||||
|
|
||||||
withavahi {
|
withavahi {
|
||||||
DEFINES += WITH_AVAHI
|
DEFINES += WITH_AVAHI
|
||||||
|
|||||||
@ -254,7 +254,7 @@ QVariantMap JsonTypes::packRule(Rule *rule)
|
|||||||
QVariantList paramDescriptors;
|
QVariantList paramDescriptors;
|
||||||
for (int j = 0; j < rule->eventDescriptors()->get(i)->paramDescriptors()->rowCount(); j++) {
|
for (int j = 0; j < rule->eventDescriptors()->get(i)->paramDescriptors()->rowCount(); j++) {
|
||||||
QVariantMap paramDescriptor;
|
QVariantMap paramDescriptor;
|
||||||
paramDescriptor.insert("paramTypeId", rule->eventDescriptors()->get(i)->paramDescriptors()->get(j)->id());
|
paramDescriptor.insert("paramTypeId", rule->eventDescriptors()->get(i)->paramDescriptors()->get(j)->paramTypeId());
|
||||||
paramDescriptor.insert("value", rule->eventDescriptors()->get(i)->paramDescriptors()->get(j)->value());
|
paramDescriptor.insert("value", rule->eventDescriptors()->get(i)->paramDescriptors()->get(j)->value());
|
||||||
QMetaEnum operatorEnum = QMetaEnum::fromType<ParamDescriptor::ValueOperator>();
|
QMetaEnum operatorEnum = QMetaEnum::fromType<ParamDescriptor::ValueOperator>();
|
||||||
paramDescriptor.insert("operator", operatorEnum.valueToKey(rule->eventDescriptors()->get(i)->paramDescriptors()->get(j)->operatorType()));
|
paramDescriptor.insert("operator", operatorEnum.valueToKey(rule->eventDescriptors()->get(i)->paramDescriptors()->get(j)->operatorType()));
|
||||||
@ -270,6 +270,14 @@ QVariantMap JsonTypes::packRule(Rule *rule)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap JsonTypes::packParam(Param *param)
|
||||||
|
{
|
||||||
|
QVariantMap ret;
|
||||||
|
ret.insert("paramTypeId", param->paramTypeId());
|
||||||
|
ret.insert("value", param->value());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
DeviceClass::SetupMethod JsonTypes::stringToSetupMethod(const QString &setupMethodString)
|
DeviceClass::SetupMethod JsonTypes::stringToSetupMethod(const QString &setupMethodString)
|
||||||
{
|
{
|
||||||
if (setupMethodString == "SetupMethodJustAdd") {
|
if (setupMethodString == "SetupMethodJustAdd") {
|
||||||
|
|||||||
@ -56,6 +56,7 @@ public:
|
|||||||
static Device *unpackDevice(const QVariantMap &deviceMap, QObject *parent);
|
static Device *unpackDevice(const QVariantMap &deviceMap, QObject *parent);
|
||||||
|
|
||||||
static QVariantMap packRule(Rule* rule);
|
static QVariantMap packRule(Rule* rule);
|
||||||
|
static QVariantMap packParam(Param *param);
|
||||||
private:
|
private:
|
||||||
static DeviceClass::SetupMethod stringToSetupMethod(const QString &setupMethodString);
|
static DeviceClass::SetupMethod stringToSetupMethod(const QString &setupMethodString);
|
||||||
static QList<DeviceClass::BasicTag> stringListToBasicTags(const QStringList &basicTagsStringList);
|
static QList<DeviceClass::BasicTag> stringListToBasicTags(const QStringList &basicTagsStringList);
|
||||||
|
|||||||
@ -44,6 +44,7 @@
|
|||||||
#include "types/rule.h"
|
#include "types/rule.h"
|
||||||
#include "models/logsmodel.h"
|
#include "models/logsmodel.h"
|
||||||
#include "models/valuelogsproxymodel.h"
|
#include "models/valuelogsproxymodel.h"
|
||||||
|
#include "basicconfiguration.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -105,6 +106,7 @@ int main(int argc, char *argv[])
|
|||||||
qmlRegisterUncreatableType<EventDescriptor>(uri, 1, 0, "EventDescriptor", "Get them from rules");
|
qmlRegisterUncreatableType<EventDescriptor>(uri, 1, 0, "EventDescriptor", "Get them from rules");
|
||||||
qmlRegisterUncreatableType<ParamTypes>(uri, 1, 0, "ParamTypes", "Uncreatable");
|
qmlRegisterUncreatableType<ParamTypes>(uri, 1, 0, "ParamTypes", "Uncreatable");
|
||||||
qmlRegisterUncreatableType<ParamType>(uri, 1, 0, "ParamType", "Uncreatable");
|
qmlRegisterUncreatableType<ParamType>(uri, 1, 0, "ParamType", "Uncreatable");
|
||||||
|
qmlRegisterType<Param>(uri, 1, 0, "Param");
|
||||||
qmlRegisterUncreatableType<ParamDescriptor>(uri, 1, 0, "ParamDescriptor", "Uncreatable");
|
qmlRegisterUncreatableType<ParamDescriptor>(uri, 1, 0, "ParamDescriptor", "Uncreatable");
|
||||||
qmlRegisterUncreatableType<ParamDescriptors>(uri, 1, 0, "ParamDescriptors", "Uncreatable");
|
qmlRegisterUncreatableType<ParamDescriptors>(uri, 1, 0, "ParamDescriptors", "Uncreatable");
|
||||||
|
|
||||||
@ -112,6 +114,8 @@ int main(int argc, char *argv[])
|
|||||||
qmlRegisterUncreatableType<Plugins>(uri, 1, 0, "Plugins", "Can't create this in QML. Get it from the DeviceManager.");
|
qmlRegisterUncreatableType<Plugins>(uri, 1, 0, "Plugins", "Can't create this in QML. Get it from the DeviceManager.");
|
||||||
qmlRegisterType<PluginsProxy>(uri, 1, 0, "PluginsProxy");
|
qmlRegisterType<PluginsProxy>(uri, 1, 0, "PluginsProxy");
|
||||||
|
|
||||||
|
qmlRegisterUncreatableType<BasicConfiguration>(uri, 1, 0, "BasicConfiguration", "Uncreatable");
|
||||||
|
|
||||||
qmlRegisterType<GuhDiscovery>(uri, 1, 0, "GuhDiscovery");
|
qmlRegisterType<GuhDiscovery>(uri, 1, 0, "GuhDiscovery");
|
||||||
qmlRegisterUncreatableType<DiscoveryModel>(uri, 1, 0, "DiscoveryModel", "Get it from GuhDiscovery");
|
qmlRegisterUncreatableType<DiscoveryModel>(uri, 1, 0, "DiscoveryModel", "Get it from GuhDiscovery");
|
||||||
|
|
||||||
|
|||||||
@ -15,6 +15,7 @@ bool LogsModel::busy() const
|
|||||||
|
|
||||||
int LogsModel::rowCount(const QModelIndex &parent) const
|
int LogsModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(parent)
|
||||||
return m_list.count();
|
return m_list.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +175,6 @@ void LogsModel::logsReply(const QVariantMap &data)
|
|||||||
LogEntry::LoggingEventType loggingEventType = (LogEntry::LoggingEventType)loggingEventTypeEnum.keyToValue(entryMap.value("eventType").toByteArray());
|
LogEntry::LoggingEventType loggingEventType = (LogEntry::LoggingEventType)loggingEventTypeEnum.keyToValue(entryMap.value("eventType").toByteArray());
|
||||||
LogEntry *entry = new LogEntry(timeStamp, value, deviceId, typeId, loggingSource, loggingEventType, this);
|
LogEntry *entry = new LogEntry(timeStamp, value, deviceId, typeId, loggingSource, loggingEventType, this);
|
||||||
m_list.append(entry);
|
m_list.append(entry);
|
||||||
qDebug() << "Added log entry" << entry->dayString() << entry->value() << entry->deviceId() << entryMap << loggingEventType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
@ -199,7 +199,6 @@ void LogsModel::newLogEntryReceived(const QVariantMap &data)
|
|||||||
LogEntry::LoggingEventType loggingEventType = (LogEntry::LoggingEventType)loggingEventTypeEnum.keyToValue(entryMap.value("eventType").toByteArray());
|
LogEntry::LoggingEventType loggingEventType = (LogEntry::LoggingEventType)loggingEventTypeEnum.keyToValue(entryMap.value("eventType").toByteArray());
|
||||||
LogEntry *entry = new LogEntry(timeStamp, value, deviceId, typeId, loggingSource, loggingEventType, this);
|
LogEntry *entry = new LogEntry(timeStamp, value, deviceId, typeId, loggingSource, loggingEventType, this);
|
||||||
m_list.append(entry);
|
m_list.append(entry);
|
||||||
qDebug() << "Added log entry" << entry->dayString() << entry->value() << entry->deviceId() << entryMap << loggingEventType;
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
emit countChanged();
|
emit countChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,6 @@
|
|||||||
<file>ui/images/torch-on.svg</file>
|
<file>ui/images/torch-on.svg</file>
|
||||||
<file>ui/images/media-preview-start.svg</file>
|
<file>ui/images/media-preview-start.svg</file>
|
||||||
<file>ui/MagicPage.qml</file>
|
<file>ui/MagicPage.qml</file>
|
||||||
<file>ui/magic/NewRulePage.qml</file>
|
|
||||||
<file>ui/images/mediaplayer-app-symbolic.svg</file>
|
<file>ui/images/mediaplayer-app-symbolic.svg</file>
|
||||||
<file>ui/images/system-shutdown.svg</file>
|
<file>ui/images/system-shutdown.svg</file>
|
||||||
<file>ui/devicepages/ButtonDevicePage.qml</file>
|
<file>ui/devicepages/ButtonDevicePage.qml</file>
|
||||||
@ -121,5 +120,9 @@
|
|||||||
<file>ui/system/LogViewerPage.qml</file>
|
<file>ui/system/LogViewerPage.qml</file>
|
||||||
<file>ui/images/next.svg</file>
|
<file>ui/images/next.svg</file>
|
||||||
<file>ui/images/go-down.svg</file>
|
<file>ui/images/go-down.svg</file>
|
||||||
|
<file>ui/system/PluginsPage.qml</file>
|
||||||
|
<file>ui/system/PluginParamsPage.qml</file>
|
||||||
|
<file>ui/paramdelegates-ng/ParamDelegate.qml</file>
|
||||||
|
<file>ui/components/ErrorDialog.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@ -74,7 +74,7 @@ void RuleManager::editRule(Rule *rule)
|
|||||||
|
|
||||||
void RuleManager::handleRulesNotification(const QVariantMap ¶ms)
|
void RuleManager::handleRulesNotification(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
qDebug() << "rules notification received" << params;
|
// qDebug() << "rules notification received" << params;
|
||||||
if (params.value("notification").toString() == "Rules.RuleAdded") {
|
if (params.value("notification").toString() == "Rules.RuleAdded") {
|
||||||
QVariantMap ruleMap = params.value("params").toMap().value("rule").toMap();
|
QVariantMap ruleMap = params.value("params").toMap().value("rule").toMap();
|
||||||
QUuid ruleId = ruleMap.value("id").toUuid();
|
QUuid ruleId = ruleMap.value("id").toUuid();
|
||||||
@ -94,6 +94,8 @@ void RuleManager::handleRulesNotification(const QVariantMap ¶ms)
|
|||||||
} else if (params.value("notification").toString() == "Rules.RuleRemoved") {
|
} else if (params.value("notification").toString() == "Rules.RuleRemoved") {
|
||||||
QUuid ruleId = params.value("params").toMap().value("ruleId").toUuid();
|
QUuid ruleId = params.value("params").toMap().value("ruleId").toUuid();
|
||||||
m_rules->remove(ruleId);
|
m_rules->remove(ruleId);
|
||||||
|
} else {
|
||||||
|
qWarning() << "Unhandled rule notification" << params;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +148,7 @@ void RuleManager::removeRuleReply(const QVariantMap ¶ms)
|
|||||||
|
|
||||||
void RuleManager::onEditRuleReply(const QVariantMap ¶ms)
|
void RuleManager::onEditRuleReply(const QVariantMap ¶ms)
|
||||||
{
|
{
|
||||||
qDebug() << "Edit rule reply:" << params.value("params").toMap();
|
qDebug() << "Edit rule reply:" << params.value("params").toMap().value("ruleError").toString();
|
||||||
emit editRuleReply(params.value("params").toMap().value("ruleError").toString());
|
emit editRuleReply(params.value("params").toMap().value("ruleError").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ Page {
|
|||||||
MenuSeparator {}
|
MenuSeparator {}
|
||||||
IconMenuItem {
|
IconMenuItem {
|
||||||
iconSource: "../images/settings.svg"
|
iconSource: "../images/settings.svg"
|
||||||
text: "App settings"
|
text: "Settings"
|
||||||
onTriggered: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
onTriggered: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
||||||
}
|
}
|
||||||
MenuSeparator {}
|
MenuSeparator {}
|
||||||
@ -50,13 +50,13 @@ Page {
|
|||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: app.margins
|
|
||||||
|
|
||||||
SwipeView {
|
SwipeView {
|
||||||
id: swipeView
|
id: swipeView
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
currentIndex: pageIndicator.currentIndex
|
currentIndex: pageIndicator.currentIndex
|
||||||
|
clip: true
|
||||||
|
|
||||||
DevicesPage {
|
DevicesPage {
|
||||||
width: parent.view.width
|
width: parent.view.width
|
||||||
|
|||||||
@ -14,74 +14,141 @@ Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors { left: parent.left; right: parent.right; top: parent.top; margins: app.margins }
|
anchors { left: parent.left; right: parent.right; top: parent.top }
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.margins: app.margins
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: "Application".toUpperCase()
|
||||||
|
color: app.guhAccent
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: "View mode"
|
||||||
|
}
|
||||||
|
ComboBox {
|
||||||
|
model: ["Windowed", "Maximized", "Fullscreen"]
|
||||||
|
currentIndex: {
|
||||||
|
switch (settings.viewMode) {
|
||||||
|
case ApplicationWindow.Windowed:
|
||||||
|
return 0;
|
||||||
|
case ApplicationWindow.Maximized:
|
||||||
|
return 1;
|
||||||
|
case ApplicationWindow.FullScreen:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onCurrentIndexChanged: {
|
||||||
|
switch (currentIndex) {
|
||||||
|
case 0:
|
||||||
|
settings.viewMode = ApplicationWindow.Windowed;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
settings.viewMode = ApplicationWindow.Maximized;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
settings.viewMode = ApplicationWindow.FullScreen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: "Return to home on idle"
|
||||||
|
}
|
||||||
|
CheckBox {
|
||||||
|
checked: settings.returnToHome
|
||||||
|
onClicked: settings.returnToHome = checked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: "Graph style"
|
||||||
|
}
|
||||||
|
RadioButton {
|
||||||
|
checked: settings.graphStyle === "bars"
|
||||||
|
text: "Bars"
|
||||||
|
onClicked: settings.graphStyle = "bars"
|
||||||
|
}
|
||||||
|
RadioButton {
|
||||||
|
checked: settings.graphStyle === "bezier"
|
||||||
|
text: "Lines"
|
||||||
|
onClicked: settings.graphStyle = "bezier"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ThinDivider {}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: "Application".toUpperCase()
|
Layout.leftMargin: app.margins
|
||||||
|
Layout.rightMargin: app.margins
|
||||||
|
Layout.topMargin: app.margins
|
||||||
|
text: "System".toUpperCase()
|
||||||
color: app.guhAccent
|
color: app.guhAccent
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.leftMargin: app.margins
|
||||||
|
Layout.rightMargin: app.margins
|
||||||
|
spacing: app.margins
|
||||||
Label {
|
Label {
|
||||||
|
text: qsTr("Debug server enabled")
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: "View mode"
|
|
||||||
}
|
}
|
||||||
ComboBox {
|
Switch {
|
||||||
model: ["Windowed", "Maximized", "Fullscreen"]
|
checked: Engine.basicConfiguration.debugServerEnabled
|
||||||
currentIndex: {
|
onClicked: Engine.basicConfiguration.debugServerEnabled = checked
|
||||||
switch (settings.viewMode) {
|
}
|
||||||
case ApplicationWindow.Windowed:
|
}
|
||||||
return 0;
|
|
||||||
case ApplicationWindow.Maximized:
|
|
||||||
return 1;
|
|
||||||
case ApplicationWindow.FullScreen:
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onCurrentIndexChanged: {
|
RowLayout {
|
||||||
switch (currentIndex) {
|
Layout.fillWidth: true
|
||||||
case 0:
|
Layout.leftMargin: app.margins
|
||||||
settings.viewMode = ApplicationWindow.Windowed;
|
Layout.rightMargin: app.margins
|
||||||
break;
|
spacing: app.margins
|
||||||
case 1:
|
Label {
|
||||||
settings.viewMode = ApplicationWindow.Maximized;
|
text: qsTr("Server name")
|
||||||
break;
|
}
|
||||||
case 2:
|
TextField {
|
||||||
settings.viewMode = ApplicationWindow.FullScreen;
|
Layout.fillWidth: true
|
||||||
}
|
text: Engine.basicConfiguration.serverName
|
||||||
|
onAccepted: Engine.basicConfiguration.serverName = text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemDelegate {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
contentItem: RowLayout {
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: "Plugins"
|
||||||
|
}
|
||||||
|
Image {
|
||||||
|
source: "images/next.svg"
|
||||||
|
Layout.preferredHeight: parent.height
|
||||||
|
Layout.preferredWidth: height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
onClicked: {
|
||||||
RowLayout {
|
pageStack.push(Qt.resolvedUrl("system/PluginsPage.qml"))
|
||||||
Layout.fillWidth: true
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: "Return to home on idle"
|
|
||||||
}
|
|
||||||
CheckBox {
|
|
||||||
checked: settings.returnToHome
|
|
||||||
onClicked: settings.returnToHome = checked
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: "Graph style"
|
|
||||||
}
|
|
||||||
RadioButton {
|
|
||||||
checked: settings.graphStyle === "bars"
|
|
||||||
text: "Bars"
|
|
||||||
onClicked: settings.graphStyle = "bars"
|
|
||||||
}
|
|
||||||
RadioButton {
|
|
||||||
checked: settings.graphStyle === "bezier"
|
|
||||||
text: "Lines"
|
|
||||||
onClicked: settings.graphStyle = "bezier"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ ActionDelegateBase {
|
|||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
text: root.actionType ? root.actionType.name : ""
|
text: root.actionType ? root.actionType.displayName : ""
|
||||||
}
|
}
|
||||||
Switch {
|
Switch {
|
||||||
position: root.actionState ? root.actionState : 0
|
position: root.actionState ? root.actionState : 0
|
||||||
|
|||||||
@ -12,7 +12,7 @@ ActionDelegateBase {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: root.actionType.paramTypes.get(0).name
|
text: root.actionType.paramTypes.get(0).displayName
|
||||||
}
|
}
|
||||||
|
|
||||||
Slider {
|
Slider {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ ActionDelegateBase {
|
|||||||
id: layout
|
id: layout
|
||||||
anchors { left: parent.left; top: parent.top; right: parent.right; margins: app.margins }
|
anchors { left: parent.left; top: parent.top; right: parent.right; margins: app.margins }
|
||||||
Label {
|
Label {
|
||||||
text: root.paramType.name
|
text: root.paramType.displayName
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
ComboBox {
|
ComboBox {
|
||||||
|
|||||||
20
guh-control/ui/components/ErrorDialog.qml
Normal file
20
guh-control/ui/components/ErrorDialog.qml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import QtQuick 2.8
|
||||||
|
import QtQuick.Controls 2.1
|
||||||
|
|
||||||
|
Dialog {
|
||||||
|
width: parent.width * .6
|
||||||
|
height: parent.height * .6
|
||||||
|
x: (parent.width - width) / 2
|
||||||
|
y: (parent.height - height) / 2
|
||||||
|
|
||||||
|
title: qsTr("Error")
|
||||||
|
property alias text: contentLabel.text
|
||||||
|
|
||||||
|
standardButtons: Dialog.Ok
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: contentLabel
|
||||||
|
width: parent.width
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -39,8 +39,8 @@ Page {
|
|||||||
page = "ButtonDevicePage.qml";
|
page = "ButtonDevicePage.qml";
|
||||||
} else if (deviceClass.interfaces.indexOf("weather") >= 0) {
|
} else if (deviceClass.interfaces.indexOf("weather") >= 0) {
|
||||||
page = "WeatherDevicePage.qml";
|
page = "WeatherDevicePage.qml";
|
||||||
// } else if (deviceClass.interfaces.indexOf("sensor") >= 0) {
|
} else if (deviceClass.interfaces.indexOf("sensor") >= 0) {
|
||||||
// page = "SensorDevicePage.qml";
|
page = "SensorDevicePage.qml";
|
||||||
} else {
|
} else {
|
||||||
page = "GenericDevicePage.qml";
|
page = "GenericDevicePage.qml";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import QtQuick.Controls 2.1
|
|||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import Guh 1.0
|
import Guh 1.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
import "../paramdelegates-ng"
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
id: root
|
id: root
|
||||||
@ -29,25 +30,24 @@ Page {
|
|||||||
pageStack.pop();
|
pageStack.pop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print("Remove device error!", params)
|
var popup = errorDialog.createObject(root, {text: "Remove device error: " + JSON.stringify(params.deviceError) })
|
||||||
|
popup.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
model: root.device.params
|
model: root.device.params
|
||||||
delegate: ItemDelegate {
|
delegate: ParamDelegate {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
contentItem: RowLayout {
|
paramType: root.deviceClass.paramTypes.getParamType(model.id)
|
||||||
Label {
|
param: root.device.params.get(index)
|
||||||
text: root.deviceClass.paramTypes.getParamType(model.id).displayName
|
writable: false
|
||||||
}
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: model.value
|
|
||||||
horizontalAlignment: Text.AlignRight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: errorDialog
|
||||||
|
ErrorDialog { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,6 +42,11 @@ Page {
|
|||||||
height: app.iconSize
|
height: app.iconSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
text: qsTr("Thing is not connected!")
|
||||||
|
visible: infoPane.connectedState !== null && infoPane.connectedState.value === false
|
||||||
|
}
|
||||||
|
|
||||||
ColorIcon {
|
ColorIcon {
|
||||||
height: app.iconSize
|
height: app.iconSize
|
||||||
width: height
|
width: height
|
||||||
@ -54,6 +59,7 @@ Page {
|
|||||||
height: app.iconSize
|
height: app.iconSize
|
||||||
width: height * 1.23
|
width: height * 1.23
|
||||||
name: infoPane.batteryState !== null ? "../images/battery/battery-" + ("00" + (Math.floor(infoPane.batteryState.value / 10) * 10)).slice(-3) + ".svg" : ""
|
name: infoPane.batteryState !== null ? "../images/battery/battery-" + ("00" + (Math.floor(infoPane.batteryState.value / 10) * 10)).slice(-3) + ".svg" : ""
|
||||||
|
visible: infoPane.batteryState !== null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ DevicePageBase {
|
|||||||
id: interfaceViewsRepeater
|
id: interfaceViewsRepeater
|
||||||
property bool unhandledInterface: false
|
property bool unhandledInterface: false
|
||||||
|
|
||||||
model: deviceClass.interfaces
|
// model: deviceClass.interfaces
|
||||||
delegate: Loader {
|
delegate: Loader {
|
||||||
id: stateViewLoader
|
id: stateViewLoader
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|||||||
@ -10,6 +10,7 @@ Page {
|
|||||||
|
|
||||||
property var device
|
property var device
|
||||||
readonly property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
readonly property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
||||||
|
property bool readOnly: true
|
||||||
|
|
||||||
header: GuhHeader {
|
header: GuhHeader {
|
||||||
text: "Details for " + root.device.name
|
text: "Details for " + root.device.name
|
||||||
@ -43,7 +44,7 @@ Page {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
sourceComponent: {
|
sourceComponent: {
|
||||||
var writable = deviceClass.actionTypes.getActionType(id) !== null;
|
var writable = deviceClass.actionTypes.getActionType(id) !== null;
|
||||||
if (!writable) {
|
if (root.readOnly || !writable) {
|
||||||
return labelComponent;
|
return labelComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,6 +59,8 @@ Page {
|
|||||||
return textFieldComponent;
|
return textFieldComponent;
|
||||||
case "String":
|
case "String":
|
||||||
return textFieldComponent;
|
return textFieldComponent;
|
||||||
|
case "Color":
|
||||||
|
return colorPreviewComponent;
|
||||||
}
|
}
|
||||||
console.warn("DeviceStateDetailsPage: Type delegate not implemented", stateType.type)
|
console.warn("DeviceStateDetailsPage: Type delegate not implemented", stateType.type)
|
||||||
return null;
|
return null;
|
||||||
@ -126,6 +129,18 @@ Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: colorPreviewComponent
|
||||||
|
Rectangle {
|
||||||
|
property var value: "blue"
|
||||||
|
property var stateTypeId: null
|
||||||
|
color: value
|
||||||
|
implicitHeight: app.mediumFont
|
||||||
|
implicitWidth: height
|
||||||
|
radius: height / 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function executeAction(stateTypeId, value) {
|
function executeAction(stateTypeId, value) {
|
||||||
var paramList = []
|
var paramList = []
|
||||||
var muteParam = {}
|
var muteParam = {}
|
||||||
|
|||||||
@ -5,21 +5,8 @@ import Guh 1.0
|
|||||||
import "../components"
|
import "../components"
|
||||||
import "../customviews"
|
import "../customviews"
|
||||||
|
|
||||||
Page {
|
DevicePageBase {
|
||||||
id: root
|
id: root
|
||||||
property var device: null
|
|
||||||
readonly property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
|
|
||||||
|
|
||||||
|
|
||||||
header: GuhHeader {
|
|
||||||
text: device.name
|
|
||||||
onBackPressed: pageStack.pop()
|
|
||||||
|
|
||||||
HeaderButton {
|
|
||||||
imageSource: "../images/info.svg"
|
|
||||||
onClicked: pageStack.push(Qt.resolvedUrl("GenericDeviceStateDetailsPage.qml"), {device: root.device})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
anchors { fill: parent }
|
anchors { fill: parent }
|
||||||
|
|||||||
@ -1,132 +0,0 @@
|
|||||||
import QtQuick 2.8
|
|
||||||
import QtQuick.Layouts 1.3
|
|
||||||
import QtQuick.Controls 2.1
|
|
||||||
import "../components"
|
|
||||||
import Guh 1.0
|
|
||||||
|
|
||||||
Page {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property var rule: null
|
|
||||||
|
|
||||||
StackView {
|
|
||||||
id: internalPageStack
|
|
||||||
anchors.fill: parent
|
|
||||||
initialItem: newRulePage1
|
|
||||||
}
|
|
||||||
|
|
||||||
function addEventDescriptor() {
|
|
||||||
var eventDescriptor = root.rule.eventDescriptors.createNewEventDescriptor();
|
|
||||||
var page = internalPageStack.push(Qt.resolvedUrl("SelectThingPage.qml"));
|
|
||||||
page.onBackPressed.connect(function() { internalPageStack.pop(); });
|
|
||||||
page.onThingSelected.connect(function(device) {
|
|
||||||
eventDescriptor.deviceId = device.id;
|
|
||||||
selectEventDescriptorData(eventDescriptor)
|
|
||||||
})
|
|
||||||
page.onInterfaceSelected.connect(function(interfaceName) {
|
|
||||||
eventDescriptor.interfaceName = interfaceName;
|
|
||||||
selectEventDescriptorData(eventDescriptor)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function selectEventDescriptorData(eventDescriptor) {
|
|
||||||
var eventPage = internalPageStack.push(Qt.resolvedUrl("SelectEventPage.qml"), {text: "Select event", eventDescriptor: eventDescriptor});
|
|
||||||
eventPage.onBackPressed.connect(function() {internalPageStack.pop()})
|
|
||||||
eventPage.onDone.connect(function() {
|
|
||||||
root.rule.eventDescriptors.addEventDescriptor(eventPage.eventDescriptor);
|
|
||||||
internalPageStack.pop(newRulePage1)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function addAction() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Page {
|
|
||||||
id: newRulePage1
|
|
||||||
|
|
||||||
header: GuhHeader {
|
|
||||||
text: "New rule"
|
|
||||||
onBackPressed: pageStack.pop()
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
anchors.fill: parent
|
|
||||||
RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
RadioButton {
|
|
||||||
id: whenButton
|
|
||||||
text: "When"
|
|
||||||
checked: true
|
|
||||||
}
|
|
||||||
RadioButton {
|
|
||||||
id: whileButton
|
|
||||||
text: "While"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
visible: eventsRepeater.count == 0
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: "Add an event which should trigger the execution of the rule"
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: "+"
|
|
||||||
onClicked: root.addEventDescriptor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
id: eventsRepeater
|
|
||||||
model: root.rule.eventDescriptors
|
|
||||||
delegate: ItemDelegate {
|
|
||||||
id: eventDelegate
|
|
||||||
property var device: Engine.deviceManager.devices.getDevice(root.rule.eventDescriptors.get(index).deviceId)
|
|
||||||
property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
|
|
||||||
property var eventType: deviceClass ? deviceClass.eventTypes.getEventType(root.rule.eventDescriptors.get(index).eventTypeId) : null
|
|
||||||
contentItem: ColumnLayout {
|
|
||||||
Label {
|
|
||||||
text: eventDelegate.device ? eventDelegate.device.name : "Unknown device" + root.rule.eventDescriptors.get(index).deviceId
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
Label {
|
|
||||||
text: eventDelegate.eventType ? eventDelegate.eventType.displayName : "Unknown event" + root.rule.eventDescriptors.get(index).eventTypeId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label {
|
|
||||||
text: "do the following:"
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
visible: actionsRepeater.count == 0
|
|
||||||
Label {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
text: "Add action which should be executed when the rule is triggered"
|
|
||||||
}
|
|
||||||
Button {
|
|
||||||
text: "+"
|
|
||||||
onClicked: root.addAction();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater {
|
|
||||||
id: actionsRepeater
|
|
||||||
model: root.rule.actions
|
|
||||||
delegate: ItemDelegate {
|
|
||||||
id: actionDelegate
|
|
||||||
contentItem: ColumnLayout {
|
|
||||||
Label {
|
|
||||||
text: "bla"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,7 +2,7 @@ import QtQuick 2.8
|
|||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../paramdelegates"
|
import "../paramdelegates-ng"
|
||||||
import Guh 1.0
|
import Guh 1.0
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
@ -27,10 +27,8 @@ Page {
|
|||||||
id: delegateRepeater
|
id: delegateRepeater
|
||||||
model: root.actionType.paramTypes
|
model: root.actionType.paramTypes
|
||||||
delegate: ParamDelegate {
|
delegate: ParamDelegate {
|
||||||
width: parent.width
|
Layout.fillWidth: true
|
||||||
paramType: root.actionType.paramTypes.get(index)
|
paramType: root.actionType.paramTypes.get(index)
|
||||||
value: paramType.defaultValue
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item {
|
Item {
|
||||||
|
|||||||
193
guh-control/ui/paramdelegates-ng/ParamDelegate.qml
Normal file
193
guh-control/ui/paramdelegates-ng/ParamDelegate.qml
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
import QtQuick 2.8
|
||||||
|
import QtQuick.Layouts 1.2
|
||||||
|
import QtQuick.Controls 2.1
|
||||||
|
import QtQuick.Controls.Material 2.1
|
||||||
|
import Guh 1.0
|
||||||
|
import "../components"
|
||||||
|
|
||||||
|
ItemDelegate {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property var paramType: null
|
||||||
|
property alias value: d.value
|
||||||
|
property var param: Param {
|
||||||
|
id: d
|
||||||
|
paramTypeId: paramType.id
|
||||||
|
value: paramType.defaultValue
|
||||||
|
}
|
||||||
|
property bool writable: true
|
||||||
|
|
||||||
|
contentItem: ColumnLayout {
|
||||||
|
RowLayout {
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: root.paramType.displayName
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
Loader {
|
||||||
|
id: loader
|
||||||
|
Layout.fillWidth: sourceComponent == textFieldComponent
|
||||||
|
sourceComponent: {
|
||||||
|
if (!root.writable) {
|
||||||
|
return stringComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (root.paramType.type) {
|
||||||
|
case "Bool":
|
||||||
|
return boolComponent;
|
||||||
|
case "Int":
|
||||||
|
return stringComponent;
|
||||||
|
case "String":
|
||||||
|
if (root.paramType.allowedValues.length > 0) {
|
||||||
|
return comboBoxComponent;
|
||||||
|
}
|
||||||
|
return textFieldComponent;
|
||||||
|
case "Color":
|
||||||
|
return colorPreviewComponent;
|
||||||
|
}
|
||||||
|
console.warn("Param Delegate: Fallback to stringComponent", root.paramType.name, root.paramType.type)
|
||||||
|
return stringComponent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loader {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
sourceComponent: {
|
||||||
|
switch (root.paramType.type) {
|
||||||
|
case "Int":
|
||||||
|
case "Double":
|
||||||
|
if (root.paramType.minValue != undefined && root.paramType.maxValue != undefined) {
|
||||||
|
return sliderComponent
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "Color":
|
||||||
|
return colorPickerComponent
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: stringComponent
|
||||||
|
Label {
|
||||||
|
text: {
|
||||||
|
switch (root.paramType.type) {
|
||||||
|
case "Int":
|
||||||
|
return Math.round(root.param.value);
|
||||||
|
}
|
||||||
|
return root.param.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: boolComponent
|
||||||
|
Switch {
|
||||||
|
checked: root.param.value === true
|
||||||
|
onClicked: {
|
||||||
|
root.param.value = checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: sliderComponent
|
||||||
|
RowLayout {
|
||||||
|
spacing: app.margins
|
||||||
|
Label {
|
||||||
|
text: root.paramType.minValue
|
||||||
|
}
|
||||||
|
Slider {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
from: root.paramType.minValue
|
||||||
|
to: root.paramType.maxValue
|
||||||
|
value: root.param.value
|
||||||
|
stepSize: {
|
||||||
|
switch (root.paramType.type) {
|
||||||
|
case "Int":
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0.01;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
onMoved: {
|
||||||
|
root.param.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
text: root.paramType.maxValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: textFieldComponent
|
||||||
|
TextField {
|
||||||
|
text: root.param.value
|
||||||
|
onEditingFinished: {
|
||||||
|
root.param.value = text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: comboBoxComponent
|
||||||
|
ComboBox {
|
||||||
|
model: root.paramType.allowedValues
|
||||||
|
currentIndex: root.paramType.allowedValues.indexOf(root.param.value)
|
||||||
|
onActivated: {
|
||||||
|
root.param.value = root.paramType.allowedValues[index]
|
||||||
|
print("setting value to", root.param.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: colorPickerComponent
|
||||||
|
ColorPicker {
|
||||||
|
id: colorPicker
|
||||||
|
implicitHeight: 200
|
||||||
|
// color: root.param.value
|
||||||
|
|
||||||
|
Binding {
|
||||||
|
target: colorPicker
|
||||||
|
property: "color"
|
||||||
|
value: root.param.value
|
||||||
|
when: !colorPicker.pressed
|
||||||
|
}
|
||||||
|
|
||||||
|
onColorChanged: {
|
||||||
|
root.param.value = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
touchDelegate: Rectangle {
|
||||||
|
height: 15
|
||||||
|
width: height
|
||||||
|
radius: height / 2
|
||||||
|
color: Material.accent
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
color: colorPicker.hovered || colorPicker.pressed ? "#11000000" : "transparent"
|
||||||
|
anchors.centerIn: parent
|
||||||
|
height: 30
|
||||||
|
width: height
|
||||||
|
radius: width / 2
|
||||||
|
Behavior on color { ColorAnimation { duration: 200 } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: colorPreviewComponent
|
||||||
|
Rectangle {
|
||||||
|
implicitHeight: app.mediumFont
|
||||||
|
implicitWidth: implicitHeight
|
||||||
|
color: root.param.value
|
||||||
|
radius: width / 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,19 +2,20 @@ import QtQuick 2.8
|
|||||||
import QtQuick.Layouts 1.2
|
import QtQuick.Layouts 1.2
|
||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
|
|
||||||
RowLayout {
|
ParamDelegateBase {
|
||||||
id: root
|
id: root
|
||||||
|
contentItem: RowLayout {
|
||||||
|
|
||||||
property alias text: label.text
|
Label {
|
||||||
property alias value: theSwitch.checked
|
id: label
|
||||||
|
Layout.fillWidth: true
|
||||||
Label {
|
text: root.paramType.displayName + "- " + root.value
|
||||||
id: label
|
}
|
||||||
Layout.fillWidth: true
|
Switch {
|
||||||
}
|
id: theSwitch
|
||||||
Switch {
|
checked: root.value == true
|
||||||
id: theSwitch
|
onClicked: root.value = checked
|
||||||
checked: root.value === true
|
}
|
||||||
onClicked: root.value = checked
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ ParamDelegateBase {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: label
|
id: label
|
||||||
text: root.paramType.name
|
text: root.paramType.displayName
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
id: textField
|
id: textField
|
||||||
|
|||||||
@ -10,16 +10,16 @@ ParamDelegateBase {
|
|||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: label
|
id: label
|
||||||
text: root.paramType.name
|
text: root.paramType.displayName
|
||||||
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
id: textField
|
id: textField
|
||||||
Layout.fillWidth: true
|
|
||||||
text: root.value ? root.value : root.paramType.defaultValue
|
text: root.value ? root.value : root.paramType.defaultValue
|
||||||
|
Layout.preferredWidth: implicitWidth
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
root.value = text;
|
root.value = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,78 +5,112 @@ import Guh 1.0
|
|||||||
|
|
||||||
ItemDelegate {
|
ItemDelegate {
|
||||||
id: root
|
id: root
|
||||||
height: layout.height
|
|
||||||
|
|
||||||
property var paramType: null
|
property var paramType: null
|
||||||
property var value: null
|
property var value: null
|
||||||
property int operatorType: ParamDescriptors.ValueOperatorEquals
|
property int operatorType: ParamDescriptors.ValueOperatorEquals
|
||||||
|
|
||||||
RowLayout {
|
contentItem: ColumnLayout {
|
||||||
id: layout
|
RowLayout {
|
||||||
anchors { left: parent.left; top: parent.top; right: parent.right}
|
Layout.fillWidth: true
|
||||||
anchors.margins: app.margins
|
spacing: app.margins
|
||||||
spacing: app.margins
|
Label {
|
||||||
Label {
|
text: paramType.displayName
|
||||||
text: paramType.displayName
|
}
|
||||||
}
|
ComboBox {
|
||||||
ComboBox {
|
Layout.fillWidth: true
|
||||||
model: {
|
model: {
|
||||||
switch (paramType.type) {
|
switch (paramType.type) {
|
||||||
case "Bool":
|
case "Bool":
|
||||||
case "String":
|
case "String":
|
||||||
return ["is", "is not"];
|
return ["is", "is not"];
|
||||||
case "Int":
|
case "Int":
|
||||||
case "Double":
|
case "Double":
|
||||||
return ["is", "is not", "is greater", "is smaller", "is greater or equal", "is smaller or equal"]
|
return ["is", "is not", "is greater", "is smaller", "is greater or equal", "is smaller or equal"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onCurrentTextChanged: {
|
||||||
|
switch (currentText) {
|
||||||
|
case "is":
|
||||||
|
root.operatorType = ParamDescriptor.ValueOperatorEquals;
|
||||||
|
break;
|
||||||
|
case "is not":
|
||||||
|
root.operatorType = ParamDescriptor.ValueOperatorNotEquals;
|
||||||
|
break;
|
||||||
|
case "is greater":
|
||||||
|
root.operatorType = ParamDescriptor.ValueOperatorGreater;
|
||||||
|
break;
|
||||||
|
case "is smaller":
|
||||||
|
root.operatorType = ParamDescriptor.ValueOperatorLess;
|
||||||
|
break;
|
||||||
|
case "is greater or equal":
|
||||||
|
root.operatorType = ParamDescriptor.ValueOperatorGreaterOrEqual;
|
||||||
|
break;
|
||||||
|
case "is smaller or equal":
|
||||||
|
root.operatorType = ParamDescriptor.ValueOperatorLessOrEqual;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
print("set operator to", root.operatorType, currentText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onCurrentTextChanged: {
|
|
||||||
switch (currentText) {
|
|
||||||
case "is":
|
Loader {
|
||||||
root.operatorType = ParamDescriptor.ValueOperatorEquals;
|
id: placeHolder
|
||||||
break;
|
Layout.fillWidth: true
|
||||||
case "is not":
|
|
||||||
root.operatorType = ParamDescriptor.ValueOperatorNotEquals;
|
sourceComponent: {
|
||||||
break;
|
print("Datatye is:", paramType.type, paramType.minValue, paramType.maxValue)
|
||||||
case "is greater":
|
switch (paramType.type) {
|
||||||
root.operatorType = ParamDescriptor.ValueOperatorGreater;
|
case "Bool":
|
||||||
break;
|
return boolComponent;
|
||||||
case "is smaller":
|
case "Int":
|
||||||
root.operatorType = ParamDescriptor.ValueOperatorLess;
|
case "Double":
|
||||||
break;
|
if (paramType.minValue !== undefined && paramType.maxValue !== undefined) {
|
||||||
case "is greater or equal":
|
return labelComponent;
|
||||||
root.operatorType = ParamDescriptor.ValueOperatorGreaterOrEqual;
|
}
|
||||||
break;
|
return textFieldComponent;
|
||||||
case "is smaller or equal":
|
case "String":
|
||||||
root.operatorType = ParamDescriptor.ValueOperatorLessOrEqual;
|
if (paramType.allowedValues.length > 0) {
|
||||||
break;
|
return comboBoxComponent
|
||||||
|
}
|
||||||
|
return textFieldComponent;
|
||||||
|
}
|
||||||
|
console.warn("ParamDescriptorDelegate: Type delegate not implemented", paramType.type)
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
print("set operator to", root.operatorType, currentText)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: placeHolder
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
sourceComponent: {
|
sourceComponent: {
|
||||||
print("Datatye is:", paramType.type, paramType.minValue, paramType.maxValue)
|
|
||||||
switch (paramType.type) {
|
switch (paramType.type) {
|
||||||
case "Bool":
|
|
||||||
return boolComponent;
|
|
||||||
case "Int":
|
case "Int":
|
||||||
case "Double":
|
case "Double":
|
||||||
if (paramType.minValue !== undefined && paramType.maxValue !== undefined) {
|
if (paramType.minValue !== undefined && paramType.maxValue !== undefined) {
|
||||||
return sliderComponent;
|
return sliderComponent
|
||||||
}
|
}
|
||||||
return textFieldComponent;
|
|
||||||
}
|
}
|
||||||
console.warn("ParamDescriptorDelegate: Type delegate not implemented", paramType.type)
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: labelComponent
|
||||||
|
Label {
|
||||||
|
text: {
|
||||||
|
switch (root.paramType.type) {
|
||||||
|
case "Int":
|
||||||
|
return Math.round(root.value)
|
||||||
|
}
|
||||||
|
return root.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: textFieldComponent
|
id: textFieldComponent
|
||||||
TextField {
|
TextField {
|
||||||
@ -89,13 +123,20 @@ ItemDelegate {
|
|||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: sliderComponent
|
id: sliderComponent
|
||||||
Slider {
|
RowLayout {
|
||||||
from: paramType.minValue
|
spacing: app.margins
|
||||||
to: paramType.maxValue
|
Label { text: root.paramType.minValue }
|
||||||
onMoved: {
|
Slider {
|
||||||
root.value = value;
|
from: paramType.minValue
|
||||||
|
to: paramType.maxValue
|
||||||
|
Layout.fillWidth: true
|
||||||
|
onMoved: {
|
||||||
|
root.value = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Label { text: root.paramType.maxValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
@ -110,4 +151,15 @@ ItemDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: comboBoxComponent
|
||||||
|
ComboBox {
|
||||||
|
model: paramType.allowedValues
|
||||||
|
currentIndex: root.paramType.value
|
||||||
|
onActivated: {
|
||||||
|
root.value = paramType.allowedValues[index]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,10 +49,10 @@ Page {
|
|||||||
clip: true
|
clip: true
|
||||||
headerPositioning: ListView.OverlayHeader
|
headerPositioning: ListView.OverlayHeader
|
||||||
|
|
||||||
property int column0Width: root.width / 10 * 3
|
property int column0Width: root.width / 10 * 2
|
||||||
property int column1Width: root.width / 10 * 1
|
property int column1Width: root.width / 10 * 1
|
||||||
property int column2Width: root.width / 10 * 3
|
property int column2Width: root.width / 10 * 3
|
||||||
property int column3Width: root.width / 10 * 2
|
property int column3Width: root.width / 10 * 3
|
||||||
property int column4Width: root.width / 10 * 1
|
property int column4Width: root.width / 10 * 1
|
||||||
|
|
||||||
header: Rectangle {
|
header: Rectangle {
|
||||||
@ -97,7 +97,7 @@ Page {
|
|||||||
property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
|
property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
|
||||||
Label {
|
Label {
|
||||||
width: listView.column0Width
|
width: listView.column0Width
|
||||||
text: Qt.formatDateTime(model.timestamp,"dd.MM.yy - hh:mm:ss")
|
text: width > 130 ? Qt.formatDateTime(model.timestamp,"dd.MM.yy - hh:mm:ss") : Qt.formatDateTime(model.timestamp,"hh:mm:ss")
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
|
|||||||
63
guh-control/ui/system/PluginParamsPage.qml
Normal file
63
guh-control/ui/system/PluginParamsPage.qml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import QtQuick 2.8
|
||||||
|
import QtQuick.Controls 2.1
|
||||||
|
import QtQuick.Controls.Material 2.1
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import "../components"
|
||||||
|
import "../paramdelegates-ng"
|
||||||
|
import Guh 1.0
|
||||||
|
|
||||||
|
Page {
|
||||||
|
id: root
|
||||||
|
property var plugin: null
|
||||||
|
|
||||||
|
header: GuhHeader {
|
||||||
|
text: qsTr("%1 settings").arg(plugin.name)
|
||||||
|
backButtonVisible: true
|
||||||
|
onBackPressed: pageStack.pop()
|
||||||
|
|
||||||
|
HeaderButton {
|
||||||
|
imageSource: "../images/tick.svg"
|
||||||
|
onClicked: {
|
||||||
|
Engine.deviceManager.savePluginConfig(root.plugin.pluginId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Engine.deviceManager
|
||||||
|
onSavePluginConfigReply: {
|
||||||
|
if (params.params.deviceError == "DeviceErrorNoError") {
|
||||||
|
pageStack.pop();
|
||||||
|
} else {
|
||||||
|
console.warn("Error saving plugin params:", JSON.stringify(params))
|
||||||
|
var dialog = errorDialog.createObject(root, {title: "Error", text: "Error saving params: " + JSON.stringify(params.params.deviceError)});
|
||||||
|
dialog.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Flickable {
|
||||||
|
anchors.fill: parent
|
||||||
|
contentHeight: column.implicitHeight
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: column
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: plugin.paramTypes
|
||||||
|
|
||||||
|
delegate: ParamDelegate {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
paramType: root.plugin.paramTypes.get(index)
|
||||||
|
param: root.plugin.params.getParam(model.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: errorDialog
|
||||||
|
ErrorDialog { }
|
||||||
|
}
|
||||||
|
}
|
||||||
38
guh-control/ui/system/PluginsPage.qml
Normal file
38
guh-control/ui/system/PluginsPage.qml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import QtQuick 2.8
|
||||||
|
import QtQuick.Controls 2.1
|
||||||
|
import QtQuick.Controls.Material 2.1
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import "../components"
|
||||||
|
import Guh 1.0
|
||||||
|
|
||||||
|
Page {
|
||||||
|
id: root
|
||||||
|
header: GuhHeader {
|
||||||
|
text: "Plugins"
|
||||||
|
backButtonVisible: true
|
||||||
|
onBackPressed: pageStack.pop()
|
||||||
|
}
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
anchors.fill: parent
|
||||||
|
model: Engine.deviceManager.plugins
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
delegate: ItemDelegate {
|
||||||
|
width: parent.width
|
||||||
|
contentItem: RowLayout {
|
||||||
|
Label {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: model.name
|
||||||
|
}
|
||||||
|
Image {
|
||||||
|
source: "../images/next.svg"
|
||||||
|
Layout.preferredHeight: parent.height
|
||||||
|
Layout.preferredWidth: height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onClicked: pageStack.push(Qt.resolvedUrl("PluginParamsPage.qml"), {plugin: Engine.deviceManager.plugins.get(index)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -22,22 +22,24 @@
|
|||||||
|
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
|
|
||||||
Param::Param(const QString &id, const QVariant &value, QObject *parent) :
|
Param::Param(const QString ¶mTypeId, const QVariant &value, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_id(id),
|
m_paramTypeId(paramTypeId),
|
||||||
m_value(value)
|
m_value(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Param::id() const
|
QString Param::paramTypeId() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_paramTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Param::setId(const QString &id)
|
void Param::setParamTypeId(const QString ¶mTypeId)
|
||||||
{
|
{
|
||||||
m_id = id;
|
if (m_paramTypeId != paramTypeId) {
|
||||||
emit idChanged();
|
m_paramTypeId = paramTypeId;
|
||||||
|
emit paramTypeIdChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant Param::value() const
|
QVariant Param::value() const
|
||||||
|
|||||||
@ -30,24 +30,24 @@
|
|||||||
class Param : public QObject
|
class Param : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged)
|
Q_PROPERTY(QString paramTypeId READ paramTypeId WRITE setParamTypeId NOTIFY paramTypeIdChanged)
|
||||||
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
|
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Param(const QString &id = QString(), const QVariant &value = QVariant(), QObject *parent = 0);
|
Param(const QString ¶mTypeId = QString(), const QVariant &value = QVariant(), QObject *parent = 0);
|
||||||
|
|
||||||
QString id() const;
|
QString paramTypeId() const;
|
||||||
void setId(const QString &id);
|
void setParamTypeId(const QString ¶mTypeId);
|
||||||
|
|
||||||
QVariant value() const;
|
QVariant value() const;
|
||||||
void setValue(const QVariant &value);
|
void setValue(const QVariant &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_id;
|
QString m_paramTypeId;
|
||||||
QVariant m_value;
|
QVariant m_value;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void idChanged();
|
void paramTypeIdChanged();
|
||||||
void valueChanged();
|
void valueChanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -20,7 +20,7 @@ void ParamDescriptor::setOperatorType(ParamDescriptor::ValueOperator operatorTyp
|
|||||||
|
|
||||||
ParamDescriptor *ParamDescriptor::clone() const
|
ParamDescriptor *ParamDescriptor::clone() const
|
||||||
{
|
{
|
||||||
ParamDescriptor *ret = new ParamDescriptor(this->id(), this->value());
|
ParamDescriptor *ret = new ParamDescriptor(this->paramTypeId(), this->value());
|
||||||
ret->setOperatorType(this->operatorType());
|
ret->setOperatorType(this->operatorType());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ QVariant ParamDescriptors::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case RoleId:
|
case RoleId:
|
||||||
return m_list.at(index.row())->id();
|
return m_list.at(index.row())->paramTypeId();
|
||||||
case RoleValue:
|
case RoleValue:
|
||||||
return m_list.at(index.row())->value();
|
return m_list.at(index.row())->value();
|
||||||
case RoleOperator:
|
case RoleOperator:
|
||||||
@ -56,7 +56,7 @@ void ParamDescriptors::addParamDescriptor(ParamDescriptor *paramDescriptor)
|
|||||||
void ParamDescriptors::setParamDescriptor(const QString ¶mTypeId, const QVariant &value, ValueOperator operatorType)
|
void ParamDescriptors::setParamDescriptor(const QString ¶mTypeId, const QVariant &value, ValueOperator operatorType)
|
||||||
{
|
{
|
||||||
foreach (ParamDescriptor* paramDescriptor, m_list) {
|
foreach (ParamDescriptor* paramDescriptor, m_list) {
|
||||||
if (paramDescriptor->id() == paramTypeId) {
|
if (paramDescriptor->paramTypeId() == paramTypeId) {
|
||||||
paramDescriptor->setValue(value);
|
paramDescriptor->setValue(value);
|
||||||
paramDescriptor->setOperatorType((ParamDescriptor::ValueOperator)operatorType);
|
paramDescriptor->setOperatorType((ParamDescriptor::ValueOperator)operatorType);
|
||||||
return;
|
return;
|
||||||
@ -64,7 +64,7 @@ void ParamDescriptors::setParamDescriptor(const QString ¶mTypeId, const QVar
|
|||||||
}
|
}
|
||||||
// Still here? need to add a new one
|
// Still here? need to add a new one
|
||||||
ParamDescriptor* paramDescriptor = createNewParamDescriptor();
|
ParamDescriptor* paramDescriptor = createNewParamDescriptor();
|
||||||
paramDescriptor->setId(paramTypeId);
|
paramDescriptor->setParamTypeId(paramTypeId);
|
||||||
paramDescriptor->setValue(value);
|
paramDescriptor->setValue(value);
|
||||||
paramDescriptor->setOperatorType((ParamDescriptor::ValueOperator)operatorType);
|
paramDescriptor->setOperatorType((ParamDescriptor::ValueOperator)operatorType);
|
||||||
addParamDescriptor(paramDescriptor);
|
addParamDescriptor(paramDescriptor);
|
||||||
|
|||||||
@ -47,7 +47,7 @@ Param *Params::get(int index) const
|
|||||||
Param *Params::getParam(QString paramTypeId) const
|
Param *Params::getParam(QString paramTypeId) const
|
||||||
{
|
{
|
||||||
foreach (Param *param, m_params) {
|
foreach (Param *param, m_params) {
|
||||||
if (param->id() == paramTypeId) {
|
if (param->paramTypeId() == paramTypeId) {
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ QVariant Params::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
Param *param = m_params.at(index.row());
|
Param *param = m_params.at(index.row());
|
||||||
if (role == RoleId) {
|
if (role == RoleId) {
|
||||||
return param->id();
|
return param->paramTypeId();
|
||||||
} else if (role == RoleValue) {
|
} else if (role == RoleValue) {
|
||||||
return param->value();
|
return param->value();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,6 +71,10 @@ QVariant ParamTypes::data(const QModelIndex &index, int role) const
|
|||||||
ParamType *paramType = m_paramTypes.at(index.row());
|
ParamType *paramType = m_paramTypes.at(index.row());
|
||||||
if (role == NameRole) {
|
if (role == NameRole) {
|
||||||
return paramType->name();
|
return paramType->name();
|
||||||
|
} else if (role == DisplayNameRole) {
|
||||||
|
return paramType->displayName();
|
||||||
|
} else if (role == IdRole) {
|
||||||
|
return paramType->id();
|
||||||
} else if (role == TypeRole) {
|
} else if (role == TypeRole) {
|
||||||
return paramType->type();
|
return paramType->type();
|
||||||
} else if (role == DefaultValueRole) {
|
} else if (role == DefaultValueRole) {
|
||||||
@ -111,7 +115,9 @@ void ParamTypes::clearModel()
|
|||||||
QHash<int, QByteArray> ParamTypes::roleNames() const
|
QHash<int, QByteArray> ParamTypes::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
roles[IdRole] = "id";
|
||||||
roles[NameRole] = "name";
|
roles[NameRole] = "name";
|
||||||
|
roles[DisplayNameRole] = "displayName";
|
||||||
roles[TypeRole] = "type";
|
roles[TypeRole] = "type";
|
||||||
roles[MinValueRole] = "minValue";
|
roles[MinValueRole] = "minValue";
|
||||||
roles[MaxValueRole] = "maxValue";
|
roles[MaxValueRole] = "maxValue";
|
||||||
|
|||||||
@ -34,6 +34,8 @@ class ParamTypes : public QAbstractListModel
|
|||||||
public:
|
public:
|
||||||
enum ParamTypeRole {
|
enum ParamTypeRole {
|
||||||
NameRole = Qt::DisplayRole,
|
NameRole = Qt::DisplayRole,
|
||||||
|
DisplayNameRole,
|
||||||
|
IdRole,
|
||||||
TypeRole,
|
TypeRole,
|
||||||
DefaultValueRole,
|
DefaultValueRole,
|
||||||
MinValueRole,
|
MinValueRole,
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
Plugin::Plugin(QObject *parent) : QObject(parent)
|
Plugin::Plugin(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
m_params = new Params(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Plugin::name() const
|
QString Plugin::name() const
|
||||||
|
|||||||
@ -55,8 +55,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QUuid m_pluginId;
|
QUuid m_pluginId;
|
||||||
ParamTypes *m_paramTypes;
|
ParamTypes *m_paramTypes = nullptr;
|
||||||
Params *m_params;
|
Params *m_params = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PLUGIN_H
|
#endif // PLUGIN_H
|
||||||
|
|||||||
Reference in New Issue
Block a user