diff --git a/libnymea-app/connection/nymeaconnection.cpp b/libnymea-app/connection/nymeaconnection.cpp index 9ed2c2bd..1648b2d5 100644 --- a/libnymea-app/connection/nymeaconnection.cpp +++ b/libnymea-app/connection/nymeaconnection.cpp @@ -248,6 +248,7 @@ void NymeaConnection::onConnected() if (!m_currentTransport) { m_currentTransport = newTransport; qDebug() << "NymeaConnection: Connected to" << m_currentHost->name() << "via" << m_currentTransport->url(); + emit currentConnectionChanged(); emit connectedChanged(true); return; } diff --git a/libnymea-app/devicemanager.cpp b/libnymea-app/devicemanager.cpp index a1ac1532..ce0a07a7 100644 --- a/libnymea-app/devicemanager.cpp +++ b/libnymea-app/devicemanager.cpp @@ -195,7 +195,7 @@ void DeviceManager::notificationReceived(const QVariantMap &data) m_devices->addDevice(dev); } else if (notification == "Devices.DeviceRemoved") { QUuid deviceId = data.value("params").toMap().value("deviceId").toUuid(); - qDebug() << "JsonRpc: Notification: Device removed" << deviceId.toString(); +// qDebug() << "JsonRpc: Notification: Device removed" << deviceId.toString(); Device *device = m_devices->getDevice(deviceId); if (!device) { qWarning() << "Received a DeviceRemoved notification for a device we don't know!"; @@ -205,7 +205,7 @@ void DeviceManager::notificationReceived(const QVariantMap &data) device->deleteLater(); } else if (notification == "Devices.DeviceChanged") { QUuid deviceId = data.value("params").toMap().value("device").toMap().value("id").toUuid(); - qDebug() << "Device changed notification" << deviceId << data.value("params").toMap(); +// qDebug() << "Device changed notification" << deviceId << data.value("params").toMap(); Device *oldDevice = m_devices->getDevice(deviceId); if (!oldDevice) { qWarning() << "Received a device changed notification for a device we don't know"; @@ -215,12 +215,11 @@ void DeviceManager::notificationReceived(const QVariantMap &data) qWarning() << "Error parsing device changed notification"; return; } - qDebug() << "*** device unpacked" << oldDevice->stateValue("98e4476f-e745-4a7f-b795-19269cb70c40"); } else if (notification == "Devices.DeviceSettingChanged") { QUuid deviceId = data.value("params").toMap().value("deviceId").toUuid(); QString paramTypeId = data.value("params").toMap().value("paramTypeId").toString(); QVariant value = data.value("params").toMap().value("value"); - qDebug() << "Device settings changed notification for device" << deviceId << data.value("params").toMap().value("settings").toList(); +// qDebug() << "Device settings changed notification for device" << deviceId << data.value("params").toMap().value("settings").toList(); Device *dev = m_devices->getDevice(deviceId); if (!dev) { qWarning() << "Device settings changed notification for a device we don't know" << deviceId.toString(); diff --git a/nymea-app/images.qrc b/nymea-app/images.qrc index c9423e13..0c6a5287 100644 --- a/nymea-app/images.qrc +++ b/nymea-app/images.qrc @@ -243,5 +243,8 @@ ui/images/like.svg ui/images/zigbee.svg ui/images/stock_usb.svg + ui/images/twitter.svg + ui/images/discourse.svg + ui/images/telegram.svg diff --git a/nymea-app/resources.qrc b/nymea-app/resources.qrc index ccd269f7..42aabf68 100644 --- a/nymea-app/resources.qrc +++ b/nymea-app/resources.qrc @@ -229,5 +229,6 @@ ui/system/ZigbeeAddNetworkPage.qml ui/system/ZigbeeNetworkPage.qml ui/system/ZigbeeNetworkInfoPage.qml + ui/MainMenu.qml diff --git a/nymea-app/ui/MainMenu.qml b/nymea-app/ui/MainMenu.qml new file mode 100644 index 00000000..8251eb7b --- /dev/null +++ b/nymea-app/ui/MainMenu.qml @@ -0,0 +1,171 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.1 +import "components" +import Nymea 1.0 + +Rectangle { + id: root + visible: !Qt.colorEqual(color, "transparent") + property bool shown: false + + property Engine currentEngine: null + + signal openThingSettings(); + signal openMagicSettings(); + signal openAppSettings(); + signal openSystemSettings(); + + function show() { + shown = true; + } + function hide() { + shown = false; + } + + color: root.shown ? "#88000000" : "transparent" + Behavior on color { ColorAnimation { duration: 200 } } + + MouseArea { + anchors.fill: parent + onClicked: root.hide() + hoverEnabled: true + } + + Pane { + anchors { top: parent.top; bottom: parent.bottom; left: parent.left } + width: Math.min(root.width, 300) + anchors.leftMargin: root.shown ? 0 : -width + Behavior on anchors.leftMargin { NumberAnimation { duration: 200; easing.type: Easing.InOutQuad } } + + leftPadding: 0 + topPadding: 0 + rightPadding: 0 + bottomPadding: 0 + + ColumnLayout { + anchors { left: parent.left; top: parent.top; right: parent.right } + spacing: 0 + + Rectangle { + Layout.fillWidth: true + Layout.preferredHeight: topSectionLayout.implicitHeight + app.margins * 2 + color: Qt.tint(app.backgroundColor, Qt.rgba(app.foregroundColor.r, app.foregroundColor.g, app.foregroundColor.b, 0.05)) + ColumnLayout { + id: topSectionLayout + anchors { left: parent.left; top: parent.top; right: parent.right; margins: app.margins } + + RowLayout { + Image { + Layout.preferredHeight: app.hugeIconSize + Layout.preferredWidth: height + sourceSize.width: width + sourceSize.height: height + + source: "qrc:/styles/%1/logo.svg".arg(styleController.currentStyle) + } + Item { + Layout.fillHeight: true + Layout.fillWidth: true + } + ColorIcon { + Layout.preferredHeight: app.iconSize + Layout.preferredWidth: app.iconSize + name: { + if (root.currentEngine === null) { + return ""; + } + + switch (root.currentEngine.jsonRpcClient.currentConnection.bearerType) { + case Connection.BearerTypeLan: + case Connection.BearerTypeWan: + if (root.currentEngine.jsonRpcClient.availableBearerTypes & NymeaConnection.BearerTypeEthernet != NymeaConnection.BearerTypeNone) { + return "../images/connections/network-wired.svg" + } + return "../images/connections/network-wifi.svg"; + case Connection.BearerTypeBluetooth: + return "../images/connections/network-wifi.svg"; + case Connection.BearerTypeCloud: + return "../images/connections/cloud.svg" + case Connection.BearerTypeLoopback: + } + return "" + } + + } + } + + Label { + Layout.fillWidth: true + text: root.currentEngine.jsonRpcClient.currentHost.name + } + Label { + Layout.fillWidth: true + text: root.currentEngine.jsonRpcClient.currentConnection.url + font.pixelSize: app.smallFont + enabled: false + } + + } + } + + SettingsPageSectionHeader { + text: qsTr("Configuration") + } + + NymeaListItemDelegate { + Layout.fillWidth: true + text: qsTr("Configure things") + iconName: "../images/things.svg" + visible: root.currentEngine != null + progressive: false + onClicked: { + root.openThingSettings() + root.hide(); + } + } + NymeaListItemDelegate { + Layout.fillWidth: true + text: qsTr("Magic") + iconName: "../images/magic.svg" + progressive: false + visible: root.currentEngine != null + } + NymeaListItemDelegate { + Layout.fillWidth: true + text: qsTr("App settings") + iconName: "../images/stock_application.svg" + progressive: false + } + NymeaListItemDelegate { + Layout.fillWidth: true + text: qsTr("System settings") + iconName: "../images/settings.svg" + progressive: false + visible: root.currentEngine != null + } + SettingsPageSectionHeader { + text: qsTr("Community") + } + + NymeaListItemDelegate { + Layout.fillWidth: true + text: qsTr("Forum") + iconName: "../images/discourse.svg" + progressive: false + } + NymeaListItemDelegate { + Layout.fillWidth: true + text: qsTr("Telegram") + iconName: "../images/telegram.svg" + progressive: false + } + NymeaListItemDelegate { + Layout.fillWidth: true + text: qsTr("Twitter") + iconName: "../images/twitter.svg" + progressive: false + } + } + } +} diff --git a/nymea-app/ui/MainPage.qml b/nymea-app/ui/MainPage.qml index c88e870c..885d4d28 100644 --- a/nymea-app/ui/MainPage.qml +++ b/nymea-app/ui/MainPage.qml @@ -71,8 +71,9 @@ Page { return "" } onLeftButtonClicked: { - var dialog = connectionDialogComponent.createObject(root) - dialog.open(); + app.mainMenu.show() +// var dialog = connectionDialogComponent.createObject(root) +// dialog.open(); } onMenuOpenChanged: { if (menuOpen && d.configOverlay) { @@ -211,55 +212,6 @@ Page { } } -// Pane { -// Layout.fillWidth: true -// Layout.preferredHeight: shownHeight -// property int shownHeight: shown ? contentRow.implicitHeight : 0 -// property bool shown: updatesModel.count > 0 || engine.systemController.updateRunning -// visible: shownHeight > 0 -// Behavior on shownHeight { NumberAnimation { easing.type: Easing.InOutQuad; duration: 150 } } -// Material.elevation: 2 -// padding: 0 - -// MouseArea { -// anchors.fill: parent -// onClicked: pageStack.push(Qt.resolvedUrl("system/SystemUpdatePage.qml")) -// } - -// Rectangle { -// color: app.accentColor -// anchors.fill: parent - -// PackagesFilterModel { -// id: updatesModel -// packages: engine.systemController.packages -// updatesOnly: true -// } - -// RowLayout { -// id: contentRow -// anchors { left: parent.left; top: parent.top; right: parent.right; leftMargin: app.margins; rightMargin: app.margins } -// Item { -// Layout.fillWidth: true -// height: app.iconSize -// } - -// Label { -// text: engine.systemController.updateRunning ? qsTr("System update in progress...") : qsTr("%n system update(s) available", "", updatesModel.count) -// color: "white" -// font.pixelSize: app.smallFont -// } -// ColorIcon { -// height: app.iconSize / 2 -// width: height -// color: "white" -// name: "../images/system-update.svg" -// RotationAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; running: engine.systemController.updateRunning } -// } -// } -// } -// } - Item { id: contentContainer Layout.fillWidth: true diff --git a/nymea-app/ui/Nymea.qml b/nymea-app/ui/Nymea.qml index 509b1fab..fb2ff5fe 100644 --- a/nymea-app/ui/Nymea.qml +++ b/nymea-app/ui/Nymea.qml @@ -62,8 +62,8 @@ ApplicationWindow { property int smallIconSize: 16 property int iconSize: 24 - property int largeIconSize: 32 - property int hugeIconSize: 40 + property int largeIconSize: 40 + property int hugeIconSize: 64 property int delegateHeight: 60 property color backgroundColor: Material.background @@ -98,6 +98,15 @@ ApplicationWindow { value: settings.units === "metric" ? Types.UnitSystemMetric : Types.UnitSystemImperial } + property alias mainMenu: m + MainMenu { + id: m + anchors.fill: parent + z: 1000 + currentEngine: rootItem.currentEngine + onOpenThingSettings: rootItem.openThigSettings(); + } + RootItem { id: rootItem anchors.fill: parent diff --git a/nymea-app/ui/RootItem.qml b/nymea-app/ui/RootItem.qml index 990f14e9..1aff705f 100644 --- a/nymea-app/ui/RootItem.qml +++ b/nymea-app/ui/RootItem.qml @@ -40,10 +40,16 @@ import "connection" Item { id: root + readonly property Engine currentEngine: swipeView.currentItem.engine + function handleAndroidBackButton() { return swipeView.currentItem.handleAndroidBackButton() } + function openThigSettings() { + swipeView.currentItem.pageStack.push("thingconfiguration/EditThingsPage.qml") + } + ListModel { id: tabModel @@ -125,8 +131,9 @@ Item { value: engine.jsonRpcClient.currentHost === null } + readonly property alias pageStack: _pageStack StackView { - id: pageStack + id: _pageStack objectName: "pageStack" anchors.fill: parent initialItem: Page {} diff --git a/nymea-app/ui/components/MainPageTile.qml b/nymea-app/ui/components/MainPageTile.qml index 8c466eba..250ea509 100644 --- a/nymea-app/ui/components/MainPageTile.qml +++ b/nymea-app/ui/components/MainPageTile.qml @@ -132,7 +132,7 @@ Item { ColorIcon { id: colorIcon anchors.centerIn: parent - height: app.hugeIconSize + height: app.largeIconSize width: height ColorIcon { id: fallbackIcon diff --git a/nymea-app/ui/images/discourse.svg b/nymea-app/ui/images/discourse.svg new file mode 100644 index 00000000..6ee4506f --- /dev/null +++ b/nymea-app/ui/images/discourse.svg @@ -0,0 +1,180 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/nymea-app/ui/images/telegram.svg b/nymea-app/ui/images/telegram.svg new file mode 100644 index 00000000..5d961e4c --- /dev/null +++ b/nymea-app/ui/images/telegram.svg @@ -0,0 +1,23 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/nymea-app/ui/images/twitter.svg b/nymea-app/ui/images/twitter.svg new file mode 100644 index 00000000..ad453a3e --- /dev/null +++ b/nymea-app/ui/images/twitter.svg @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + +