Engine isn't a singleton any more!

This commit is contained in:
Michael Zanetti 2018-09-01 01:52:23 +02:00
parent 56d30ea0ca
commit be50036584
67 changed files with 352 additions and 373 deletions

View File

@ -31,14 +31,42 @@
#include "connection/bluetoothtransport.h"
#include "connection/cloudtransport.h"
Engine* Engine::s_instance = nullptr;
Engine *Engine::instance()
Engine::Engine(QObject *parent) :
QObject(parent),
m_connection(new NymeaConnection(this)),
m_jsonRpcClient(new JsonRpcClient(m_connection, this)),
m_deviceManager(new DeviceManager(m_jsonRpcClient, this)),
m_ruleManager(new RuleManager(m_jsonRpcClient, this)),
m_logManager(new LogManager(m_jsonRpcClient, this)),
m_tagsManager(new TagsManager(m_jsonRpcClient, this)),
m_basicConfiguration(new BasicConfiguration(m_jsonRpcClient, this)),
m_aws(new AWSClient(this))
{
if (!s_instance)
s_instance = new Engine();
m_connection->registerTransport(new TcpSocketTransportFactory());
m_connection->registerTransport(new WebsocketTransportFactory());
m_connection->registerTransport(new BluetoothTransportFactoy());
m_connection->registerTransport(new CloudTransportFactory(m_aws));
connect(m_jsonRpcClient, &JsonRpcClient::connectedChanged, this, &Engine::onConnectedChanged);
connect(m_jsonRpcClient, &JsonRpcClient::authenticationRequiredChanged, this, &Engine::onConnectedChanged);
connect(m_deviceManager, &DeviceManager::fetchingDataChanged, this, &Engine::onDeviceManagerFetchingChanged);
connect(m_aws, &AWSClient::devicesFetched, this, [this]() {
if (m_jsonRpcClient->connected() && m_jsonRpcClient->cloudConnectionState() == JsonRpcClient::CloudConnectionStateConnected) {
if (m_aws->awsDevices()->getDevice(m_jsonRpcClient->serverUuid()) == nullptr) {
m_jsonRpcClient->setupRemoteAccess(m_aws->idToken(), m_aws->userId());
}
}
});
connect(m_jsonRpcClient, &JsonRpcClient::connectedChanged, this, [this]() {
if (m_jsonRpcClient->connected() && m_jsonRpcClient->cloudConnectionState() == JsonRpcClient::CloudConnectionStateConnected) {
if (m_aws->awsDevices()->getDevice(m_jsonRpcClient->serverUuid()) == nullptr) {
m_jsonRpcClient->setupRemoteAccess(m_aws->idToken(), m_aws->userId());
}
}
});
return s_instance;
}
DeviceManager *Engine::deviceManager() const
@ -97,44 +125,6 @@ NymeaConnection *Engine::connection() const
return m_connection;
}
Engine::Engine(QObject *parent) :
QObject(parent),
m_connection(new NymeaConnection(this)),
m_jsonRpcClient(new JsonRpcClient(m_connection, this)),
m_deviceManager(new DeviceManager(m_jsonRpcClient, this)),
m_ruleManager(new RuleManager(m_jsonRpcClient, this)),
m_logManager(new LogManager(m_jsonRpcClient, this)),
m_tagsManager(new TagsManager(m_jsonRpcClient, this)),
m_basicConfiguration(new BasicConfiguration(m_jsonRpcClient, this)),
m_aws(new AWSClient(this))
{
m_connection->registerTransport(new TcpSocketTransportFactory());
m_connection->registerTransport(new WebsocketTransportFactory());
m_connection->registerTransport(new BluetoothTransportFactoy());
m_connection->registerTransport(new CloudTransportFactory(m_aws));
connect(m_jsonRpcClient, &JsonRpcClient::connectedChanged, this, &Engine::onConnectedChanged);
connect(m_jsonRpcClient, &JsonRpcClient::authenticationRequiredChanged, this, &Engine::onConnectedChanged);
connect(m_deviceManager, &DeviceManager::fetchingDataChanged, this, &Engine::onDeviceManagerFetchingChanged);
connect(m_aws, &AWSClient::devicesFetched, this, [this]() {
if (m_jsonRpcClient->connected() && m_jsonRpcClient->cloudConnectionState() == JsonRpcClient::CloudConnectionStateConnected) {
if (m_aws->awsDevices()->getDevice(m_jsonRpcClient->serverUuid()) == nullptr) {
m_jsonRpcClient->setupRemoteAccess(m_aws->idToken(), m_aws->userId());
}
}
});
connect(m_jsonRpcClient, &JsonRpcClient::connectedChanged, this, [this]() {
if (m_jsonRpcClient->connected() && m_jsonRpcClient->cloudConnectionState() == JsonRpcClient::CloudConnectionStateConnected) {
if (m_aws->awsDevices()->getDevice(m_jsonRpcClient->serverUuid()) == nullptr) {
m_jsonRpcClient->setupRemoteAccess(m_aws->idToken(), m_aws->userId());
}
}
});
}
void Engine::onConnectedChanged()
{
qDebug() << "Engine: connected changed:" << m_jsonRpcClient->connected();

View File

@ -46,7 +46,7 @@ class Engine : public QObject
Q_PROPERTY(AWSClient* awsClient READ awsClient CONSTANT)
public:
static Engine *instance();
explicit Engine(QObject *parent = nullptr);
bool connected() const;
QString connectedHost() const;
@ -63,9 +63,6 @@ public:
Q_INVOKABLE void deployCertificate();
private:
explicit Engine(QObject *parent = nullptr);
static Engine *s_instance;
NymeaConnection *m_connection;
JsonRpcClient *m_jsonRpcClient;
DeviceManager *m_deviceManager;

View File

@ -63,26 +63,18 @@ static QObject* interfacesModel_provider(QQmlEngine *engine, QJSEngine *scriptEn
return new Interfaces();
}
QObject* engine_provider(QQmlEngine *qmlEngine, QJSEngine *jsEngine)
{
Q_UNUSED(qmlEngine)
Q_UNUSED(jsEngine)
return Engine::instance();
}
void registerQmlTypes() {
const char uri[] = "Nymea";
qmlRegisterSingletonType<Engine>(uri, 1, 0, "Engine", engine_provider);
qmlRegisterType<Engine>(uri, 1, 0, "Engine");
qmlRegisterUncreatableType<DeviceManager>(uri, 1, 0, "DeviceManager", "Can't create this in QML. Get it from the Core.");
qmlRegisterUncreatableType<JsonRpcClient>(uri, 1, 0, "JsonRpcClient", "Can't create this in QML. Get it from the Core.");
qmlRegisterUncreatableType<NymeaConnection>(uri, 1, 0, "NymeaConnection", "Can't create this in QML. Get it from the Core.");
qmlRegisterUncreatableType<DeviceManager>(uri, 1, 0, "DeviceManager", "Can't create this in QML. Get it from the Engine.");
qmlRegisterUncreatableType<JsonRpcClient>(uri, 1, 0, "JsonRpcClient", "Can't create this in QML. Get it from the Engine.");
qmlRegisterUncreatableType<NymeaConnection>(uri, 1, 0, "NymeaConnection", "Can't create this in QML. Get it from the Engine.");
// libnymea-common
qmlRegisterUncreatableType<Types>(uri, 1, 0, "Types", "Can't create this in QML. Get it from the Core.");
qmlRegisterUncreatableType<Types>(uri, 1, 0, "Types", "Can't create this in QML. Get it from the Engine.");
qmlRegisterUncreatableType<ParamType>(uri, 1, 0, "ParamType", "Can't create this in QML. Get it from the ParamTypes.");
qmlRegisterUncreatableType<ParamTypes>(uri, 1, 0, "ParamTypes", "Can't create this in QML. Get it from the DeviceClass.");

View File

@ -205,7 +205,7 @@ void LogsModel::fetchEarlier(int hours)
timeFilter.insert("startDate", m_startTime.toSecsSinceEpoch());
timeFilters.append(timeFilter);
params.insert("timeFilters", timeFilters);
Engine::instance()->jsonRpcClient()->sendCommand("Logging.GetLogEntries", params, this, "fetchEarlierReply");
m_engine->jsonRpcClient()->sendCommand("Logging.GetLogEntries", params, this, "fetchEarlierReply");
}
void LogsModel::logsReply(const QVariantMap &data)

View File

@ -87,8 +87,6 @@ int main(int argc, char *argv[])
registerQmlTypes();
Engine::instance();
QQmlApplicationEngine *engine = new QQmlApplicationEngine();
qmlRegisterSingletonType<PlatformHelper>("Nymea", 1, 0, "PlatformHelper", platformHelperProvider);

View File

@ -23,7 +23,7 @@ Page {
}
Connections {
target: Engine.deviceManager
target: engine.deviceManager
onRemoveDeviceReply: {
if (!d.deviceToRemove) {
return;
@ -49,7 +49,7 @@ Page {
anchors.fill: parent
model: DevicesProxy {
id: deviceProxy
engine: Engine
engine: app.engine
groupByInterface: true
}
section.property: "baseInterface"
@ -75,7 +75,7 @@ Page {
}
onDeleteClicked: {
d.deviceToRemove = deviceProxy.get(index);
Engine.deviceManager.removeDevice(d.deviceToRemove.id)
engine.deviceManager.removeDevice(d.deviceToRemove.id)
}
}
}
@ -83,7 +83,7 @@ Page {
EmptyViewPlaceholder {
anchors { left: parent.left; right: parent.right; margins: app.margins }
anchors.verticalCenter: parent.verticalCenter
visible: Engine.deviceManager.devices.count === 0 && !Engine.deviceManager.fetchingData
visible: engine.deviceManager.devices.count === 0 && !engine.deviceManager.fetchingData
title: qsTr("There are no things set up yet.")
text: qsTr("In order for your %1 box to be useful, go ahead and add some things.").arg(app.systemName)
imageSource: "qrc:/styles/%1/logo.svg".arg(styleController.currentStyle)

View File

@ -16,7 +16,7 @@ Page {
Connections {
target: Engine.jsonRpcClient
target: engine.jsonRpcClient
onAuthenticationFailed: {
var popup = errorDialog.createObject(root)
popup.text = qsTr("Sorry, that wasn't right. Try again please.")
@ -51,7 +51,7 @@ Page {
Label {
Layout.fillWidth: true
text: Engine.jsonRpcClient.initialSetupRequired ?
text: engine.jsonRpcClient.initialSetupRequired ?
qsTr("In order to use your %1 system, please enter your email address and set a password for your nymea box.").arg(app.systemName)
: qsTr("In order to use your %1 system, please log in.").arg(app.systemName)
wrapMode: Text.WordWrap
@ -87,7 +87,7 @@ Page {
ColumnLayout {
Layout.fillWidth: true
visible: Engine.jsonRpcClient.initialSetupRequired
visible: engine.jsonRpcClient.initialSetupRequired
Label {
Layout.fillWidth: true
@ -102,7 +102,7 @@ Page {
Label {
Layout.fillWidth: true
visible: Engine.jsonRpcClient.initialSetupRequired
visible: engine.jsonRpcClient.initialSetupRequired
opacity: (passwordTextField.text.length > 0 && passwordTextField.text.length < 8) || passwordTextField.text != confirmPasswordTextField.text ? 1 : 0
text: passwordTextField.text.length < 8 ? qsTr("This password isn't long enought to be secure, add some more characters please.")
: qsTr("The passwords don't match.")
@ -115,14 +115,14 @@ Page {
Layout.fillWidth: true
text: qsTr("OK")
enabled: usernameTextField.text.length >= 5 && passwordTextField.text.length >= 8
&& (!Engine.jsonRpcClient.initialSetupRequired || confirmPasswordTextField.text == passwordTextField.text)
&& (!engine.jsonRpcClient.initialSetupRequired || confirmPasswordTextField.text == passwordTextField.text)
onClicked: {
if (Engine.jsonRpcClient.initialSetupRequired) {
if (engine.jsonRpcClient.initialSetupRequired) {
print("create user")
Engine.jsonRpcClient.createUser(usernameTextField.text, passwordTextField.text);
engine.jsonRpcClient.createUser(usernameTextField.text, passwordTextField.text);
} else {
print("authenticate", usernameTextField.text, passwordTextField.text, "nymea-app")
Engine.jsonRpcClient.authenticate(usernameTextField.text, passwordTextField.text, "nymea-app");
engine.jsonRpcClient.authenticate(usernameTextField.text, passwordTextField.text, "nymea-app");
}
}
}

View File

@ -19,14 +19,14 @@ Page {
}
function addRule() {
var newRule = Engine.ruleManager.createNewRule();
var newRule = engine.ruleManager.createNewRule();
d.editRulePage = pageStack.push(Qt.resolvedUrl("magic/EditRulePage.qml"), {rule: newRule });
d.editRulePage.StackView.onRemoved.connect(function() {
newRule.destroy();
})
d.editRulePage.onAccept.connect(function() {
d.editRulePage.busy = true;
Engine.ruleManager.addRule(d.editRulePage.rule);
engine.ruleManager.addRule(d.editRulePage.rule);
})
d.editRulePage.onCancel.connect(function() {
pageStack.pop();
@ -39,13 +39,13 @@ Page {
}
Connections {
target: Engine.ruleManager
target: engine.ruleManager
onAddRuleReply: {
d.editRulePage.busy = false;
if (ruleError == "RuleErrorNoError") {
print("should tag rule now:", d.editRulePage.rule.id, d.editRulePage.ruleIcon, d.editRulePage.ruleColor)
Engine.tagsManager.tagRule(ruleId, "color", d.editRulePage.ruleColor)
Engine.tagsManager.tagRule(ruleId, "icon", d.editRulePage.ruleIcon)
engine.tagsManager.tagRule(ruleId, "color", d.editRulePage.ruleColor)
engine.tagsManager.tagRule(ruleId, "icon", d.editRulePage.ruleIcon)
pageStack.pop();
} else {
var popup = errorDialog.createObject(app, {errorCode: ruleError })
@ -57,8 +57,8 @@ Page {
d.editRulePage.busy = false;
if (ruleError == "RuleErrorNoError") {
print("should tag rule now:", d.editRulePage.ruleIcon, d.editRulePage.ruleColor)
Engine.tagsManager.tagRule(d.editRulePage.rule.id, "color", d.editRulePage.ruleColor)
Engine.tagsManager.tagRule(d.editRulePage.rule.id, "icon", d.editRulePage.ruleIcon)
engine.tagsManager.tagRule(d.editRulePage.rule.id, "color", d.editRulePage.ruleColor)
engine.tagsManager.tagRule(d.editRulePage.rule.id, "icon", d.editRulePage.ruleIcon)
pageStack.pop();
} else {
var popup = errorDialog.createObject(app, {errorCode: ruleError })
@ -72,7 +72,7 @@ Page {
model: RulesFilterModel {
id: rulesProxy
rules: Engine.ruleManager.rules
rules: engine.ruleManager.rules
}
delegate: MeaListItemDelegate {
id: ruleDelegate
@ -82,17 +82,17 @@ Page {
text: model.name
canDelete: true
property var colorTag: model.executable ? Engine.tagsManager.tags.findRuleTag(model.id, "color") : null
property var iconTag: model.executable ? Engine.tagsManager.tags.findRuleTag(model.id, "icon") : null
property var colorTag: model.executable ? engine.tagsManager.tags.findRuleTag(model.id, "color") : null
property var iconTag: model.executable ? engine.tagsManager.tags.findRuleTag(model.id, "icon") : null
Connections {
target: Engine.tagsManager.tags
target: engine.tagsManager.tags
onCountChanged: {
colorTag = Engine.tagsManager.tags.findRuleTag(model.id, "color")
iconTag = Engine.tagsManager.tags.findRuleTag(model.id, "icon")
colorTag = engine.tagsManager.tags.findRuleTag(model.id, "color")
iconTag = engine.tagsManager.tags.findRuleTag(model.id, "icon")
}
}
onDeleteClicked: Engine.ruleManager.removeRule(model.id)
onDeleteClicked: engine.ruleManager.removeRule(model.id)
onClicked: {
var newRule = rulesProxy.get(index).clone();
@ -102,7 +102,7 @@ Page {
})
d.editRulePage.onAccept.connect(function() {
d.editRulePage.busy = true;
Engine.ruleManager.editRule(d.editRulePage.rule);
engine.ruleManager.editRule(d.editRulePage.rule);
})
d.editRulePage.onCancel.connect(function() {
pageStack.pop();
@ -114,7 +114,7 @@ Page {
EmptyViewPlaceholder {
anchors { left: parent.left; right: parent.right; margins: app.margins }
anchors.verticalCenter: parent.verticalCenter
visible: Engine.ruleManager.rules.count === 0
visible: engine.ruleManager.rules.count === 0
title: qsTr("There is no magic set up yet.")
text: qsTr("Use magic to make your things smart! In a few easy steps you'll have your things wired up and work for you.")
imageSource: "images/magic.svg"

View File

@ -29,7 +29,7 @@ Page {
// FIXME: Currently we don't have any feedback for executeAction
// we don't want all the results, e.g. on looped calls like "all off"
// Connections {
// target: Engine.deviceManager
// target: engine.deviceManager
// onExecuteActionReply: {
// var text = params["deviceError"]
// switch(text) {
@ -60,7 +60,7 @@ Page {
anchors.fill: parent
anchors.leftMargin: (systemProductType === "ios" && Screen.width === 812) ? 25 : 0
anchors.rightMargin: anchors.leftMargin
opacity: Engine.deviceManager.fetchingData ? 0 : 1
opacity: engine.deviceManager.fetchingData ? 0 : 1
Behavior on opacity { NumberAnimation { duration: 300 } }
onCurrentIndexChanged: {
@ -68,7 +68,7 @@ Page {
}
Component.onCompleted: {
if (Engine.jsonRpcClient.ensureServerVersion(1.6)) {
if (engine.jsonRpcClient.ensureServerVersion(1.6)) {
swipeView.insertItem(0, favoritesViewComponent.createObject(swipeView))
}
if (settings.currentMainViewIndex > swipeView.count) {
@ -89,13 +89,13 @@ Page {
EmptyViewPlaceholder {
anchors { left: parent.left; right: parent.right; margins: app.margins }
anchors.verticalCenter: parent.verticalCenter
visible: favoritesView.count === 0 && !Engine.deviceManager.fetchingData
visible: favoritesView.count === 0 && !engine.deviceManager.fetchingData
title: qsTr("There are no favorite things yet.")
text: Engine.deviceManager.devices.count === 0 ?
text: engine.deviceManager.devices.count === 0 ?
qsTr("It appears there are no things set up either yet. In order to use favorites you need to add some things first.") :
qsTr("Favorites allow you to keep track of your most important things when you have lots of them. Watch out for the star when interacting with things and use it to mark them as your favorites.")
imageSource: "images/starred.svg"
buttonVisible: Engine.deviceManager.devices.count === 0
buttonVisible: engine.deviceManager.devices.count === 0
buttonText: qsTr("Add a thing")
onButtonClicked: pageStack.push(Qt.resolvedUrl("NewDeviceWizard.qml"))
}
@ -109,7 +109,7 @@ Page {
height: swipeView.height
model: InterfacesSortModel {
interfacesModel: InterfacesModel {
deviceManager: Engine.deviceManager
deviceManager: engine.deviceManager
shownInterfaces: app.supportedInterfaces
}
}
@ -117,7 +117,7 @@ Page {
EmptyViewPlaceholder {
anchors { left: parent.left; right: parent.right; margins: app.margins }
anchors.verticalCenter: parent.verticalCenter
visible: Engine.deviceManager.devices.count === 0 && !Engine.deviceManager.fetchingData
visible: engine.deviceManager.devices.count === 0 && !engine.deviceManager.fetchingData
title: qsTr("Welcome to %1!").arg(app.systemName)
// Have that split in 2 because we need those strings separated in EditDevicesPage too and don't want translators to do them twice
text: qsTr("There are no things set up yet.") + "\n" + qsTr("In order for your %1 box to be useful, go ahead and add some things.").arg(app.systemName)
@ -136,15 +136,15 @@ Page {
EmptyViewPlaceholder {
anchors { left: parent.left; right: parent.right; margins: app.margins }
anchors.verticalCenter: parent.verticalCenter
visible: scenesView.count === 0 && !Engine.deviceManager.fetchingData
visible: scenesView.count === 0 && !engine.deviceManager.fetchingData
title: qsTr("There are no scenes set up yet")
text: Engine.deviceManager.devices.count === 0 ?
text: engine.deviceManager.devices.count === 0 ?
qsTr("It appears there are no things set up either yet. In order to use scenes you need to add some things first.") :
qsTr("Scenes provide a useful way to control your things with just one click.")
imageSource: "images/slideshow.svg"
buttonText: Engine.deviceManager.devices.count === 0 ? qsTr("Add a thing") : qsTr("Add a scene")
buttonText: engine.deviceManager.devices.count === 0 ? qsTr("Add a thing") : qsTr("Add a scene")
onButtonClicked: {
if (Engine.deviceManager.devices.count === 0) {
if (engine.deviceManager.devices.count === 0) {
pageStack.push(Qt.resolvedUrl("NewDeviceWizard.qml"))
} else {
var page = pageStack.push(Qt.resolvedUrl("MagicPage.qml"))
@ -158,7 +158,7 @@ Page {
ColumnLayout {
anchors { left: parent.left; right: parent.right; verticalCenter: parent.verticalCenter; margins: app.margins }
spacing: app.margins
visible: Engine.deviceManager.fetchingData
visible: engine.deviceManager.fetchingData
BusyIndicator {
Layout.alignment: Qt.AlignHCenter
running: parent.visible
@ -189,7 +189,7 @@ Page {
// has troubles dealing with that. For now, let's manually fill it and use a timer to initialize the currentIndex.
Component.onCompleted: {
var pi = 0;
if (Engine.jsonRpcClient.ensureServerVersion(1.6)) {
if (engine.jsonRpcClient.ensureServerVersion(1.6)) {
tabEntryComponent.createObject(tabBar, {text: qsTr("Favorites"), iconSource: "../images/starred.svg", pageIndex: pi++})
}
tabEntryComponent.createObject(tabBar, {text: qsTr("Things"), iconSource: "../images/share.svg", pageIndex: pi++})

View File

@ -35,7 +35,7 @@ Page {
}
Connections {
target: Engine.deviceManager
target: engine.deviceManager
onPairDeviceReply: {
switch (params["setupMethod"]) {
case "SetupMethodPushButton":
@ -61,7 +61,7 @@ Page {
DeviceDiscovery {
id: discovery
jsonRpcClient: Engine.jsonRpcClient
jsonRpcClient: engine.jsonRpcClient
}
StackView {
@ -71,7 +71,7 @@ Page {
ListView {
anchors.fill: parent
model: VendorsProxy {
vendors: Engine.deviceManager.vendors
vendors: engine.deviceManager.vendors
}
delegate: MeaListItemDelegate {
width: parent.width
@ -95,7 +95,7 @@ Page {
model: DeviceClassesProxy {
id: deviceClassesProxy
vendorId: d.vendorId ? d.vendorId : ""
deviceClasses: Engine.deviceManager.deviceClasses
deviceClasses: engine.deviceManager.deviceClasses
}
delegate: MeaListItemDelegate {
id: deviceClassDelegate
@ -336,7 +336,7 @@ Page {
switch (d.deviceClass.setupMethod) {
case 0:
if (d.deviceDescriptorId) {
Engine.deviceManager.addDiscoveredDevice(d.deviceClass.id, d.deviceDescriptorId, nameTextField.text);
engine.deviceManager.addDiscoveredDevice(d.deviceClass.id, d.deviceDescriptorId, nameTextField.text);
} else {
var params = []
for (var i = 0; i < paramRepeater.count; i++) {
@ -347,14 +347,14 @@ Page {
params.push(param)
}
Engine.deviceManager.addDevice(d.deviceClass.id, nameTextField.text, params);
engine.deviceManager.addDevice(d.deviceClass.id, nameTextField.text, params);
}
break;
case 1:
case 2:
case 3:
Engine.deviceManager.pairDevice(d.deviceClass.id, d.deviceDescriptorId, nameTextField.text);
engine.deviceManager.pairDevice(d.deviceClass.id, d.deviceDescriptorId, nameTextField.text);
break;
}
@ -384,7 +384,7 @@ Page {
Layout.fillWidth: true
text: "OK"
onClicked: {
Engine.deviceManager.confirmPairing(d.pairingTransactionId, d.deviceDescriptorId);
engine.deviceManager.confirmPairing(d.pairingTransactionId, d.deviceDescriptorId);
}
}
}

View File

@ -43,8 +43,12 @@ ApplicationWindow {
property int cloudEnvironment: 0
}
property var engine: Engine {
}
Binding {
target: Engine.awsClient
target: engine.awsClient
property: "config"
value: settings.cloudEnvironment
}
@ -67,18 +71,18 @@ ApplicationWindow {
}
Connections {
target: Engine.awsClient
target: engine.awsClient
onIsLoggedInChanged: {
setupPushNotifications()
}
}
Connections {
target: Engine.jsonRpcClient
target: engine.jsonRpcClient
onConnectedChanged: {
print("json client connected changed", Engine.jsonRpcClient.connected)
if (Engine.jsonRpcClient.connected) {
settings.lastConnectedHost = Engine.connection.url
print("json client connected changed", engine.jsonRpcClient.connected)
if (engine.jsonRpcClient.connected) {
settings.lastConnectedHost = engine.connection.url
}
init();
}
@ -102,31 +106,31 @@ ApplicationWindow {
}
function init() {
print("calling init. Auth required:", Engine.jsonRpcClient.authenticationRequired, "initial setup required:", Engine.jsonRpcClient.initialSetupRequired, "jsonrpc connected:", Engine.jsonRpcClient.connected)
print("calling init. Auth required:", engine.jsonRpcClient.authenticationRequired, "initial setup required:", engine.jsonRpcClient.initialSetupRequired, "jsonrpc connected:", engine.jsonRpcClient.connected)
pageStack.clear()
if (!Engine.connection.connected) {
if (!engine.connection.connected) {
pageStack.push(Qt.resolvedUrl("connection/ConnectPage.qml"))
return;
}
if (Engine.jsonRpcClient.authenticationRequired || Engine.jsonRpcClient.initialSetupRequired) {
if (Engine.jsonRpcClient.pushButtonAuthAvailable) {
if (engine.jsonRpcClient.authenticationRequired || engine.jsonRpcClient.initialSetupRequired) {
if (engine.jsonRpcClient.pushButtonAuthAvailable) {
print("opening push button auth")
var page = pageStack.push(Qt.resolvedUrl("PushButtonAuthPage.qml"))
page.backPressed.connect(function() {
settings.lastConnectedHost = "";
Engine.connection.disconnect();
engine.connection.disconnect();
init();
})
} else {
var page = pageStack.push(Qt.resolvedUrl("LoginPage.qml"));
page.backPressed.connect(function() {
settings.lastConnectedHost = "";
Engine.connection.disconnect()
engine.connection.disconnect()
init();
})
}
} else if (Engine.jsonRpcClient.connected) {
} else if (engine.jsonRpcClient.connected) {
pageStack.push(Qt.resolvedUrl("MainPage.qml"))
} else {
pageStack.push(Qt.resolvedUrl("connection/ConnectPage.qml"))
@ -138,7 +142,7 @@ ApplicationWindow {
askForPermissions = true;
}
if (!Engine.awsClient.isLoggedIn) {
if (!engine.awsClient.isLoggedIn) {
print("AWS not logged in. Cannot register for push");
return;
}
@ -153,7 +157,7 @@ ApplicationWindow {
PlatformHelper.requestPermissions();
}
} else {
Engine.awsClient.registerPushNotificationEndpoint(PushNotifications.token, PlatformHelper.deviceManufacturer + " " + PlatformHelper.deviceModel, PlatformHelper.deviceSerial + "+io.guh.nymeaapp");
engine.awsClient.registerPushNotificationEndpoint(PushNotifications.token, PlatformHelper.deviceManufacturer + " " + PlatformHelper.deviceModel, PlatformHelper.deviceSerial + "+io.guh.nymeaapp");
}
}
@ -176,9 +180,9 @@ ApplicationWindow {
onClosing: {
if (Qt.platform.os == "android") {
// If we're connected, allow going back up to MainPage
if ((Engine.jsonRpcClient.connected && pageStack.depth > 1)
if ((engine.jsonRpcClient.connected && pageStack.depth > 1)
// if we're not connected, only allow using the back button in wizards
|| (!Engine.jsonRpcClient.connected && pageStack.depth > 3)) {
|| (!engine.jsonRpcClient.connected && pageStack.depth > 3)) {
close.accepted = false;
pageStack.pop();
}
@ -187,7 +191,7 @@ ApplicationWindow {
Connections {
target: Qt.application
enabled: Engine.jsonRpcClient.connected && settings.returnToHome
enabled: engine.jsonRpcClient.connected && settings.returnToHome
onStateChanged: {
print("App active state changed:", state)
if (state !== Qt.ApplicationActive) {
@ -419,7 +423,7 @@ ApplicationWindow {
Layout.fillWidth: true
text: qsTr("OK")
onClicked: {
Engine.connection.disconnect();
engine.connection.disconnect();
popup.close()
}
}

View File

@ -17,11 +17,11 @@ Page {
}
Component.objectName: {
Engine.jsonRpcClient.requestPushButtonAuth("");
engine.jsonRpcClient.requestPushButtonAuth("");
}
Connections {
target: Engine.jsonRpcClient
target: engine.jsonRpcClient
onPushButtonAuthFailed: {
var popup = errorDialog.createObject(root)
popup.text = qsTr("Sorry, something went wrong during the setup. Try again please.")

View File

@ -31,13 +31,13 @@ Page {
Label {
Layout.fillWidth: true
elide: Text.ElideMiddle
text: Engine.connection.url
text: engine.connection.url
}
Button {
text: qsTr("Disconnect")
onClicked: {
settings.lastConnectedHost = "";
Engine.connection.disconnect();
engine.connection.disconnect();
}
}
}
@ -56,12 +56,12 @@ Page {
TextField {
id: nameTextField
Layout.fillWidth: true
text: Engine.basicConfiguration.serverName
text: engine.basicConfiguration.serverName
}
Button {
text: qsTr("OK")
visible: nameTextField.displayText !== Engine.basicConfiguration.serverName
onClicked: Engine.basicConfiguration.serverName = nameTextField.displayText
visible: nameTextField.displayText !== engine.basicConfiguration.serverName
onClicked: engine.basicConfiguration.serverName = nameTextField.displayText
}
}
@ -79,8 +79,8 @@ Page {
}
Switch {
id: debugServerEnabledSwitch
checked: Engine.basicConfiguration.debugServerEnabled
onClicked: Engine.basicConfiguration.debugServerEnabled = checked
checked: engine.basicConfiguration.debugServerEnabled
onClicked: engine.basicConfiguration.debugServerEnabled = checked
}
}
@ -90,7 +90,7 @@ Page {
Layout.margins: app.margins
visible: debugServerEnabledSwitch.checked
text: qsTr("Open debug interface")
onClicked: Qt.openUrlExternally("http://" + Engine.connection.hostAddress + "/debug")
onClicked: Qt.openUrlExternally("http://" + engine.connection.hostAddress + "/debug")
}
}
@ -99,7 +99,7 @@ Page {
Layout.fillWidth: true
iconName: "../images/cloud.svg"
text: qsTr("Cloud")
visible: Engine.jsonRpcClient.ensureServerVersion("1.9")
visible: engine.jsonRpcClient.ensureServerVersion("1.9")
onClicked: pageStack.push(Qt.resolvedUrl("system/CloudSettingsPage.qml"))
}

View File

@ -12,17 +12,17 @@ Page {
}
Component.onCompleted: {
if (Engine.awsClient.isLoggedIn) {
Engine.awsClient.fetchDevices();
if (engine.awsClient.isLoggedIn) {
engine.awsClient.fetchDevices();
}
}
Connections {
target: Engine.awsClient
target: engine.awsClient
onLoginResult: {
busyOverlay.shown = false;
if (error === AWSClient.LoginErrorNoError) {
Engine.awsClient.fetchDevices();
engine.awsClient.fetchDevices();
}
}
onDeleteAccountResult: {
@ -39,14 +39,14 @@ Page {
ColumnLayout {
anchors.fill: parent
visible: Engine.awsClient.isLoggedIn
visible: engine.awsClient.isLoggedIn
Label {
Layout.fillWidth: true
Layout.topMargin: app.margins
Layout.leftMargin: app.margins
Layout.rightMargin: app.margins
wrapMode: Text.WordWrap
text: qsTr("Logged in as %1").arg(Engine.awsClient.username)
text: qsTr("Logged in as %1").arg(engine.awsClient.username)
}
Button {
@ -66,15 +66,15 @@ Page {
Layout.leftMargin: app.margins
Layout.rightMargin: app.margins
wrapMode: Text.WordWrap
text: Engine.awsClient.awsDevices.count === 0 ?
text: engine.awsClient.awsDevices.count === 0 ?
qsTr("There are no boxes connected to your cloud yet.") :
qsTr("There are %n boxes connected to your cloud", "", Engine.awsClient.awsDevices.count)
qsTr("There are %n boxes connected to your cloud", "", engine.awsClient.awsDevices.count)
}
ListView {
Layout.fillWidth: true
Layout.fillHeight: true
model: Engine.awsClient.awsDevices
clip: true
model: engine.awsClient.awsDevices
delegate: MeaListItemDelegate {
width: parent.width
text: model.name
@ -86,25 +86,25 @@ Page {
secondaryIconName: !model.online ? "../images/cloud-error.svg" : ""
onClicked: {
if (!Engine.connection.connected) {
if (!engine.connection.connected) {
var page = pageStack.push(Qt.resolvedUrl("../connection/ConnectingPage.qml"))
page.cancel.connect(function() {
Engine.connection.disconnect()
engine.connection.disconnect()
pageStack.pop(root, StackView.Immediate);
pageStack.push(discoveryPage)
})
Engine.connection.connect("cloud://" + model.id)
engine.connection.connect("cloud://" + model.id)
}
}
onDeleteClicked: {
Engine.awsClient.unpairDevice(model.id);
engine.awsClient.unpairDevice(model.id);
}
}
BusyIndicator {
anchors.centerIn: parent
visible: Engine.awsClient.awsDevices.busy
visible: engine.awsClient.awsDevices.busy
}
}
}
@ -132,16 +132,16 @@ Page {
onAccepted: {
if (deleteCheckbox.checked) {
busyOverlay.shown = true;
Engine.awsClient.deleteAccount()
engine.awsClient.deleteAccount()
} else {
Engine.awsClient.logout()
engine.awsClient.logout()
}
}
}
ColumnLayout {
anchors { left: parent.left; right: parent.right; top: parent.top }
visible: !Engine.awsClient.isLoggedIn
visible: !engine.awsClient.isLoggedIn
Label {
Layout.fillWidth: true
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins; Layout.topMargin: app.margins
@ -197,12 +197,12 @@ Page {
enabled: usernameTextField.acceptableInput
onClicked: {
busyOverlay.shown = true
Engine.awsClient.login(usernameTextField.text, passwordTextField.text);
engine.awsClient.login(usernameTextField.text, passwordTextField.text);
}
}
Connections {
target: Engine.awsClient
target: engine.awsClient
onLoginResult: {
errorLabel.visible = (error !== AWSClient.LoginErrorNoError)
}
@ -310,14 +310,14 @@ Page {
enabled: usernameTextField.acceptableInput && passwordTextField.isValidPassword
onClicked: {
busyOverlay.shown = true;
Engine.awsClient.signup(usernameTextField.text, passwordTextField.password)
engine.awsClient.signup(usernameTextField.text, passwordTextField.password)
}
}
}
Connections {
target: Engine.awsClient
target: engine.awsClient
onSignupResult: {
busyOverlay.shown = false;
var text;
@ -371,12 +371,12 @@ Page {
text: qsTr("OK")
onClicked: {
busyOverlay.shown = true;
Engine.awsClient.confirmRegistration(confirmationCodeTextField.text)
engine.awsClient.confirmRegistration(confirmationCodeTextField.text)
}
}
Connections {
target: Engine.awsClient
target: engine.awsClient
onConfirmationResult: {
busyOverlay.shown = false;
var text
@ -418,7 +418,7 @@ Page {
}
Connections {
target: Engine.awsClient
target: engine.awsClient
onForgotPasswordResult: {
busyOverlay.shown = false
if (error !== AWSClient.LoginErrorNoError) {
@ -459,7 +459,7 @@ Page {
Layout.fillWidth: true; Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
text: qsTr("Reset password")
onClicked: {
Engine.awsClient.forgotPassword(emailTextField.text)
engine.awsClient.forgotPassword(emailTextField.text)
busyOverlay.shown = true
}
}
@ -478,7 +478,7 @@ Page {
id: confirmResetPasswordPage
Connections {
target: Engine.awsClient
target: engine.awsClient
onConfirmForgotPasswordResult: {
busyOverlay.shown = false
if (error !== AWSClient.LoginErrorNoError) {
@ -545,7 +545,7 @@ Page {
enabled: passwordTextField.isValidPassword && codeTextField.text.length > 0
onClicked: {
busyOverlay.shown = true
Engine.awsClient.confirmForgotPassword(confirmResetPasswordPage.email, codeTextField.text, passwordTextField.password)
engine.awsClient.confirmForgotPassword(confirmResetPasswordPage.email, codeTextField.text, passwordTextField.password)
}
}
BusyOverlay {

View File

@ -17,8 +17,8 @@ Item {
}
onModelChanged: canvas.requestPaint()
readonly property var device: root.model ? Engine.deviceManager.devices.getDevice(root.model.deviceId) : null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var device: root.model ? engine.deviceManager.devices.getDevice(root.model.deviceId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var stateType: deviceClass ? deviceClass.stateTypes.getStateType(root.model.typeIds[0]) : null
Label {

View File

@ -32,7 +32,7 @@ Dialog {
height: app.iconSize
width: parent.width
elide: Text.ElideRight
text: Engine.ruleManager.rules.getRule(modelData).name
text: engine.ruleManager.rules.getRule(modelData).name
verticalAlignment: Text.AlignVCenter
}
}
@ -42,7 +42,7 @@ Dialog {
text: qsTr("Remove all those rules")
Layout.fillWidth: true
onClicked: {
Engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyCascade)
engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyCascade)
root.close()
root.destroy();
}
@ -51,7 +51,7 @@ Dialog {
text: qsTr("Update rules, removing this thing")
Layout.fillWidth: true
onClicked: {
Engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyUpdate)
engine.deviceManager.removeDevice(root.device.id, DeviceManager.RemovePolicyUpdate)
root.close()
root.destroy();
}

View File

@ -11,7 +11,7 @@ RowLayout {
implicitWidth: childrenRect.width
property var device: null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var openState: device ? device.states.getState(deviceClass.stateTypes.findByName("state").id) : null
property bool invert: false
@ -26,7 +26,7 @@ RowLayout {
name: root.invert ? "../images/down.svg" : "../images/up.svg"
color: root.openState && root.openState.value === "opening" ? Material.accent : keyColor
}
onClicked: Engine.deviceManager.executeAction(root.device.id, root.deviceClass.actionTypes.findByName("open").id)
onClicked: engine.deviceManager.executeAction(root.device.id, root.deviceClass.actionTypes.findByName("open").id)
}
@ -41,7 +41,7 @@ RowLayout {
anchors.margins: app.margins
name: "../images/media-playback-stop.svg"
}
onClicked: Engine.deviceManager.executeAction(root.device.id, root.deviceClass.actionTypes.findByName("stop").id)
onClicked: engine.deviceManager.executeAction(root.device.id, root.deviceClass.actionTypes.findByName("stop").id)
}
ItemDelegate {
@ -54,6 +54,6 @@ RowLayout {
name: root.invert ? "../images/up.svg" : "../images/down.svg"
color: root.openState && root.openState.value === "closing" ? Material.accent : keyColor
}
onClicked: Engine.deviceManager.executeAction(root.device.id, root.deviceClass.actionTypes.findByName("close").id)
onClicked: engine.deviceManager.executeAction(root.device.id, root.deviceClass.actionTypes.findByName("close").id)
}
}

View File

@ -12,10 +12,10 @@ Page {
Component.onCompleted: {
print("completed connectPage. last connected host:", settings.lastConnectedHost)
if (settings.lastConnectedHost.length > 0 && Engine.connection.connect(settings.lastConnectedHost)) {
if (settings.lastConnectedHost.length > 0 && engine.connection.connect(settings.lastConnectedHost)) {
var page = pageStack.push(Qt.resolvedUrl("ConnectingPage.qml"))
page.cancel.connect(function() {
Engine.connection.disconnect();
engine.connection.disconnect();
pageStack.pop(root, StackView.Immediate);
pageStack.push(discoveryPage)
})
@ -27,22 +27,22 @@ Page {
function connectToHost(url) {
var page = pageStack.push(Qt.resolvedUrl("ConnectingPage.qml"))
page.cancel.connect(function() {
Engine.connection.disconnect()
engine.connection.disconnect()
pageStack.pop(root, StackView.Immediate);
pageStack.push(discoveryPage)
})
Engine.connection.connect(url)
engine.connection.connect(url)
}
NymeaDiscovery {
id: discovery
objectName: "discovery"
awsClient: Engine.awsClient
awsClient: engine.awsClient
discovering: pageStack.currentItem.objectName === "discoveryPage"
}
Connections {
target: Engine.connection
target: engine.connection
onVerifyConnectionCertificate: {
print("verify cert!")
var popup = certDialogComponent.createObject(root, {url: url, issuerInfo: issuerInfo, fingerprint: fingerprint, pem: pem});
@ -215,7 +215,7 @@ Page {
prominentSubText: false
progressive: false
property bool isSecure: discoveryDevice.connections.get(defaultConnectionIndex).secure
property bool isTrusted: Engine.connection.isTrusted(discoveryDeviceDelegate.discoveryDevice.connections.get(defaultConnectionIndex).url)
property bool isTrusted: engine.connection.isTrusted(discoveryDeviceDelegate.discoveryDevice.connections.get(defaultConnectionIndex).url)
property bool isOnline: discoveryDevice.connections.get(defaultConnectionIndex).online
tertiaryIconName: isSecure ? "../images/network-secure.svg" : ""
tertiaryIconColor: isTrusted ? app.accentColor : Material.foreground
@ -285,7 +285,7 @@ Page {
Layout.leftMargin: app.margins
Layout.rightMargin: app.margins
text: qsTr("Cloud login")
visible: !Engine.awsClient.isLoggedIn
visible: !engine.awsClient.isLoggedIn
onClicked: pageStack.push(Qt.resolvedUrl("../appsettings/CloudLoginPage.qml"))
}
@ -334,7 +334,7 @@ Page {
property var issuerInfo
property var pem
readonly property bool hasOldFingerprint: Engine.connection.isTrusted(url)
readonly property bool hasOldFingerprint: engine.connection.isTrusted(url)
ColumnLayout {
id: certLayout
@ -422,7 +422,7 @@ Page {
}
onAccepted: {
Engine.connection.acceptCertificate(certDialog.url, certDialog.pem)
engine.connection.acceptCertificate(certDialog.url, certDialog.pem)
root.connectToHost(certDialog.url)
}
}
@ -537,7 +537,7 @@ Page {
tertiaryIconName: model.secure ? "../images/network-secure.svg" : ""
tertiaryIconColor: isTrusted ? app.accentColor : "gray"
readonly property bool isTrusted: Engine.connection.isTrusted(url)
readonly property bool isTrusted: engine.connection.isTrusted(url)
secondaryIconName: !model.online ? "../images/cloud-error.svg" : ""
secondaryIconColor: "red"

View File

@ -28,7 +28,7 @@ Page {
}
Label {
Layout.fillWidth: true
text: Engine.connection.url
text: engine.connection.url
font.pixelSize: app.smallFont
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
horizontalAlignment: Text.AlignHCenter

View File

@ -96,10 +96,10 @@ Page {
}
print("Try to connect ", rpcUrl)
Engine.connection.connect(rpcUrl)
engine.connection.connect(rpcUrl)
var page = pageStack.push(Qt.resolvedUrl("ConnectingPage.qml"))
page.cancel.connect(function() {
Engine.connection.disconnect()
engine.connection.disconnect()
pageStack.pop(root)
})
}

View File

@ -31,7 +31,7 @@ CustomViewBase {
muteParam["paramTypeId"] = deviceClass.stateTypes.findByName("mute").id
muteParam["value"] = !isMuted
paramList.push(muteParam)
Engine.deviceManager.executeAction(root.device.id, deviceClass.actionTypes.findByName("mute").id, paramList)
engine.deviceManager.executeAction(root.device.id, deviceClass.actionTypes.findByName("mute").id, paramList)
}
}
@ -46,7 +46,7 @@ CustomViewBase {
muteParam["paramTypeId"] = deviceClass.stateTypes.findByName("volume").id
muteParam["value"] = value
paramList.push(muteParam)
Engine.deviceManager.executeAction(root.device.id, deviceClass.actionTypes.findByName("volume").id, paramList)
engine.deviceManager.executeAction(root.device.id, deviceClass.actionTypes.findByName("volume").id, paramList)
}
}
}

View File

@ -30,7 +30,7 @@ Item {
RulesFilterModel {
id: rulesFilterModel
rules: Engine.ruleManager.rules
rules: engine.ruleManager.rules
filterDeviceId: root.logsModel.deviceId
}
@ -52,8 +52,8 @@ Item {
id: logEntryDelegate
width: parent.width
implicitHeight: app.delegateHeight
property var device: Engine.deviceManager.devices.getDevice(model.deviceId)
property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
property var device: engine.deviceManager.devices.getDevice(model.deviceId)
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
contentItem: RowLayout {
ColorIcon {
Layout.preferredHeight: app.iconSize

View File

@ -11,7 +11,7 @@ CustomViewBase {
function executeAction(actionName) {
var actionTypeId = deviceClass.actionTypes.findByName(actionName).id;
print("executing", device, device.id, actionTypeId, actionName, deviceClass.actionTypes)
Engine.deviceManager.executeAction(device.id, actionTypeId)
engine.deviceManager.executeAction(device.id, actionTypeId)
}
property var playbackState: device.states.getState(deviceClass.stateTypes.findByName("playbackStatus").id)

View File

@ -42,7 +42,7 @@ CustomViewBase {
param2.paramTypeId = paramTypeId
param2.value = bodyTextArea.text
params.push(param2)
Engine.deviceManager.executeAction(root.device.id, root.deviceClass.actionTypes.findByName("notify").id, params)
engine.deviceManager.executeAction(root.device.id, root.deviceClass.actionTypes.findByName("notify").id, params)
}
}
}

View File

@ -25,7 +25,7 @@ CustomViewBase {
ValueLogsProxyModel {
id: logsModel
engine: Engine
engine: app.engine
deviceId: root.device.id
typeIds: [stateType.id]
average: zoomTabBar.currentItem.avg

View File

@ -16,7 +16,7 @@ MeaListItemDelegate {
property var device: null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property bool batteryCritical: deviceClass && deviceClass.interfaces.indexOf("battery") >= 0 ? device.stateValue(deviceClass.stateTypes.findByName("batteryCritical").id) === true : false
readonly property bool disconnected: deviceClass && deviceClass.interfaces.indexOf("connectable") >= 0 ? device.stateValue(deviceClass.stateTypes.findByName("connected").id) === false : false

View File

@ -21,7 +21,7 @@ Page {
function enterPage(index, replace) {
var device = devicesProxy.get(index);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var page = app.interfaceListToDevicePage(deviceClass.interfaces);
if (replace) {
pageStack.replace(Qt.resolvedUrl("../devicepages/" + page), {device: devicesProxy.get(index)})
@ -32,6 +32,6 @@ Page {
DevicesProxy {
id: devicesProxyInternal
engine: Engine
engine: app.engine
}
}

View File

@ -28,7 +28,7 @@ DeviceListPageBase {
model: root.devicesProxy
delegate: ThingDelegate {
width: parent.width
device: Engine.deviceManager.devices.getDevice(model.id);
device: engine.deviceManager.devices.getDevice(model.id);
onClicked: {
enterPage(index, false)
}

View File

@ -16,7 +16,7 @@ DeviceListPageBase {
onClicked: {
for (var i = 0; i < devicesProxy.count; i++) {
var device = devicesProxy.get(i);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var actionType = deviceClass.actionTypes.findByName("power");
var params = [];
@ -24,7 +24,7 @@ DeviceListPageBase {
param1["paramTypeId"] = actionType.paramTypes.get(0).id;
param1["value"] = false;
params.push(param1)
Engine.deviceManager.executeAction(device.id, actionType.id, params)
engine.deviceManager.executeAction(device.id, actionType.id, params)
}
}
}
@ -42,7 +42,7 @@ DeviceListPageBase {
property bool inline: width > 500
property var device: devicesProxy.get(index);
property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
property var connectedStateType: deviceClass.stateTypes.findByName("connected");
property var connectedState: device.states.getState(connectedStateType.id)
@ -110,7 +110,7 @@ DeviceListPageBase {
param1["paramTypeId"] = itemDelegate.brightnessActionType.paramTypes.get(0).id;
param1["value"] = value;
params.push(param1)
Engine.deviceManager.executeAction(itemDelegate.device.id, itemDelegate.brightnessActionType.id, params)
engine.deviceManager.executeAction(itemDelegate.device.id, itemDelegate.brightnessActionType.id, params)
}
}
Switch {
@ -121,7 +121,7 @@ DeviceListPageBase {
param1["paramTypeId"] = itemDelegate.powerActionType.paramTypes.get(0).id;
param1["value"] = checked;
params.push(param1)
Engine.deviceManager.executeAction(device.id, itemDelegate.powerActionType.id, params)
engine.deviceManager.executeAction(device.id, itemDelegate.powerActionType.id, params)
}
}
}
@ -143,7 +143,7 @@ DeviceListPageBase {
param1["paramTypeId"] = itemDelegate.brightnessActionType.paramTypes.get(0).id;
param1["value"] = value;
params.push(param1)
Engine.deviceManager.executeAction(itemDelegate.device.id, itemDelegate.brightnessActionType.id, params)
engine.deviceManager.executeAction(itemDelegate.device.id, itemDelegate.brightnessActionType.id, params)
}
}
}

View File

@ -24,7 +24,7 @@ DeviceListPageBase {
property bool inline: width > 500
property var device: devicesProxy.get(index);
property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0
contentItem: Pane {

View File

@ -25,7 +25,7 @@ DeviceListPageBase {
property bool inline: width > 500
property var device: devicesProxy.get(index);
property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0
contentItem: Pane {
@ -71,7 +71,7 @@ DeviceListPageBase {
}
onClicked: {
var device = devicesProxy.get(index);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
pageStack.push(Qt.resolvedUrl("../devicepages/WeatherDevicePage.qml"), {device: devicesProxy.get(index)})
}
}

View File

@ -65,7 +65,7 @@ DevicePageBase {
percentageParam["paramTypeId"] = actionType.paramTypes.findByName("percentage").id;
percentageParam["value"] = value
params.push(percentageParam);
Engine.deviceManager.executeAction(root.device.id, actionType.id, params);
engine.deviceManager.executeAction(root.device.id, actionType.id, params);
}
}

View File

@ -14,7 +14,7 @@ GenericDevicePage {
text: qsTr("This button has been pressed %1 times in the last %2 days.")
logsModel: LogsModel {
engine: Engine
engine: app.engine
deviceId: root.device.id
live: true
typeIds: {
@ -29,7 +29,7 @@ GenericDevicePage {
}
onAddRuleClicked: {
var rule = Engine.ruleManager.createNewRule();
var rule = engine.ruleManager.createNewRule();
var eventDescriptor = rule.eventDescriptors.createNewEventDescriptor();
eventDescriptor.deviceId = device.id;
var eventType = root.deviceClass.eventTypes.findByName("pressed");

View File

@ -8,7 +8,7 @@ import "../delegates"
Page {
id: root
property var device: null
readonly property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
readonly property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
header: GuhHeader {
text: root.device.name
@ -27,7 +27,7 @@ Page {
IconMenuItem {
iconSource: "../images/delete.svg"
text: qsTr("Delete Thing")
onTriggered: Engine.deviceManager.removeDevice(root.device.id)
onTriggered: engine.deviceManager.removeDevice(root.device.id)
}
IconMenuItem {
iconSource: "../images/edit.svg"
@ -40,7 +40,7 @@ Page {
}
Connections {
target: Engine.deviceManager
target: engine.deviceManager
onRemoveDeviceReply: {
switch (params.deviceError) {
case "DeviceErrorNoError":
@ -109,7 +109,7 @@ Page {
}
onAccepted: {
Engine.deviceManager.editDevice(root.device.id, textField.text)
engine.deviceManager.editDevice(root.device.id, textField.text)
dialog.destroy();
}
}

View File

@ -7,7 +7,7 @@ import "../components"
Page {
id: root
property var device: null
readonly property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
readonly property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
default property alias data: contentItem.data
@ -23,7 +23,7 @@ Page {
TagsProxyModel {
id: favoritesProxy
tags: Engine.tagsManager.tags
tags: engine.tagsManager.tags
filterDeviceId: root.device.id
filterTagId: "favorites"
}
@ -36,7 +36,7 @@ Page {
thingMenu.addItem(menuEntryComponent.createObject(thingMenu, {text: qsTr("Magic"), iconSource: "../images/magic.svg", functionName: "openDeviceMagicPage"}))
thingMenu.addItem(menuEntryComponent.createObject(thingMenu, {text: qsTr("Thing details"), iconSource: "../images/info.svg", functionName: "openDeviceInfoPage"}))
if (Engine.jsonRpcClient.ensureServerVersion(1.6)) {
if (engine.jsonRpcClient.ensureServerVersion(1.6)) {
thingMenu.addItem(menuEntryComponent.createObject(thingMenu,
{
text: Qt.binding(function() { return favoritesProxy.count === 0 ? qsTr("Mark as favorite") : qsTr("Remove from favorites")}),
@ -53,9 +53,9 @@ Page {
}
function toggleFavorite() {
if (favoritesProxy.count === 0) {
Engine.tagsManager.tagDevice(root.device.id, "favorites", 100000)
engine.tagsManager.tagDevice(root.device.id, "favorites", 100000)
} else {
Engine.tagsManager.untagDevice(root.device.id, "favorites")
engine.tagsManager.untagDevice(root.device.id, "favorites")
}
}

View File

@ -103,7 +103,7 @@ DevicePageBase {
param["paramTypeId"] = root.lightStateType.id;
param["value"] = !root.lightState.value;
params.push(param)
Engine.deviceManager.executeAction(root.device.id, root.lightStateType.id, params)
engine.deviceManager.executeAction(root.device.id, root.lightStateType.id, params)
}
}
}

View File

@ -114,11 +114,11 @@ DevicePageBase {
Connections {
target: delegateLoader.item ? delegateLoader.item : null
onExecuteAction: {
Engine.deviceManager.executeAction(root.device.id, model.id, params)
engine.deviceManager.executeAction(root.device.id, model.id, params)
}
}
Connections {
target: Engine.jsonRpcClient
target: engine.jsonRpcClient
onResponseReceived: {
if (commandId == delegateLoader.commandId) {
print("response:", response["error"])

View File

@ -8,7 +8,7 @@ Page {
id: root
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 {
@ -161,6 +161,6 @@ Page {
muteParam["paramTypeId"] = stateTypeId;
muteParam["value"] = value;
paramList.push(muteParam)
Engine.deviceManager.executeAction(root.device.id, stateTypeId, paramList)
engine.deviceManager.executeAction(root.device.id, stateTypeId, paramList)
}
}

View File

@ -13,7 +13,7 @@ GenericDevicePage {
text: qsTr("This event has appeared %1 times in the last %2 days.")
logsModel: LogsModel {
engine: Engine
engine: app.engine
deviceId: root.device.id
live: true
Component.onCompleted: update()
@ -21,7 +21,7 @@ GenericDevicePage {
}
onAddRuleClicked: {
var rule = Engine.ruleManager.createNewRule();
var rule = engine.ruleManager.createNewRule();
var eventDescriptor = rule.eventDescriptors.createNewEventDescriptor();
eventDescriptor.deviceId = device.id;
var eventType = root.deviceClass.eventTypes.findByName("triggered");

View File

@ -49,7 +49,7 @@ DevicePageBase {
param["paramTypeId"] = root.powerActionType.paramTypes.get(0).id;
param["value"] = !root.powerState.value;
params.push(param)
Engine.deviceManager.executeAction(root.device.id, root.powerStateType.id, params);
engine.deviceManager.executeAction(root.device.id, root.powerStateType.id, params);
}
}
@ -69,7 +69,7 @@ DevicePageBase {
param["paramTypeId"] = root.brightnessActionType.paramTypes.get(0).id;
param["value"] = brightness;
params.push(param)
Engine.deviceManager.executeAction(root.device.id, root.brightnessActionType.id, params);
engine.deviceManager.executeAction(root.device.id, root.brightnessActionType.id, params);
}
}
@ -105,7 +105,7 @@ DevicePageBase {
param["paramTypeId"] = root.ctActionType.paramTypes.get(0).id;
param["value"] = ct;
params.push(param)
Engine.deviceManager.executeAction(root.device.id, root.ctActionType.id, params);
engine.deviceManager.executeAction(root.device.id, root.ctActionType.id, params);
}
}
ColorPicker {
@ -145,7 +145,7 @@ DevicePageBase {
param1["paramTypeId"] = root.colorActionType.paramTypes.get(0).id;
param1["value"] = color;
params.push(param1)
Engine.deviceManager.executeAction(root.device.id, root.colorActionType.id, params)
engine.deviceManager.executeAction(root.device.id, root.colorActionType.id, params)
lastSentTime = currentTime
}
}

View File

@ -63,7 +63,7 @@ DevicePageBase {
bodyParam["paramTypeId"] = actionType.paramTypes.findByName("body").id
bodyParam["value"] = bodyTextField.text
params.push(bodyParam)
Engine.deviceManager.executeAction(root.device.id, actionType.id, params)
engine.deviceManager.executeAction(root.device.id, actionType.id, params)
}
root.inputVisible = !root.inputVisible
}

View File

@ -64,7 +64,7 @@ DevicePageBase {
percentageParam["paramTypeId"] = actionType.paramTypes.findByName("percentage").id;
percentageParam["value"] = value
params.push(percentageParam);
Engine.deviceManager.executeAction(root.device.id, actionType.id, params);
engine.deviceManager.executeAction(root.device.id, actionType.id, params);
}
}

View File

@ -28,7 +28,7 @@ Page {
LogsModel {
id: logsModel
engine: Engine
engine: app.engine
deviceId: root.device.id
live: true
Component.onCompleted: update()
@ -78,7 +78,7 @@ Page {
logsModel: logsModel
onAddRuleClicked: {
var rule = Engine.ruleManager.createNewRule();
var rule = engine.ruleManager.createNewRule();
var stateEvaluator = rule.createStateEvaluator();
stateEvaluator.stateDescriptor.deviceId = device.id;
stateEvaluator.stateDescriptor.stateTypeId = root.stateType.id;

View File

@ -26,7 +26,7 @@ Page {
RuleTemplatesFilterModel {
id: ruleTemplatesModel
ruleTemplates: RuleTemplates {}
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(root.device.deviceClassId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(root.device.deviceClassId) : null
filterInterfaceNames: deviceClass ? deviceClass.interfaces : []
}
@ -39,13 +39,13 @@ Page {
d.editRulePage = pageStack.push(Qt.resolvedUrl("NewThingMagicPage.qml"), {device: root.device});
d.editRulePage.manualCreation.connect(function() {
pageStack.pop();
rule = Engine.ruleManager.createNewRule();
rule = engine.ruleManager.createNewRule();
addRule(rule)
})
d.editRulePage.done.connect(function() {pageStack.pop(root);});
return;
}
rule = Engine.ruleManager.createNewRule();
rule = engine.ruleManager.createNewRule();
}
d.editRulePage = pageStack.push(Qt.resolvedUrl("EditRulePage.qml"), {rule: rule, initialDeviceToBeAdded: root.device});
d.editRulePage.StackView.onRemoved.connect(function() {
@ -53,7 +53,7 @@ Page {
})
d.editRulePage.onAccept.connect(function() {
d.editRulePage.busy = true;
Engine.ruleManager.addRule(d.editRulePage.rule);
engine.ruleManager.addRule(d.editRulePage.rule);
})
d.editRulePage.onCancel.connect(function() {
pageStack.pop();
@ -73,7 +73,7 @@ Page {
}
Connections {
target: Engine.ruleManager
target: engine.ruleManager
onAddRuleReply: {
d.editRulePage.busy = false;
if (ruleError == "RuleErrorNoError") {
@ -103,7 +103,7 @@ Page {
model: RulesFilterModel {
id: rulesFilterModel
rules: Engine.ruleManager.rules
rules: engine.ruleManager.rules
filterDeviceId: root.device.id
}
@ -114,7 +114,7 @@ Page {
text: model.name
canDelete: true
onDeleteClicked: Engine.ruleManager.removeRule(model.id)
onDeleteClicked: engine.ruleManager.removeRule(model.id)
onClicked: {
print("clicked")
var newRule = rulesFilterModel.get(index).clone();
@ -126,7 +126,7 @@ Page {
})
d.editRulePage.onAccept.connect(function() {
d.editRulePage.busy = true
Engine.ruleManager.editRule(d.editRulePage.rule);
engine.ruleManager.editRule(d.editRulePage.rule);
})
d.editRulePage.onCancel.connect(function() {
pageStack.pop();

View File

@ -15,13 +15,13 @@ Page {
readonly property bool isEventBased: rule.eventDescriptors.count > 0 || rule.timeDescriptor.timeEventItems.count > 0
readonly property bool isStateBased: (rule.stateEvaluator !== null || rule.timeDescriptor.calendarItems.count > 0) && !isEventBased
readonly property bool actionsVisible: true
readonly property bool exitActionsVisible: (Engine.jsonRpcClient.ensureServerVersion(1.7) && !isEmpty) || isStateBased
readonly property bool exitActionsVisible: (engine.jsonRpcClient.ensureServerVersion(1.7) && !isEmpty) || isStateBased
readonly property bool hasActions: rule.actions.count > 0
readonly property bool hasExitActions: rule.exitActions.count > 0
readonly property bool isEmpty: !isEventBased && !isStateBased && !hasActions
property string ruleIcon: Engine.tagsManager.tags.findRuleTag(rule.id, "icon").value
property string ruleColor: Engine.tagsManager.tags.findRuleTag(rule.id, "color").value
property string ruleIcon: engine.tagsManager.tags.findRuleTag(rule.id, "icon").value
property string ruleColor: engine.tagsManager.tags.findRuleTag(rule.id, "color").value
signal accept();
signal cancel();
@ -313,7 +313,7 @@ Page {
columnSpacing: app.margins
rowSpacing: app.margins
Layout.preferredHeight: opacity > 0 ? implicitHeight : 0
opacity: Engine.jsonRpcClient.ensureServerVersion(1.6) && ruleSettings.showDetails && root.rule.executable ? 1 : 0
opacity: engine.jsonRpcClient.ensureServerVersion(1.6) && ruleSettings.showDetails && root.rule.executable ? 1 : 0
Behavior on Layout.preferredHeight { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad} }
Behavior on opacity { NumberAnimation {duration: 200; easing.type: Easing.InOutQuad } }
@ -691,7 +691,7 @@ Page {
text: model.text
progressive: true
iconSize: app.iconSize * 2
visible: Engine.jsonRpcClient.ensureServerVersion(model.minimumJsonRpcVersion)
visible: engine.jsonRpcClient.ensureServerVersion(model.minimumJsonRpcVersion)
onClicked: {
root[model.method]()
@ -741,7 +741,7 @@ Page {
text: model.text
progressive: true
iconSize: app.iconSize * 2
visible: Engine.jsonRpcClient.ensureServerVersion(model.minimumJsonRpcVersion)
visible: engine.jsonRpcClient.ensureServerVersion(model.minimumJsonRpcVersion)
onClicked: {
root[model.method]()
@ -804,7 +804,7 @@ Page {
text: model.text
progressive: true
iconSize: app.iconSize * 2
visible: ruleActionQuestionPage.exitAction === model.isExitAction && Engine.jsonRpcClient.ensureServerVersion(model.minimumJsonRpcVersion)
visible: ruleActionQuestionPage.exitAction === model.isExitAction && engine.jsonRpcClient.ensureServerVersion(model.minimumJsonRpcVersion)
onClicked: {
root[model.method]()

View File

@ -11,8 +11,8 @@ MeaListItemDelegate {
progressive: false
property var eventDescriptor: null
readonly property var device: eventDescriptor ? Engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var device: eventDescriptor ? engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var iface: eventDescriptor.interfaceName ? Interfaces.findByName(eventDescriptor.interfaceName) : null
readonly property var eventType: deviceClass ? deviceClass.eventTypes.getEventType(eventDescriptor.eventTypeId)
: iface ? iface.eventTypes.findByName(eventDescriptor.interfaceEvent) : null

View File

@ -8,7 +8,7 @@ Page {
id: root
property var device: null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property bool busy: false
signal done();
@ -25,7 +25,7 @@ Page {
print("RuleFromTemplate: Filling eventDescriptor:", eventDescriptorTemplate.interfaceName, eventDescriptorTemplate.interfaceEvent, eventDescriptorTemplate.selectionId)
// If we already have a thing selected for this selectionIndex, use that
if (selectedThings.length > eventDescriptorTemplate.selectionId) {
var device = Engine.deviceManager.devices.getDevice(selectedThings[eventDescriptorTemplate.selectionId]);
var device = engine.deviceManager.devices.getDevice(selectedThings[eventDescriptorTemplate.selectionId]);
createEventDescriptor(rule, ruleTemplate, selectedThings, device, eventDescriptorTemplate)
return;
}
@ -80,7 +80,7 @@ Page {
// Did we pick a thing for this index before?
if (selectedThings.length > ruleActionTemplate.selectionId) {
var device = Engine.deviceManager.devices.getDevice(selectedThings[ruleActionTemplate.selectionId]);
var device = engine.deviceManager.devices.getDevice(selectedThings[ruleActionTemplate.selectionId]);
createRuleAction(rule, ruleTemplate, selectedThings, rule.actions, device, ruleActionTemplate)
return;
}
@ -96,8 +96,6 @@ Page {
print("Need to select a thing")
var page = pageStack.push(Qt.resolvedUrl("SelectThingPage.qml"), {shownInterfaces: [ruleActionTemplate.interfaceName]});
page.thingSelected.connect(function(device) {
print("selected device", device.name)
print("template is", ruleActionTemplate.interfaceName)
selectedThings.push(device.id);
createRuleAction(rule, ruleTemplate, selectedThings, rule.actions, device, ruleActionTemplate)
return;
@ -126,7 +124,7 @@ Page {
// Did we pick a thing for this index before?
if (selectedThings.length > ruleExitActionTemplate.selectionId) {
var device = Engine.deviceManager.devices.getDevice(selectedThings[ruleExitActionTemplate.selectionId]);
var device = engine.deviceManager.devices.getDevice(selectedThings[ruleExitActionTemplate.selectionId]);
createRuleAction(rule, ruleTemplate, selectedThings, rule.exitActions, device, ruleExitActionTemplate);
return;
}
@ -153,7 +151,7 @@ Page {
// Now replace %i in title and action params with selectedThings[i].name
rule.name = ruleTemplate.ruleNameTemplate;
for (var i = 0; i < selectedThings.length; i++) {
var device = Engine.deviceManager.devices.getDevice(selectedThings[i]);
var device = engine.deviceManager.devices.getDevice(selectedThings[i]);
rule.name = rule.name.arg(device.name)
for (var j = 0; j < rule.actions.count; j++) {
@ -178,7 +176,7 @@ Page {
}
print("Rule complete!")
Engine.ruleManager.addRule(rule);
engine.ruleManager.addRule(rule);
rule.destroy();
root.done();
}
@ -200,8 +198,8 @@ Page {
// did we pick a thing for this index before?
if (selectedThings.length > stateEvaluatorTemplate.stateDescriptorTemplate.selectionId) {
var deviceId = selectedThings[stateEvaluatorTemplate.stateDescriptorTemplate.selectionId]
var device = Engine.deviceManager.devices.getDevice(deviceId)
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var device = engine.deviceManager.devices.getDevice(deviceId)
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
stateEvaluator.stateDescriptor.deviceId = deviceId;
stateEvaluator.stateDescriptor.stateTypeId = deviceClass.stateTypes.findByName(stateEvaluatorTemplate.stateDescriptorTemplate.interfaceState).id
stateEvaluator.stateDescriptor.valueOperator = stateEvaluatorTemplate.stateDescriptorTemplate.valueOperator;
@ -222,7 +220,7 @@ Page {
print("..", stateEvaluatorTemplate.stateDescriptorTemplate.interfaceName)
var page = pageStack.push(Qt.resolvedUrl("SelectThingPage.qml"), {shownInterfaces: [stateEvaluatorTemplate.stateDescriptorTemplate.interfaceName], allowSelectAny: stateEvaluatorTemplate.stateDescriptorTemplate.selectionMode === StateDescriptorTemplate.SelectionModeAny});
page.thingSelected.connect(function(device) {
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
stateEvaluator.stateDescriptor.deviceId = device.id;
stateEvaluator.stateDescriptor.stateTypeId = deviceClass.stateTypes.findByName(stateEvaluatorTemplate.stateDescriptorTemplate.interfaceState).id;
stateEvaluator.stateDescriptor.valueOperator = stateEvaluatorTemplate.stateDescriptorTemplate.valueOperator;
@ -253,7 +251,7 @@ Page {
function createEventDescriptor(rule, ruleTemplate, selectedThings, device, eventDescriptorTemplate) {
var eventDescriptor = rule.eventDescriptors.createNewEventDescriptor();
eventDescriptor.deviceId = device.id;
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
eventDescriptor.eventTypeId = deviceClass.eventTypes.findByName(eventDescriptorTemplate.interfaceEvent).id
var needsParams = false;
for (var j = 0; j < eventDescriptorTemplate.paramDescriptors.count; j++) {
@ -278,7 +276,7 @@ Page {
function createRuleAction(rule, ruleTemplate, selectedThings, ruleActions, device, ruleActionTemplate) {
var ruleAction = ruleActions.createNewRuleAction();
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
ruleAction.deviceId = device.id;
ruleAction.actionTypeId = deviceClass.actionTypes.findByName(ruleActionTemplate.interfaceAction).id
for (var j = 0; j < ruleActionTemplate.ruleActionParams.count; j++) {
@ -312,7 +310,7 @@ Page {
onClicked: {
var ruleTemplate = ruleTemplatesModel.get(index);
var rule = Engine.ruleManager.createNewRule();
var rule = engine.ruleManager.createNewRule();
root.fillRuleFromTemplate(rule, ruleTemplate)
}
}

View File

@ -12,9 +12,9 @@ MeaListItemDelegate {
property var ruleAction: null
property var device: ruleAction.deviceId ? Engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
property var device: ruleAction.deviceId ? engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
property var iface: ruleAction.interfaceName ? Interfaces.findByName(ruleAction.interfaceName) : null
property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property var actionType: deviceClass ? deviceClass.actionTypes.getActionType(ruleAction.actionTypeId)
: iface ? iface.actionTypes.findByName(ruleAction.interfaceAction) : null

View File

@ -31,7 +31,7 @@ Page {
DevicesProxy {
id: ifaceFilterModel
engine: Engine
engine: app.engine
}
Component.onCompleted: {
@ -101,7 +101,7 @@ Page {
ListView {
Layout.fillHeight: true
Layout.fillWidth: true
model: Engine.deviceManager.devices
model: engine.deviceManager.devices
delegate: ItemDelegate {
width: parent.width
Label {
@ -111,7 +111,7 @@ Page {
verticalAlignment: Text.AlignVCenter
}
onClicked: {
var device = Engine.deviceManager.devices.get(index)
var device = engine.deviceManager.devices.get(index)
pageStack.push(selectDeviceActionComponent, {device: device})
}
}
@ -125,7 +125,7 @@ Page {
Page {
id: page
property var device
readonly property var deviceClass: Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
readonly property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
header: GuhHeader {
text: qsTr("Select action")
@ -252,7 +252,7 @@ Page {
model: DevicesProxy {
id: lightsModel
engine: Engine
engine: app.engine
shownInterfaces: ["light"]
}
delegate: CheckDelegate {
@ -273,7 +273,7 @@ Page {
continue;
}
var device = lightsModel.get(i);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId)
var action = {}
action["deviceId"] = device.id
@ -337,7 +337,7 @@ Page {
model: DevicesProxy {
id: notificationsModel
engine: Engine
engine: app.engine
shownInterfaces: ["notifications"]
}
delegate: CheckDelegate {

View File

@ -10,8 +10,8 @@ Page {
// an eventDescriptor object needs to be set and prefilled with either deviceId or interfaceName
property var eventDescriptor: null
readonly property var device: eventDescriptor && eventDescriptor.deviceId ? Engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var device: eventDescriptor && eventDescriptor.deviceId ? engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
signal backPressed();
signal done();

View File

@ -10,9 +10,9 @@ Page {
// Needs to be set and filled in with deviceId and eventTypeId
property var eventDescriptor: null
readonly property var device: eventDescriptor && eventDescriptor.deviceId ? Engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
readonly property var device: eventDescriptor && eventDescriptor.deviceId ? engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
readonly property var iface: eventDescriptor && eventDescriptor.interfaceName ? Interfaces.findByName(eventDescriptor.interfaceName) : null
readonly property var eventType: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId).eventTypes.getEventType(eventDescriptor.eventTypeId)
readonly property var eventType: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId).eventTypes.getEventType(eventDescriptor.eventTypeId)
: iface ? iface.eventTypes.findByName(eventDescriptor.interfaceEvent) : null
signal backPressed();

View File

@ -13,8 +13,8 @@ Page {
// optionally, a rule which will be used when determining params for the actions
property var rule: null
readonly property var device: ruleAction && ruleAction.deviceId ? Engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var device: ruleAction && ruleAction.deviceId ? engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
signal backPressed();
signal done();

View File

@ -13,9 +13,9 @@ Page {
// optionally a rule which will be used to propose event's params as param values
property var rule: null
readonly property var device: ruleAction && ruleAction.deviceId ? Engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
readonly property var device: ruleAction && ruleAction.deviceId ? engine.deviceManager.devices.getDevice(ruleAction.deviceId) : null
readonly property var iface: ruleAction && ruleAction.interfaceName ? Interfaces.findByName(ruleAction.interfaceName) : null
readonly property var actionType: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId).actionTypes.getActionType(ruleAction.actionTypeId)
readonly property var actionType: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId).actionTypes.getActionType(ruleAction.actionTypeId)
: iface ? iface.actionTypes.findByName(ruleAction.interfaceAction) : null
signal backPressed();
@ -79,8 +79,8 @@ Page {
visible: count > 0
Component.onCompleted: currentIndex = 0;
property var eventDescriptor: root.rule.eventDescriptors.count === 1 ? root.rule.eventDescriptors.get(0) : null
property var device: eventDescriptor ? Engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property var device: eventDescriptor ? engine.deviceManager.devices.getDevice(eventDescriptor.deviceId) : null
property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property var eventType: deviceClass ? deviceClass.eventTypes.getEventType(eventDescriptor.eventTypeId) : null
property var currentParamDescriptor: eventType.paramTypes.get(eventParamsComboBox.currentIndex)

View File

@ -10,8 +10,8 @@ Page {
// a ruleAction object needs to be set and prefilled with either deviceId or interfaceName
property var stateDescriptor: null
readonly property var device: stateDescriptor && stateDescriptor.deviceId ? Engine.deviceManager.devices.getDevice(stateDescriptor.deviceId) : null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var device: stateDescriptor && stateDescriptor.deviceId ? engine.deviceManager.devices.getDevice(stateDescriptor.deviceId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
signal backPressed();
signal done();

View File

@ -10,9 +10,9 @@ Page {
// Needs to be set and filled in with deviceId and eventTypeId
property var stateDescriptor: null
readonly property var device: stateDescriptor && stateDescriptor.deviceId ? Engine.deviceManager.devices.getDevice(stateDescriptor.deviceId) : null
readonly property var device: stateDescriptor && stateDescriptor.deviceId ? engine.deviceManager.devices.getDevice(stateDescriptor.deviceId) : null
readonly property var iface: stateDescriptor && stateDescriptor.interfaceName ? Interfaces.findByName(stateDescriptor.interfaceName) : null
readonly property var stateType: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId).stateTypes.getStateType(stateDescriptor.stateTypeId)
readonly property var stateType: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId).stateTypes.getStateType(stateDescriptor.stateTypeId)
: iface ? iface.stateTypes.findByName(stateDescriptor.interfaceState) : null
signal backPressed();

View File

@ -29,12 +29,12 @@ Page {
InterfacesProxy {
id: interfacesProxy
devicesFilter: Engine.deviceManager.devices
devicesFilter: engine.deviceManager.devices
}
DevicesProxy {
id: devicesProxy
engine: Engine
engine: app.engine
}
ColumnLayout {

View File

@ -12,8 +12,8 @@ SwipeDelegate {
property var stateEvaluator: null
property bool showChilds: false
readonly property var device: stateEvaluator ? Engine.deviceManager.devices.getDevice(stateEvaluator.stateDescriptor.deviceId) : null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var device: stateEvaluator ? engine.deviceManager.devices.getDevice(stateEvaluator.stateDescriptor.deviceId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var iface: stateEvaluator ? Interfaces.findByName(stateEvaluator.stateDescriptor.interfaceName) : null
readonly property var stateType: deviceClass ? deviceClass.stateTypes.getStateType(stateEvaluator.stateDescriptor.stateTypeId)
: iface ? iface.stateTypes.findByName(stateEvaluator.stateDescriptor.interfaceState) : null
@ -86,8 +86,8 @@ SwipeDelegate {
property var stateEvaluator: root.stateEvaluator.childEvaluators.get(index)
property var stateDescriptor: stateEvaluator.stateDescriptor
readonly property var device: Engine.deviceManager.devices.getDevice(stateDescriptor.deviceId)
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var device: engine.deviceManager.devices.getDevice(stateDescriptor.deviceId)
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var iface: Interfaces.findByName(stateEvaluator.stateDescriptor.interfaceName)
readonly property var stateType: device ? deviceClass.stateTypes.getStateType(stateDescriptor.stateTypeId)
: iface ? iface.stateTypes.findByName(stateEvaluator.stateDescriptor.interfaceState)

View File

@ -8,8 +8,8 @@ ItemDelegate {
id: root
property var stateEvaluator: null
readonly property var device: stateEvaluator ? Engine.deviceManager.devices.getDevice(stateEvaluator.stateDescriptor.deviceId) : null
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var device: stateEvaluator ? engine.deviceManager.devices.getDevice(stateEvaluator.stateDescriptor.deviceId) : null
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var stateType: deviceClass ? deviceClass.stateTypes.getStateType(stateEvaluator.stateDescriptor.stateTypeId) : null
property bool canDelete: true

View File

@ -21,7 +21,7 @@ Item {
model: InterfacesModel {
id: interfacesModel
deviceManager: Engine.deviceManager
deviceManager: engine.deviceManager
}
cellWidth: width / tilesPerRow
cellHeight: cellWidth

View File

@ -37,19 +37,19 @@ MainPageTile {
DevicesProxy {
id: devicesProxy
engine: Engine
engine: app.engine
shownInterfaces: [model.name]
}
DevicesProxy {
id: devicesSubProxyConnectables
engine: Engine
engine: app.engine
parentProxy: devicesProxy
filterDisconnected: true
}
DevicesProxy {
id: devicesSubProxyBattery
engine: Engine
engine: app.engine
parentProxy: devicesProxy
filterBatteryCritical: true
}
@ -99,7 +99,7 @@ MainPageTile {
var count = 0;
for (var i = 0; i < devicesProxy.count; i++) {
var device = devicesProxy.get(i);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var stateType = deviceClass.stateTypes.findByName("power")
if (device.states.getState(stateType.id).value === true) {
count++;
@ -110,7 +110,7 @@ MainPageTile {
var count = 0;
for (var i = 0; i < devicesProxy.count; i++) {
var device = devicesProxy.get(i);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var stateType = deviceClass.stateTypes.findByName("state");
if (device.states.getState(stateType.id).value !== "closed") {
count++;
@ -145,7 +145,7 @@ MainPageTile {
switch (model.name) {
case "media":
var device = devicesProxy.get(0)
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var stateType = deviceClass.stateTypes.findByName("playbackStatus");
var state = device.states.getState(stateType.id)
return state.value === "Playing" ? "../images/media-playback-pause.svg" :
@ -172,7 +172,7 @@ MainPageTile {
case "light":
if (devicesProxy.count == 1) {
var device = devicesProxy.get(0);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var stateType = deviceClass.stateTypes.findByName("power")
var actionType = deviceClass.actionTypes.findByName("power")
var params = [];
@ -180,11 +180,11 @@ MainPageTile {
param1["paramTypeId"] = actionType.paramTypes.get(0).id;
param1["value"] = !device.states.getState(stateType.id).value;
params.push(param1)
Engine.deviceManager.executeAction(device.id, actionType.id, params)
engine.deviceManager.executeAction(device.id, actionType.id, params)
} else {
for (var i = 0; i < devicesProxy.count; i++) {
var device = devicesProxy.get(i);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var actionType = deviceClass.actionTypes.findByName("power");
var params = [];
@ -192,13 +192,13 @@ MainPageTile {
param1["paramTypeId"] = actionType.paramTypes.get(0).id;
param1["value"] = false;
params.push(param1)
Engine.deviceManager.executeAction(device.id, actionType.id, params)
engine.deviceManager.executeAction(device.id, actionType.id, params)
}
}
break;
case "media":
var device = devicesProxy.get(0)
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var stateType = deviceClass.stateTypes.findByName("playbackStatus");
var state = device.states.getState(stateType.id)
@ -215,7 +215,7 @@ MainPageTile {
print("executing", device, device.id, actionTypeId, actionName, deviceClass.actionTypes)
Engine.deviceManager.executeAction(device.id, actionTypeId)
engine.deviceManager.executeAction(device.id, actionTypeId)
case "garagegate":
case "shutter":
case "extendedshutter":
@ -226,9 +226,9 @@ MainPageTile {
case "simpleclosable":
for (var i = 0; i < devicesProxy.count; i++) {
var device = devicesProxy.get(i);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var actionType = deviceClass.actionTypes.findByName("close");
Engine.deviceManager.executeAction(device.id, actionType.id)
engine.deviceManager.executeAction(device.id, actionType.id)
}
default:
@ -247,7 +247,7 @@ MainPageTile {
spacing: 0
property var device: devicesProxy.get(0)
property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property var state: deviceClass ? device.states.getState(deviceClass.stateTypes.findByName("temperature").id) : null
Label {

View File

@ -13,7 +13,7 @@ Item {
TagsProxyModel {
id: tagsProxy
tags: Engine.tagsManager.tags
tags: engine.tagsManager.tags
filterTagId: "favorites"
}
@ -44,8 +44,8 @@ Item {
property string deviceId: model.deviceId
property string ruleId: model.ruleId
readonly property var device: Engine.deviceManager.devices.getDevice(deviceId)
readonly property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var device: engine.deviceManager.devices.getDevice(deviceId)
readonly property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
readonly property var connectedState: deviceClass.interfaces.indexOf("connectable") >= 0 ? device.states.getState(deviceClass.stateTypes.findByName("connected").id) : null
readonly property var batteryCriticalState: deviceClass.interfaces.indexOf("battery") >= 0 ? device.states.getState(deviceClass.stateTypes.findByName("batteryCritical").id) : null
@ -161,7 +161,7 @@ Item {
}
var tag = tagsProxy.get(i);
Engine.tagsManager.tagDevice(tag.deviceId, tag.tagId, newIdx);
engine.tagsManager.tagDevice(tag.deviceId, tag.tagId, newIdx);
}
from = index;
}
@ -186,14 +186,14 @@ Item {
color: app.accentColor
}
onClicked: {
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var actionType = deviceClass.actionTypes.findByName("power");
var params = [];
var powerParam = {}
powerParam["paramTypeId"] = actionType.paramTypes.get(0).id;
powerParam["value"] = false;
params.push(powerParam)
Engine.deviceManager.executeAction(device.id, actionType.id, params);
engine.deviceManager.executeAction(device.id, actionType.id, params);
}
}
@ -207,14 +207,14 @@ Item {
to: 100
value: brightnessState.value
onMoved: {
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var actionType = deviceClass.actionTypes.findByName("brightness");
var params = [];
var powerParam = {}
powerParam["paramTypeId"] = actionType.paramTypes.get(0).id;
powerParam["value"] = value;
params.push(powerParam)
Engine.deviceManager.executeAction(device.id, actionType.id, params);
engine.deviceManager.executeAction(device.id, actionType.id, params);
}
}
@ -229,14 +229,14 @@ Item {
color: app.accentColor
}
onClicked: {
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var actionType = deviceClass.actionTypes.findByName("power");
var params = [];
var powerParam = {}
powerParam["paramTypeId"] = actionType.paramTypes.get(0).id;
powerParam["value"] = true;
params.push(powerParam)
Engine.deviceManager.executeAction(device.id, actionType.id, params);
engine.deviceManager.executeAction(device.id, actionType.id, params);
}
}
}
@ -370,9 +370,9 @@ Item {
color: app.accentColor
}
onClicked: {
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var actionType = deviceClass.actionTypes.findByName("open");
Engine.deviceManager.executeAction(device.id, actionType.id);
engine.deviceManager.executeAction(device.id, actionType.id);
}
}
@ -404,9 +404,9 @@ Item {
color: app.accentColor
}
onClicked: {
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var deviceClass = engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var actionType = deviceClass.actionTypes.findByName("close");
Engine.deviceManager.executeAction(device.id, actionType.id);
engine.deviceManager.executeAction(device.id, actionType.id);
}
}
}

View File

@ -20,7 +20,7 @@ Item {
readonly property int tilesPerRow: root.width / minTileWidth
model: RulesFilterModel {
rules: Engine.ruleManager.rules
rules: engine.ruleManager.rules
filterExecutable: true
}
cellWidth: width / tilesPerRow
@ -34,16 +34,16 @@ Item {
iconColor: colorTag ? colorTag.value : app.accentColor;
text: model.name.toUpperCase()
property var colorTag: Engine.tagsManager.tags.findRuleTag(model.id, "color")
property var iconTag: Engine.tagsManager.tags.findRuleTag(model.id, "icon")
property var colorTag: engine.tagsManager.tags.findRuleTag(model.id, "color")
property var iconTag: engine.tagsManager.tags.findRuleTag(model.id, "icon")
onClicked: Engine.ruleManager.executeActions(model.id)
onClicked: engine.ruleManager.executeActions(model.id)
Connections {
target: Engine.tagsManager.tags
target: engine.tagsManager.tags
onCountChanged: {
colorTag = Engine.tagsManager.tags.findRuleTag(model.id, "color")
iconTag = Engine.tagsManager.tags.findRuleTag(model.id, "icon")
colorTag = engine.tagsManager.tags.findRuleTag(model.id, "color")
iconTag = engine.tagsManager.tags.findRuleTag(model.id, "icon")
}
}
}

View File

@ -18,21 +18,21 @@ Page {
MeaListItemDelegate {
Layout.fillWidth: true
text: qsTr("Server UUID:")
subText: Engine.jsonRpcClient.serverUuid
subText: engine.jsonRpcClient.serverUuid
progressive: false
}
MeaListItemDelegate {
Layout.fillWidth: true
text: qsTr("Server version:")
subText: Engine.jsonRpcClient.serverVersion
subText: engine.jsonRpcClient.serverVersion
progressive: false
}
MeaListItemDelegate {
Layout.fillWidth: true
text: qsTr("Protocol version:")
subText: Engine.jsonRpcClient.jsonRpcVersion
subText: engine.jsonRpcClient.jsonRpcVersion
progressive: false
}
}

View File

@ -16,13 +16,13 @@ Page {
property bool deploymentStarted: false
Connections {
target: Engine.jsonRpcClient
target: engine.jsonRpcClient
onCloudConnectionStateChanged: {
print("cloud connection state changed", Engine.jsonRpcClient.cloudConnectionState)
if (Engine.jsonRpcClient.cloudConnectionState == JsonRpcClient.CloudConnectionStateConnected) {
print("cloud connection state changed", engine.jsonRpcClient.cloudConnectionState)
if (engine.jsonRpcClient.cloudConnectionState === JsonRpcClient.CloudConnectionStateConnected) {
d.deploymentStarted = false;
if (Engine.awsClient.awsDevices.getDevice(Engine.jsonRpcClient.serverUuid) === null) {
Engine.jsonRpcClient.setupRemoteAccess(Engine.awsClient.idToken, Engine.awsClient.userId)
if (engine.awsClient.awsDevices.getDevice(engine.jsonRpcClient.serverUuid) === null) {
engine.jsonRpcClient.setupRemoteAccess(engine.awsClient.idToken, engine.awsClient.userId)
}
}
}
@ -43,15 +43,15 @@ Page {
// Button {
// text: "pair"
// onClicked: Engine.jsonRpcClient.setupRemoteAccess(Engine.awsClient.idToken, Engine.awsClient.userId)
// onClicked: engine.jsonRpcClient.setupRemoteAccess(engine.awsClient.idToken, engine.awsClient.userId)
// }
SwitchDelegate {
Layout.fillWidth: true
text: qsTr("Cloud connection enabled")
checked: Engine.basicConfiguration.cloudEnabled
checked: engine.basicConfiguration.cloudEnabled
onToggled: {
Engine.basicConfiguration.cloudEnabled = checked;
engine.basicConfiguration.cloudEnabled = checked;
}
}
@ -65,9 +65,9 @@ Page {
ColorIcon {
Layout.preferredHeight: busyIndicator.height
Layout.preferredWidth: height
name: Engine.jsonRpcClient.cloudConnectionState === JsonRpcClient.CloudConnectionStateConnected
name: engine.jsonRpcClient.cloudConnectionState === JsonRpcClient.CloudConnectionStateConnected
? "../images/cloud.svg"
: Engine.jsonRpcClient.cloudConnectionState === JsonRpcClient.CloudConnectionStateUnconfigured
: engine.jsonRpcClient.cloudConnectionState === JsonRpcClient.CloudConnectionStateUnconfigured
? "../images/cloud-error.svg"
: "../images/cloud-offline.svg"
}
@ -76,7 +76,7 @@ Page {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: {
switch (Engine.jsonRpcClient.cloudConnectionState) {
switch (engine.jsonRpcClient.cloudConnectionState) {
case JsonRpcClient.CloudConnectionStateDisabled:
return qsTr("This box is not connected to %1:cloud").arg(app.systemName)
case JsonRpcClient.CloudConnectionStateUnconfigured:
@ -89,20 +89,20 @@ Page {
case JsonRpcClient.CloudConnectionStateConnected:
return qsTr("The box is connected to %1:cloud.").arg(app.systemName);
}
return Engine.jsonRpcClient.cloudConnectionState
return engine.jsonRpcClient.cloudConnectionState
}
}
BusyIndicator {
id: busyIndicator
visible: (Engine.jsonRpcClient.cloudConnectionState == JsonRpcClient.CloudConnectionStateUnconfigured && d.deploymentStarted) ||
Engine.jsonRpcClient.cloudConnectionState == JsonRpcClient.CloudConnectionStateConnecting
visible: (engine.jsonRpcClient.cloudConnectionState == JsonRpcClient.CloudConnectionStateUnconfigured && d.deploymentStarted) ||
engine.jsonRpcClient.cloudConnectionState == JsonRpcClient.CloudConnectionStateConnecting
}
}
Label {
Layout.fillWidth: true
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
visible: Engine.jsonRpcClient.cloudConnectionState === JsonRpcClient.CloudConnectionStateUnconfigured && !d.deploymentStarted
visible: engine.jsonRpcClient.cloudConnectionState === JsonRpcClient.CloudConnectionStateUnconfigured && !d.deploymentStarted
text: qsTr("This box is not configured to access the %1:cloud. In order for a box to connect to %1:cloud it needs to be registered first.").arg(app.systemName)
wrapMode: Text.WordWrap
}
@ -110,12 +110,12 @@ Page {
Button {
Layout.fillWidth: true
Layout.leftMargin: app.margins; Layout.rightMargin: app.margins
visible: Engine.jsonRpcClient.cloudConnectionState === JsonRpcClient.CloudConnectionStateUnconfigured && !d.deploymentStarted
text: Engine.awsClient.isLoggedIn ? qsTr("Register box") : qsTr("Log in to cloud")
visible: engine.jsonRpcClient.cloudConnectionState === JsonRpcClient.CloudConnectionStateUnconfigured && !d.deploymentStarted
text: engine.awsClient.isLoggedIn ? qsTr("Register box") : qsTr("Log in to cloud")
onClicked: {
if (Engine.awsClient.isLoggedIn) {
if (engine.awsClient.isLoggedIn) {
d.deploymentStarted = true
Engine.deployCertificate();
engine.deployCertificate();
} else {
pageStack.push(Qt.resolvedUrl("qrc:/ui/appsettings/CloudLoginPage.qml"))
}
@ -127,8 +127,8 @@ Page {
// Layout.fillWidth: true
// Layout.leftMargin: app.margins
// Layout.rightMargin: app.margins
// visible: Engine.basicConfiguration.cloudEnabled && Engine.awsClient.isLoggedIn
// text: Engine.awsClient.awsDevices.getDevice(Engine.jsonRpcClient.serverUuid) !== null ?
// visible: engine.basicConfiguration.cloudEnabled && engine.awsClient.isLoggedIn
// text: engine.awsClient.awsDevices.getDevice(engine.jsonRpcClient.serverUuid) !== null ?
// qsTr("This box is connected to a nymea:cloud.") :
// qsTr("Connecting to nymea:cloud...")
// }

View File

@ -25,7 +25,7 @@ Page {
LogsModel {
id: logsModel
engine: Engine
engine: app.engine
startTime: {
var date = new Date();
date.setHours(new Date().getHours() - 2);
@ -70,8 +70,8 @@ Page {
delegate: ItemDelegate {
id: delegate
width: parent.width
property var device: Engine.deviceManager.devices.getDevice(model.deviceId)
property var deviceClass: device ? Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
property var device: engine.deviceManager.devices.getDevice(model.deviceId)
property var deviceClass: device ? engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId) : null
leftPadding: 0
rightPadding: 0
topPadding: 0
@ -119,7 +119,7 @@ Page {
text: model.source === LogEntry.LoggingSourceSystem ?
qsTr("%1 Server").arg(app.systemName)
: model.source === LogEntry.LoggingSourceRules ?
Engine.ruleManager.rules.getRule(model.typeId).name
engine.ruleManager.rules.getRule(model.typeId).name
: delegate.device.name
elide: Text.ElideRight
}

View File

@ -18,13 +18,13 @@ Page {
HeaderButton {
imageSource: "../images/tick.svg"
onClicked: {
Engine.deviceManager.savePluginConfig(root.plugin.pluginId)
engine.deviceManager.savePluginConfig(root.plugin.pluginId)
}
}
}
Connections {
target: Engine.deviceManager
target: engine.deviceManager
onSavePluginConfigReply: {
if (params.params.deviceError === "DeviceErrorNoError") {
pageStack.pop();

View File

@ -15,14 +15,14 @@ Page {
ListView {
anchors.fill: parent
model: Engine.deviceManager.plugins
model: engine.deviceManager.plugins
clip: true
delegate: MeaListItemDelegate {
width: parent.width
iconName: "../images/plugin.svg"
text: model.name
onClicked: pageStack.push(Qt.resolvedUrl("PluginParamsPage.qml"), {plugin: Engine.deviceManager.plugins.get(index)})
onClicked: pageStack.push(Qt.resolvedUrl("PluginParamsPage.qml"), {plugin: engine.deviceManager.plugins.get(index)})
}
}
}