diff options
author | Scott Murray <scott.murray@konsulko.com> | 2022-09-10 12:59:02 -0400 |
---|---|---|
committer | Jan-Simon Moeller <jsmoeller@linuxfoundation.org> | 2022-09-16 14:19:01 +0000 |
commit | 20f629dd6d8628611d950073c4f7a0446c40365a (patch) | |
tree | f5918ebce7ec2cbcaad8588290ae55e7c3fea3ae /homescreen/src/main.cpp | |
parent | d1347bf236f84908fea96ba929e0e8376c2b1d78 (diff) |
Rework to use launcher wrapper from libqtappfw
Changes:
- Switch to using the new app launcher API wrapper from libqtappfw
in order to migrate to the new gRPC based API implementation.
- The appStarted and appTerminated methods in HomescreenHandler have
been renamed to activateApp and deactivateApp, respectively, to
better reflect what they do. A new processAppStatusEvent method
had been added that calls them as appropriate based on the event
from the AppLauncherClient status update signal.
- The copyright headers in the source files have been tweaked to
remove the Apache license boilerplate in favour of a SPDX license
tag.
- The code in main.cpp that was not formatted with Linux-style has
been reformatted to match the rest of the file.
Bug-AGL: SPEC-4559
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I236cb6a412945a6df7d35652c55f664264964f9c
Diffstat (limited to 'homescreen/src/main.cpp')
-rw-r--r-- | homescreen/src/main.cpp | 144 |
1 files changed, 67 insertions, 77 deletions
diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index e9a5817..2c2f7c0 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -1,18 +1,8 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH * Copyright (c) 2017, 2018 TOYOTA MOTOR CORPORATION - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright (c) 2022 Konsulko Group */ #include <QGuiApplication> @@ -69,7 +59,7 @@ agl_shell_desktop_state_app(void *data, HomescreenHandler *homescreenHandler = static_cast<HomescreenHandler *>(data); if (homescreenHandler && state == AGL_SHELL_DESKTOP_APP_STATE_DESTROYED) - homescreenHandler->appTerminated(app_id); + homescreenHandler->deactivateApp(app_id); } static const struct agl_shell_desktop_listener shell_desktop_listener = { @@ -252,68 +242,68 @@ load_agl_shell_app(QPlatformNativeInterface *native, int main(int argc, char *argv[]) { - setenv("QT_QPA_PLATFORM", "wayland", 1); - setenv("QT_QUICK_CONTROLS_STYLE", "AGL", 1); - QGuiApplication a(argc, argv); - const char *screen_name; - bool is_demo_val = false; - struct shell_data shell_data = { nullptr, nullptr }; - - QPlatformNativeInterface *native = qApp->platformNativeInterface(); - screen_name = getenv("HOMESCREEN_START_SCREEN"); - - const char *is_demo = getenv("HOMESCREEN_DEMO_CI"); - if (is_demo && strcmp(is_demo, "1") == 0) - is_demo_val = true; - - QCoreApplication::setOrganizationDomain("LinuxFoundation"); - QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); - QCoreApplication::setApplicationName("HomeScreen"); - QCoreApplication::setApplicationVersion("0.7.0"); - /* we need to have an app_id */ - a.setDesktopFileName("homescreen"); - - register_agl_shell(native, &shell_data); - if (!shell_data.shell) { - fprintf(stderr, "agl_shell extension is not advertised. " - "Are you sure that agl-compositor is running?\n"); - exit(EXIT_FAILURE); - } - if (!shell_data.shell_desktop) { - fprintf(stderr, "agl_shell_desktop extension is not advertised. " - "Are you sure that agl-compositor is running?\n"); - exit(EXIT_FAILURE); - } - - std::shared_ptr<struct agl_shell> agl_shell{shell_data.shell, agl_shell_destroy}; - Shell *aglShell = new Shell(agl_shell, &a); - - // import C++ class to QML - qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel"); - qmlRegisterType<MasterVolume>("MasterVolume", 1, 0, "MasterVolume"); - - ApplicationLauncher *launcher = new ApplicationLauncher(); - launcher->setCurrent(QStringLiteral("launcher")); - HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell, launcher); - homescreenHandler->init(); - - agl_shell_desktop_add_listener(shell_data.shell_desktop, &shell_desktop_listener, homescreenHandler); - - QQmlApplicationEngine engine; - QQmlContext *context = engine.rootContext(); - - context->setContextProperty("homescreenHandler", homescreenHandler); - context->setContextProperty("launcher", launcher); - context->setContextProperty("weather", new Weather()); - context->setContextProperty("bluetooth", new Bluetooth(false, context)); - - // we add it here even if we don't use it - context->setContextProperty("shell", aglShell); - - /* instead of loading main.qml we load one-by-one each of the QMLs, - * divided now between several surfaces: panels, background. - */ - load_agl_shell_app(native, &engine, shell_data.shell, screen_name, is_demo_val); - - return a.exec(); + setenv("QT_QPA_PLATFORM", "wayland", 1); + setenv("QT_QUICK_CONTROLS_STYLE", "AGL", 1); + + QGuiApplication app(argc, argv); + const char *screen_name; + bool is_demo_val = false; + struct shell_data shell_data = { nullptr, nullptr }; + + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + screen_name = getenv("HOMESCREEN_START_SCREEN"); + + const char *is_demo = getenv("HOMESCREEN_DEMO_CI"); + if (is_demo && strcmp(is_demo, "1") == 0) + is_demo_val = true; + + QCoreApplication::setOrganizationDomain("LinuxFoundation"); + QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); + QCoreApplication::setApplicationName("HomeScreen"); + QCoreApplication::setApplicationVersion("0.7.0"); + + // we need to have an app_id + app.setDesktopFileName("homescreen"); + + register_agl_shell(native, &shell_data); + if (!shell_data.shell) { + fprintf(stderr, "agl_shell extension is not advertised. " + "Are you sure that agl-compositor is running?\n"); + exit(EXIT_FAILURE); + } + if (!shell_data.shell_desktop) { + fprintf(stderr, "agl_shell_desktop extension is not advertised. " + "Are you sure that agl-compositor is running?\n"); + exit(EXIT_FAILURE); + } + + std::shared_ptr<struct agl_shell> agl_shell{shell_data.shell, agl_shell_destroy}; + Shell *aglShell = new Shell(agl_shell, &app); + + // Import C++ class to QML + qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel"); + qmlRegisterType<MasterVolume>("MasterVolume", 1, 0, "MasterVolume"); + + ApplicationLauncher *launcher = new ApplicationLauncher(); + launcher->setCurrent(QStringLiteral("launcher")); + HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell, launcher); + + agl_shell_desktop_add_listener(shell_data.shell_desktop, &shell_desktop_listener, homescreenHandler); + + QQmlApplicationEngine engine; + QQmlContext *context = engine.rootContext(); + + context->setContextProperty("homescreenHandler", homescreenHandler); + context->setContextProperty("launcher", launcher); + context->setContextProperty("weather", new Weather()); + context->setContextProperty("bluetooth", new Bluetooth(false, context)); + + // We add it here even if we don't use it + context->setContextProperty("shell", aglShell); + + // Instead of loading main.qml we load one-by-one each of the QMLs, + // divided now between several surfaces: panels, background. + load_agl_shell_app(native, &engine, shell_data.shell, screen_name, is_demo_val); + + return app.exec(); } |