Use The displayMessage in discovery results

This commit is contained in:
Michael Zanetti 2020-01-09 15:54:49 +01:00
parent 7a1cd43a03
commit 9dca083f0e
3 changed files with 19 additions and 4 deletions

View File

@ -66,6 +66,7 @@ void DeviceDiscovery::discoverDevices(const QUuid &deviceClassId, const QVariant
}
m_engine->jsonRpcClient()->sendCommand("Devices.GetDiscoveredDevices", params, this, "discoverDevicesResponse");
m_busy = true;
m_displayMessage.clear();
emit busyChanged();
}
@ -95,11 +96,13 @@ bool DeviceDiscovery::busy() const
return m_busy;
}
QString DeviceDiscovery::displayMessage() const
{
return m_displayMessage;
}
void DeviceDiscovery::discoverDevicesResponse(const QVariantMap &params)
{
m_busy = false;
emit busyChanged();
// qDebug() << "response received" << params;
QVariantList descriptors = params.value("params").toMap().value("deviceDescriptors").toList();
foreach (const QVariant &descriptorVariant, descriptors) {
@ -120,6 +123,10 @@ void DeviceDiscovery::discoverDevicesResponse(const QVariantMap &params)
emit countChanged();
}
}
m_displayMessage = params.value("params").toMap().value("displayMessage").toString();
m_busy = false;
emit busyChanged();
}
bool DeviceDiscovery::contains(const QUuid &deviceDescriptorId) const

View File

@ -36,6 +36,7 @@ class DeviceDiscovery : public QAbstractListModel
Q_PROPERTY(Engine* engine READ engine WRITE setEngine)
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
Q_PROPERTY(QString displayMessage READ displayMessage NOTIFY busyChanged)
public:
enum Roles {
RoleId,
@ -59,6 +60,7 @@ public:
void setEngine(Engine *jsonRpcClient);
bool busy() const;
QString displayMessage() const;
private slots:
void discoverDevicesResponse(const QVariantMap &params);
@ -71,6 +73,7 @@ signals:
private:
Engine *m_engine = nullptr;
bool m_busy = false;
QString m_displayMessage;
bool contains(const QUuid &deviceDescriptorId) const;
QList<DeviceDescriptor*> m_foundDevices;

View File

@ -292,16 +292,21 @@ Page {
text: qsTr("Too bad...")
font.pixelSize: app.largeFont
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
Label {
text: qsTr("No things of this kind could be found...")
Layout.fillWidth: true
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
}
Label {
Layout.fillWidth: true
text: qsTr("Make sure your things are set up and connected, try searching again or go back and pick a different kind of thing.")
horizontalAlignment: Text.AlignHCenter
text: discovery.displayMessage.length === 0 ?
qsTr("Make sure your things are set up and connected, try searching again or go back and pick a different kind of thing.")
: discovery.displayMessage
wrapMode: Text.WordWrap
}
}