first attempt to provide better feedback on executeAction results

pull/1/head
Michael Zanetti 2018-05-06 20:54:51 +02:00
parent 3c3cb76bf8
commit 677536e463
5 changed files with 35 additions and 17 deletions

View File

@ -291,6 +291,12 @@ void DeviceManager::editDeviceResponse(const QVariantMap &params)
emit editDeviceReply(params);
}
void DeviceManager::executeActionResponse(const QVariantMap &params)
{
qDebug() << "Execute Action response" << params;
emit executeActionReply(params.value("params").toMap());
}
void DeviceManager::savePluginConfig(const QUuid &pluginId)
{
Plugin *p = m_plugins->getPlugin(pluginId);
@ -364,5 +370,5 @@ void DeviceManager::executeAction(const QUuid &deviceId, const QUuid &actionType
}
qDebug() << "Params:" << p;
m_jsonClient->sendCommand("Actions.ExecuteAction", p);
m_jsonClient->sendCommand("Actions.ExecuteAction", p, this, "executeActionResponse");
}

View File

@ -76,6 +76,7 @@ private:
Q_INVOKABLE void confirmPairingResponse(const QVariantMap &params);
Q_INVOKABLE void setPluginConfigResponse(const QVariantMap &params);
Q_INVOKABLE void editDeviceResponse(const QVariantMap &params);
Q_INVOKABLE void executeActionResponse(const QVariantMap &params);
public slots:
void savePluginConfig(const QUuid &pluginId);
@ -87,6 +88,7 @@ signals:
void removeDeviceReply(const QVariantMap &params);
void savePluginConfigReply(const QVariantMap &params);
void editDeviceReply(const QVariantMap &params);
void executeActionReply(const QVariantMap &params);
void fetchingDataChanged();
private:

View File

@ -1,4 +1,4 @@
import QtQuick 2.5
import QtQuick 2.8
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.2
@ -23,6 +23,26 @@ Page {
opacity: .2
}
// FIXME: Currently we don't have any feedback for executeAction
// we don't want all the results, e.g. on looped calls like "all off"
// Connections {
// target: Engine.deviceManager
// onExecuteActionReply: {
// var text = params["deviceError"]
// switch(text) {
// case "DeviceErrorNoError":
// return;
// case "DeviceErrorHardwareNotAvailable":
// text = qsTr("Could not execute action. The thing is not available");
// break;
// }
// var errorDialog = Qt.createComponent(Qt.resolvedUrl("components/ErrorDialog.qml"))
// var popup = errorDialog.createObject(root, {text: text})
// popup.open()
// }
// }
Menu {
id: mainMenu
width: implicitWidth + app.margins

View File

@ -4,10 +4,10 @@ import QtQuick.Layouts 1.2
Dialog {
id: root
width: Math.min(parent.width * .6, 400)
// height: content.height
width: Math.min(parent.width * .8, contentLabel.implicitWidth)
x: (parent.width - width) / 2
y: (parent.height - height) / 2
modal: true
title: qsTr("Error")
property alias text: contentLabel.text
@ -31,7 +31,7 @@ Dialog {
Label {
id: titleLabel
Layout.fillWidth: true
wrapMode: Text.WordWrap
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
text: root.title
color: app.guhAccent
font.pixelSize: app.largeFont
@ -42,12 +42,11 @@ Dialog {
ColumnLayout {
id: content
anchors { left: parent.left; top: parent.top; right: parent.right }
height: childrenRect.height
Label {
id: contentLabel
Layout.fillWidth: true
wrapMode: Text.WordWrap
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
}
}
}

View File

@ -44,13 +44,7 @@ CustomViewBase {
id: controlsRow
Layout.fillWidth: true
property int iconSize: Math.max(app.iconSize * 2, column.width / (controlsModel.count + 0))
// Item {
// width: Math.max(app.iconSize * 2, column.width / (controlsModel.count + 2))
// height: 1
// }
property int iconSize: Math.max(app.iconSize * 2, column.width / controlsModel.count)
Repeater {
model: ListModel {
@ -71,9 +65,6 @@ CustomViewBase {
}
}
}
// Item { Layout.fillWidth: true; height: 1 }
}
}
}