diff options
author | Robert Griebl <robert.griebl@pelagicore.com> | 2018-10-17 18:05:05 +0200 |
---|---|---|
committer | Daniel d'Andrada <daniel.dandrada@luxoft.com> | 2018-10-24 14:54:55 +0000 |
commit | 68c88b3456c20bcdea5df1b297fce03deed954ed (patch) | |
tree | fe7637a99ffc90d16a6e918df63f08ead325f9fa /examples/applicationmanager/intents/system-ui.qml | |
parent | 5c08826b6c794fe67ed2ebecca4a53ecf918ecca (diff) |
Heavily extended the intents example
These intents features are now available:
- requests from the system-ui
- disambiguation when no applicationId is specified
- requesting from/replying to an in-process app
(green is always running as a single-process app)
- private intents (blue-window-private)
- intents that require capabilities
(only the sysui and red can call rotate-window on blue)
Also, the example wrapper script is now able to deal with
developer builds.
Change-Id: I9ff2d6012b2c9cf29e32abaaa7d4fa3b3122944e
Reviewed-by: Daniel d'Andrada <daniel.dandrada@luxoft.com>
Diffstat (limited to 'examples/applicationmanager/intents/system-ui.qml')
-rw-r--r-- | examples/applicationmanager/intents/system-ui.qml | 134 |
1 files changed, 127 insertions, 7 deletions
diff --git a/examples/applicationmanager/intents/system-ui.qml b/examples/applicationmanager/intents/system-ui.qml index 9bca06a3..ecc15236 100644 --- a/examples/applicationmanager/intents/system-ui.qml +++ b/examples/applicationmanager/intents/system-ui.qml @@ -50,15 +50,21 @@ ** ****************************************************************************/ -import QtQuick 2.4 +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.4 import QtApplicationManager 1.0 +import "shared" Item { - width: 800 + id: root + width: 900 height: 600 // Show application names and icons Column { + id: launcher + width: 100 spacing: 20 Repeater { model: ApplicationManager @@ -71,23 +77,137 @@ Item { } } Text { - font.pixelSize: 20 + width: parent.width + font.pixelSize: 10 text: model.name + horizontalAlignment: Text.AlignHCenter } } } } // Show windows - Column { - anchors.right: parent.right + Grid { + anchors { + right: parent.right + left: launcher.right + top: parent.top + bottom: parent.bottom + } + columns: 2 + + IntentPage { + id: sysui_page + width: parent.width / 2 + height: parent.height / 2 + title: "System-UI" + + onRequest: { + var request = IntentClient.createIntentRequest(intentId, applicationId, parameters) + request.onFinished.connect(function() { + sysui_page.setResult(request.requestId, request.succeeded, + request.succeeded ? request.result : request.errorMessage) + }) + } + } + Repeater { model: WindowManager WindowItem { - width: 600 - height: 200 + width: sysui_page.width + height: sysui_page.height window: model.window } } } + + + Dialog { + id: disambiguationDialog + title: "Disambiguation" + standardButtons: Dialog.Ok | Dialog.Cancel + closePolicy: Popup.NoAutoClose + modal: true + + parent: Overlay.overlay + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: parent.width / 3 * 2 + height: parent.height / 3 * 2 + + property var allRequests: [] + property var currentRequest: ({}) + + function add(requestId, potentialIntents) { + allRequests.push({ "requestId": requestId, "intents": potentialIntents}) + + if (!visible) + showNext() + } + function showNext() { + currentRequest = {} + if (allRequests.length !== 0) { + currentRequest = allRequests.pop() + intentRequest.text = currentRequest.requestId + intent.text = currentRequest.intents[0].intentId + handlingApplications.model = currentRequest.intents + open() + } + } + onAccepted: { + IntentServer.acknowledgeDisambiguationRequest(currentRequest.requestId, + currentRequest.intents[handlingApplications.currentIndex]); + showNext() + } + onRejected: { + IntentServer.rejectDisambiguationRequest(currentRequest.requestId) + showNext() + } + + GridLayout { + id: grid + anchors.fill: parent + anchors.margins: 5 + rowSpacing: 5 + columns: 2 + + Label { text: "Request Id:" } + Label { id: intentRequest; font.bold: true; Layout.fillWidth: true } + Label { text: "Intent Id:" } + Label { id: intent; font.bold: true; Layout.fillWidth: true } + + Label { + text: "Select one of the potential handler applications:" + Layout.columnSpan: 2 + Layout.fillWidth: true + Layout.alignment: Qt.AlignCenter + } + + ListView { + id: handlingApplications + + Layout.columnSpan: 2 + Layout.fillWidth: true + Layout.fillHeight: true + + delegate: ItemDelegate { + property ApplicationObject application: ApplicationManager.application(modelData.applicationId) + width: parent.width + text: application.name("en") + " (" + modelData.applicationId + ")" + icon.source: application.icon + icon.color: "transparent" + highlighted: ListView.isCurrentItem + onClicked: { handlingApplications.currentIndex = index } + } + model: [] + clip: true + ScrollIndicator.vertical: ScrollIndicator { } + } + } + } + + Connections { + target: IntentServer + onDisambiguationRequest: { disambiguationDialog.add(requestId, potentialIntents) } + } } |