diff --git a/guh-control/guh-control.pro b/guh-control/guh-control.pro index 2fa7abf9..4bdf0d04 100644 --- a/guh-control/guh-control.pro +++ b/guh-control/guh-control.pro @@ -3,7 +3,7 @@ TARGET=guh-control include(../guh-control.pri) -QT += qml quick quickcontrols2 websockets svg charts +QT += qml quick quickcontrols2 websockets svg INCLUDEPATH += $$top_srcdir/libguh-common LIBS += -L$$top_builddir/libguh-common/ -lguh-common diff --git a/guh-control/jsonrpc/jsontypes.cpp b/guh-control/jsonrpc/jsontypes.cpp index d8e6763b..419681fe 100644 --- a/guh-control/jsonrpc/jsontypes.cpp +++ b/guh-control/jsonrpc/jsontypes.cpp @@ -166,6 +166,7 @@ ActionType *JsonTypes::unpackActionType(const QVariantMap &actionTypeMap, QObjec ActionType *actionType = new ActionType(parent); actionType->setId(actionTypeMap.value("id").toUuid()); actionType->setName(actionTypeMap.value("name").toString()); + actionType->setDisplayName(actionTypeMap.value("displayName").toString()); actionType->setIndex(actionTypeMap.value("index").toInt()); ParamTypes *paramTypes = new ParamTypes(actionType); foreach (QVariant paramType, actionTypeMap.value("paramTypes").toList()) { diff --git a/guh-control/resources.qrc b/guh-control/resources.qrc index cc2c0a09..104513f5 100644 --- a/guh-control/resources.qrc +++ b/guh-control/resources.qrc @@ -107,5 +107,6 @@ ui/magic/DeviceRulesPage.qml ui/magic/SelectEventPage.qml ui/magic/NewThingMagicPage.qml + ui/magic/EditRulePage.qml diff --git a/guh-control/ui/LoginPage.qml b/guh-control/ui/LoginPage.qml index 2cf9ea30..a3df70be 100644 --- a/guh-control/ui/LoginPage.qml +++ b/guh-control/ui/LoginPage.qml @@ -33,7 +33,7 @@ Page { TextField { id: usernameTextField Layout.fillWidth: true - + inputMethodHints: Qt.ImhEmailCharactersOnly } Label { Layout.fillWidth: true @@ -42,7 +42,7 @@ Page { TextField { id: passwordTextField Layout.fillWidth: true - + echoMode: TextInput.Password } Button { Layout.fillWidth: true diff --git a/guh-control/ui/MagicPage.qml b/guh-control/ui/MagicPage.qml index f6791eb4..4559b23f 100644 --- a/guh-control/ui/MagicPage.qml +++ b/guh-control/ui/MagicPage.qml @@ -24,6 +24,10 @@ Page { Label { text: model.name } + + onClicked: { + pageStack.push(Qt.resolvedUrl("magic/EditRulePage.qml")) + } } } } diff --git a/guh-control/ui/actiondelegates/ActionDelegateFallback.qml b/guh-control/ui/actiondelegates/ActionDelegateFallback.qml index cab960ff..f57c21c3 100644 --- a/guh-control/ui/actiondelegates/ActionDelegateFallback.qml +++ b/guh-control/ui/actiondelegates/ActionDelegateFallback.qml @@ -12,7 +12,7 @@ ActionDelegateBase { Label { Layout.fillWidth: true - text: actionType.name + text: actionType.displayName } Label { Layout.fillWidth: true diff --git a/guh-control/ui/actiondelegates/ActionDelegateNoParams.qml b/guh-control/ui/actiondelegates/ActionDelegateNoParams.qml index d709ffa6..97fed6c2 100644 --- a/guh-control/ui/actiondelegates/ActionDelegateNoParams.qml +++ b/guh-control/ui/actiondelegates/ActionDelegateNoParams.qml @@ -10,7 +10,7 @@ ActionDelegateBase { id: layout anchors { left: parent.left; right: parent.right; top: parent.top; margins: app.margins } Label { - text: root.actionType.name + text: root.actionType.displayName Layout.fillWidth: true } Button { diff --git a/guh-control/ui/magic/EditRulePage.qml b/guh-control/ui/magic/EditRulePage.qml new file mode 100644 index 00000000..dd77fa60 --- /dev/null +++ b/guh-control/ui/magic/EditRulePage.qml @@ -0,0 +1,19 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import "../components" +import QtQuick.Layouts 1.2 + +Page { + header: GuhHeader { + text: "Add some magic" + onBackPressed: pageStack.pop() + } + + ColumnLayout { + anchors.fill: parent + Label { + text: "When" + } + } + +} diff --git a/libguh-common/types/actiontype.cpp b/libguh-common/types/actiontype.cpp index 236faa5d..805f4363 100644 --- a/libguh-common/types/actiontype.cpp +++ b/libguh-common/types/actiontype.cpp @@ -47,6 +47,16 @@ void ActionType::setName(const QString &name) m_name = name; } +QString ActionType::displayName() const +{ + return m_displayName; +} + +void ActionType::setDisplayName(const QString &displayName) +{ + m_displayName = displayName; +} + int ActionType::index() const { return m_index; diff --git a/libguh-common/types/actiontype.h b/libguh-common/types/actiontype.h index 771af508..b53c4123 100644 --- a/libguh-common/types/actiontype.h +++ b/libguh-common/types/actiontype.h @@ -33,6 +33,7 @@ class ActionType : public QObject Q_OBJECT Q_PROPERTY(QUuid id READ id CONSTANT) Q_PROPERTY(QString name READ name CONSTANT) + Q_PROPERTY(QString displayName READ displayName CONSTANT) Q_PROPERTY(int index READ index CONSTANT) Q_PROPERTY(ParamTypes *paramTypes READ paramTypes NOTIFY paramTypesChanged) @@ -45,6 +46,9 @@ public: QString name() const; void setName(const QString &name); + QString displayName() const; + void setDisplayName(const QString &displayName); + int index() const; void setIndex(const int &index); @@ -54,6 +58,7 @@ public: private: QUuid m_id; QString m_name; + QString m_displayName; int m_index; ParamTypes *m_paramTypes; diff --git a/libguh-common/types/stateevaluator.cpp b/libguh-common/types/stateevaluator.cpp index 2a891d9b..bd665b3e 100644 --- a/libguh-common/types/stateevaluator.cpp +++ b/libguh-common/types/stateevaluator.cpp @@ -28,9 +28,18 @@ StateDescriptor *StateEvaluator::stateDescriptor() const return m_stateDescriptor; } +void StateEvaluator::setStateDescriptor(StateDescriptor *stateDescriptor) +{ + if (m_stateDescriptor) { + m_stateDescriptor->deleteLater(); + } + stateDescriptor->setParent(this); + m_stateDescriptor = stateDescriptor; +} + bool StateEvaluator::containsDevice(const QUuid &deviceId) const { - if (m_stateDescriptor->deviceId() == deviceId) { + if (m_stateDescriptor && m_stateDescriptor->deviceId() == deviceId) { return true; } for (int i = 0; i < m_childEvaluators->rowCount(); i++) { diff --git a/libguh-common/types/stateevaluator.h b/libguh-common/types/stateevaluator.h index 10880a5f..77de70f8 100644 --- a/libguh-common/types/stateevaluator.h +++ b/libguh-common/types/stateevaluator.h @@ -27,6 +27,7 @@ public: StateEvaluators* childEvaluators() const; StateDescriptor* stateDescriptor() const; + void setStateDescriptor(StateDescriptor *stateDescriptor); bool containsDevice(const QUuid &deviceId) const;