Merge PR #859: Show an appropriate message if Z-Wave is not available on the system
This commit is contained in:
commit
35250e3f2c
@ -50,6 +50,11 @@ bool ZWaveManager::fetchingData() const
|
|||||||
return m_fetchingData;
|
return m_fetchingData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ZWaveManager::zwaveAvailable() const
|
||||||
|
{
|
||||||
|
return m_zwaveAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
SerialPorts *ZWaveManager::serialPorts() const
|
SerialPorts *ZWaveManager::serialPorts() const
|
||||||
{
|
{
|
||||||
return m_serialPorts;
|
return m_serialPorts;
|
||||||
@ -103,6 +108,9 @@ int ZWaveManager::removeFailedNode(const QUuid &networkUuid, int nodeId)
|
|||||||
|
|
||||||
void ZWaveManager::init()
|
void ZWaveManager::init()
|
||||||
{
|
{
|
||||||
|
m_zwaveAvailable = false;
|
||||||
|
emit zwaveAvailableChanged();
|
||||||
|
|
||||||
m_fetchingData = true;
|
m_fetchingData = true;
|
||||||
emit fetchingDataChanged();
|
emit fetchingDataChanged();
|
||||||
|
|
||||||
@ -111,9 +119,16 @@ void ZWaveManager::init()
|
|||||||
|
|
||||||
m_engine->jsonRpcClient()->registerNotificationHandler(this, "ZWave", "notificationReceived");
|
m_engine->jsonRpcClient()->registerNotificationHandler(this, "ZWave", "notificationReceived");
|
||||||
|
|
||||||
|
m_engine->jsonRpcClient()->sendCommand("ZWave.IsZWaveAvailable", this, "isZWaveAvailableResponse");
|
||||||
m_engine->jsonRpcClient()->sendCommand("ZWave.GetSerialPorts", this, "getSerialPortsResponse");
|
m_engine->jsonRpcClient()->sendCommand("ZWave.GetSerialPorts", this, "getSerialPortsResponse");
|
||||||
m_engine->jsonRpcClient()->sendCommand("ZWave.GetNetworks", this, "getNetworksResponse");
|
m_engine->jsonRpcClient()->sendCommand("ZWave.GetNetworks", this, "getNetworksResponse");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZWaveManager::isZWaveAvailableResponse(int commandId, const QVariantMap ¶ms)
|
||||||
|
{
|
||||||
|
Q_UNUSED(commandId)
|
||||||
|
m_zwaveAvailable = params.value("available").toBool();
|
||||||
|
emit zwaveAvailableChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZWaveManager::getSerialPortsResponse(int commandId, const QVariantMap ¶ms)
|
void ZWaveManager::getSerialPortsResponse(int commandId, const QVariantMap ¶ms)
|
||||||
|
|||||||
@ -46,6 +46,7 @@ class ZWaveManager : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||||
Q_PROPERTY(bool fetchingData READ fetchingData NOTIFY fetchingDataChanged)
|
Q_PROPERTY(bool fetchingData READ fetchingData NOTIFY fetchingDataChanged)
|
||||||
|
Q_PROPERTY(bool zwaveAvailable READ zwaveAvailable NOTIFY zwaveAvailableChanged)
|
||||||
|
|
||||||
Q_PROPERTY(SerialPorts *serialPorts READ serialPorts CONSTANT)
|
Q_PROPERTY(SerialPorts *serialPorts READ serialPorts CONSTANT)
|
||||||
Q_PROPERTY(ZWaveNetworks *networks READ networks CONSTANT)
|
Q_PROPERTY(ZWaveNetworks *networks READ networks CONSTANT)
|
||||||
@ -68,6 +69,7 @@ public:
|
|||||||
Engine *engine() const;
|
Engine *engine() const;
|
||||||
|
|
||||||
bool fetchingData() const;
|
bool fetchingData() const;
|
||||||
|
bool zwaveAvailable() const;
|
||||||
|
|
||||||
SerialPorts *serialPorts() const;
|
SerialPorts *serialPorts() const;
|
||||||
ZWaveNetworks *networks() const;
|
ZWaveNetworks *networks() const;
|
||||||
@ -84,6 +86,7 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void engineChanged();
|
void engineChanged();
|
||||||
void fetchingDataChanged();
|
void fetchingDataChanged();
|
||||||
|
void zwaveAvailableChanged();
|
||||||
void addNetworkReply(int commandId, ZWaveManager::ZWaveError error, const QUuid &networkUuid);
|
void addNetworkReply(int commandId, ZWaveManager::ZWaveError error, const QUuid &networkUuid);
|
||||||
void removeNetworkReply(int commandId, ZWaveManager::ZWaveError error);
|
void removeNetworkReply(int commandId, ZWaveManager::ZWaveError error);
|
||||||
void cancelPendingOperationReply(int commandId, ZWaveManager::ZWaveError error);
|
void cancelPendingOperationReply(int commandId, ZWaveManager::ZWaveError error);
|
||||||
@ -96,6 +99,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
Q_INVOKABLE void isZWaveAvailableResponse(int commandId, const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void getSerialPortsResponse(int commandId, const QVariantMap ¶ms);
|
Q_INVOKABLE void getSerialPortsResponse(int commandId, const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void getNetworksResponse(int commandId, const QVariantMap ¶ms);
|
Q_INVOKABLE void getNetworksResponse(int commandId, const QVariantMap ¶ms);
|
||||||
Q_INVOKABLE void getNodesResponse(int commandId, const QVariantMap ¶ms);
|
Q_INVOKABLE void getNodesResponse(int commandId, const QVariantMap ¶ms);
|
||||||
@ -115,6 +119,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
Engine* m_engine = nullptr;
|
Engine* m_engine = nullptr;
|
||||||
bool m_fetchingData = false;
|
bool m_fetchingData = false;
|
||||||
|
bool m_zwaveAvailable = false;
|
||||||
SerialPorts *m_serialPorts = nullptr;
|
SerialPorts *m_serialPorts = nullptr;
|
||||||
ZWaveNetworks *m_networks = nullptr;
|
ZWaveNetworks *m_networks = nullptr;
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ Page {
|
|||||||
|
|
||||||
Flickable {
|
Flickable {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
contentHeight: contentColumn.height + app.margins
|
contentHeight: contentColumn.height + Style.margins
|
||||||
interactive: contentHeight > height
|
interactive: contentHeight > height
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
|
|||||||
@ -64,8 +64,8 @@ SettingsPageBase {
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: root.height
|
Layout.preferredHeight: root.height - root.header.height - Style.margins
|
||||||
visible: zwaveManager.fetchingData || zwaveManager.networks.count == 0
|
visible: !zwaveManager.fetchingData || !zwaveManager.zwaveAvailable || zwaveManager.networks.count == 0
|
||||||
|
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
@ -74,12 +74,15 @@ SettingsPageBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EmptyViewPlaceholder {
|
EmptyViewPlaceholder {
|
||||||
visible: !zwaveManager.fetchingData && zwaveManager.networks.count == 0
|
visible: !zwaveManager.fetchingData
|
||||||
width: parent.width - app.margins * 2
|
width: parent.width - app.margins * 2
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
title: qsTr("Z-Wave")
|
title: qsTr("Z-Wave")
|
||||||
text: qsTr("There are no Z-Wave networks set up yet. In order to use Z-Wave, create a Z-Wave network.")
|
text: zwaveManager.zwaveAvailable
|
||||||
|
? qsTr("There are no Z-Wave networks set up yet. In order to use Z-Wave, create a Z-Wave network.")
|
||||||
|
: qsTr("Z-Wave is not available on this system as no Z-Wave backend is installed.")
|
||||||
imageSource: "/ui/images/z-wave.svg"
|
imageSource: "/ui/images/z-wave.svg"
|
||||||
|
buttonVisible: zwaveManager.zwaveAvailable
|
||||||
buttonText: qsTr("Add network")
|
buttonText: qsTr("Add network")
|
||||||
onButtonClicked: {
|
onButtonClicked: {
|
||||||
addNetwork()
|
addNetwork()
|
||||||
@ -90,6 +93,7 @@ SettingsPageBase {
|
|||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
Layout.margins: app.margins / 2
|
Layout.margins: app.margins / 2
|
||||||
|
visible: !zwaveManager.fetchingData && zwaveManager.zwaveAvailable && zwaveManager.networks.count > 0
|
||||||
Repeater {
|
Repeater {
|
||||||
model: zwaveManager.networks
|
model: zwaveManager.networks
|
||||||
delegate: BigTile {
|
delegate: BigTile {
|
||||||
|
|||||||
Reference in New Issue
Block a user