diff options
author | Bernd Weimer <bernd.weimer@pelagicore.com> | 2019-07-31 10:10:18 +0200 |
---|---|---|
committer | Bernd Weimer <bernd.weimer@pelagicore.com> | 2019-08-29 18:10:16 +0200 |
commit | f8237e87f7e254120f6a20974fe18a723b1ec0a5 (patch) | |
tree | 1a74caf0402f6673ca3ea79f438b8dd6d97b4fca | |
parent | f086c5e563fe4e414e0b4f2e10a0d071a33692d7 (diff) | |
download | qtapplicationmanager-f8237e87f7e254120f6a20974fe18a723b1ec0a5.tar.gz |
Add application-features example
This example showcases client applications with various features,
including a native application.
Change-Id: Id7a8a40481b8b9503434f6576f3bf9f97b093435
Task-number: AUTOSUITE-1142
Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
30 files changed, 1089 insertions, 1 deletions
@@ -9,7 +9,7 @@ moc_* qrc_* *.moc *.user* -Makefile +Makefile* core DEADJOE *.gcda @@ -49,3 +49,5 @@ src/tools/appman/config.qrc doc/codeattributions.qdoc examples/applicationmanager/custom-appman/custom-appman tests/qml/crash/apps/tld.test.crash/terminator2/Terminator/ +examples/applicationmanager/fancyapps/apps/crash/Terminator/ +examples/applicationmanager/fancyapps/apps/widgets/widgets diff --git a/examples/applicationmanager/application-features/am-config.yaml b/examples/applicationmanager/application-features/am-config.yaml new file mode 100644 index 00000000..effb5bfc --- /dev/null +++ b/examples/applicationmanager/application-features/am-config.yaml @@ -0,0 +1,25 @@ +formatVersion: 1 +formatType: am-configuration +--- +applications: + builtinAppsManifestDir: "${CONFIG_PWD}/apps" + installationDir: "/tmp/application-features/apps" + installedAppsManifestDir: "/tmp/application-features/manifests" + +logging: + rules: + - "*=false" + - "qt.*=false" + - "am.*=false" + - "qml*=true" + - "*.warning=true" + - "*.critical=true" + +ui: + fullscreen: no + mainQml: "${CONFIG_PWD}/system-ui/main.qml" + +# development setup: +flags: + noSecurity: yes + noUiWatchdog: yes diff --git a/examples/applicationmanager/application-features/application-features.pro b/examples/applicationmanager/application-features/application-features.pro new file mode 100644 index 00000000..f986222b --- /dev/null +++ b/examples/applicationmanager/application-features/application-features.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = ui.pro \ + imports \ + native diff --git a/examples/applicationmanager/application-features/application-features.qmlproject b/examples/applicationmanager/application-features/application-features.qmlproject new file mode 100644 index 00000000..33df4360 --- /dev/null +++ b/examples/applicationmanager/application-features/application-features.qmlproject @@ -0,0 +1,17 @@ +import QmlProject 1.1 + +Project { + mainFile: "system-ui/main.qml" + + QmlFiles { + directory: "." + } + ImageFiles { + directory: "." + } + Files { + directory: "." + filter: "*.yaml" + } +} + diff --git a/examples/applicationmanager/application-features/apps/compositor/compositor.qml b/examples/applicationmanager/application-features/apps/compositor/compositor.qml new file mode 100644 index 00000000..c6979158 --- /dev/null +++ b/examples/applicationmanager/application-features/apps/compositor/compositor.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** 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.11 +import QtApplicationManager.Application 2.0 +import QtWayland.Compositor 1.3 + +ApplicationManagerWindow { + id: root + color: "lightgrey" + + property ListModel shellSurfaces: ListModel {} + + Text { + anchors.fill: parent + anchors.margins: 8 + font.pointSize: 14 + wrapMode: Text.Wrap + textFormat: Text.RichText + text: "This Wayland<sup>*</sup> client window implements a Wayland compositor (nested compositor). " + + "To display Wayland clients here, set:<br><br><b>WAYLAND_DISPLAY=qtam-wayland-nested</b>" + + "<br><br>For instance:<br>WAYLAND_DISPLAY=qtam-wayland-nested qmlscene client.qml -platform wayland" + + "<br><br><small>* in multi-process mode</small>" + } + + WaylandCompositor { + socketName: "qtam-wayland-nested" + + WaylandOutput { + window: root + sizeFollowsWindow: true + } + + WlShell { + onWlShellSurfaceCreated: shellSurfaces.append({shellSurface: shellSurface}); + } + + XdgShellV6 { + onToplevelCreated: shellSurfaces.append({shellSurface: xdgSurface}); + } + + XdgShell { + onToplevelCreated: shellSurfaces.append({shellSurface: xdgSurface}); + } + } + + Repeater { + model: shellSurfaces + ShellSurfaceItem { + shellSurface: modelData + onSurfaceDestroyed: shellSurfaces.remove(index) + } + } + + Component.onCompleted: console.info("Start a client application in the nested compositor for instance with:\n " + + "WAYLAND_DISPLAY=qtam-wayland-nested QT_WAYLAND_DISABLE_WINDOWDECORATION=1 " + + "QT_WAYLAND_SHELL_INTEGRATION=xdg-shell qmlscene client.qml -platform wayland"); +} diff --git a/examples/applicationmanager/application-features/apps/compositor/icon.png b/examples/applicationmanager/application-features/apps/compositor/icon.png Binary files differnew file mode 100644 index 00000000..7648da9b --- /dev/null +++ b/examples/applicationmanager/application-features/apps/compositor/icon.png diff --git a/examples/applicationmanager/application-features/apps/compositor/info.yaml b/examples/applicationmanager/application-features/apps/compositor/info.yaml new file mode 100644 index 00000000..c122f66b --- /dev/null +++ b/examples/applicationmanager/application-features/apps/compositor/info.yaml @@ -0,0 +1,9 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'compositor' +icon: 'icon.png' +code: 'compositor.qml' +runtime: 'qml' +name: + en: 'Nested Compositor' diff --git a/examples/applicationmanager/application-features/apps/crash/crashapp.qml b/examples/applicationmanager/application-features/apps/crash/crashapp.qml new file mode 100644 index 00000000..4db96568 --- /dev/null +++ b/examples/applicationmanager/application-features/apps/crash/crashapp.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:LGPL-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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: LGPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.11 +import QtApplicationManager.Application 2.0 +import Terminator 2.0 + +ApplicationManagerWindow { + id: root + + property var methods: ({ illegalMemory: "Illegal memory access", + illegalMemoryInThread: "Illegal memory access in a thread", + stackOverflow: "Force stack overflow", + divideByZero: "Divide by zero", + unhandledException: "Throw unhandled exception", + abort: "Call abort", + raise: "Raise signal 7", + gracefully: "Exit gracefully" }) + + + function accessIllegalMemory() + { + Terminator.accessIllegalMemory(); + } + + Grid { + columns: 2 + Repeater { + model: Object.keys(methods) + Rectangle { + width: root.width / 2 + height: root.height / 4 + border.width: 1 + color: "lightgrey" + + Text { + anchors.fill: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.Wrap + font.pointSize: 14 + text: methods[modelData] + } + + MouseArea { + anchors.fill: parent + onClicked: { + switch (modelData) { + case "illegalMemory": accessIllegalMemory(); break; + case "illegalMemoryInThread": Terminator.accessIllegalMemoryInThread(); break; + case "stackOverflow": Terminator.forceStackOverflow(); break; + case "divideByZero": Terminator.divideByZero(); break; + case "unhandledException": Terminator.throwUnhandledException(); break; + case "abort": Terminator.abort(); break; + case "raise": Terminator.raise(7); break; + case "gracefully": Terminator.exitGracefully(); break; + } + } + } + } + } + } +} diff --git a/examples/applicationmanager/application-features/apps/crash/icon.png b/examples/applicationmanager/application-features/apps/crash/icon.png Binary files differnew file mode 100644 index 00000000..c3e6f8d4 --- /dev/null +++ b/examples/applicationmanager/application-features/apps/crash/icon.png diff --git a/examples/applicationmanager/application-features/apps/crash/info.yaml b/examples/applicationmanager/application-features/apps/crash/info.yaml new file mode 100644 index 00000000..50bafe2a --- /dev/null +++ b/examples/applicationmanager/application-features/apps/crash/info.yaml @@ -0,0 +1,11 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'crash' +icon: 'icon.png' +code: 'crashapp.qml' +runtime: 'qml' +name: + en: 'Crash Simulation' +runtimeParameters: + importPaths: [ "." ] diff --git a/examples/applicationmanager/application-features/apps/twins/icon.png b/examples/applicationmanager/application-features/apps/twins/icon.png Binary files differnew file mode 100644 index 00000000..3a3cb0bb --- /dev/null +++ b/examples/applicationmanager/application-features/apps/twins/icon.png diff --git a/examples/applicationmanager/application-features/apps/twins/info.yaml b/examples/applicationmanager/application-features/apps/twins/info.yaml new file mode 100644 index 00000000..580445bf --- /dev/null +++ b/examples/applicationmanager/application-features/apps/twins/info.yaml @@ -0,0 +1,9 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'twins' +icon: 'icon.png' +code: 'twins.qml' +runtime: 'qml' +name: + en: 'Two Top-Level Windows' diff --git a/examples/applicationmanager/application-features/apps/twins/twins.qml b/examples/applicationmanager/application-features/apps/twins/twins.qml new file mode 100644 index 00000000..29416973 --- /dev/null +++ b/examples/applicationmanager/application-features/apps/twins/twins.qml @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** 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.11 +import QtApplicationManager.Application 2.0 + +QtObject { + property var win1: ApplicationManagerWindow { + color: "lightsteelblue" + + Rectangle { + width: 80; height: 80; radius: 40 + color: "orange" + + MouseArea { + anchors.fill: parent + drag.target: parent + } + } + } + + property var win2: ApplicationManagerWindow { + color: "transparent" + + Rectangle { + id: rect + anchors.fill: parent + color: "orange" + opacity: 0.4 + } + + ApplicationManagerWindow { + id: popup + + Rectangle { + anchors.fill: parent + border.width: 1 + color: "orangered" + } + + Text { + anchors.centerIn: parent + text: "Click to hide!" + } + + MouseArea { + anchors.fill: parent + onClicked: popup.visible = false; + } + + Component.onCompleted: setWindowProperty("type", "pop-up"); + } + } +} diff --git a/examples/applicationmanager/application-features/apps/widgets/icon.png b/examples/applicationmanager/application-features/apps/widgets/icon.png Binary files differnew file mode 100644 index 00000000..cfcd8fcb --- /dev/null +++ b/examples/applicationmanager/application-features/apps/widgets/icon.png diff --git a/examples/applicationmanager/application-features/apps/widgets/info.yaml b/examples/applicationmanager/application-features/apps/widgets/info.yaml new file mode 100644 index 00000000..9d9cfce5 --- /dev/null +++ b/examples/applicationmanager/application-features/apps/widgets/info.yaml @@ -0,0 +1,12 @@ +formatVersion: 1 +formatType: am-application +--- +id: 'widgets' +icon: 'icon.png' +code: 'widgets' +runtime: 'native' +runtimeParameters: + environmentVariables: + QT_WAYLAND_DISABLE_WINDOWDECORATION: "1" +name: + en: 'Native Widgets' diff --git a/examples/applicationmanager/application-features/client.qml b/examples/applicationmanager/application-features/client.qml new file mode 100644 index 00000000..b761a656 --- /dev/null +++ b/examples/applicationmanager/application-features/client.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** 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.11 + +Rectangle { + id: root + + width: 320 + height: 240 + color: "lightsteelblue" + + Rectangle { + anchors.centerIn: parent + width: 180; height: 180; radius: width/4 + color: "orange" + + RotationAnimation on rotation { + id: rotation + from: 0; to: 360; loops: Animation.Infinite; duration: 2000 + } + + MouseArea { + anchors.fill: parent + onClicked: rotation.paused = !rotation.paused + } + } +} diff --git a/examples/applicationmanager/application-features/doc/images/application-features.png b/examples/applicationmanager/application-features/doc/images/application-features.png Binary files differnew file mode 100644 index 00000000..6d28e91f --- /dev/null +++ b/examples/applicationmanager/application-features/doc/images/application-features.png diff --git a/examples/applicationmanager/application-features/doc/src/application-features.qdoc b/examples/applicationmanager/application-features/doc/src/application-features.qdoc new file mode 100644 index 00000000..43dc7c71 --- /dev/null +++ b/examples/applicationmanager/application-features/doc/src/application-features.qdoc @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** 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/application-features +\title Application Features Example +\image application-features.png +\brief Showcases client applications with various features, including a native application. +\ingroup applicationmanager-examples + +\section1 Introduction + +This example demonstrates some particular features that an application might implement, for +instance it shows how to implement a nested compositor and it is the only example with an +application that uses the "native" runtime. Most of the features are only supported properly in +multi-process mode (for details see the following section). + +\note This example focuses on the application (client) side. The System UI (compositor/server) is just a +modified version of the "Desktop System UI Example" (minidesk). For more information on how this +System UI is implemented, see \l{Desktop System UI Example}. + + +\section1 The Client Applications + +The following applications are included in this example: + +\section2 Nested Compositor +The nested compositor application shows how a Wayland compositor can be implemented inside an +application (Wayland client) window. The compositor is implemented in pure QML and is kept to a +minimum. In order to display Wayland clients inside this compositor, the WAYLAND_DISPLAY +environment variable needs to be set appropriately. Starting a client on the command line could be +done like this: +\badcode +WAYLAND_DISPLAY=qtam-wayland-nested qmlscene client.qml -platform wayland +\endcode +Note that this works only in multi-process mode, since the nested compositor needs a real window as +its root element. + +\section2 Crash Simulation and Recovery +The crash application provides various means to force a crash in the application, like a +segmentation fault. It utilizes a QML plugin implemented in C++, that provides the \c Terminator +QML type to trigger crashes. The application manager will print the cause of the crash and other +information like a backtrace. The System UI implements a basic form of crash recovery: it simply +restarts the application. Note that this works only in mulit-process mode. In single process mode a +crash will affect the entire (System UI) program. + +\section2 Two Top-Level Windows +This application shows how multiple top-level windows can be displayed by having a QtObject as the +application's root element. + +\section2 Native Widgets +The native widgets application is based on \l{QWidget}s. In contrast to the other applications +which are QML applications, this one uses the "native" runtime. Consequently, the application's +entry point isn't a main QML file, but an executable. It is probably the most basic application, +that still adheres to this particular System UI. It is just for illustrating the concept: the +System UI needs a \c type window property to differentiate between normal windows and popups. Note +that this works only in multi-process mode; naturally, application processes cannot be started in +single-process mode. +\endlist + +\section1 Code Structure +In contrast to other application manager examples, which are purely based on QML, this example +needs to be built necessarily. The code is structured in a way, that the resulting application +folders only contain the needed artifacts to run the application. Hence they could be packaged and +installed, as well (for instance to the \l{Desktop System UI Example}). + +*/ diff --git a/examples/applicationmanager/application-features/imports/imports.pro b/examples/applicationmanager/application-features/imports/imports.pro new file mode 100644 index 00000000..4f736dac --- /dev/null +++ b/examples/applicationmanager/application-features/imports/imports.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = terminator2 diff --git a/examples/applicationmanager/application-features/imports/terminator2/qmldir b/examples/applicationmanager/application-features/imports/terminator2/qmldir new file mode 100644 index 00000000..ac15a495 --- /dev/null +++ b/examples/applicationmanager/application-features/imports/terminator2/qmldir @@ -0,0 +1,2 @@ +module Terminator +plugin terminator2plugin diff --git a/examples/applicationmanager/application-features/imports/terminator2/qmlterminator2.cpp b/examples/applicationmanager/application-features/imports/terminator2/qmlterminator2.cpp new file mode 100644 index 00000000..ae03e600 --- /dev/null +++ b/examples/applicationmanager/application-features/imports/terminator2/qmlterminator2.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT-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 General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QQmlEngine> +#include <QJSEngine> + +#include "qmlterminator2.h" + +#include <signal.h> + + +static QObject *terminator_provider(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(scriptEngine) + return new Terminator(engine); +} + +void TerminatorPlugin::registerTypes(const char *uri) +{ + qmlRegisterSingletonType<Terminator>(uri, 2, 0, "Terminator", terminator_provider); +} + + +void Terminator::accessIllegalMemory() const +{ + *(int*)1 = 42; +} + +void Terminator::accessIllegalMemoryInThread() +{ + TerminatorThread *t = new TerminatorThread(this); + t->start(); +} + +void Terminator::forceStackOverflow() const +{ + static constexpr int len = 100000; + volatile char buf[len]; + buf[len-1] = 42; + if (buf[len-1] == 42) + forceStackOverflow(); +} + +void Terminator::divideByZero() const +{ + int d = 0; + volatile int x = 42 / d; + Q_UNUSED(x) +} + +void Terminator::abort() const +{ + ::abort(); +} + +void Terminator::raise(int sig) const +{ + ::raise(sig); +} + +void Terminator::throwUnhandledException() const +{ + throw 42; +} + +void Terminator::exitGracefully() const +{ + exit(5); +} + + +TerminatorThread::TerminatorThread(Terminator *parent) + : QThread(parent), m_terminator(parent) +{ +} + +void TerminatorThread::run() +{ + m_terminator->accessIllegalMemory(); +} diff --git a/examples/applicationmanager/application-features/imports/terminator2/qmlterminator2.h b/examples/applicationmanager/application-features/imports/terminator2/qmlterminator2.h new file mode 100644 index 00000000..d8fabbf9 --- /dev/null +++ b/examples/applicationmanager/application-features/imports/terminator2/qmlterminator2.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Luxoft Application Manager. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT-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 General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#pragma once + +#include <QQmlExtensionPlugin> +#include <QThread> + + +class TerminatorPlugin : public QQmlExtensionPlugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + +public: + void registerTypes(const char *uri) override; +}; + + +class Terminator : public QObject +{ + Q_OBJECT + +public: + Terminator(QObject *parent) : QObject(parent) {} + + Q_INVOKABLE void accessIllegalMemory() const; + Q_INVOKABLE void accessIllegalMemoryInThread(); + Q_INVOKABLE void forceStackOverflow() const; + Q_INVOKABLE void divideByZero() const; + Q_INVOKABLE void abort() const; + Q_INVOKABLE void raise(int sig) const; + Q_INVOKABLE void throwUnhandledException() const; + Q_INVOKABLE void exitGracefully() const; +}; + + +class TerminatorThread : public QThread +{ + Q_OBJECT + +public: + explicit TerminatorThread(Terminator *parent); + +private: + void run() override; + Terminator *m_terminator; +}; diff --git a/examples/applicationmanager/application-features/imports/terminator2/terminator2.pro b/examples/applicationmanager/application-features/imports/terminator2/terminator2.pro new file mode 100644 index 00000000..c10008d7 --- /dev/null +++ b/examples/applicationmanager/application-features/imports/terminator2/terminator2.pro @@ -0,0 +1,18 @@ +TEMPLATE = lib +CONFIG += plugin exceptions install_ok +QT += qml quick + +TARGET = $$qtLibraryTarget(terminator2plugin) + +HEADERS += qmlterminator2.h +SOURCES += qmlterminator2.cpp + +OTHER_FILES += qmldir + +DESTDIR = $$OUT_PWD/../../apps/crash/Terminator +target.path=$$DESTDIR +qmldir.files=$$PWD/qmldir +qmldir.path=$$DESTDIR + +INSTALLS += target +COPIES += qmldir diff --git a/examples/applicationmanager/application-features/native/native.pro b/examples/applicationmanager/application-features/native/native.pro new file mode 100644 index 00000000..df48bdc9 --- /dev/null +++ b/examples/applicationmanager/application-features/native/native.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +qtHaveModule(waylandclient) { + SUBDIRS = widgets +} diff --git a/examples/applicationmanager/application-features/native/widgets/main.cpp b/examples/applicationmanager/application-features/native/widgets/main.cpp new file mode 100644 index 00000000..f6a9b326 --- /dev/null +++ b/examples/applicationmanager/application-features/native/widgets/main.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Application Manager. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT-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 General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QPushButton> +#include <QDialog> +#include "private/waylandqtamclientextension_p.h" + +QT_USE_NAMESPACE_AM + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + WaylandQtAMClientExtension waylandExtension; + + QPushButton window("I'm a top-level window!\nClick to open/close a popup."); + QDialog *popup = new QDialog(&window); + (new QPushButton("I'm a popup!", popup))->resize(300, 100); + + window.setStyleSheet("QPushButton { background-color : lightgrey; font-size: 36px; }"); + popup->setStyleSheet("QPushButton { background-color : green; color : white; font-size: 24px; }"); + + QObject::connect(&window, &QPushButton::clicked, [&popup, &waylandExtension] () { + popup->setVisible(!popup->isVisible()); + waylandExtension.setWindowProperty(popup->windowHandle(), + "type", QVariant::fromValue(QStringLiteral("pop-up"))); + }); + + window.showNormal(); + + return app.exec(); +} diff --git a/examples/applicationmanager/application-features/native/widgets/widgets.pro b/examples/applicationmanager/application-features/native/widgets/widgets.pro new file mode 100644 index 00000000..f5ad0e66 --- /dev/null +++ b/examples/applicationmanager/application-features/native/widgets/widgets.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +CONFIG += install_ok +QT += widgets appman_launcher-private + +SOURCES = main.cpp + +DESTDIR = $$OUT_PWD/../../apps/widgets +target.path=$$DESTDIR +INSTALLS += target diff --git a/examples/applicationmanager/application-features/system-ui/grab.png b/examples/applicationmanager/application-features/system-ui/grab.png Binary files differnew file mode 100644 index 00000000..641c6960 --- /dev/null +++ b/examples/applicationmanager/application-features/system-ui/grab.png diff --git a/examples/applicationmanager/application-features/system-ui/main.qml b/examples/applicationmanager/application-features/system-ui/main.qml new file mode 100644 index 00000000..93af5d74 --- /dev/null +++ b/examples/applicationmanager/application-features/system-ui/main.qml @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2019 Luxoft Sweden AB +** 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.11 +import QtQuick.Window 2.11 +import QtApplicationManager.SystemUI 2.0 + +Window { + title: "Fancy Apps - QtApplicationManager Example" + width: 1280 + height: 800 + color: "whitesmoke" + + Text { + anchors.bottom: parent.bottom + text: (ApplicationManager.singleProcess ? "Single" : "Multi") + "-Process Mode" + } + + Column { + z: 9998 + Repeater { + model: ApplicationManager + + Image { + source: icon + opacity: isRunning ? 0.3 : 1.0 + + Rectangle { + x: 96; y: 38 + width: appid.width; height: appid.height + color: "whitesmoke" + visible: imouse.containsMouse + + Text { + id: appid + text: application.name("en") + } + } + + MouseArea { + id: imouse + anchors.fill: parent + hoverEnabled: true + onClicked: isRunning ? application.stop() : application.start(); + } + } + } + } + + Repeater { + model: ListModel { id: topLevelWindowsModel } + + delegate: Rectangle { + id: chrome + width: draggrab.x + 10; height: draggrab.y + 10 + color: "transparent" + border.width: 3 + border.color: "grey" + z: model.index + + Image { + id: draggrab + x: 710; y: 530 + source: "grab.png" + visible: dragarea.containsMouse + } + + MouseArea { + id: dragarea + anchors.fill: draggrab + hoverEnabled: true + drag.target: draggrab + drag.minimumX: 230 + drag.minimumY: 170 + } + + Rectangle { + height: 25 + width: parent.width + color: "grey" + + Text { + anchors.horizontalCenter: parent.horizontalCenter + text: model.window.application ? model.window.application.name("en") : 'External Application' + } + + MouseArea { + anchors.fill: parent + drag.target: chrome + onPressed: topLevelWindowsModel.move(model.index, topLevelWindowsModel.count - 1, 1); + } + + Rectangle { + width: 25; height: 25 + color: "chocolate" + + MouseArea { + anchors.fill: parent + onClicked: model.window.close(); + } + } + } + + WindowItem { + anchors.fill: parent + anchors.margins: 3 + anchors.topMargin: 25 + window: model.window + + Connections { + target: window + onContentStateChanged: { + if (window.contentState === WindowObject.NoSurface) + topLevelWindowsModel.remove(model.index, 1); + } + } + } + + Component.onCompleted: { + x = 200 + model.index * 50; + y = 20 + model.index * 30; + } + } + } + + Repeater { + model: ListModel { id: popupsModel } + delegate: WindowItem { + z: 9999 + model.index + width: 300; height: 100 + anchors.centerIn: parent + window: model.window + Connections { + target: model.window + onContentStateChanged: { + if (model.window.contentState === WindowObject.NoSurface) + popupsModel.remove(model.index, 1); + } + } + } + } + + Connections { + target: WindowManager + onWindowAdded: { + var model = window.windowProperty("type") === "pop-up" ? popupsModel : topLevelWindowsModel; + model.append({"window":window}); + } + } + + Connections { + target: ApplicationManager + onApplicationRunStateChanged: { + if (runState === Am.NotRunning + && ApplicationManager.application(id).lastExitStatus === Am.CrashExit) { + ApplicationManager.startApplication(id); + } + } + } +} diff --git a/examples/applicationmanager/application-features/ui.pro b/examples/applicationmanager/application-features/ui.pro new file mode 100644 index 00000000..7d9e85e6 --- /dev/null +++ b/examples/applicationmanager/application-features/ui.pro @@ -0,0 +1,36 @@ +TEMPLATE = app +CONFIG += am-systemui + +OTHER_FILES += \ + am-config.yaml \ + application-features.qmlproject \ + doc/src/*.qdoc \ + doc/images/*.png \ + system-ui/*.qml \ + system-ui/*.png \ + apps/compositor/*.yaml \ + apps/compositor/*.qml \ + apps/compositor/*.png \ + apps/crash/*.yaml \ + apps/crash/*.qml \ + apps/crash/*.png \ + apps/twins/*.yaml \ + apps/twins/*.qml \ + apps/twins/*.png \ + apps/widgets/*.yaml \ + apps/widgets/*.png + +target.path = $$[QT_INSTALL_EXAMPLES]/applicationmanager/application-features +INSTALLS += target + +AM_COPY_DIRECTORIES += apps system-ui +AM_COPY_FILES += am-config.yaml + +prefix_build:tpath = $$target.path +else:tpath = $$OUT_PWD + +AM_DEFAULT_ARGS = -c $$tpath/am-config.yaml + +example_sources.path = $$target.path +example_sources.files = $$AM_COPY_FILES $$AM_COPY_DIRECTORIES doc +INSTALLS += example_sources diff --git a/examples/applicationmanager/applicationmanager.pro b/examples/applicationmanager/applicationmanager.pro index 49cc2c82..6ea4e083 100644 --- a/examples/applicationmanager/applicationmanager.pro +++ b/examples/applicationmanager/applicationmanager.pro @@ -9,6 +9,7 @@ SUBDIRS = \ frame-timer \ hello-world \ minidesk \ + application-features \ multi-views \ process-status \ startup-plugin \ |