diff options
author | Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp> | 2024-09-27 01:31:31 +0900 |
---|---|---|
committer | Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp> | 2024-09-29 00:18:05 +0900 |
commit | 88fb60ad9d0c673f868d907ca451462ec16c9d7f (patch) | |
tree | 1c3df54cd7b518868ce2f7913ae81900e7498d6c | |
parent | 6a0b126643d36ff28d0fb9638498ca56ff3d43e7 (diff) |
Rework momiscreen to migrate to Qt6
AGL momi IVI used weston with wayland-ivi-extention.
At the scarthgap, it has issue for the touch event handling.
New momiscreen changes role from homescreen bar to
homescreen that is including compositor.
Bug-AGL: SPEC-5162
Change-Id: I9cc92c508de2b49840690af1477fd52a37de7a86
Signed-off-by: Naoto Yamaguchi <naoto.yamaguchi@aisin.co.jp>
-rw-r--r-- | CMakeLists.txt | 51 | ||||
-rw-r--r-- | DateBox.qml | 5 | ||||
-rw-r--r-- | MomiBar.qml | 28 | ||||
-rw-r--r--[-rwxr-xr-x] | README.md | 4 | ||||
-rw-r--r-- | exec.hpp | 100 | ||||
-rw-r--r-- | main.cpp | 24 | ||||
-rw-r--r-- | main.qml | 333 | ||||
-rw-r--r-- | momiscreen.pro | 38 | ||||
-rw-r--r-- | momiscreen.qml | 207 | ||||
-rw-r--r-- | qml.qrc | 14 |
10 files changed, 426 insertions, 378 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b8b4082 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,51 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(momiscreen LANGUAGES CXX) + +set(CMAKE_AUTOMOC ON) + +find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml) + +qt_add_executable(momiscreen + main.cpp +) + +set_target_properties(momiscreen PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +target_link_libraries(momiscreen PUBLIC + Qt::Core + Qt::Gui + Qt::Qml +) + +# Resources: +set(momiscreen_resource_files + "main.qml" + "MomiBar.qml" + "DateBox.qml" + "images/12_Footer.png" + "images/14_Logo.png" + "images/15_Maps.png" + "images/16_Multimedia.png" + "images/17_Dashboard.png" + "images/18_Setting.png" + "images/19_Shadow.png" +) + +qt6_add_resources(momiscreen "momiscreen" + PREFIX + "/" + FILES + ${momiscreen_resource_files} +) + +install(TARGETS momiscreen + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + BUNDLE DESTINATION . + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) diff --git a/DateBox.qml b/DateBox.qml index 9b7a48f..9b70a1f 100644 --- a/DateBox.qml +++ b/DateBox.qml @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0+ -// Copyright (C) 2021 AISIN CORPORATION +// Copyright (C) 2024 Automotive Grade Linux -import QtQuick 2.2 +import QtQuick Item { id: dateBox @@ -28,6 +28,7 @@ Item { id: dateBoxText visible: true font.pixelSize: pixSize + font.bold: true color: timeColor horizontalAlignment: Text.AlignRight anchors.horizontalCenter: parent.horizontalCenter diff --git a/MomiBar.qml b/MomiBar.qml new file mode 100644 index 0000000..d67ceea --- /dev/null +++ b/MomiBar.qml @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-3.0+ +// Copyright (C) 2024 Automotive Grade Linux +import QtQuick +import QtQuick.Effects + +Item { + id: momiBar + visible: true + + Image { + id: logoAGL + width: 200 + height: 125 + fillMode: Image.PreserveAspectFit + source: "images/14_Logo.png" + } + MultiEffect { + source: logoAGL + anchors.fill: logoAGL + brightness: 0.4 + saturation: 0.2 + shadowEnabled: true + shadowOpacity: 1.0 + shadowBlur: 0.5 + shadowHorizontalOffset: 4.0 + shadowVerticalOffset: 4.0 + } +} diff --git a/README.md b/README.md index f2d26f4..f948abd 100755..100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # Momiscreen ## AGL sample homescreen application for container integration +This source code reused Qt6 ivi compositor example. + +Those example source code was changed license to GPLv3.0 that is required by Qt license policy in case of using open source licensed version of qt6. + ### Overview Momiscreen is AGL sample homescreen application for container integration. diff --git a/exec.hpp b/exec.hpp deleted file mode 100644 index e26d482..0000000 --- a/exec.hpp +++ /dev/null @@ -1,100 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0+ -// Copyright (C) 2021 AISIN CORPORATION - -#ifndef EXEC_HPP -#define EXEC_HPP - -#include <QProcess> -#include <QVariant> - -class AppExec : public QProcess { - Q_OBJECT - -public: - AppExec(QObject *parent = 0) : QProcess(parent) { } - - Q_INVOKABLE void start(const QString &program, const QVariantList &arguments) { - QStringList args; - - // convert QVariantList from QML to QStringList for QProcess - - for (int i = 0; i < arguments.length(); i++) - args << arguments[i].toString(); - - QProcess::start(program, args); - } - - Q_INVOKABLE void runMominavi() { - QString program("systemctl"); - QStringList mominavi = {"start","mominavi"}; - QStringList momiplay = {"stop","momiplay"}; - QStringList momiradio = {"stop","momiradio"}; - QStringList momisetting = {"stop","momisetting"}; - - QProcess::start(program, mominavi); - QProcess::waitForFinished(); - QProcess::start(program, momiplay); - QProcess::waitForFinished(); - QProcess::start(program, momiradio); - QProcess::waitForFinished(); - QProcess::start(program, momisetting); - QProcess::waitForFinished(); - } - - Q_INVOKABLE void runMomiplay() { - QString program("systemctl"); - QStringList mominavi = {"stop","mominavi"}; - QStringList momiplay = {"start","momiplay"}; - QStringList momiradio = {"stop","momiradio"}; - QStringList momisetting = {"stop","momisetting"}; - - QProcess::start(program, mominavi); - QProcess::waitForFinished(); - QProcess::start(program, momiplay); - QProcess::waitForFinished(); - QProcess::start(program, momiradio); - QProcess::waitForFinished(); - QProcess::start(program, momisetting); - QProcess::waitForFinished(); - } - - Q_INVOKABLE void runMomiradio() { - QString program("systemctl"); - QStringList mominavi = {"stop","mominavi"}; - QStringList momiplay = {"stop","momiplay"}; - QStringList momiradio = {"start","momiradio"}; - QStringList momisetting = {"stop","momisetting"}; - - QProcess::start(program, mominavi); - QProcess::waitForFinished(); - QProcess::start(program, momiplay); - QProcess::waitForFinished(); - QProcess::start(program, momiradio); - QProcess::waitForFinished(); - QProcess::start(program, momisetting); - QProcess::waitForFinished(); - } - - Q_INVOKABLE void runMomisetting() { - QString program("systemctl"); - QStringList mominavi = {"stop","mominavi"}; - QStringList momiplay = {"stop","momiplay"}; - QStringList momiradio = {"stop","momiradio"}; - QStringList momisetting = {"start","momisetting"}; - - QProcess::start(program, mominavi); - QProcess::waitForFinished(); - QProcess::start(program, momiplay); - QProcess::waitForFinished(); - QProcess::start(program, momiradio); - QProcess::waitForFinished(); - QProcess::start(program, momisetting); - QProcess::waitForFinished(); - } - - - Q_INVOKABLE QByteArray readAll() { - return QProcess::readAll(); - } -}; -#endif // EXEC_HPP @@ -1,29 +1,19 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2024 Automotive Grade Linux // SPDX-License-Identifier: GPL-3.0+ -// Copyright (C) 2021 AISIN CORPORATION -#include <QGuiApplication> -#include <QQmlApplicationEngine> -#include <QtQml> -#include "exec.hpp" +#include <QtCore/QUrl> +#include <QtCore/QDebug> +#include <QtGui/QGuiApplication> +#include <QtQml/QQmlApplicationEngine> int main(int argc, char *argv[]) { - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication app(argc, argv); - qmlRegisterType<AppExec>("AppExec", 1, 0, "AppExec"); - - QQmlApplicationEngine engine; - const QUrl url(QStringLiteral("qrc:/momiscreen.qml")); - QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, - &app, [url](QObject *obj, const QUrl &objUrl) { - if (!obj && url == objUrl) - QCoreApplication::exit(-1); - }, Qt::QueuedConnection); - engine.load(url); + QQmlApplicationEngine appEngine(QUrl("qrc:///main.qml")); return app.exec(); } diff --git a/main.qml b/main.qml new file mode 100644 index 0000000..dde3849 --- /dev/null +++ b/main.qml @@ -0,0 +1,333 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2024 Automotive Grade Linux +// SPDX-License-Identifier: GPL-3.0+ + +import QtQuick +import QtWayland.Compositor +import QtWayland.Compositor.IviApplication +import QtWayland.Compositor.XdgShell +import QtQuick.Window + +WaylandCompositor { + //! [wayland output] + WaylandOutput { + sizeFollowsWindow: true + window: Window { + id: mainScreenWindow + width: 1920 + height: 1080 + color: "#004f00" + //flags: Qt.FramelessWindowHint + visible: true + Image { + id: backgroundAGL + width: parent.width + height: parent.height + z: 0 + visible: true + fillMode: Image.Pad + source: "images/14_Logo.png" + + DateBox { + id: timedate + width: 200 + height: 50 + pixSize: 40 + x: 10 + y: 10 + } + } + + function showAppList() { + appLayer2010.showAppTile(); + appLayer2011.showAppTile(); + appLayer2012.showAppTile(); + appLayer2013.showAppTile(); + } + function hideAppList() { + momibarMouseArea.onList = false; + appLayer2010.hideApp(); + appLayer2011.hideApp(); + appLayer2012.hideApp(); + appLayer2013.hideApp(); + } + + Rectangle { + id: appLayer2010 + z: 10 + visible: false + color: "#000000" + border.color: "#003000" + Image { + id: backgroundAppLayer2010 + width: parent.width + height: parent.height + visible: true + fillMode: Image.Pad + source: "images/15_Maps.png" + } + + MouseArea { + id: appLayer2010MouseArea + z: 20 + enabled: false + anchors.fill: parent + acceptedButtons: Qt.LeftButton + + onClicked : { + mainScreenWindow.hideAppList(); + appLayer2010.showApp(); + } + } + + function showAppTile() { + width = (parent.width / 3); + height = (parent.height / 3); + x = (parent.width / 8) * 1; + y = (parent.height / 8) * 1; + border.width = 10; + visible = true; + appLayer2010MouseArea.enabled = true; + } + + function showApp() { + width = parent.width; + height = parent.height; + x = 0; + y = 0; + border.width = 0; + visible = true; + appLayer2010MouseArea.enabled = false; + } + + function hideApp() { + visible = false; + appLayer2010MouseArea.enabled = false; + } + } + Rectangle { + id: appLayer2011 + width: parent.width + height: parent.height + z: 10 + visible: false + color: "#000000" + border.color: "#003000" + Image { + id: backgroundAppLayer2011 + width: parent.width + height: parent.height + visible: true + fillMode: Image.Pad + source: "images/16_Multimedia.png" + } + + MouseArea { + id: appLayer2011MouseArea + z: 20 + enabled: false + anchors.fill: parent + acceptedButtons: Qt.LeftButton + + onClicked : { + mainScreenWindow.hideAppList(); + appLayer2011.showApp(); + } + } + + function showAppTile() { + width = (parent.width / 3); + height = (parent.height / 3); + x = (parent.width / 8) * 4; + y = (parent.height / 8) * 1; + border.width = 10; + visible = true; + appLayer2011MouseArea.enabled = true; + } + + function showApp() { + width = parent.width; + height = parent.height; + x = 0; + y = 0; + border.width = 0; + visible = true; + appLayer2011MouseArea.enabled = false; + } + + function hideApp() { + visible = false; + appLayer2011MouseArea.enabled = false; + } + } + Rectangle { + id: appLayer2012 + z: 10 + visible: false + color: "#000000" + border.color: "#003000" + Image { + id: backgroundAppLayer2012 + width: parent.width + height: parent.height + visible: true + fillMode: Image.Pad + source: "images/17_Dashboard.png" + } + + MouseArea { + id: appLayer2012MouseArea + z: 20 + enabled: false + anchors.fill: parent + acceptedButtons: Qt.LeftButton + + onClicked : { + mainScreenWindow.hideAppList(); + appLayer2012.showApp(); + } + } + + function showAppTile() { + width = (parent.width / 3); + height = (parent.height / 3); + x = (parent.width / 8) * 1; + y = (parent.height / 8) * 4; + border.width = 10; + visible = true; + appLayer2012MouseArea.enabled = true; + } + + function showApp() { + width = parent.width; + height = parent.height; + x = 0; + y = 0; + border.width = 0; + visible = true; + appLayer2012MouseArea.enabled = false; + } + + function hideApp() { + visible = false; + appLayer2012MouseArea.enabled = false; + } + } + Rectangle { + id: appLayer2013 + z: 10 + visible: false + color: "#000000" + border.color: "#003000" + Image { + id: backgroundAppLayer2013 + width: parent.width + height: parent.height + visible: true + fillMode: Image.Pad + source: "images/18_Setting.png" + } + + MouseArea { + id: appLayer2013MouseArea + z: 20 + enabled: false + anchors.fill: parent + acceptedButtons: Qt.LeftButton + + onClicked : { + mainScreenWindow.hideAppList(); + appLayer2013.showApp(); + } + } + + function showAppTile() { + width = (parent.width / 3); + height = (parent.height / 3); + x = (parent.width / 8) * 4; + y = (parent.height / 8) * 4; + border.width = 10; + visible = true; + appLayer2013MouseArea.enabled = true; + } + + function showApp() { + width = parent.width; + height = parent.height; + x = 0; + y = 0; + border.width = 0; + visible = true; + appLayer2013MouseArea.enabled = false; + } + + function hideApp() { + visible = false; + appLayer2013MouseArea.enabled = false; + } + } + MomiBar { + id: momibar + width: 200 + height: 125 + x: 1920 - width + y: 1080 - height + z: 100 + visible: true + focus: true + + MouseArea { + id: momibarMouseArea + property bool onList: false + anchors.fill: parent + acceptedButtons: Qt.LeftButton + + onClicked : { + if (onList === false) { + mainScreenWindow.showAppList(); + onList = true; + } else { + mainScreenWindow.hideAppList(); + onList = false; + } + } + } + } + } + } + + Component { + id: chromeComponent + ShellSurfaceItem { + anchors.fill: parent + onSurfaceDestroyed: destroy() + } + } + + IviApplication { + onIviSurfaceCreated: (iviSurface) => { + var surfaceArea; + var validValue = true; + + if (iviSurface.iviId === 2010) { + surfaceArea = appLayer2010; + } else if (iviSurface.iviId === 2011) { + surfaceArea = appLayer2011; + } else if (iviSurface.iviId === 2012) { + surfaceArea = appLayer2012; + } else if (iviSurface.iviId === 2013) { + surfaceArea = appLayer2013; + } else { + validValue = false; + } + + if (validValue === true) { + var item = chromeComponent.createObject(surfaceArea, + { + "shellSurface": iviSurface, + z: 10 + } ); + } + } + } +} diff --git a/momiscreen.pro b/momiscreen.pro deleted file mode 100644 index 60bd580..0000000 --- a/momiscreen.pro +++ /dev/null @@ -1,38 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0+ -# Copyright (C) 2021 AISIN CORPORATION - -QT += quick - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Refer to the documentation for the -# deprecated API to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp - -RESOURCES += qml.qrc - -# Additional import path used to resolve QML modules in Qt Creator's code model -QML_IMPORT_PATH = - -# Additional import path used to resolve QML modules just for Qt Quick Designer -QML_DESIGNER_IMPORT_PATH = - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /usr/bin -!isEmpty(target.path): INSTALLS += target - -DISTFILES += - -HEADERS += \ - exec.hpp diff --git a/momiscreen.qml b/momiscreen.qml deleted file mode 100644 index bf58b67..0000000 --- a/momiscreen.qml +++ /dev/null @@ -1,207 +0,0 @@ -// SPDX-License-Identifier: GPL-3.0+ -// Copyright (C) 2021 AISIN CORPORATION -import QtQuick 2.12 -import QtQuick.Window 2.12 -import QtQuick.Controls 1.5 -import QtQuick.Controls.Styles 1.4 -import AppExec 1.0 - - -ApplicationWindow { - id: momiScreen - visible: true - width: 1920 - height: 93 - flags: Qt.FramelessWindowHint - title: qsTr("momiscreen") - color: "transparent" - - AppExec { - id: exec - } - - Image { - id: homeScreen_footer_image - y: 70 - width: 1920 - height: 93 - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.bottom: parent.bottom - anchors.bottomMargin: 0 - opacity: 1 - source: "images/12_Footer.png" - - Item { - id: homeScreenMap - x:450 - y: 0 - width: parent.height - height: width - anchors.verticalCenter: parent.verticalCenter - anchors.bottomMargin: 5 - - Button { - id: map_sw - x: 0 - y: 0 - width: parent.height - height: width - opacity: 0 - - function homescreen_map_sw() { - exec.runMominavi() - } - onClicked: { homescreen_map_sw() } - } - - Image { - id: map_sw_image - x: 4 - y: 4 - width: 62 - height: 54 - anchors.bottomMargin: 10 - anchors.bottom: parent.bottom - opacity: 1 - source: "images/15_Maps.png" - } - - } - - Item { - id: homeScreenMedia - x: 800 - y: 0 - width: parent.height - height: width - anchors.bottomMargin: 5 - anchors.verticalCenterOffset: 0 - anchors.verticalCenter: parent.verticalCenter - - Button { - id: media_sw - x: 0 - y: 0 - width: parent.height - height: width - opacity: 0 - visible: true - function homescreen_media_sw() { - exec.runMomiplay() - } - onClicked: { homescreen_media_sw() } - } - - Image { - id: media_image - x: 4 - y: 4 - width: 46 - height: 51 - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - opacity: 1 - source: "images/16_Multimedia.png" - } - } - - Item { - id: homeScreenDashBoard - x: 1150 - y: 0 - width: parent.height - height: width - anchors.bottomMargin: 5 - anchors.verticalCenter: parent.verticalCenter - - Button { - id: dashBoard_sw - x: 0 - y: 0 - width: parent.height - height: width - opacity: 0 - visible: true - - function homescreen_dash_sw() { - //exec.runMomiradio() - } - onClicked: { homescreen_dash_sw() } - } - - Image { - id: dashBoard_image - x: 4 - y: 4 - width: 74 - height: 37 - anchors.bottom: parent.bottom - anchors.bottomMargin: 16 - opacity: 1 - source: "images/17_Dashboard.png" - } - } - - Item { - id: homeScreenSetting - x: 1500 - y: 0 - width: parent.height - height: width - anchors.bottomMargin: 5 - anchors.verticalCenter: parent.verticalCenter - - Button { - id: setting_sw - x: 0 - y: 0 - width: parent.height - height: width - opacity: 0 - visible: true - function homescreen_setting_sw() { - exec.runMomisetting() - } - onClicked: { homescreen_setting_sw() } - } - - Image { - id: setting_image - x: 4 - y: 4 - width: 56 - height: 55 - anchors.bottom: parent.bottom - anchors.bottomMargin: 10 - opacity: 1 - source: "images/18_Setting.png" - } - } - - Item { - x: 38 - y: 0 - width: 200 - height: parent.height - - DateBox { - id: timedate - width: 200 - height: 50 - pixSize: 40 - } - } - - Image { - id: logo - x: 1769 - y: -28 - width: 150 - height: width - fillMode: Image.PreserveAspectFit - source: "images/14_Logo.png" - } - - } -} diff --git a/qml.qrc b/qml.qrc deleted file mode 100644 index 054378d..0000000 --- a/qml.qrc +++ /dev/null @@ -1,14 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>images/11_Header.png</file> - <file>images/12_Footer.png</file> - <file>images/14_Logo.png</file> - <file>images/15_Maps.png</file> - <file>images/16_Multimedia.png</file> - <file>images/17_Dashboard.png</file> - <file>images/18_Setting.png</file> - <file>images/19_Shadow.png</file> - <file>momiscreen.qml</file> - <file>DateBox.qml</file> - </qresource> -</RCC> |