From 677536e463b92f5dd7ed08b4691c99715c28e993 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sun, 6 May 2018 20:54:51 +0200 Subject: [PATCH] first attempt to provide better feedback on executeAction results --- mea/devicemanager.cpp | 8 +++++++- mea/devicemanager.h | 2 ++ mea/ui/MainPage.qml | 22 +++++++++++++++++++++- mea/ui/components/ErrorDialog.qml | 9 ++++----- mea/ui/customviews/MediaControllerView.qml | 11 +---------- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/mea/devicemanager.cpp b/mea/devicemanager.cpp index 443f1ca2..ca0d3798 100644 --- a/mea/devicemanager.cpp +++ b/mea/devicemanager.cpp @@ -291,6 +291,12 @@ void DeviceManager::editDeviceResponse(const QVariantMap ¶ms) emit editDeviceReply(params); } +void DeviceManager::executeActionResponse(const QVariantMap ¶ms) +{ + 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"); } diff --git a/mea/devicemanager.h b/mea/devicemanager.h index b531105f..5738b64f 100644 --- a/mea/devicemanager.h +++ b/mea/devicemanager.h @@ -76,6 +76,7 @@ private: Q_INVOKABLE void confirmPairingResponse(const QVariantMap ¶ms); Q_INVOKABLE void setPluginConfigResponse(const QVariantMap ¶ms); Q_INVOKABLE void editDeviceResponse(const QVariantMap ¶ms); + Q_INVOKABLE void executeActionResponse(const QVariantMap ¶ms); public slots: void savePluginConfig(const QUuid &pluginId); @@ -87,6 +88,7 @@ signals: void removeDeviceReply(const QVariantMap ¶ms); void savePluginConfigReply(const QVariantMap ¶ms); void editDeviceReply(const QVariantMap ¶ms); + void executeActionReply(const QVariantMap ¶ms); void fetchingDataChanged(); private: diff --git a/mea/ui/MainPage.qml b/mea/ui/MainPage.qml index 5f8d046f..21dfb5ca 100644 --- a/mea/ui/MainPage.qml +++ b/mea/ui/MainPage.qml @@ -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 diff --git a/mea/ui/components/ErrorDialog.qml b/mea/ui/components/ErrorDialog.qml index 4e9e0931..64fb3cf6 100644 --- a/mea/ui/components/ErrorDialog.qml +++ b/mea/ui/components/ErrorDialog.qml @@ -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 } } } diff --git a/mea/ui/customviews/MediaControllerView.qml b/mea/ui/customviews/MediaControllerView.qml index 07e0fce3..1c47e5f3 100644 --- a/mea/ui/customviews/MediaControllerView.qml +++ b/mea/ui/customviews/MediaControllerView.qml @@ -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 } - } } }