summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-04 16:49:31 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-05-04 16:49:31 +0200
commite4fba677a9755a5aee1a0ea1513b6f737429d832 (patch)
tree956856d3635249a6d7af98934f7f14885f264818 /framework
parent8cfe1ed71dd342bfb625a94319f7b3d42709c8b0 (diff)
downloadkube-e4fba677a9755a5aee1a0ea1513b6f737429d832.tar.gz
kube-e4fba677a9755a5aee1a0ea1513b6f737429d832.zip
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).
Diffstat (limited to 'framework')
-rw-r--r--framework/actions/action.cpp7
-rw-r--r--framework/actions/action.h3
-rw-r--r--framework/actions/actionplugin.cpp2
-rw-r--r--framework/actions/actionresult.h2
-rw-r--r--framework/domain/actions/tests/sinkactiontest.cpp4
5 files changed, 14 insertions, 4 deletions
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
85 return ActionBroker::instance().isActionReady(mActionId, mContext); 85 return ActionBroker::instance().isActionReady(mActionId, mContext);
86} 86}
87 87
88ActionResult Action::execute() 88void Action::execute()
89{
90 ActionBroker::instance().executeAction(mActionId, mContext);
91}
92
93ActionResult Action::executeWithResult()
89{ 94{
90 return ActionBroker::instance().executeAction(mActionId, mContext); 95 return ActionBroker::instance().executeAction(mActionId, mContext);
91} 96}
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:
44 44
45 bool ready() const; 45 bool ready() const;
46 46
47 Q_INVOKABLE ActionResult execute(); 47 Q_INVOKABLE void execute();
48 ActionResult executeWithResult();
48 49
49Q_SIGNALS: 50Q_SIGNALS:
50 void readyChanged(); 51 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 @@
3#include "action.h" 3#include "action.h"
4#include "context.h" 4#include "context.h"
5#include "actionhandler.h" 5#include "actionhandler.h"
6#include "actionresult.h"
6 7
7#include <QtQml> 8#include <QtQml>
8 9
@@ -12,4 +13,5 @@ void KubePlugin::registerTypes (const char *uri)
12 qmlRegisterType<Kube::Context>(uri, 1, 0, "Context"); 13 qmlRegisterType<Kube::Context>(uri, 1, 0, "Context");
13 qmlRegisterType<Kube::Action>(uri, 1, 0, "Action"); 14 qmlRegisterType<Kube::Action>(uri, 1, 0, "Action");
14 qmlRegisterType<Kube::ActionHandler>(uri, 1, 0, "ActionHandler"); 15 qmlRegisterType<Kube::ActionHandler>(uri, 1, 0, "ActionHandler");
16 qmlRegisterType<Kube::ActionResult>(uri, 1, 0, "ActionResult");
15} 17}
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:
64}; 64};
65 65
66} 66}
67
68Q_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:
25 void testSaveAsDraftFail() 25 void testSaveAsDraftFail()
26 { 26 {
27 Kube::Context context; 27 Kube::Context context;
28 auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).execute(); 28 auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).executeWithResult();
29 29
30 QTRY_VERIFY(future.isDone()); 30 QTRY_VERIFY(future.isDone());
31 //because of empty context 31 //because of empty context
@@ -45,7 +45,7 @@ private slots:
45 Kube::Context context; 45 Kube::Context context;
46 context.setProperty("message", QVariant::fromValue(message)); 46 context.setProperty("message", QVariant::fromValue(message));
47 context.setProperty("accountId", QVariant::fromValue(account.identifier)); 47 context.setProperty("accountId", QVariant::fromValue(account.identifier));
48 auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).execute(); 48 auto future = Kube::Action("org.kde.kube.actions.save-as-draft", context).executeWithResult();
49 49
50 QTRY_VERIFY(future.isDone()); 50 QTRY_VERIFY(future.isDone());
51 QVERIFY(!future.error()); 51 QVERIFY(!future.error());