diff options
author | Robert Griebl <robert.griebl@qt.io> | 2019-10-13 16:59:42 +0200 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2020-01-24 16:58:04 +0100 |
commit | b78c2d48c9df47ecce3d775654ad61d9e413a023 (patch) | |
tree | 223f292b42e49ac9610250f4da58d40304b87c36 /examples | |
parent | 4f7b3e720f3c65d4243865ed5734d3271583177e (diff) | |
download | qtapplicationmanager-b78c2d48c9df47ecce3d775654ad61d9e413a023.tar.gz |
Add a new Hello-World type example, using intents
Change-Id: I408e76086534fa88a396a1b1189576341cc1ad9d
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Diffstat (limited to 'examples')
14 files changed, 609 insertions, 0 deletions
diff --git a/examples/applicationmanager/applicationmanager.pro b/examples/applicationmanager/applicationmanager.pro index 6ea4e083..2e893fe2 100644 --- a/examples/applicationmanager/applicationmanager.pro +++ b/examples/applicationmanager/applicationmanager.pro @@ -8,6 +8,7 @@ SUBDIRS = \ animated-windows \ frame-timer \ hello-world \ + launch-intents \ minidesk \ application-features \ multi-views \ diff --git a/examples/applicationmanager/launch-intents/apps/launch-intents.blue/icon.png b/examples/applicationmanager/launch-intents/apps/launch-intents.blue/icon.png Binary files differnew file mode 100644 index 00000000..be6ffc57 --- /dev/null +++ b/examples/applicationmanager/launch-intents/apps/launch-intents.blue/icon.png diff --git a/examples/applicationmanager/launch-intents/apps/launch-intents.blue/info.yaml b/examples/applicationmanager/launch-intents/apps/launch-intents.blue/info.yaml new file mode 100644 index 00000000..f801054e --- /dev/null +++ b/examples/applicationmanager/launch-intents/apps/launch-intents.blue/info.yaml @@ -0,0 +1,18 @@ +formatVersion: 1 +formatType: am-package +--- +id: 'launch-intents.blue' +icon: 'icon.png' +name: + en: 'Blue App' + +applications: +- id: launch-intents.blue + runtime: 'qml' + code: 'main.qml' + +intents: +- id: launch + name: + en: 'Launch Blue' + categories: [ launcher ] diff --git a/examples/applicationmanager/launch-intents/apps/launch-intents.blue/main.qml b/examples/applicationmanager/launch-intents/apps/launch-intents.blue/main.qml new file mode 100644 index 00000000..45bd168b --- /dev/null +++ b/examples/applicationmanager/launch-intents/apps/launch-intents.blue/main.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 +import QtApplicationManager.Application 2.0 + +ApplicationManagerWindow { + color: "blue" + + Text { + id: txt + + property int counter: 0 + + anchors.centerIn: parent + text: ApplicationInterface.name["en"] + "\nLaunch intents received: " + counter + } + + IntentHandler { + intentIds: [ "launch" ] + onRequestReceived: { + txt.counter++ + request.sendReply({}) + } + } +} diff --git a/examples/applicationmanager/launch-intents/apps/launch-intents.green/icon.png b/examples/applicationmanager/launch-intents/apps/launch-intents.green/icon.png Binary files differnew file mode 100644 index 00000000..b149340c --- /dev/null +++ b/examples/applicationmanager/launch-intents/apps/launch-intents.green/icon.png diff --git a/examples/applicationmanager/launch-intents/apps/launch-intents.green/info.yaml b/examples/applicationmanager/launch-intents/apps/launch-intents.green/info.yaml new file mode 100644 index 00000000..7381fa7c --- /dev/null +++ b/examples/applicationmanager/launch-intents/apps/launch-intents.green/info.yaml @@ -0,0 +1,18 @@ +formatVersion: 1 +formatType: am-package +--- +id: 'launch-intents.green' +icon: 'icon.png' +name: + en: 'Green App' + +applications: +- id: launch-intents.green + runtime: 'qml' + code: 'main.qml' + +intents: +- id: launch + name: + en: 'Launch Green' + categories: [ launcher ] diff --git a/examples/applicationmanager/launch-intents/apps/launch-intents.green/main.qml b/examples/applicationmanager/launch-intents/apps/launch-intents.green/main.qml new file mode 100644 index 00000000..46c64640 --- /dev/null +++ b/examples/applicationmanager/launch-intents/apps/launch-intents.green/main.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 +import QtApplicationManager.Application 2.0 + +ApplicationManagerWindow { + color: "green" + + Text { + id: txt + + property int counter: 0 + + anchors.centerIn: parent + text: ApplicationInterface.name["en"] + "\nLaunch intents received: " + counter + } + + IntentHandler { + intentIds: [ "launch" ] + onRequestReceived: { + txt.counter++ + request.sendReply({}) + } + } +} diff --git a/examples/applicationmanager/launch-intents/apps/launch-intents.red/icon.png b/examples/applicationmanager/launch-intents/apps/launch-intents.red/icon.png Binary files differnew file mode 100644 index 00000000..04ca44dd --- /dev/null +++ b/examples/applicationmanager/launch-intents/apps/launch-intents.red/icon.png diff --git a/examples/applicationmanager/launch-intents/apps/launch-intents.red/info.yaml b/examples/applicationmanager/launch-intents/apps/launch-intents.red/info.yaml new file mode 100644 index 00000000..25ba4d96 --- /dev/null +++ b/examples/applicationmanager/launch-intents/apps/launch-intents.red/info.yaml @@ -0,0 +1,23 @@ +formatVersion: 1 +formatType: am-package +--- +id: 'launch-intents.red' +icon: 'icon.png' +name: + en: 'Red App' + +applications: +- id: launch-intents.red + runtime: 'qml' + code: 'main.qml' + +intents: +- id: launch + name: + en: 'Launch Red' + categories: [ launcher ] + +- id: another-launch + name: + en: 'Launch Another Red' + categories: [ launcher ] diff --git a/examples/applicationmanager/launch-intents/apps/launch-intents.red/main.qml b/examples/applicationmanager/launch-intents/apps/launch-intents.red/main.qml new file mode 100644 index 00000000..1bb842b9 --- /dev/null +++ b/examples/applicationmanager/launch-intents/apps/launch-intents.red/main.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 +import QtApplicationManager.Application 2.0 + +ApplicationManagerWindow { + color: "red" + + Text { + id: txt + + property int counter: 0 + property int anotherCounter: 0 + + anchors.centerIn: parent + text: ApplicationInterface.name["en"] + "\n" + + "Launch intents received: " + counter + " (normal)\n" + + "Launch intents received: " + anotherCounter + " (another)" + } + + IntentHandler { + intentIds: [ "launch", "another-launch" ] + onRequestReceived: { + if (request.intentId === "launch") + txt.counter++ + else + txt.anotherCounter++ + request.sendReply({}) + } + } +} diff --git a/examples/applicationmanager/launch-intents/doc/images/launch-intents-example.png b/examples/applicationmanager/launch-intents/doc/images/launch-intents-example.png Binary files differnew file mode 100644 index 00000000..af9aff4d --- /dev/null +++ b/examples/applicationmanager/launch-intents/doc/images/launch-intents-example.png diff --git a/examples/applicationmanager/launch-intents/doc/src/launch-intents.qdoc b/examples/applicationmanager/launch-intents/doc/src/launch-intents.qdoc new file mode 100644 index 00000000..02f926c6 --- /dev/null +++ b/examples/applicationmanager/launch-intents/doc/src/launch-intents.qdoc @@ -0,0 +1,180 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:FDL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + +\example applicationmanager/launch-intents +\brief Learn how to use Intents to start applications from the System UI. +\ingroup applicationmanager-examples +\title Launch Applications Using Intents System UI Example +\image launch-intents-example.png The Launch Intents example with two applications running. + +\section1 Introduction + +This example shows you how to use intents as a basis for a launcher in a System UI. + +\b Prerequisites: You're already familiar with the concepts and topics introduced in the + \l {"Hello World!" System UI Example}. This example uses the same folder structure and can be + started in the same way. + +Unlike the \l{"Hello World!" System UI Example}{Hello World} example, we are not using the +ApplicationObject abstraction layer directly to launch appliations, but instead we are using +\c launch intents registered by the packages. This way we can have multiple icons in a launcher +that can start the same application, triggering different functionality within the application. + +\note \e Any intent directed at an application would launch it, if it was not already running. For + the purpose of this example we are calling our intents \c launch, but the application-manager + does not attach a special meaning to this name. + +All the intents' icons and names that are in the \c launcher category are on the left. You can click +on their icons to send the respective intent request to the system: if the corresponding +application is not yet running, it will be started automatically. Doing a press-and-hold on the +icon will stop the application via the ApplicationObject. +Just like in the "Hello World!" example, the column layout on the right shows the windows of all +running applications. + +The applications display their application name against a background of that color. In addition +they also show how many times they have received an intent of the \c launch category. + +\section1 Implement the System UI + +Like any simple QML application, our example's code starts with some imports and a plain Item at +the root. The only difference is that our System UI also imports the +\c QtApplicationManager and \c QtApplicationManager.SystemUI modules, besides \c QtQuick. + +\quotefromfile applicationmanager/launch-intents/system-ui.qml +\skipto import QtQuick +\printuntil height: + + +Unlike in the "Hello World!" example, we now create an IntentModel to get access to all intents that +are in the \c launcher category. Since this model is unsorted by default, we also set the sorting +order to descending based on the name of the intent. +\note The name of the category could be anything you like it to be - as long as it is consistent + between here and the applications' \c info.yaml metadata and the corresponding IntentHandler + within the application. + +\printto Show intent names + +Next, we have a Column on the left side of the root Item where we place the icons of the available +intents along with their names. + +\printto Show windows + +We use our IntentModel, which provides a row for each intent available. In each row, we have: + +\list + \li an \c icon role with the icon URL + \li a \c name role with the localized intent's name + \li an \c intentId role that contains the id of the intent + \li an \c applicationId role that contains the id of the handling application +\endlist + +For information on the other roles available, see \l{IntentServer}{IntentServer QML Type}. + +Next, we place a \c Column anchored to the right side of the root \c Item. This item is exactly the +same as in the "Hello World!" example, showing all the application windows. + +\section1 Implement the Application + +Our Launch Intents applications display their application name as text against a colored background. + +\quotefromfile applicationmanager/launch-intents/apps/launch-intents.blue/main.qml +\skipto import QtQuick +\printuntil /^\}/ + +The only difference between this example and the one from the "Hello World" example is that we +are additionally handling incoming \c launch intent requests via an IntentHandler: this intent +handler doesn't do anything useful in this example, besides increasing a counter in the Text object, +so that you can see how many times the launch intent has been received. Have +a look at the documentation for IntentHandler::requestReceived for more +information on the IntentClientRequest::sendReply call. + +\section2 Application Metadata + +The \c info.yaml file contains the metadata about a package. It starts with some boilerplate +describing that this file contains Qt Application Manager package metadata. + +\quotefromfile applicationmanager/launch-intents/apps/launch-intents.blue/info.yaml +\printuntil -- + +Then comes the package ID, which uniquely identifies the package. It's recommended to +follow a reverse DNS scheme, but it's not enforced. Here it's the "Blue" package from the +"Launch Intents" example UI. + +\printline id: + +Then the icon filename: + +\printline icon: + +Next comes the user-visible name of the application in any number of languages. For this +example, we only provide English: + +\printto applications: + +For each package, we define one application that gets the same id as the package itself +(this is not a requirement, but useful approach to single-application packages. + +\printto intents: + +Every package will at least register one \c launch intent in the \c launcher category. The exact name +of the intent does not really matter in this case, since the system-ui will just request all +intents that are in the \c launcher category. +The name and icon of an intent default to the name and icon of the package, but we override the name +here: + +\printuntil + +\section2 Alias handling + +The red application does a bit more then the blue and green counterparts: it implements the +deprecated "aliases" mechanism using intents. + +In its \c info.yaml file it defines a second intent in the \c launcher category, named +\c another-launch: +\quotefromfile applicationmanager/launch-intents/apps/launch-intents.red/info.yaml +\skipto id: another-launch +\printuntil + +In order to handle this intent, the IntentHandler in the \c main.qml file is extended to accept +both intents: + +\quotefromfile applicationmanager/launch-intents/apps/launch-intents.red/main.qml +\skipto IntentHandler { +\printto onRequestReceived: { + +The signal handler for incoming intent request can then disambiguate between the requested intents +based on their \c intentId and increase either the normal \c counter or the \c anotherCounter +property of the text field. + +\printuntil /\s+\}/ + +\note Instead of one IntentHandler handling both intents, this could have also been implemented + using two separate IntentHandlers, handling one intent each. + +*/ diff --git a/examples/applicationmanager/launch-intents/launch-intents.pro b/examples/applicationmanager/launch-intents/launch-intents.pro new file mode 100644 index 00000000..e6cd92f0 --- /dev/null +++ b/examples/applicationmanager/launch-intents/launch-intents.pro @@ -0,0 +1,31 @@ +TEMPLATE = app +CONFIG += am-systemui + +OTHER_FILES += \ + *.qml \ + doc/images/*.png \ + doc/src/*.qdoc \ + apps/launch-intents.blue/*.yaml \ + apps/launch-intents.blue/*.qml \ + apps/launch-intents.blue/*.png \ + apps/launch-intents.green/*.yaml \ + apps/launch-intents.green/*.qml \ + apps/launch-intents.green/*.png \ + apps/launch-intents.red/*.yaml \ + apps/launch-intents.red/*.qml \ + apps/launch-intents.red/*.png \ + +target.path = $$[QT_INSTALL_EXAMPLES]/applicationmanager/launch-intents +INSTALLS += target + +AM_COPY_DIRECTORIES += apps +AM_COPY_FILES += system-ui.qml + +prefix_build:tpath = $$target.path +else:tpath = $$_PRO_FILE_PWD_ + +AM_DEFAULT_ARGS=--builtin-apps-manifest-dir $$tpath/apps $$tpath/system-ui.qml + +example_sources.path = $$target.path +example_sources.files = $$AM_COPY_FILES $$AM_COPY_DIRECTORIES +INSTALLS += example_sources diff --git a/examples/applicationmanager/launch-intents/system-ui.qml b/examples/applicationmanager/launch-intents/system-ui.qml new file mode 100644 index 00000000..fc0d78b9 --- /dev/null +++ b/examples/applicationmanager/launch-intents/system-ui.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:BSD-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: BSD-3-Clause +** +****************************************************************************/ + +import QtQuick 2.12 +import QtApplicationManager 2.0 +import QtApplicationManager.SystemUI 2.0 + +Item { + width: 800 + height: 600 + + IntentModel { + id: intentModel + filterFunction: function(i) { return i.categories.contains("launcher") } + sortFunction: function(li, ri) { return li.name > ri.name } + } + + // Show intent names and icons + Column { + spacing: 20 + Repeater { + model: intentModel + Column { + Image { + source: model.icon + MouseArea { + anchors.fill: parent + onPressAndHold: { + var app = ApplicationManager.application(model.applicationId) + if (app.runState === Am.Running) + app.stop() + } + onClicked: { + IntentClient.sendIntentRequest(model.intentId, model.applicationId, {}) + } + } + } + Text { + font.pixelSize: 20 + text: model.name + } + } + } + } + + // Show windows + Column { + anchors.right: parent.right + Repeater { + model: WindowManager + WindowItem { + width: 600 + height: 200 + window: model.window + } + } + } +} |