diff --git a/nymea-app/resources.qrc b/nymea-app/resources.qrc
index 06696919..b17e625e 100644
--- a/nymea-app/resources.qrc
+++ b/nymea-app/resources.qrc
@@ -136,7 +136,6 @@
ui/devicepages/StateLogPage.qml
ui/customviews/GenericTypeLogView.qml
qtquickcontrols2.conf
- ui/BluetoothDiscoveryPage.qml
ui/images/bluetooth.svg
ui/images/refresh.svg
ui/WirelessControlerPage.qml
@@ -213,5 +212,7 @@
ui/components/EmptyViewPlaceholder.qml
ui/components/RemoveDeviceMethodDialog.qml
ui/components/FancyHeader.qml
+ ui/connection/ManualConnectPage.qml
+ ui/connection/BluetoothDiscoveryPage.qml
diff --git a/nymea-app/ui/ConnectPage.qml b/nymea-app/ui/ConnectPage.qml
index d2715c50..61fe1110 100644
--- a/nymea-app/ui/ConnectPage.qml
+++ b/nymea-app/ui/ConnectPage.qml
@@ -76,11 +76,26 @@ Page {
Page {
objectName: "discoveryPage"
- header: GuhHeader {
- text: qsTr("Connect %1").arg(app.systemName)
- backButtonVisible: false
- menuButtonVisible: true
- onMenuPressed: connectionMenu.open()
+ header: FancyHeader {
+ title: qsTr("Connect %1").arg(app.systemName)
+ model: ListModel {
+ ListElement { iconSource: "../images/network-vpn.svg"; text: qsTr("Manual connection"); page: "connection/ManualConnectPage.qml" }
+ ListElement { iconSource: "../images/bluetooth.svg"; text: qsTr("Wireless setup"); page: "connection/BluetoothDiscoveryPage.qml" }
+ ListElement { iconSource: "../images/private-browsing.svg"; text: qsTr("Demo mode"); page: "" }
+ ListElement { iconSource: "../images/stock_application.svg"; text: qsTr("App settings"); page: "AppSettingsPage.qml" }
+ }
+ onClicked: {
+ switch (index) {
+ case 0:
+ case 1:
+ case 3:
+ pageStack.push(model.get(index).page);
+ break;
+ case 2:
+ Engine.connection.connect("nymea://nymea.nymea.io:2222")
+ break;
+ }
+ }
}
Timer {
@@ -90,41 +105,6 @@ Page {
running: true
}
- Menu {
- id: connectionMenu
- objectName: "connectionMenu"
- width: implicitWidth + app.margins
-
- IconMenuItem {
- objectName: "manualConnectMenuItem"
- iconSource: "../images/network-vpn.svg"
- text: qsTr("Manual connection")
- onTriggered: pageStack.push(manualConnectPage)
- }
-
- IconMenuItem {
- iconSource: "../images/bluetooth.svg"
- text: qsTr("Wireless setup")
- onTriggered: pageStack.push(Qt.resolvedUrl("BluetoothDiscoveryPage.qml"))
- }
-
- IconMenuItem {
- iconSource: "../images/private-browsing.svg"
- text: qsTr("Demo mode")
- onTriggered: {
- pageStack.push(connectingPage)
- Engine.connection.connect("nymea://nymea.nymea.io:2222")
- }
- }
-
- MenuSeparator { }
-
- IconMenuItem {
- iconSource: "../images/stock_application.svg"
- text: qsTr("App settings")
- onTriggered: pageStack.push(Qt.resolvedUrl("AppSettingsPage.qml"))
- }
- }
ColumnLayout {
anchors.fill: parent
@@ -304,107 +284,6 @@ Page {
}
}
-
- Component {
- id: manualConnectPage
-
- Page {
- objectName: "manualConnectPage"
- header: GuhHeader {
- text: qsTr("Manual connection")
- onBackPressed: pageStack.pop()
- }
-
- ColumnLayout {
- anchors { left: parent.left; top: parent.top; right: parent.right }
- anchors.margins: app.margins
- spacing: app.margins
-
- GridLayout {
- columns: 2
-
- Label {
- text: qsTr("Protocol")
- }
-
- ComboBox {
- id: connectionTypeComboBox
- Layout.fillWidth: true
- model: [ qsTr("TCP"), qsTr("Websocket") ]
- }
-
- Label { text: qsTr("Address:") }
- TextField {
- id: addressTextInput
- objectName: "addressTextInput"
- Layout.fillWidth: true
- placeholderText: "127.0.0.1"
- }
-
- Label { text: qsTr("Port:") }
- TextField {
- id: portTextInput
- Layout.fillWidth: true
- placeholderText: connectionTypeComboBox.currentIndex === 0 ? "2222" : "4444"
- validator: IntValidator{bottom: 1; top: 65535;}
- }
-
- Label {
- Layout.fillWidth: true
- text: qsTr("Encrypted connection:")
- }
- CheckBox {
- id: secureCheckBox
- checked: true
- }
- }
-
-
- Button {
- text: qsTr("Connect")
- objectName: "connectButton"
- Layout.fillWidth: true
- onClicked: {
- var rpcUrl
- var hostAddress
- var port
-
- // Set default to placeholder
- if (addressTextInput.text === "") {
- hostAddress = addressTextInput.placeholderText
- } else {
- hostAddress = addressTextInput.text
- }
-
- if (portTextInput.text === "") {
- port = portTextInput.placeholderText
- } else {
- port = portTextInput.text
- }
-
- if (connectionTypeComboBox.currentIndex == 0) {
- if (secureCheckBox.checked) {
- rpcUrl = "nymeas://" + hostAddress + ":" + port
- } else {
- rpcUrl = "nymea://" + hostAddress + ":" + port
- }
- } else if (connectionTypeComboBox.currentIndex == 1) {
- if (secureCheckBox.checked) {
- rpcUrl = "wss://" + hostAddress + ":" + port
- } else {
- rpcUrl = "ws://" + hostAddress + ":" + port
- }
- }
-
- print("Try to connect ", rpcUrl)
- Engine.connection.connect(rpcUrl)
- pageStack.push(connectingPage)
- }
- }
- }
- }
- }
-
Component {
id: connectingPage
Page {
diff --git a/nymea-app/ui/MainPage.qml b/nymea-app/ui/MainPage.qml
index 1b989aef..23ee8bd6 100644
--- a/nymea-app/ui/MainPage.qml
+++ b/nymea-app/ui/MainPage.qml
@@ -14,10 +14,14 @@ Page {
title: swipeView.currentItem.title
model: ListModel {
- ListElement { iconSource: "../images/share.svg"; text: qsTr("Configure things"); page: "../EditDevicesPage.qml" }
- ListElement { iconSource: "../images/magic.svg"; text: qsTr("Magic"); page: "../MagicPage.qml" }
- ListElement { iconSource: "../images/settings.svg"; text: qsTr("System settings"); page: "../SettingsPage.qml" }
- ListElement { iconSource: "../images/stock_application.svg"; text: qsTr("App settings"); page: "../AppSettingsPage.qml" }
+ ListElement { iconSource: "../images/share.svg"; text: qsTr("Configure things"); page: "EditDevicesPage.qml" }
+ ListElement { iconSource: "../images/magic.svg"; text: qsTr("Magic"); page: "MagicPage.qml" }
+ ListElement { iconSource: "../images/settings.svg"; text: qsTr("System settings"); page: "SettingsPage.qml" }
+ ListElement { iconSource: "../images/stock_application.svg"; text: qsTr("App settings"); page: "AppSettingsPage.qml" }
+ }
+
+ onClicked: {
+ pageStack.push(model.get(index).page)
}
}
diff --git a/nymea-app/ui/components/FancyHeader.qml b/nymea-app/ui/components/FancyHeader.qml
index 432ab946..8e1e16af 100644
--- a/nymea-app/ui/components/FancyHeader.qml
+++ b/nymea-app/ui/components/FancyHeader.qml
@@ -10,6 +10,8 @@ ToolBar {
property string title
property alias model: menuRepeater.model
+ signal clicked(int index);
+
QtObject {
id: d
property bool menuOpen: false
@@ -87,7 +89,7 @@ ToolBar {
onClicked: {
d.menuOpen = false
- pageStack.push(model.page)
+ root.clicked(index)
}
Rectangle {
diff --git a/nymea-app/ui/BluetoothDiscoveryPage.qml b/nymea-app/ui/connection/BluetoothDiscoveryPage.qml
similarity index 96%
rename from nymea-app/ui/BluetoothDiscoveryPage.qml
rename to nymea-app/ui/connection/BluetoothDiscoveryPage.qml
index a47aaeed..77fbaa42 100644
--- a/nymea-app/ui/BluetoothDiscoveryPage.qml
+++ b/nymea-app/ui/connection/BluetoothDiscoveryPage.qml
@@ -1,7 +1,7 @@
import QtQuick 2.4
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.2
-import "components"
+import "../components"
import Nymea 1.0
@@ -12,7 +12,7 @@ Page {
onBackPressed: pageStack.pop()
HeaderButton {
- imageSource: Qt.resolvedUrl("images/refresh.svg")
+ imageSource: Qt.resolvedUrl("../images/refresh.svg")
onClicked: Engine.bluetoothDiscovery.start()
}
}
@@ -68,7 +68,7 @@ Page {
delegate: MeaListItemDelegate {
width: parent.width
- iconName: Qt.resolvedUrl("images/bluetooth.svg")
+ iconName: Qt.resolvedUrl("../images/bluetooth.svg")
text: model.name
subText: model.address
@@ -138,7 +138,7 @@ Page {
sourceSize.height: 540
fillMode: Image.PreserveAspectFit
Layout.alignment: Qt.AlignHCenter
- source: "images/rpi-setup.svg"
+ source: "../images/rpi-setup.svg"
}
ThinDivider {}
Label {
@@ -164,7 +164,7 @@ Page {
sourceSize.height: width
fillMode: Image.PreserveAspectFit
Layout.alignment: Qt.AlignHCenter
- source: "images/nymea-box-setup.svg"
+ source: "../images/nymea-box-setup.svg"
}
}
}
diff --git a/nymea-app/ui/connection/ManualConnectPage.qml b/nymea-app/ui/connection/ManualConnectPage.qml
new file mode 100644
index 00000000..9d53e60f
--- /dev/null
+++ b/nymea-app/ui/connection/ManualConnectPage.qml
@@ -0,0 +1,101 @@
+import QtQuick 2.9
+import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
+import Nymea 1.0
+import "../components"
+
+Page {
+ objectName: "manualConnectPage"
+ header: GuhHeader {
+ text: qsTr("Manual connection")
+ onBackPressed: pageStack.pop()
+ }
+
+ ColumnLayout {
+ anchors { left: parent.left; top: parent.top; right: parent.right }
+ anchors.margins: app.margins
+ spacing: app.margins
+
+ GridLayout {
+ columns: 2
+
+ Label {
+ text: qsTr("Protocol")
+ }
+
+ ComboBox {
+ id: connectionTypeComboBox
+ Layout.fillWidth: true
+ model: [ qsTr("TCP"), qsTr("Websocket") ]
+ }
+
+ Label { text: qsTr("Address:") }
+ TextField {
+ id: addressTextInput
+ objectName: "addressTextInput"
+ Layout.fillWidth: true
+ placeholderText: "127.0.0.1"
+ }
+
+ Label { text: qsTr("Port:") }
+ TextField {
+ id: portTextInput
+ Layout.fillWidth: true
+ placeholderText: connectionTypeComboBox.currentIndex === 0 ? "2222" : "4444"
+ validator: IntValidator{bottom: 1; top: 65535;}
+ }
+
+ Label {
+ Layout.fillWidth: true
+ text: qsTr("Encrypted connection:")
+ }
+ CheckBox {
+ id: secureCheckBox
+ checked: true
+ }
+ }
+
+
+ Button {
+ text: qsTr("Connect")
+ objectName: "connectButton"
+ Layout.fillWidth: true
+ onClicked: {
+ var rpcUrl
+ var hostAddress
+ var port
+
+ // Set default to placeholder
+ if (addressTextInput.text === "") {
+ hostAddress = addressTextInput.placeholderText
+ } else {
+ hostAddress = addressTextInput.text
+ }
+
+ if (portTextInput.text === "") {
+ port = portTextInput.placeholderText
+ } else {
+ port = portTextInput.text
+ }
+
+ if (connectionTypeComboBox.currentIndex == 0) {
+ if (secureCheckBox.checked) {
+ rpcUrl = "nymeas://" + hostAddress + ":" + port
+ } else {
+ rpcUrl = "nymea://" + hostAddress + ":" + port
+ }
+ } else if (connectionTypeComboBox.currentIndex == 1) {
+ if (secureCheckBox.checked) {
+ rpcUrl = "wss://" + hostAddress + ":" + port
+ } else {
+ rpcUrl = "ws://" + hostAddress + ":" + port
+ }
+ }
+
+ print("Try to connect ", rpcUrl)
+ Engine.connection.connect(rpcUrl)
+ pageStack.push(connectingPage)
+ }
+ }
+ }
+}