diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index f3cff6a..16b4091 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -1,2 +1,2 @@ -add_subdirectory(qmsgpack) -add_subdirectory(QtZeroConf) +add_subdirectory(qmsgpack SYSTEM) +add_subdirectory(QtZeroConf SYSTEM) diff --git a/AppSettingsPage.qml b/AppSettingsPage.qml index 88a08b5..ad88001 100644 --- a/AppSettingsPage.qml +++ b/AppSettingsPage.qml @@ -68,6 +68,15 @@ NavigationPage { onAccepted: theSettings.loadSolalawebCert(selectedFile) } } + + CheckDelegate { + Layout.columnSpan: 2 + Layout.fillWidth: true + + text: qsTr("Show solalaweb:") + checked: theSettings.showSolalaweb + onClicked: theSettings.showSolalaweb = checked + } } } } diff --git a/DeviceListScreen.qml b/DeviceListScreen.qml index 5c49292..cf2fd5c 100644 --- a/DeviceListScreen.qml +++ b/DeviceListScreen.qml @@ -260,29 +260,41 @@ StackView { Layout.fillWidth: true } - Button { - enabled: delegate.ip != "" + RowLayout { + Layout.columnSpan: 2 - text: qsTr("Connect local") - onClicked: deviceSelected("ws://" + delegate.ip + "/ws", delegate.password) - } + Button { + Layout.fillWidth: true + enabled: delegate.ip != "" - Button { - property var cloudUrl: { - for (let i = 0; i < cloudUrlsModel.count; ++i) { - const entry = cloudUrlsModel.get(i); - if (delegate.manufacturer === entry.manufacturer && - delegate.deviceType.includes(entry.deviceType)) { - return entry.url; - } - } - return null; + text: qsTr("Local") + onClicked: deviceSelected("ws://" + delegate.ip + "/ws", delegate.password) } - enabled: cloudUrl !== null + Button { + Layout.fillWidth: true + property var cloudUrl: { + for (let i = 0; i < cloudUrlsModel.count; ++i) { + const entry = cloudUrlsModel.get(i); + if (delegate.manufacturer === entry.manufacturer && + delegate.deviceType.includes(entry.deviceType)) { + return entry.url; + } + } + return null; + } - text: qsTr("Connect cloud") - onClicked: deviceSelected(cloudUrl + delegate.serial, delegate.password) + enabled: cloudUrl !== null + + text: qsTr("Cloud") + onClicked: deviceSelected(cloudUrl + delegate.serial, delegate.password) + } + + Button { + Layout.fillWidth: true + text: qsTr("Solala") + visible: theSettings.showSolalaweb + } } } } diff --git a/appsettings.cpp b/appsettings.cpp index 0d65114..0ebc2ec 100644 --- a/appsettings.cpp +++ b/appsettings.cpp @@ -155,3 +155,20 @@ bool AppSettings::loadSolalawebCert(const QString &url) return true; } + +bool AppSettings::showSolalaweb() const +{ + if (m_showSolalaweb) + return *m_showSolalaweb; + + auto showSolalaweb = value("showSolalaweb").toBool(); + m_showSolalaweb = showSolalaweb; + return showSolalaweb; +} + +void AppSettings::setShowSolalaweb(bool showSolalaweb) +{ + setValue("showSolalaweb", showSolalaweb); + m_showSolalaweb = showSolalaweb; + emit showSolalawebChanged(showSolalaweb); +} diff --git a/appsettings.h b/appsettings.h index 1d0caa2..5a1fad4 100644 --- a/appsettings.h +++ b/appsettings.h @@ -21,6 +21,7 @@ class AppSettings : public QSettings Q_PROPERTY(int numberOfAppInstances READ numberOfAppInstances WRITE setNumberOfAppInstances NOTIFY numberOfAppInstancesChanged FINAL) Q_PROPERTY(QString solalawebKey READ solalawebKey WRITE setSolalawebKey NOTIFY solalawebKeyChanged FINAL) Q_PROPERTY(QString solalawebCert READ solalawebCert WRITE setSolalawebCert NOTIFY solalawebCertChanged FINAL) + Q_PROPERTY(bool showSolalaweb READ showSolalaweb WRITE setShowSolalaweb NOTIFY showSolalawebChanged FINAL) public: std::vector getSavedDevices(); @@ -39,13 +40,18 @@ public: void setSolalawebCert(const QString &solalawebCert); Q_INVOKABLE bool loadSolalawebCert(const QString &url); + bool showSolalaweb() const; + void setShowSolalaweb(bool showSolalaweb); + signals: void numberOfAppInstancesChanged(int numberOfAppInstances); void solalawebKeyChanged(const QString &solalawebKey); void solalawebCertChanged(const QString &solalawebCert); + void showSolalawebChanged(bool showSolalaweb); private: mutable std::optional m_numberOfAppInstances; mutable std::optional m_solalawebKey; mutable std::optional m_solalawebCert; + mutable std::optional m_showSolalaweb; }; diff --git a/deviceconnection.cpp b/deviceconnection.cpp index 01cb432..f0ad4fe 100644 --- a/deviceconnection.cpp +++ b/deviceconnection.cpp @@ -105,7 +105,7 @@ void DeviceConnection::setPassword(const QString &password) void DeviceConnection::messageReceived(const QVariant &variant) { - if (variant.type() != QMetaType::QVariantMap) + if (variant.typeId() != QMetaType::QVariantMap) { emit logMessage(tr("Received something that is not a json object!")); return; @@ -120,7 +120,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) } const auto &typeVariant = *typeIter; - if (typeVariant.type() != QMetaType::QString) + if (typeVariant.typeId() != QMetaType::QString) { emit logMessage(tr("Received something with a non-string type!")); return; @@ -140,7 +140,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) } const auto &serialVariant = *iter; - if (serialVariant.type() != QMetaType::QString) + if (serialVariant.typeId() != QMetaType::QString) { emit logMessage(tr("Received hello with a non-string serial!")); return; @@ -152,7 +152,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) if (auto iter = map.find("secured"); iter != std::cend(map)) { const auto &securedVariant = *iter; - if (securedVariant.type() != QMetaType::Bool) + if (securedVariant.typeId() != QMetaType::Bool) { emit logMessage(tr("Received hello with a non-bool secured!")); return; @@ -172,7 +172,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) } const auto &manufacturerVariant = *manufacturerIter; - if (manufacturerVariant.type() != QMetaType::QString) + if (manufacturerVariant.typeId() != QMetaType::QString) { emit logMessage(tr("Received hello with a non-string manufacturer!")); return; @@ -190,7 +190,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) } const auto &deviceTypeVariant = *devicetypeIter; - if (deviceTypeVariant.type() != QMetaType::QString) + if (deviceTypeVariant.typeId() != QMetaType::QString) { emit logMessage(tr("Received hello with a non-string devicetype!")); return; @@ -208,7 +208,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) } const auto &friendlyNameVariant = *friendlyNameIter; - if (friendlyNameVariant.type() != QMetaType::QString) + if (friendlyNameVariant.typeId() != QMetaType::QString) { emit logMessage(tr("Received hello with a non-string friendly_name!")); return; @@ -236,7 +236,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) } const auto &token1Variant = *iter; - if (token1Variant.type() != QMetaType::QString) + if (token1Variant.typeId() != QMetaType::QString) { emit logMessage(tr("Received authRequired with a non-string token1!")); return; @@ -254,7 +254,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) } const auto &token2Variant = *iter; - if (token2Variant.type() != QMetaType::QString) + if (token2Variant.typeId() != QMetaType::QString) { emit logMessage(tr("Received authRequired with a non-string token2!")); return; @@ -277,7 +277,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) if (auto iter = map.find("partial"); iter != std::cend(map)) { const auto &partialVariant = *iter; - if (partialVariant.type() != QMetaType::Bool) + if (partialVariant.typeId() != QMetaType::Bool) { emit logMessage(tr("Received fullStatus with a non-bool partial!")); return; @@ -294,7 +294,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) } const auto &statusVariant = *iter; - if (statusVariant.type() != QMetaType::QVariantMap) + if (statusVariant.typeId() != QMetaType::QVariantMap) { emit logMessage(tr("Received fullStatus with a non-object status!")); return; @@ -321,7 +321,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) } const auto &statusVariant = *iter; - if (statusVariant.type() != QMetaType::QVariantMap) + if (statusVariant.typeId() != QMetaType::QVariantMap) { emit logMessage(tr("Received deltaStatus with a non-object status!")); return; @@ -335,7 +335,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) if (iter.key() == "fna") { const auto &friendlyNameVariant = iter.value(); - if (friendlyNameVariant.type() == QMetaType::QString) + if (friendlyNameVariant.typeId() == QMetaType::QString) { const auto &friendlyName = friendlyNameVariant.toString(); if (m_friendlyName != friendlyName) @@ -363,7 +363,7 @@ void DeviceConnection::messageReceived(const QVariant &variant) if (auto iter = map.find("requestId"); iter != std::cend(map)) { const auto &requestIdVariant = *iter; - if (requestIdVariant.type() != QMetaType::QString) + if (requestIdVariant.typeId() != QMetaType::QString) { emit logMessage(tr("Received message with a non-string requestId!")); return; diff --git a/i18n/qml_de.ts b/i18n/qml_de.ts index b02bba6..2015e0e 100644 --- a/i18n/qml_de.ts +++ b/i18n/qml_de.ts @@ -203,6 +203,12 @@ solalaweb cert: solalaweb cert: + + + + Show solalaweb: + + BaseNavigationPage @@ -887,8 +893,26 @@ Seriennummer %0 - - + + + 🛜 + + + + + + ☁️ + + + + + + Solala + + + + + Add or setup device Gerät hinzufügen oder einrichten @@ -937,16 +961,12 @@ Ip: - - Connect local - Lokal verbinden + Lokal verbinden - - Connect cloud - Über cloud verbinden + Über cloud verbinden Settings