Fix warnings and add showsolalaweb checkbox

This commit is contained in:
2024-07-12 19:00:53 +02:00
parent 6c235a0fed
commit 94c84af4a1
7 changed files with 106 additions and 42 deletions

View File

@@ -1,2 +1,2 @@
add_subdirectory(qmsgpack)
add_subdirectory(QtZeroConf)
add_subdirectory(qmsgpack SYSTEM)
add_subdirectory(QtZeroConf SYSTEM)

View File

@@ -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
}
}
}
}

View File

@@ -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
}
}
}
}

View File

@@ -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);
}

View File

@@ -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<SavedDevice> 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<int> m_numberOfAppInstances;
mutable std::optional<QString> m_solalawebKey;
mutable std::optional<QString> m_solalawebCert;
mutable std::optional<bool> m_showSolalaweb;
};

View File

@@ -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;

View File

@@ -203,6 +203,12 @@
<source>solalaweb cert:</source>
<translation>solalaweb cert:</translation>
</message>
<message>
<location filename="../AppSettingsPage.qml" line="74"/>
<location filename="../build/Desktop-Debug/EVChargerApp/AppSettingsPage.qml" line="74"/>
<source>Show solalaweb:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BaseNavigationPage</name>
@@ -887,8 +893,26 @@
<translation>Seriennummer %0</translation>
</message>
<message>
<location filename="../DeviceListScreen.qml" line="316"/>
<location filename="../build/Desktop-Debug/EVChargerApp/DeviceListScreen.qml" line="316"/>
<location filename="../DeviceListScreen.qml" line="266"/>
<location filename="../build/Desktop-Debug/EVChargerApp/DeviceListScreen.qml" line="266"/>
<source>🛜</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../DeviceListScreen.qml" line="284"/>
<location filename="../build/Desktop-Debug/EVChargerApp/DeviceListScreen.qml" line="284"/>
<source></source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../DeviceListScreen.qml" line="289"/>
<location filename="../build/Desktop-Debug/EVChargerApp/DeviceListScreen.qml" line="289"/>
<source>Solala</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../DeviceListScreen.qml" line="320"/>
<location filename="../build/Desktop-Debug/EVChargerApp/DeviceListScreen.qml" line="320"/>
<source>Add or setup device</source>
<translation>Gerät hinzufügen oder einrichten</translation>
</message>
@@ -937,16 +961,12 @@
<translation>Ip:</translation>
</message>
<message>
<location filename="../DeviceListScreen.qml" line="266"/>
<location filename="../build/Desktop-Debug/EVChargerApp/DeviceListScreen.qml" line="266"/>
<source>Connect local</source>
<translation>Lokal verbinden</translation>
<translation type="vanished">Lokal verbinden</translation>
</message>
<message>
<location filename="../DeviceListScreen.qml" line="284"/>
<location filename="../build/Desktop-Debug/EVChargerApp/DeviceListScreen.qml" line="284"/>
<source>Connect cloud</source>
<translation>Über cloud verbinden</translation>
<translation type="vanished">Über cloud verbinden</translation>
</message>
<message>
<source>Settings</source>