aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Hölttä <AHoelttae@luxoft.com>2017-12-13 13:02:00 +0100
committerDaniel d'Andrada <daniel.dandrada@luxoft.com>2018-02-28 15:58:10 +0100
commit851bf735fec8e9705dbfa5bcdb5323753bc1876c (patch)
tree7df977431ec27bd8c5b10e45020098511ed9ad71
parent909717cfb1703e5796f677aa228e2468adffa8c2 (diff)
Add connection dialog to the android app and several fixes related to the connection. Removed useless macos specific instructions from .pro files. Changed some build destinations so that running from build directory now works (again) as well.
-rw-r--r--README.md1
-rw-r--r--copydata.pro2
-rw-r--r--server.conf2
-rw-r--r--src/remotesettings/app/app.pro2
-rw-r--r--src/remotesettings/app_dynamicreplica/ConnectionDialog.qml88
-rw-r--r--src/remotesettings/app_dynamicreplica/abstractdynamic.cpp15
-rw-r--r--src/remotesettings/app_dynamicreplica/abstractdynamic.h2
-rw-r--r--src/remotesettings/app_dynamicreplica/client.cpp65
-rw-r--r--src/remotesettings/app_dynamicreplica/client.h10
-rw-r--r--src/remotesettings/app_dynamicreplica/main.cpp2
-rw-r--r--src/remotesettings/app_dynamicreplica/main.qml74
-rw-r--r--src/remotesettings/app_dynamicreplica/qml.qrc1
-rw-r--r--src/remotesettings/backend/backend.pro4
-rw-r--r--src/remotesettings/frontend/frontend.pro2
-rw-r--r--src/remotesettings/qml_plugin/qml_plugin.pro2
-rw-r--r--src/remotesettings/server/server.pro6
-rw-r--r--triton-ui.pro3
17 files changed, 243 insertions, 38 deletions
diff --git a/README.md b/README.md
index 6804924b..04bd14b1 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,7 @@ To get more detailed log output, run:
This will lookup the settings lib from the `./lib` folder.
+To run the settings server, just run the executable RemoteSettings_server
# Run the UI without QtIVI
diff --git a/copydata.pro b/copydata.pro
index 4b4cb278..9d7538cb 100644
--- a/copydata.pro
+++ b/copydata.pro
@@ -1,7 +1,7 @@
TEMPLATE = aux
# Copy all QML files during the build time
-do_copydata.commands = $(COPY_DIR) $$PWD/apps $$PWD/imports $$PWD/sysui $$PWD/styles $$PWD/am-config.yaml $$PWD/Main.qml $$OUT_PWD
+do_copydata.commands = $(COPY_DIR) $$PWD/apps $$PWD/imports $$PWD/sysui $$PWD/styles $$PWD/am-config.yaml $$PWD/Main.qml $$PWD/server.conf $$OUT_PWD
first.depends = do_copydata
!equals(PWD, $$OUT_PWD):QMAKE_EXTRA_TARGETS += first do_copydata
diff --git a/server.conf b/server.conf
new file mode 100644
index 00000000..0c302fe6
--- /dev/null
+++ b/server.conf
@@ -0,0 +1,2 @@
+[settings]
+Registry=tcp://0.0.0.0:9999
diff --git a/src/remotesettings/app/app.pro b/src/remotesettings/app/app.pro
index b4efb4c6..53fc5503 100644
--- a/src/remotesettings/app/app.pro
+++ b/src/remotesettings/app/app.pro
@@ -5,7 +5,7 @@ DESTDIR = ../qtivi
include($$SOURCE_DIR/config.pri)
-LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(RemoteSettings)
+LIBS += -L$$OUT_PWD/../../../lib -l$$qtLibraryTarget(RemoteSettings)
INCLUDEPATH += $$OUT_PWD/../frontend
diff --git a/src/remotesettings/app_dynamicreplica/ConnectionDialog.qml b/src/remotesettings/app_dynamicreplica/ConnectionDialog.qml
new file mode 100644
index 00000000..4d0875fc
--- /dev/null
+++ b/src/remotesettings/app_dynamicreplica/ConnectionDialog.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Triton IVI UI.
+**
+** $QT_BEGIN_LICENSE:GPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: GPL-3.0
+**
+****************************************************************************/
+import QtQuick 2.7
+import QtQuick.Controls 2.2
+import QtQuick.Layouts 1.3
+
+Dialog {
+ id: connectionDialog
+ property string url
+ property string statusText
+
+ signal accepted(bool accepted)
+
+ contentItem: Rectangle {
+
+ ColumnLayout {
+ anchors.fill: parent
+ anchors.margins: 10
+ spacing: 10
+
+ Label {
+ text: qsTr("Connection settings")
+ Layout.alignment: Qt.AlignCenter
+ }
+
+ RowLayout {
+ Layout.fillWidth: true
+ spacing: 10
+
+ Layout.alignment: Qt.AlignCenter
+
+ Label {
+ text: qsTr("Server URL")
+ }
+
+ TextField {
+ text: url
+ onTextChanged: url=text
+ }
+ }
+
+ RowLayout {
+ //Layout.fillWidth: true
+ spacing: 10
+
+ Layout.alignment: Qt.AlignCenter
+
+ Button {
+ text: qsTr("Connect")
+ onClicked: connectionDialog.accepted(true)
+ }
+
+ Button {
+ text: qsTr("Cancel")
+ onClicked: connectionDialog.accepted(false)
+ }
+ }
+ }
+ }
+}
diff --git a/src/remotesettings/app_dynamicreplica/abstractdynamic.cpp b/src/remotesettings/app_dynamicreplica/abstractdynamic.cpp
index 10fc8284..a6eada8b 100644
--- a/src/remotesettings/app_dynamicreplica/abstractdynamic.cpp
+++ b/src/remotesettings/app_dynamicreplica/abstractdynamic.cpp
@@ -34,25 +34,32 @@ AbstractDynamic::AbstractDynamic(QObject *parent)
: QObject(parent)
, m_connected(false)
{
-
}
-void AbstractDynamic::resetReplica(QSharedPointer<QRemoteObjectDynamicReplica> replicaPtr)
+void AbstractDynamic::resetReplica(QRemoteObjectDynamicReplica *replicaPtr)
{
+ if (m_replicaPtr.data()==replicaPtr)
+ return;
+
setConnected(false);
- if (m_replicaPtr) {
+ if (m_replicaPtr.data()) {
disconnect(m_replicaPtr.data(),&QRemoteObjectDynamicReplica::initialized,
this, &AbstractDynamic::onInitialized);
disconnect(m_replicaPtr.data(),&QRemoteObjectDynamicReplica::stateChanged,
this, &AbstractDynamic::onStateChanged);
}
- m_replicaPtr = replicaPtr;
+ m_replicaPtr.reset(replicaPtr);
+ if (m_replicaPtr.isNull())
+ return;
+
connect(m_replicaPtr.data(),&QRemoteObjectDynamicReplica::initialized,
this, &AbstractDynamic::onInitialized);
connect(m_replicaPtr.data(),&QRemoteObjectDynamicReplica::stateChanged,
this, &AbstractDynamic::onStateChanged);
+ if (m_replicaPtr.data()->isInitialized())
+ onInitialized();
}
bool AbstractDynamic::connected() const
diff --git a/src/remotesettings/app_dynamicreplica/abstractdynamic.h b/src/remotesettings/app_dynamicreplica/abstractdynamic.h
index 1315b0d5..e9cb731c 100644
--- a/src/remotesettings/app_dynamicreplica/abstractdynamic.h
+++ b/src/remotesettings/app_dynamicreplica/abstractdynamic.h
@@ -43,7 +43,7 @@ class AbstractDynamic : public QObject
public:
explicit AbstractDynamic(QObject *parent = nullptr);
- void resetReplica(QSharedPointer<QRemoteObjectDynamicReplica> replicaPtr);
+ void resetReplica(QRemoteObjectDynamicReplica *replicaPtr);
bool connected() const;
signals:
diff --git a/src/remotesettings/app_dynamicreplica/client.cpp b/src/remotesettings/app_dynamicreplica/client.cpp
index 9aecb0b8..d654a65b 100644
--- a/src/remotesettings/app_dynamicreplica/client.cpp
+++ b/src/remotesettings/app_dynamicreplica/client.cpp
@@ -35,7 +35,8 @@ Q_LOGGING_CATEGORY(remoteSettingsDynamicApp, "remotesettings.dynamicApp")
Client::Client(QObject *parent) : QObject(parent)
{
-
+ QObject::connect(&m_repNode, &QRemoteObjectNode::error, this, &Client::onError);
+ setStatus(tr("Not connected"));
}
void Client::setContextProperties(QQmlContext *context)
@@ -46,30 +47,58 @@ void Client::setContextProperties(QQmlContext *context)
context->setContextProperty(QStringLiteral("model3DSettings"), &m_model3DSettings);
}
-void Client::connectToServer(const QString &url)
+QUrl Client::serverUrl() const
{
- QSharedPointer<QRemoteObjectDynamicReplica> cultureRep;
- QSharedPointer<QRemoteObjectDynamicReplica> audioRep;
- QSharedPointer<QRemoteObjectDynamicReplica> navigationRep;
- QSharedPointer<QRemoteObjectDynamicReplica> model3DRep;
+ return m_serverUrl;
+}
- m_repNode.connectToNode(QUrl(url));
- //repNode.connectToNode(QUrl("tcp://10.10.1.76:9999")); // create remote object node
- //repNode.connectToNode(QUrl("local:settings"));
- QObject::connect(&m_repNode, &QRemoteObjectNode::error, this, &Client::onError);
+QString Client::status() const
+{
+ return m_status;
+}
- audioRep.reset(m_repNode.acquireDynamic("settings.AudioSettings"));
- cultureRep.reset(m_repNode.acquireDynamic("settings.CultureSettings"));
- navigationRep.reset(m_repNode.acquireDynamic("settings.NavigationSettings"));
- model3DRep.reset(m_repNode.acquireDynamic("settings.Model3DSettings"));
+void Client::connectToServer(const QString &serverUrl)
+{
+ QUrl url(serverUrl);
+ if (!url.isValid()) {
+ setStatus(tr("Invalid URL: %1").arg(url.toString()));
+ return;
+ }
- m_cultureSettings.resetReplica(cultureRep);
- m_audioSettings.resetReplica(audioRep);
- m_navigationSettings.resetReplica(navigationRep);
- m_model3DSettings.resetReplica(model3DRep);
+ if (url==m_serverUrl)
+ return;
+
+ if (m_repNode.connectToNode(url)) {
+ m_audioSettings.resetReplica(m_repNode.acquireDynamic("settings.AudioSettings"));
+ m_cultureSettings.resetReplica(m_repNode.acquireDynamic("settings.CultureSettings"));
+ m_navigationSettings.resetReplica(m_repNode.acquireDynamic("settings.NavigationSettings"));
+ m_model3DSettings.resetReplica(m_repNode.acquireDynamic("settings.Model3DSettings"));
+
+ setStatus(tr("Connected to %1").arg(url.toString()));
+ } else {
+ setStatus(tr("Connection to %1 failed").arg(url.toString()));
+ m_cultureSettings.resetReplica(nullptr);
+ m_audioSettings.resetReplica(nullptr);
+ m_navigationSettings.resetReplica(nullptr);
+ m_model3DSettings.resetReplica(nullptr);
+ }
+
+ if (m_serverUrl!=url) {
+ m_serverUrl=url;
+ emit serverUrlChanged(m_serverUrl);
+ }
}
void Client::onError(QRemoteObjectNode::ErrorCode code)
{
qCWarning(remoteSettingsDynamicApp) << "Remote objects error, code:" << code;
}
+
+void Client::setStatus(const QString &status)
+{
+ if (status==m_status)
+ return;
+ m_status=status;
+ qCWarning(remoteSettingsDynamicApp) << "Client status: " << status;
+ emit statusChanged(m_status);
+}
diff --git a/src/remotesettings/app_dynamicreplica/client.h b/src/remotesettings/app_dynamicreplica/client.h
index 5b684c66..fb247cb2 100644
--- a/src/remotesettings/app_dynamicreplica/client.h
+++ b/src/remotesettings/app_dynamicreplica/client.h
@@ -44,19 +44,29 @@ Q_DECLARE_LOGGING_CATEGORY(remoteSettingsDynamicApp)
class Client : public QObject
{
Q_OBJECT
+ Q_PROPERTY(QUrl serverUrl READ serverUrl NOTIFY serverUrlChanged)
+ Q_PROPERTY(QString status READ status NOTIFY statusChanged)
public:
explicit Client(QObject *parent = nullptr);
void setContextProperties(QQmlContext *context);
+ QUrl serverUrl() const;
+ QString status() const;
signals:
+ void serverUrlChanged(const QUrl &url);
+ void statusChanged(const QString &status);
public slots:
void connectToServer(const QString &url);
void onError(QRemoteObjectNode::ErrorCode code);
private:
+ void setStatus(const QString &status);
+
QRemoteObjectNode m_repNode;
+ QUrl m_serverUrl;
+ QString m_status;
CultureSettingsDynamic m_cultureSettings;
AudioSettingsDynamic m_audioSettings;
diff --git a/src/remotesettings/app_dynamicreplica/main.cpp b/src/remotesettings/app_dynamicreplica/main.cpp
index 7e223769..44623259 100644
--- a/src/remotesettings/app_dynamicreplica/main.cpp
+++ b/src/remotesettings/app_dynamicreplica/main.cpp
@@ -49,7 +49,5 @@ int main(int argc, char *argv[])
if (engine.rootObjects().isEmpty())
return -1;
- client.connectToServer("tcp://10.10.1.76:9999");
-
return app.exec();
}
diff --git a/src/remotesettings/app_dynamicreplica/main.qml b/src/remotesettings/app_dynamicreplica/main.qml
index 13568d7d..906f8579 100644
--- a/src/remotesettings/app_dynamicreplica/main.qml
+++ b/src/remotesettings/app_dynamicreplica/main.qml
@@ -33,23 +33,89 @@ import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
ApplicationWindow {
+ id: root
+
visible: true
width: 640
height: 480
title: qsTr("Settings app")
+ readonly property bool connected: audioSettings.connected ||
+ cultureSettings.connected ||
+ model3DSettings.connected ||
+ navigationSettings.connected
+
+ Component.onCompleted: {
+ connectionDialog.open()
+ }
+
+ ConnectionDialog {
+ id: connectionDialog
+ property string defaultUrl : "tcp://127.0.0.1:9999"
+ url: defaultUrl
+ statusText: client.status
+
+ width: parent.width / 2
+ height: parent.height / 2
+
+ x: (parent.width-width) /2
+ y: (parent.height-height) /2
+
+ onAccepted: {
+ if (accepted)
+ client.connectToServer(url);
+ else
+ connectionDialog.close();
+ }
+
+ Connections {
+ target: client
+ onServerUrlChanged: {
+ if (client.serverUrl.toString().length)
+ connectionDialog.url = client.serverUrl.toString();
+ else
+ connectionDialog.url = defaultUrl;
+ }
+ }
+
+ Connections {
+ target: root
+ onConnectedChanged: {
+ if (root.connected)
+ connectionDialog.close();
+ }
+ }
+
+ }
+
ColumnLayout {
anchors.fill: parent
anchors.margins: 10
spacing: 10
+ RowLayout {
+ Layout.fillWidth: true
+
+ Label {
+ Layout.fillWidth: true
+ Layout.alignment: Qt.AlignLeft
+ text: client.status
+ }
+
+ Button {
+ //anchors.right: parent.right
+ text: qsTr("Connect...")
+ onClicked: connectionDialog.open()
+ }
+ }
+
GroupBox {
title: qsTr("Culture settings")
Layout.fillWidth: true
- Row {
+ RowLayout {
Label {
text: qsTr("Language:")
@@ -70,7 +136,7 @@ ApplicationWindow {
Layout.fillWidth: true
- Row {
+ RowLayout {
Label {
text: qsTr("Volume:")
}
@@ -107,7 +173,7 @@ ApplicationWindow {
Layout.fillWidth: true
- Row {
+ RowLayout {
Label {
text: qsTr("Night mode:")
@@ -126,7 +192,7 @@ ApplicationWindow {
Layout.fillWidth: true
- Row {
+ RowLayout {
Label {
text: qsTr("Door 1 open:")
}
diff --git a/src/remotesettings/app_dynamicreplica/qml.qrc b/src/remotesettings/app_dynamicreplica/qml.qrc
index af1cc9bc..13d46c9f 100644
--- a/src/remotesettings/app_dynamicreplica/qml.qrc
+++ b/src/remotesettings/app_dynamicreplica/qml.qrc
@@ -2,5 +2,6 @@
<qresource prefix="/">
<file>main.qml</file>
<file>qtquickcontrols2.conf</file>
+ <file>ConnectionDialog.qml</file>
</qresource>
</RCC>
diff --git a/src/remotesettings/backend/backend.pro b/src/remotesettings/backend/backend.pro
index f614f6de..0266ae3b 100644
--- a/src/remotesettings/backend/backend.pro
+++ b/src/remotesettings/backend/backend.pro
@@ -4,8 +4,8 @@ CONFIG += ivigenerator plugin
include($$SOURCE_DIR/config.pri)
-LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(RemoteSettings)
-DESTDIR = ../../qtivi
+LIBS += -L$$OUT_PWD/../../../lib -l$$qtLibraryTarget(RemoteSettings)
+DESTDIR = ../../../qtivi
CONFIG += warn_off
INCLUDEPATH += $$OUT_PWD/../frontend
diff --git a/src/remotesettings/frontend/frontend.pro b/src/remotesettings/frontend/frontend.pro
index f9e9c5b4..d193677f 100644
--- a/src/remotesettings/frontend/frontend.pro
+++ b/src/remotesettings/frontend/frontend.pro
@@ -1,7 +1,7 @@
TARGET = $$qtLibraryTarget(RemoteSettings)
TEMPLATE = lib
CONFIG += ivigenerator
-DESTDIR = ..
+DESTDIR = ../../../lib
include($$SOURCE_DIR/config.pri)
diff --git a/src/remotesettings/qml_plugin/qml_plugin.pro b/src/remotesettings/qml_plugin/qml_plugin.pro
index 23bd853c..db4521d7 100644
--- a/src/remotesettings/qml_plugin/qml_plugin.pro
+++ b/src/remotesettings/qml_plugin/qml_plugin.pro
@@ -2,7 +2,7 @@ TEMPLATE = lib
CONFIG += plugin
TARGET = RemoteSettingsPlugin
QT += qml
-LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(RemoteSettings)
+LIBS += -L$$OUT_PWD/../../../lib -l$$qtLibraryTarget(RemoteSettings)
INCLUDEPATH += $$OUT_PWD/../frontend
include($$SOURCE_DIR/config.pri)
diff --git a/src/remotesettings/server/server.pro b/src/remotesettings/server/server.pro
index 62ad9fc8..66a9bbd2 100644
--- a/src/remotesettings/server/server.pro
+++ b/src/remotesettings/server/server.pro
@@ -2,7 +2,7 @@ QT -= gui
QT += remoteobjects
CONFIG += c++11 console
-CONFIG -= app_bundle
+macos: CONFIG -= app_bundle
CONFIG += ivigenerator
include($$SOURCE_DIR/config.pri)
@@ -27,7 +27,7 @@ HEADERS += \
DEPENDPATH += $$OUT_PWD/../server
-LIBS += -L$$OUT_PWD/../ -l$$qtLibraryTarget(RemoteSettings)
+LIBS += -L$$OUT_PWD/../../../lib -l$$qtLibraryTarget(RemoteSettings)
INCLUDEPATH += $$OUT_PWD/../frontend
@@ -36,7 +36,7 @@ QMAKE_RPATHDIR += $ORIGIN/$$relative_path($$INSTALL_PREFIX/triton/lib, $$INSTALL
DISTFILES +=
TARGET = RemoteSettings_server
-DESTDIR = ..
+DESTDIR = ../../../
target.path = $$INSTALL_PREFIX/triton
INSTALLS += target
diff --git a/triton-ui.pro b/triton-ui.pro
index 3ecceece..77a46147 100644
--- a/triton-ui.pro
+++ b/triton-ui.pro
@@ -24,6 +24,9 @@ SUBDIRS += copydata
qml.files = apps imports sysui styles am-config.yaml Main.qml
qml.path = $$INSTALL_PREFIX/triton
INSTALLS += qml
+server.files = server.conf
+server.path = $$INSTALL_PREFIX/triton
+INSTALLS += server
OTHER_FILES += $$files($$PWD/*.qml, true)
OTHER_FILES += $$files($$PWD/*.qmldir, true)