diff --git a/libnymea-app/system/systemcontroller.cpp b/libnymea-app/system/systemcontroller.cpp index a393b8eb..fcae1c65 100644 --- a/libnymea-app/system/systemcontroller.cpp +++ b/libnymea-app/system/systemcontroller.cpp @@ -59,6 +59,11 @@ void SystemController::init() m_updateManagementAvailable = false; m_timeManagementAvailable = false; } + if (m_jsonRpcClient->ensureServerVersion("5.5")) { + m_jsonRpcClient->sendCommand("System.GetSystemInfo", this, "getSystemInfoResponse"); + } else { + m_deviceSerialNumber.clear(); + } } QString SystemController::nameSpace() const @@ -203,6 +208,11 @@ int SystemController::setAutomaticTime(bool automaticTime) return m_jsonRpcClient->sendCommand("System.SetTime", params, this, "setTimeResponse"); } +QString SystemController::deviceSerialNumber() const +{ + return m_deviceSerialNumber; +} + void SystemController::getCapabilitiesResponse(int /*commandId*/, const QVariantMap &data) { m_powerManagementAvailable = data.value("powerManagement").toBool(); @@ -318,6 +328,13 @@ void SystemController::shutdownResponse(int commandId, const QVariantMap ¶ms emit shutdownReply(commandId, success); } +void SystemController::getSystemInfoResponse(int commandId, const QVariantMap ¶ms) +{ + Q_UNUSED(commandId) + m_deviceSerialNumber = params.value("deviceSerialNumber").toString(); + emit deviceSerialNumberChanged(); +} + void SystemController::notificationReceived(const QVariantMap &data) { QString notification = data.value("notification").toString(); diff --git a/libnymea-app/system/systemcontroller.h b/libnymea-app/system/systemcontroller.h index 8213bbcd..e74f9de2 100644 --- a/libnymea-app/system/systemcontroller.h +++ b/libnymea-app/system/systemcontroller.h @@ -57,6 +57,8 @@ class SystemController : public JsonHandler Q_PROPERTY(bool automaticTimeAvailable READ automaticTimeAvailable NOTIFY automaticTimeAvailableChanged) Q_PROPERTY(bool automaticTime READ automaticTime WRITE setAutomaticTime NOTIFY automaticTimeChanged) + Q_PROPERTY(QString deviceSerialNumber READ deviceSerialNumber NOTIFY deviceSerialNumberChanged) + public: explicit SystemController(JsonRpcClient *jsonRpcClient, QObject *parent = nullptr); @@ -88,6 +90,8 @@ public: bool automaticTime() const; int setAutomaticTime(bool automaticTime); + QString deviceSerialNumber() const; + signals: void powerManagementAvailableChanged(); void updateManagementAvailableChanged(); @@ -99,6 +103,7 @@ signals: void serverTimeZoneChanged(); void automaticTimeAvailableChanged(); void automaticTimeChanged(); + void deviceSerialNumberChanged(); void restartReply(int id, bool success); void rebootReply(int id, bool success); @@ -116,6 +121,7 @@ private slots: void restartResponse(int commandId, const QVariantMap ¶ms); void rebootResponse(int commandId, const QVariantMap ¶ms); void shutdownResponse(int commandId, const QVariantMap ¶ms); + void getSystemInfoResponse(int commandId, const QVariantMap ¶ms); void notificationReceived(const QVariantMap &data); @@ -140,6 +146,8 @@ private: QStringList m_timeZones; bool m_automaticTimeAvailable = false; bool m_automaticTime = false; + + QString m_deviceSerialNumber; }; #endif // SYSTEMCONTROLLER_H diff --git a/nymea-app/ui/components/NymeaSwipeDelegate.qml b/nymea-app/ui/components/NymeaSwipeDelegate.qml index 7c30f16d..b30f4284 100644 --- a/nymea-app/ui/components/NymeaSwipeDelegate.qml +++ b/nymea-app/ui/components/NymeaSwipeDelegate.qml @@ -37,6 +37,7 @@ import Nymea 1.0 SwipeDelegate { id: root implicitWidth: 200 + implicitHeight: Style.smallDelegateHeight property string subText property bool progressive: true diff --git a/nymea-app/ui/system/AboutNymeaPage.qml b/nymea-app/ui/system/AboutNymeaPage.qml index 308d6a67..d3d7930d 100644 --- a/nymea-app/ui/system/AboutNymeaPage.qml +++ b/nymea-app/ui/system/AboutNymeaPage.qml @@ -81,5 +81,13 @@ SettingsPageBase { progressive: false prominentSubText: false } + NymeaSwipeDelegate { + Layout.fillWidth: true + text: qsTr("Device serial number") + subText: engine.systemController.deviceSerialNumber + visible: engine.systemController.deviceSerialNumber.length > 0 + progressive: false + prominentSubText: false + } } }