From e4fba677a9755a5aee1a0ea1513b6f737429d832 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 4 May 2016 16:49:31 +0200 Subject: Unbreak action execution from qml QML can't do with custom return types. (we'd have to wrap it in a QVariant or use a property). --- framework/actions/action.cpp | 7 ++++++- framework/actions/action.h | 3 ++- framework/actions/actionplugin.cpp | 2 ++ framework/actions/actionresult.h | 2 ++ framework/domain/actions/tests/sinkactiontest.cpp | 4 ++-- 5 files changed, 14 insertions(+), 4 deletions(-) (limited to 'framework') diff --git a/framework/actions/action.cpp b/framework/actions/action.cpp index 28dd5e2a..4bda033e 100644 --- a/framework/actions/action.cpp +++ b/framework/actions/action.cpp @@ -85,7 +85,12 @@ bool Action::ready() const return ActionBroker::instance().isActionReady(mActionId, mContext); } -ActionResult Action::execute() +void Action::execute() +{ + ActionBroker::instance().executeAction(mActionId, mContext); +} + +ActionResult Action::executeWithResult() { return ActionBroker::instance().executeAction(mActionId, mContext); } diff --git a/framework/actions/action.h b/framework/actions/action.h index 1ad4a47e..1abf4a5c 100644 --- a/framework/actions/action.h +++ b/framework/actions/action.h @@ -44,7 +44,8 @@ public: bool ready() const; - Q_INVOKABLE ActionResult execute(); + Q_INVOKABLE void execute(); + ActionResult executeWithResult(); Q_SIGNALS: void readyChanged(); diff --git a/framework/actions/actionplugin.cpp b/framework/actions/actionplugin.cpp index 87bc4d7b..05852d2e 100644 --- a/framework/actions/actionplugin.cpp +++ b/framework/actions/actionplugin.cpp @@ -3,6 +3,7 @@ #include "action.h" #include "context.h" #include "actionhandler.h" +#include "actionresult.h" #include @@ -12,4 +13,5 @@ void KubePlugin::registerTypes (const char *uri) qmlRegisterType(uri, 1, 0, "Context"); qmlRegisterType(uri, 1, 0, "Action"); qmlRegisterType(uri, 1, 0, "ActionHandler"); + qmlRegisterType(uri, 1, 0, "ActionResult"); } diff --git a/framework/actions/actionresult.h b/framework/actions/actionresult.h index cdc6a160..e4d3efeb 100644 --- a/framework/actions/actionresult.h +++ b/framework/actions/actionresult.h @@ -64,3 +64,5 @@ private: }; } + +Q_DECLARE_METATYPE(Kube::ActionResult); diff --git a/framework/domain/actions/tests/sinkactiontest.cpp b/framework/domain/actions/tests/sinkactiontest.cpp index 3e4567fd..3ba9ffb9 100644 --- a/framework/domain/actions/tests/sinkactiontest.cpp +++ b/framework/domain/actions/tests/sinkactiontest.cpp @@ -25,7 +25,7 @@ private slots: void testSaveAsDraftFail() { Kube::Context context; - auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).execute(); + auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).executeWithResult(); QTRY_VERIFY(future.isDone()); //because of empty context @@ -45,7 +45,7 @@ private slots: Kube::Context context; context.setProperty("message", QVariant::fromValue(message)); context.setProperty("accountId", QVariant::fromValue(account.identifier)); - auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).execute(); + auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).executeWithResult(); QTRY_VERIFY(future.isDone()); QVERIFY(!future.error()); -- cgit v1.2.3