summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBramastyo Harimukti <bramastyo.harimukti.santoso@pelagicore.com>2017-10-10 11:30:43 +0200
committerBramastyo Harimukti Santoso <bramastyo.harimukti.santoso@pelagicore.com>2017-10-17 13:59:19 +0000
commitf14a911ab827f243c5b5fe31ff9746f3535d756f (patch)
tree1e67e9fb38d69f6463068f2d9a323c36a8fdc9bd
parent76db76982e3d89c0e47215b04b90cea2e07f89e3 (diff)
downloadneptune-ui-f14a911ab827f243c5b5fe31ff9746f3535d756f.tar.gz
Add Network Address information to the system monitor
Task-number: QAUTO-517 Change-Id: I7dc9a88c65682205495caea31e412ea42c769fe9 Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r--plugins/plugins.pro3
-rw-r--r--plugins/systeminfo/plugin.cpp58
-rw-r--r--plugins/systeminfo/qmldir2
-rw-r--r--plugins/systeminfo/systeminfo.cpp63
-rw-r--r--plugins/systeminfo/systeminfo.h56
-rw-r--r--plugins/systeminfo/systeminfo.pro14
-rw-r--r--sysui/settings/systemmonitor/AddressList.qml72
-rw-r--r--sysui/settings/systemmonitor/MainScreen.qml8
8 files changed, 275 insertions, 1 deletions
diff --git a/plugins/plugins.pro b/plugins/plugins.pro
index 18aeb10..1566fa2 100644
--- a/plugins/plugins.pro
+++ b/plugins/plugins.pro
@@ -4,4 +4,5 @@ SUBDIRS = datasource \
screenmanager \
comtqci18ndemo \
styles \
- translation
+ translation \
+ systeminfo
diff --git a/plugins/systeminfo/plugin.cpp b/plugins/systeminfo/plugin.cpp
new file mode 100644
index 0000000..4c0716f
--- /dev/null
+++ b/plugins/systeminfo/plugin.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Neptune 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
+**
+****************************************************************************/
+
+#include <QtQml/qqmlextensionplugin.h>
+#include <qqml.h>
+#include "systeminfo.h"
+
+static QObject *systemInfoSingletonFactory(QQmlEngine *engine, QJSEngine *scriptEngine)
+{
+ Q_UNUSED(scriptEngine)
+ Q_UNUSED(engine)
+
+ return new SystemInfo();
+}
+
+class SystemInfoPlugin : public QQmlExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("com.pelagicore.systeminfo"));
+ Q_UNUSED(uri);
+
+ qmlRegisterSingletonType<SystemInfo>(uri, 1, 0, "SystemInfo", systemInfoSingletonFactory);
+ }
+};
+
+#include "plugin.moc"
diff --git a/plugins/systeminfo/qmldir b/plugins/systeminfo/qmldir
new file mode 100644
index 0000000..99dd732
--- /dev/null
+++ b/plugins/systeminfo/qmldir
@@ -0,0 +1,2 @@
+module com.pelagicore.systeminfo
+plugin systeminfoplugin
diff --git a/plugins/systeminfo/systeminfo.cpp b/plugins/systeminfo/systeminfo.cpp
new file mode 100644
index 0000000..808f449
--- /dev/null
+++ b/plugins/systeminfo/systeminfo.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Neptune 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
+**
+****************************************************************************/
+
+#include <QNetworkInterface>
+#include "systeminfo.h"
+
+SystemInfo::SystemInfo(QObject *parent)
+ : QObject(parent)
+{
+ getAddress();
+}
+
+/*
+ * This function will return all available Addresses of your device in list.
+*/
+void SystemInfo::getAddress()
+{
+ for (const QNetworkInterface &interface : QNetworkInterface::allInterfaces())
+ {
+ if (interface.flags().testFlag(QNetworkInterface::IsUp) && !interface.flags().testFlag(QNetworkInterface::IsLoopBack)) {
+ for (const QNetworkAddressEntry &entry : interface.addressEntries())
+ {
+ if (interface.hardwareAddress() != QLatin1String("00:00:00:00:00:00")) {
+ m_addressList.append(interface.name() + QLatin1String(" ") + entry.ip().toString() + QLatin1String(" ") + interface.hardwareAddress());
+ emit addressListChanged();
+ }
+ }
+ }
+ }
+}
+
+QStringList SystemInfo::addressList() const
+{
+ return m_addressList;
+}
diff --git a/plugins/systeminfo/systeminfo.h b/plugins/systeminfo/systeminfo.h
new file mode 100644
index 0000000..76626f0
--- /dev/null
+++ b/plugins/systeminfo/systeminfo.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Neptune 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
+**
+****************************************************************************/
+
+#ifndef SYSTEMINFO_H
+#define SYSTEMINFO_H
+
+#include <QtCore/QObject>
+
+class SystemInfo : public QObject
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QStringList addressList READ addressList NOTIFY addressListChanged)
+
+public:
+ explicit SystemInfo(QObject *parent = nullptr);
+
+ void getAddress();
+ QStringList addressList() const;
+
+signals:
+ void addressListChanged();
+
+protected:
+ QStringList m_addressList;
+};
+
+#endif // SYSTEMINFO_H
diff --git a/plugins/systeminfo/systeminfo.pro b/plugins/systeminfo/systeminfo.pro
new file mode 100644
index 0000000..7ec3f0e
--- /dev/null
+++ b/plugins/systeminfo/systeminfo.pro
@@ -0,0 +1,14 @@
+TEMPLATE = lib
+TARGET = systeminfoplugin
+QT += qml quick
+CONFIG += qt plugin c++11
+
+uri = com.pelagicore.systeminfo
+load(qmlplugin)
+
+SOURCES += \
+ plugin.cpp \
+ systeminfo.cpp \
+
+HEADERS += \
+ systeminfo.h \
diff --git a/sysui/settings/systemmonitor/AddressList.qml b/sysui/settings/systemmonitor/AddressList.qml
new file mode 100644
index 0000000..d9ea5c9
--- /dev/null
+++ b/sysui/settings/systemmonitor/AddressList.qml
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Neptune 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.6
+import QtQuick.Layouts 1.0
+import QtQuick.Controls 2.0
+import utils 1.0
+import controls 1.0
+import com.pelagicore.systeminfo 1.0
+
+UIPage {
+ id: root
+
+ ListViewManager {
+ id: listView
+ width: Style.hspan(11.5)
+ height: Style.vspan(11)
+ model: SystemInfo.addressList
+ anchors.centerIn: parent
+ anchors.verticalCenterOffset: -80
+
+ delegate: ItemDelegate {
+ id: delegatedItem
+ implicitWidth: listView.width
+ implicitHeight: Style.vspan(2)
+
+ contentItem: Control {
+ anchors.fill: parent
+ Label {
+ id: titleLabel
+ anchors.verticalCenter: parent.verticalCenter
+ Layout.preferredWidth: parent.width
+ Layout.fillHeight: true
+ elide: Text.ElideRight
+ text: modelData
+ }
+ HDiv {
+ anchors.verticalCenter: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ }
+ }
+}
diff --git a/sysui/settings/systemmonitor/MainScreen.qml b/sysui/settings/systemmonitor/MainScreen.qml
index f35b6f0..9c6c7c9 100644
--- a/sysui/settings/systemmonitor/MainScreen.qml
+++ b/sysui/settings/systemmonitor/MainScreen.qml
@@ -58,9 +58,17 @@ Item {
{ title : "Info", url : infoPanel, properties : {} },
{ title : "CPU/FPS", url : systemPanel, properties : {} },
{ title : "RAM", url : appPanel, properties : {} },
+ { title : "Addresses", url : addressList, properties : {} },
]
}
+
+ Component {
+ id: addressList
+ AddressList {
+ }
+ }
+
InfoPanel {
id: infoPanel
visible: false