summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@qt.io>2020-01-30 13:14:14 +0100
committerRobert Griebl <robert.griebl@qt.io>2020-01-31 15:59:40 +0100
commit9832e276e2d120ef4d7207fa224a96d1597dadff (patch)
tree296b7b8f03d8b67cc7529ef0801419cedb9cea3c /examples
parent2887a8ce32920845c52db8950b8064092733169d (diff)
Add intent handling in the system-ui
Added a new component IntentServerHandler which lets you declare intent handlers directly in the system-ui. As an added benefit, these handlers also have access to the application id of the intent creator. Change-Id: Ia2d6f0860bc20e50ec8a0dd1f4bbca1a2b6967d0 Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/applicationmanager/intents/apps/intents.blue/info.yaml8
-rw-r--r--examples/applicationmanager/intents/apps/intents.green/info.yaml4
-rw-r--r--examples/applicationmanager/intents/apps/intents.red/info.yaml6
-rw-r--r--examples/applicationmanager/intents/doc/src/intents.qdoc34
-rw-r--r--examples/applicationmanager/intents/shared/IntentsUIPage.qml2
-rw-r--r--examples/applicationmanager/intents/system-ui.qml17
6 files changed, 66 insertions, 5 deletions
diff --git a/examples/applicationmanager/intents/apps/intents.blue/info.yaml b/examples/applicationmanager/intents/apps/intents.blue/info.yaml
index 19f252c4..7ce3930e 100644
--- a/examples/applicationmanager/intents/apps/intents.blue/info.yaml
+++ b/examples/applicationmanager/intents/apps/intents.blue/info.yaml
@@ -10,8 +10,16 @@ name:
intents:
- id: rotate-window
+ name:
+ en: Rotate Blue
requiredCapabilities: [ 'call-blue' ]
- id: scale-window
+ name:
+ en: Scale Blue
- id: blink-window
+ name:
+ en: Blink Blue
- id: blue-window-private
+ name:
+ en: Blue Private Intent
visibility: private
diff --git a/examples/applicationmanager/intents/apps/intents.green/info.yaml b/examples/applicationmanager/intents/apps/intents.green/info.yaml
index 97503419..40575f03 100644
--- a/examples/applicationmanager/intents/apps/intents.green/info.yaml
+++ b/examples/applicationmanager/intents/apps/intents.green/info.yaml
@@ -10,4 +10,8 @@ name:
intents:
- id: rotate-window
+ name:
+ en: Rotate Green
- id: scale-window
+ name:
+ en: Scale Green
diff --git a/examples/applicationmanager/intents/apps/intents.red/info.yaml b/examples/applicationmanager/intents/apps/intents.red/info.yaml
index a08392fc..d61ba316 100644
--- a/examples/applicationmanager/intents/apps/intents.red/info.yaml
+++ b/examples/applicationmanager/intents/apps/intents.red/info.yaml
@@ -12,5 +12,11 @@ capabilities: 'call-blue'
intents:
- id: rotate-window
+ name:
+ en: Rotate Red
- id: scale-window
+ name:
+ en: Scale Red
- id: blink-window
+ name:
+ en: Blink Red
diff --git a/examples/applicationmanager/intents/doc/src/intents.qdoc b/examples/applicationmanager/intents/doc/src/intents.qdoc
index f1da854a..958fa483 100644
--- a/examples/applicationmanager/intents/doc/src/intents.qdoc
+++ b/examples/applicationmanager/intents/doc/src/intents.qdoc
@@ -127,7 +127,7 @@ For information on these and other command line options you can run \tt{appman -
look at the \l{Configuration} documentation.
-\section1 Application implementation
+\section1 Application Implementation
All the applications (red, green and blue) are identical and their \c main.qml just
instantiates the shared IntentsApplicationWindow component.
@@ -197,10 +197,36 @@ required capability, while the \b Green doesn't.
\printto
-\section1 System-UI implementation
+\section1 System-UI Implementation
-What is special about the System-UI as compared to the applications, is the \l
-{IntentServer::disambiguationRequest}{disambiguation mechanism} and the accompanying UI.
+Apart from the left side bar that deals with starting and stopping the apps, the System-UI has two
+special features that deal with the intent mechanism:
+
+\list
+ \li Handling Intents in the System-UI and
+ \li Disambiguation of Intent Requests
+\endlist
+
+\section2 Handling Intents in the System-UI
+
+Intents can not only be handled in applications, but also in the System-UI. Since the System-UI is
+always running, we do not need to rely on \c info.yaml manifest files to define the supported
+intents, but instead can declare the needed meta-data directly as properties of the
+IntentServerHandler component. The IntentServerHandler is actually derived from IntentHandler, so
+it works the same way as its application side counter part: it only adds the required properties to
+define all the meta-data (e.g. \c names, \c icon, ...) on top.
+
+\snippet applicationmanager/intents/system-ui.qml IntentServerHandler
+
+The handler callback is nearly the same as the one in the applications. The only noteworthy
+difference here is, that we have access to the \l{IntentRequest::}{requestingApplicationId}
+to identify where the request originated from; for security reasons, this data is not available to
+intent handlers in applications.
+
+\section2 Disambiguation of Intent Requests
+
+The example implements an UI that lets the user choose how to
+\l {IntentServer::disambiguationRequest}{to disambiguate incoming intent requests}.
Registering for the IntentServer's disambiguation requests is done here:
\snippet applicationmanager/intents/system-ui.qml Connection
diff --git a/examples/applicationmanager/intents/shared/IntentsUIPage.qml b/examples/applicationmanager/intents/shared/IntentsUIPage.qml
index 0420a089..010a1501 100644
--- a/examples/applicationmanager/intents/shared/IntentsUIPage.qml
+++ b/examples/applicationmanager/intents/shared/IntentsUIPage.qml
@@ -104,7 +104,7 @@ Rectangle {
Label { text: "Application:" }
ComboBox {
id: cbApplication
- model: [ "<not specified>", "intents.red", "intents.green", "intents.blue" ]
+ model: [ "<not specified>", "intents.red", "intents.green", "intents.blue", ":sysui:" ]
Layout.fillWidth: true
}
Button {
diff --git a/examples/applicationmanager/intents/system-ui.qml b/examples/applicationmanager/intents/system-ui.qml
index e3198f80..f212d3c8 100644
--- a/examples/applicationmanager/intents/system-ui.qml
+++ b/examples/applicationmanager/intents/system-ui.qml
@@ -112,6 +112,23 @@ Item {
request.succeeded ? request.result : request.errorMessage)
})
}
+ RotationAnimation on rotation {
+ id: rotationAnimation
+ running: false
+ duration: 500; from: 0; to: 360
+ }
+ //! [IntentServerHandler]
+ IntentServerHandler {
+ intentIds: "rotate-window"
+ names: { "en": "Rotate System-UI" }
+ visibility: IntentObject.Public
+
+ onRequestReceived: {
+ rotationAnimation.start()
+ request.sendReply({ "wasRequestedBy": request.requestingApplicationId })
+ }
+ }
+ //! [IntentServerHandler]
}
Repeater {