diff options
author | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-03-08 09:44:06 +0100 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2017-03-08 08:54:31 +0000 |
commit | 6d04bd496fd11ae5adcf8aa8974d08483c4ff89d (patch) | |
tree | 64308f939d1f82af83d5e1a415f621b631a074a5 /tradeshow | |
parent | da65192baaab330b5f516c451ad0d08f3a9ad4b2 (diff) |
iot-sensortag: Add IP display
When the app automatically runs on startup, we need to have a way to
identify the device's IP address to deploy updates, for instance new MAC
filter addresses.
When clicking on the date string, it switches to show the IP addresses
available.
Change-Id: Ie3b10f2b701674ee07f1a8c7a3b064e67d8f6373
Reviewed-by: Risto Avila <risto.avila@qt.io>
Diffstat (limited to 'tradeshow')
-rw-r--r-- | tradeshow/iot-sensortag/main.cpp | 9 | ||||
-rw-r--r-- | tradeshow/iot-sensortag/resources/base/TopToolbar.qml | 7 | ||||
-rw-r--r-- | tradeshow/iot-sensortag/resources/base/main.qml | 1 |
3 files changed, 16 insertions, 1 deletions
diff --git a/tradeshow/iot-sensortag/main.cpp b/tradeshow/iot-sensortag/main.cpp index 0925a5a..5164919 100644 --- a/tradeshow/iot-sensortag/main.cpp +++ b/tradeshow/iot-sensortag/main.cpp @@ -161,6 +161,14 @@ int main(int argc, char *argv[]) qCDebug(boot2QtDemos) << "screen dimensions" << scr->geometry().size(); qCDebug(boot2QtDemos) << "Scale factor:" << sf.data(); + QString addressString; + for (auto address : QNetworkInterface::allAddresses()) { + if (address.protocol() == QAbstractSocket::IPv4Protocol && address != QHostAddress(QHostAddress::LocalHost) + && !address.toString().startsWith(QLatin1String("169"))) { + addressString.append(address.toString()); + addressString.append(QLatin1Char('/')); + } + } #if defined(UI_SMALL) mainFile = namingScheme + QStringLiteral("/resources/small/MainSmall.qml"); styleFile = namingScheme + QStringLiteral("/resources/small/StyleSmall.qml"); @@ -216,6 +224,7 @@ int main(int argc, char *argv[]) item->setProperty("dataProviderPool", QVariant::fromValue(dataProviderPool)); item->setProperty("contentFile", mainFile); item->setProperty("seriesStorage", QVariant::fromValue(&seriesStorage)); + item->setProperty("addresses", addressString); } int returnValue = app.exec(); dataProviderPool->stopScanning(); diff --git a/tradeshow/iot-sensortag/resources/base/TopToolbar.qml b/tradeshow/iot-sensortag/resources/base/TopToolbar.qml index eb94cb2..fd5054d 100644 --- a/tradeshow/iot-sensortag/resources/base/TopToolbar.qml +++ b/tradeshow/iot-sensortag/resources/base/TopToolbar.qml @@ -151,7 +151,8 @@ Item { } Text { - text: Qt.formatDateTime(new Date, "dddd, MMMM d, yyyy") + property bool showAddress : false + text: showAddress ? mainWindow.addresses : Qt.formatDateTime(new Date, "dddd, MMMM d, yyyy") color: "white" anchors.bottom: parent.bottom anchors.bottomMargin: 16 @@ -160,6 +161,10 @@ Item { horizontalAlignment: Text.AlignRight font.pixelSize: Style.topToolbarSmallFontSize font.capitalization: Font.AllUppercase + MouseArea { + anchors.fill: parent + onClicked: parent.showAddress = !parent.showAddress + } } Text { diff --git a/tradeshow/iot-sensortag/resources/base/main.qml b/tradeshow/iot-sensortag/resources/base/main.qml index 2840433..6d492d5 100644 --- a/tradeshow/iot-sensortag/resources/base/main.qml +++ b/tradeshow/iot-sensortag/resources/base/main.qml @@ -59,6 +59,7 @@ Window { property DataProviderPool dataProviderPool property SeriesStorage seriesStorage property real globalBlinkOpacity: 1.0 + property string addresses : "" // Size defaults to the small display width: 1920 |