Show an appropriate message if Z-Wave is not available on the system
parent
9f08f628d0
commit
17248772da
|
|
@ -50,6 +50,11 @@ bool ZWaveManager::fetchingData() const
|
|||
return m_fetchingData;
|
||||
}
|
||||
|
||||
bool ZWaveManager::zwaveAvailable() const
|
||||
{
|
||||
return m_zwaveAvailable;
|
||||
}
|
||||
|
||||
SerialPorts *ZWaveManager::serialPorts() const
|
||||
{
|
||||
return m_serialPorts;
|
||||
|
|
@ -103,6 +108,9 @@ int ZWaveManager::removeFailedNode(const QUuid &networkUuid, int nodeId)
|
|||
|
||||
void ZWaveManager::init()
|
||||
{
|
||||
m_zwaveAvailable = false;
|
||||
emit zwaveAvailableChanged();
|
||||
|
||||
m_fetchingData = true;
|
||||
emit fetchingDataChanged();
|
||||
|
||||
|
|
@ -111,9 +119,16 @@ void ZWaveManager::init()
|
|||
|
||||
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.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)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ class ZWaveManager : public QObject
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(Engine* engine READ engine WRITE setEngine NOTIFY engineChanged)
|
||||
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(ZWaveNetworks *networks READ networks CONSTANT)
|
||||
|
|
@ -68,6 +69,7 @@ public:
|
|||
Engine *engine() const;
|
||||
|
||||
bool fetchingData() const;
|
||||
bool zwaveAvailable() const;
|
||||
|
||||
SerialPorts *serialPorts() const;
|
||||
ZWaveNetworks *networks() const;
|
||||
|
|
@ -84,6 +86,7 @@ public:
|
|||
signals:
|
||||
void engineChanged();
|
||||
void fetchingDataChanged();
|
||||
void zwaveAvailableChanged();
|
||||
void addNetworkReply(int commandId, ZWaveManager::ZWaveError error, const QUuid &networkUuid);
|
||||
void removeNetworkReply(int commandId, ZWaveManager::ZWaveError error);
|
||||
void cancelPendingOperationReply(int commandId, ZWaveManager::ZWaveError error);
|
||||
|
|
@ -96,6 +99,7 @@ signals:
|
|||
private:
|
||||
void init();
|
||||
|
||||
Q_INVOKABLE void isZWaveAvailableResponse(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 getNodesResponse(int commandId, const QVariantMap ¶ms);
|
||||
|
|
@ -115,6 +119,7 @@ private:
|
|||
private:
|
||||
Engine* m_engine = nullptr;
|
||||
bool m_fetchingData = false;
|
||||
bool m_zwaveAvailable = false;
|
||||
SerialPorts *m_serialPorts = nullptr;
|
||||
ZWaveNetworks *m_networks = nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ Page {
|
|||
|
||||
Flickable {
|
||||
anchors.fill: parent
|
||||
contentHeight: contentColumn.height + app.margins
|
||||
contentHeight: contentColumn.height + Style.margins
|
||||
interactive: contentHeight > height
|
||||
clip: true
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ SettingsPageBase {
|
|||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: root.height
|
||||
visible: zwaveManager.fetchingData || zwaveManager.networks.count == 0
|
||||
Layout.preferredHeight: root.height - root.header.height - Style.margins
|
||||
visible: !zwaveManager.fetchingData || !zwaveManager.zwaveAvailable || zwaveManager.networks.count == 0
|
||||
|
||||
BusyIndicator {
|
||||
anchors.centerIn: parent
|
||||
|
|
@ -74,12 +74,15 @@ SettingsPageBase {
|
|||
}
|
||||
|
||||
EmptyViewPlaceholder {
|
||||
visible: !zwaveManager.fetchingData && zwaveManager.networks.count == 0
|
||||
visible: !zwaveManager.fetchingData
|
||||
width: parent.width - app.margins * 2
|
||||
anchors.centerIn: parent
|
||||
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"
|
||||
buttonVisible: zwaveManager.zwaveAvailable
|
||||
buttonText: qsTr("Add network")
|
||||
onButtonClicked: {
|
||||
addNetwork()
|
||||
|
|
@ -90,6 +93,7 @@ SettingsPageBase {
|
|||
|
||||
ColumnLayout {
|
||||
Layout.margins: app.margins / 2
|
||||
visible: !zwaveManager.fetchingData && zwaveManager.zwaveAvailable && zwaveManager.networks.count > 0
|
||||
Repeater {
|
||||
model: zwaveManager.networks
|
||||
delegate: BigTile {
|
||||
|
|
|
|||
Loading…
Reference in New Issue