From: wang_zhiqiang Date: Wed, 13 Feb 2019 10:10:20 +0000 (+0800) Subject: Add onscreenapp X-Git-Tag: halibut_7.99.1~1 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?p=apps%2Fonscreenapp.git;a=commitdiff_plain;h=aee1b69e8e207081a3d8b2670980671a9fbc78b8 Add onscreenapp Onscreenapp is a qt application for showing onscreens. Applications can show/hide onscreen by calling homescreen-service's showWindow/hideWindow verb. Applications also can customize onscreen's title,type, display contents and buttons. Some images about onscreen pattern had uploaded in JIRA SPEC-1967. Bug-AGL: SPEC-1967 Change-Id: I421193f7d089584a26db629be27414d050a74337 Signed-off-by: wang_zhiqiang --- diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..31c692a --- /dev/null +++ b/LICENSE @@ -0,0 +1,54 @@ +Apache License + +Version 2.0, January 2004 + +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + You must give any other recipients of the Work or Derivative Works a copy of this License; and + You must cause any modified files to carry prominent notices stating that You changed the files; and + You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + + You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/app/Onscreen.qml b/app/Onscreen.qml new file mode 100644 index 0000000..cfad090 --- /dev/null +++ b/app/Onscreen.qml @@ -0,0 +1,156 @@ +import QtQuick 2.0 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 + +Rectangle { + id: mainform + height: 300 + width: 1000 + radius:2 + + gradient: Gradient { + GradientStop { position: 0.0; color: "#12262E" } + GradientStop { position: 1.0; color: "#18899B" } + } + + ColumnLayout { + anchors { + topMargin: 10; bottomMargin:10 + leftMargin: 20; rightMargin: 20 + fill: parent + } + spacing: 2 + + ColumnLayout { + id: title_part + anchors { + top: parent.top + left: parent.left + topMargin: 10 + } + + Label { + id: title + text: dsp_title + color: "white" + font.pixelSize: 32 + font.bold: true + maximumLineCount: 1 + wrapMode: Text.Wrap + elide: Text.ElideRight + horizontalAlignment: Label.AlignHCenter + verticalAlignment: Label.AlignVCenter + Layout.preferredWidth: 960 + Layout.preferredHeight: 40 + } + + Image { + source: '../images/DividingLine.svg' + anchors.left: title.left + anchors.top: title.bottom + } + } + + RowLayout { + id: contents_part + anchors { + left: parent.left; leftMargin: 20 + right: parent.right; rightMargin: 20 + } + Layout.preferredWidth: 920 + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter + spacing: 10 + Image { + id: dsp_mark + source: dsp_icon + Layout.maximumHeight: 120 + Layout.maximumWidth: 120 + } + Label { + text: dsp_contents + color: "white" + font.pixelSize: 24 + wrapMode: Text.Wrap + maximumLineCount: btn_area.visible ? 4 : 5 + elide: Text.ElideRight + horizontalAlignment: Label.AlignLeft + verticalAlignment: Label.AlignVCenter + Layout.preferredWidth: 780 + Layout.preferredHeight: 160 + } + } + + RowLayout { + id: btn_area + spacing: 60 + visible: btnNum > 0 ? true : false + anchors { + horizontalCenter: parent.horizontalCenter + } + Layout.preferredWidth: parent.width*0.75 + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + + Button { + id: btn1 + visible: btn1Name == "" ? false : true + text: btn1Name + onReleased: { + btn1.highlighted = false + eventHandler.onScreenReply(btn1.text) + } + onPressed: { + btn1.highlighted = true + } + onCanceled: { + btn1.highlighted = false + } + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + } + + Button { + id: btn2 + visible: btn2Name == "" ? false : true + text: btn2Name + onReleased: { + btn2.highlighted = false + eventHandler.onScreenReply(btn2.text) + } + onPressed: { + btn2.highlighted = true + } + onCanceled: { + btn2.highlighted = false + } + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + } + + Button { + id: btn3 + visible: btn3Name == "" ? false : true + text: btn3Name + onReleased: { + btn3.highlighted = false + eventHandler.onScreenReply(btn3.text) + } + onPressed: { + btn3.highlighted = true + } + onCanceled: { + btn3.highlighted = false + } + Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter + } + } + + Rectangle { + id: footer + opacity: 0 + width: parent.width + height: 5 + anchors { + bottom: parent.bottom + } + } + } + +} diff --git a/app/app.pro b/app/app.pro new file mode 100644 index 0000000..0cc31aa --- /dev/null +++ b/app/app.pro @@ -0,0 +1,36 @@ +# +# Copyright (c) 2019 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. + +TEMPLATE = app +TARGET = onscreenapp +QT += quickcontrols2 quick qml +CONFIG += c++11 link_pkgconfig +DESTDIR = $${OUT_PWD}/../package/root/bin +PKGCONFIG += qlibwindowmanager libhomescreen + +HEADERS += \ + eventhandler.h \ + onscreenmodel.h + +SOURCES += \ + eventhandler.cpp \ + main.cpp \ + onscreenmodel.cpp + +RESOURCES += \ + qml.qrc \ + images/images.qrc + +LIBS += -ljson-c diff --git a/app/eventhandler.cpp b/app/eventhandler.cpp new file mode 100644 index 0000000..c33022a --- /dev/null +++ b/app/eventhandler.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2019 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "eventhandler.h" + +const char _myrole[] = "on_screen"; +const char _parameter[] = "parameter"; +const char _replyto[] = "replyto"; +const char _button_name[] = "buttonName"; +const char _drawing_name[] = "drawing_name"; +const char _application_id[] = "application_id"; + + +void* EventHandler::myThis = 0; + +EventHandler::EventHandler(QObject *parent) : + QObject(parent), + mp_hs(nullptr), + mp_wm(nullptr), + m_dsp_sts(false) +{ +} + +EventHandler::~EventHandler() +{ + if (mp_hs != nullptr) { + delete mp_hs; + } + if (mp_wm != nullptr) { + delete mp_wm; + } +} + +void EventHandler::init(int port, const char *token) +{ + myThis = this; + mp_wm = new QLibWindowmanager(); + mp_wm->init(port, token); + + mp_hs = new LibHomeScreen(); + mp_hs->init(port, token); + + mp_hs->registerCallback(nullptr, EventHandler::onRep_static); + mp_hs->set_event_handler(LibHomeScreen::Event_ShowWindow, [this](json_object *object){ + /* + { + "application_id": "onscreenapp", + "parameter": { + "title": "onscreen title", + "type": "critical,exclamation,question,information", + "contents": "message contents", + "buttons": ["button_name1", "button_name2", "button_name3"], + "replyto":"caller application id" + } + } */ + HMI_DEBUG(APP_ID, "recived json message is[%s]", json_object_get_string(object)); + + struct json_object *param; + if(!json_object_object_get_ex(object, _parameter, ¶m) + || json_object_get_type(param) != json_type_object) { + HMI_DEBUG(APP_ID, "parameter error!"); + return; + } + + struct json_object *replyid; + const char *replyto = nullptr; + if(json_object_object_get_ex(param, _replyto, &replyid)) + replyto = json_object_get_string(replyid); + if(replyto == nullptr) { + HMI_DEBUG(APP_ID, "received replyto is null!"); + return; + } + m_req = qMakePair(QString(replyto), QString(json_object_to_json_string(param))); + + if (this->getDisplayStatus() == HIDING) { + this->activateWindow(_myrole, "on_screen"); + } + else if(this->getDisplayStatus() == SHOWING) { + this->setDisplayStatus(SWAPPING); + emit this->hideOnScreen(); + } + else { + HMI_DEBUG(APP_ID, "onscreen swapping!"); + } + HMI_DEBUG(APP_ID, "received showWindow event, end!, line=%d", __LINE__); + }); + + mp_hs->set_event_handler(LibHomeScreen::Event_HideWindow, [this](json_object *object){ + emit this->hideOnScreen(); + HMI_DEBUG(APP_ID, "hideWindow json_object=%s", json_object_get_string(object)); + }); + + if (mp_wm->requestSurface(_myrole) != 0) { + HMI_DEBUG(APP_ID, "!!!!LayoutHandler requestSurface Failed!!!!!"); + exit(EXIT_FAILURE); + } + + mp_wm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [this](json_object *object) { + HMI_DEBUG(APP_ID, "Surface %s got syncDraw!", _myrole); + this->mp_wm->endDraw(QString(_myrole)); + }); + + mp_wm->set_event_handler(QLibWindowmanager::Event_Visible, [this](json_object *object) { + struct json_object *value; + json_object_object_get_ex(object, _drawing_name, &value); + const char *name = json_object_get_string(value); + if(!strcasecmp(_myrole, name)){ + this->setDisplayStatus(SHOWING); + this->m_dsp = this->m_req; + this->updateModel(QVariant(this->m_dsp.second)); + emit this->showOnScreen(); + } + + HMI_DEBUG(APP_ID, "Event_Visible kKeyDrawingName = %s", name); + }); + + mp_wm->set_event_handler(QLibWindowmanager::Event_Invisible, [this](json_object *object) { + struct json_object *value; + json_object_object_get_ex(object, _drawing_name, &value); + const char *name = json_object_get_string(value); + + HMI_DEBUG(APP_ID, "Event_Invisible kKeyDrawingName = %s", name); + }); + + HMI_DEBUG(APP_ID, "LayoutHander::init() finished."); +} + +void EventHandler::onRep_static(struct json_object* reply_contents) +{ + static_cast(EventHandler::myThis)->onRep(reply_contents); +} + +void EventHandler::onRep(struct json_object* reply_contents) +{ + const char* str = json_object_to_json_string(reply_contents); + HMI_DEBUG(APP_ID, "EventHandler::onReply %s", str); +} + +void EventHandler::activateWindow(const char *role, const char *area) +{ + HMI_DEBUG(APP_ID, "EventHandler::activateWindow()"); + mp_wm->activateWindow(role, area); +} + +void EventHandler::deactivateWindow() +{ + HMI_DEBUG(APP_ID, "EventHandler::deactivateWindow()"); + if(getDisplayStatus() == SWAPPING) { + setDisplayStatus(SHOWING); + m_dsp = m_req; + updateModel(QVariant(this->m_dsp.second)); + emit showOnScreen(); + } + else { + this->setDisplayStatus(HIDING); + mp_wm->deactivateWindow(_myrole); + } +} + +void EventHandler::onScreenReply(const QString &btn_name) +{ + HMI_DEBUG(APP_ID, "EventHandler::onScreenReply(),btn_name=%s", btn_name.toStdString().c_str()); + emit this->hideOnScreen(); + + struct json_object* j_param = json_object_new_object(); + json_object_object_add(j_param, _button_name, json_object_new_string(btn_name.toStdString().c_str())); + mp_hs->replyShowWindow(m_dsp.first.toStdString().c_str(), j_param); +} diff --git a/app/eventhandler.h b/app/eventhandler.h new file mode 100644 index 0000000..567c8a9 --- /dev/null +++ b/app/eventhandler.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2019 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. + */ + +#ifndef HOMESCREENHANDLER_H +#define HOMESCREENHANDLER_H + +#include +#include +#include +#include +#include +#include +#include "hmi-debug.h" + +#define APP_ID "onscreenapp" + +class QQmlApplicationEngine; + +class EventHandler : public QObject +{ + Q_OBJECT +public: + explicit EventHandler(QObject *parent = 0); + ~EventHandler(); + EventHandler(const EventHandler&) = delete; + EventHandler& operator=(const EventHandler&) = delete; + + void init(int port, const char* token); + void onRep(struct json_object* reply_contents); + + static void* myThis; + static void onRep_static(struct json_object* reply_contents); + + Q_INVOKABLE void deactivateWindow(); + Q_INVOKABLE void onScreenReply(const QString &btn_name); + +signals: + void updateModel(QVariant data); + void showOnScreen(); + void hideOnScreen(); + +private: + enum { + HIDING = 0, + SHOWING, + SWAPPING + }; + + int getDisplayStatus() {return m_dsp_sts;} + void setDisplayStatus(int sts) {m_dsp_sts = sts;} + void activateWindow(const char *role, const char *area = "normal.full"); + + LibHomeScreen *mp_hs; + QLibWindowmanager* mp_wm; + QPair m_req, m_dsp; + int m_dsp_sts = HIDING; +}; +#endif // HOMESCREENHANDLER_H diff --git a/app/hmi-debug.h b/app/hmi-debug.h new file mode 100644 index 0000000..5178aa5 --- /dev/null +++ b/app/hmi-debug.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017 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. + */ + +#ifndef __HMI_DEBUG_H__ +#define __HMI_DEBUG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +enum LOG_LEVEL{ + LOG_LEVEL_NONE = 0, + LOG_LEVEL_ERROR, + LOG_LEVEL_WARNING, + LOG_LEVEL_NOTICE, + LOG_LEVEL_INFO, + LOG_LEVEL_DEBUG, + LOG_LEVEL_MAX = LOG_LEVEL_DEBUG +}; + +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) + +#define HMI_ERROR(prefix, args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, prefix, args, ##__VA_ARGS__) +#define HMI_WARNING(prefix, args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) +#define HMI_NOTICE(prefix, args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) +#define HMI_INFO(prefix, args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) +#define HMI_DEBUG(prefix, args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) + +static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}; + +static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...) +{ + const int log_level = (getenv("USE_HMI_DEBUG") == NULL)?LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG")); + if(log_level < level) + { + return; + } + + char *message; + struct timespec tp; + unsigned int time; + + clock_gettime(CLOCK_REALTIME, &tp); + time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); + + va_list args; + va_start(args, log); + if (log == NULL || vasprintf(&message, log, args) < 0) + message = NULL; + fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message); + va_end(args); + free(message); +} + +#ifdef __cplusplus +} +#endif +#endif //__HMI_DEBUG_H__ diff --git a/app/images/DividingLine.svg b/app/images/DividingLine.svg new file mode 100644 index 0000000..788256c --- /dev/null +++ b/app/images/DividingLine.svg @@ -0,0 +1,62 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/images/critical.svg b/app/images/critical.svg new file mode 100644 index 0000000..e2df6fc --- /dev/null +++ b/app/images/critical.svg @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/app/images/exclamation.svg b/app/images/exclamation.svg new file mode 100644 index 0000000..c43ebdd --- /dev/null +++ b/app/images/exclamation.svg @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + ! + + diff --git a/app/images/images.qrc b/app/images/images.qrc new file mode 100644 index 0000000..842a9fb --- /dev/null +++ b/app/images/images.qrc @@ -0,0 +1,10 @@ + + + DividingLine.svg + critical.svg + exclamation.svg + information.svg + question.svg + + + diff --git a/app/images/information.svg b/app/images/information.svg new file mode 100644 index 0000000..44b0ef8 --- /dev/null +++ b/app/images/information.svg @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + i + + diff --git a/app/images/question.svg b/app/images/question.svg new file mode 100644 index 0000000..7d55a46 --- /dev/null +++ b/app/images/question.svg @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + ? + + diff --git a/app/main.cpp b/app/main.cpp new file mode 100644 index 0000000..007711c --- /dev/null +++ b/app/main.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2019 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "eventhandler.h" +#include "onscreenmodel.h" + + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QCoreApplication::setOrganizationDomain("LinuxFoundation"); + QCoreApplication::setOrganizationName("AutomotiveGradeLinux"); + QCoreApplication::setApplicationName("Onscreenapp"); + QCoreApplication::setApplicationVersion("0.1.0"); + + QQuickStyle::setStyle("AGL"); + + QCommandLineParser parser; + parser.addPositionalArgument("port", app.translate("main", "port for binding")); + parser.addPositionalArgument("secret", app.translate("main", "secret for binding")); + parser.addHelpOption(); + parser.addVersionOption(); + parser.process(app); + QStringList positionalArguments = parser.positionalArguments(); + + int port = 1700; + QString token = "wm"; + + if (positionalArguments.length() == 2) { + port = positionalArguments.takeFirst().toInt(); + token = positionalArguments.takeFirst(); + } + + HMI_DEBUG(APP_ID, "port = %d, token = %s", port, token.toStdString().c_str()); + + QQmlApplicationEngine engine; + EventHandler *eventHandler = new EventHandler(); + eventHandler->init(port, token.toStdString().c_str()); + engine.rootContext()->setContextProperty("eventHandler", eventHandler); + qmlRegisterType("OnScreenModel", 1, 0, "OnScreenModel"); + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) { + HMI_DEBUG(APP_ID, "Fatal Error, rootObject is empty!"); + return -1; + } + + QObject *root = engine.rootObjects().first(); + QQuickWindow *window = qobject_cast(root); + QObject::connect(eventHandler, SIGNAL(updateModel(QVariant)), window, SLOT(setOnScreenModel(QVariant))); + QObject::connect(eventHandler, SIGNAL(showOnScreen()), window, SLOT(showOnScreen())); + QObject::connect(eventHandler, SIGNAL(hideOnScreen()), window, SLOT(hideOnScreen())); + + HMI_DEBUG(APP_ID, "onscreenapp started!"); + return app.exec(); +} + diff --git a/app/main.qml b/app/main.qml new file mode 100644 index 0000000..99d50f8 --- /dev/null +++ b/app/main.qml @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2017 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. + */ + +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 +import OnScreenModel 1.0 + +Window { + id: root + flags: Qt.FramelessWindowHint + visible: true + x: 0 + y: 218 + width: 1080 + height: 1488 + color: '#00000000' + + Onscreen { + id: ons + anchors.centerIn: parent + visible: true + scale: 0 + + property string dsp_sts: "hide" + property string dsp_title: "" + property string dsp_icon: "" + property string dsp_contents: "" + property int btnNum: 0 + property string btn1Name: "" + property string btn2Name: "" + property string btn3Name: "" + + states: [ + State { + name: 'active' + when: ons.dsp_sts == "show" + PropertyChanges { + target: ons + scale: 1 + z: 1 + } + }, + State { + name: 'inactive' + when: ons.dsp_sts == "hide" + PropertyChanges { + target: ons + scale: 0 + z: -1 + } + } + ] + transitions: Transition { + NumberAnimation { + properties: 'scale'; + duration: 300; + easing.type: Easing.Linear + alwaysRunToEnd: true + } + } + } + + OnScreenModel { + id: onscreenModel + } + + Timer { + id: ons_timer + interval: 3000 + onTriggered: { + hideOnScreen(); + clearOnScreenModel(); + } + } + + Connections { + target: ons + onScaleChanged : { + if(ons.scale == 0) { + console.log(qsTr('hide animation finished')); + eventHandler.deactivateWindow(); + } + } + } + + function showOnScreen() { + console.log(qsTr('show onscreenapp')); + ons.dsp_title = onscreenModel.getTitle() + ons.dsp_icon = "../images/" + onscreenModel.getType() + ".svg" + ons.dsp_contents = onscreenModel.getContents() + ons.btnNum = onscreenModel.buttonNum() + ons.btn1Name = onscreenModel.buttonName(0) + ons.btn2Name = onscreenModel.buttonName(1) + ons.btn3Name = onscreenModel.buttonName(2) + ons_timer.running = ons.btnNum > 0 ? false : true + ons.dsp_sts = "show" + } + + function hideOnScreen() { + console.log(qsTr('hide onscreenapp')); + ons.dsp_sts = "hide" + ons_timer.running = false + } + + function setOnScreenModel(data) { + console.log(qsTr('onscreenapp >>> setModel status: ' + data)); + onscreenModel.setModel(data) + } +} diff --git a/app/onscreenmodel.cpp b/app/onscreenmodel.cpp new file mode 100644 index 0000000..184d1a6 --- /dev/null +++ b/app/onscreenmodel.cpp @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "onscreenmodel.h" +#include "hmi-debug.h" +#include + +const char _modelName[] = "OnScreenModel"; +const char _title[] = "title"; +const char _type[] = "type"; +const char _contents[] = "contents"; +const char _buttons[] = "buttons"; + + +void OnScreenModel::setModel(QVariant data) +{ + HMI_DEBUG(_modelName, "setModel start!"); + clearModel(); + struct json_object *j_title = nullptr, *j_type = nullptr, *j_contents = nullptr, *j_buttons = nullptr; + struct json_object *j_param = json_tokener_parse(data.toString().toStdString().c_str()); + if(json_object_object_get_ex(j_param, _title, &j_title)) { + m_title = json_object_get_string(j_title); + } + else { + HMI_DEBUG(_modelName, "title input is null"); + } + + if(json_object_object_get_ex(j_param, _type, &j_type)) { + m_type = json_object_get_string(j_type); + } + else { + HMI_DEBUG(_modelName, "type input is null"); + } + + if(json_object_object_get_ex(j_param, _contents, &j_contents)) { + m_contents = json_object_get_string(j_contents); + } + else { + HMI_DEBUG(_modelName, "contents input is null"); + } + + if(json_object_object_get_ex(j_param, _buttons, &j_buttons)) { + if(json_object_get_type(j_buttons) != json_type_array) { + HMI_DEBUG(_modelName, "buttons josn type isn't array!"); + } + else { + m_buttons.clear(); + int len = json_object_array_length(j_buttons); + struct json_object *json_tmp = nullptr; + for (int i = 0; i < len; i++) { + json_tmp = json_object_array_get_idx(j_buttons, i); + m_buttons << QString(json_object_get_string(json_tmp)); + } + } + } + else { + HMI_DEBUG("OnScreenModel", "buttons input is null"); + } + HMI_DEBUG(_modelName, "setModel end!titile=%s,type=%s,contents=%s,btnNum=%d", + m_title.toStdString().c_str(), m_type.toStdString().c_str(), m_contents.toStdString().c_str(), m_buttons.size()); +} + +QString OnScreenModel::buttonName(int index) const +{ + if(index >= m_buttons.size()) + return QString(""); + else + return m_buttons[index]; +} + +void OnScreenModel::clearModel(void) +{ + m_title = ""; + m_type = ""; + m_contents = ""; + m_buttons.clear(); +} diff --git a/app/onscreenmodel.h b/app/onscreenmodel.h new file mode 100644 index 0000000..e12b269 --- /dev/null +++ b/app/onscreenmodel.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 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. + */ + +#ifndef ONSCREENMODEL_H +#define ONSCREENMODEL_H + +#include +#include +#include + + +class OnScreenModel : public QObject +{ + Q_OBJECT +public: + explicit OnScreenModel(QObject *parent = nullptr){} + ~OnScreenModel() = default; + + Q_INVOKABLE QString getTitle(void) const {return m_title;} + Q_INVOKABLE QString getType(void) const {return m_type;} + Q_INVOKABLE QString getContents(void) const {return m_contents;} + Q_INVOKABLE int buttonNum(void) const {return m_buttons.size();} + Q_INVOKABLE QString buttonName(int index) const; + Q_INVOKABLE void setModel(QVariant data); + +private: + void clearModel(void); + + QString m_title; + QString m_type; + QString m_contents; + QStringList m_buttons; +}; + +#endif // ONSCREENMODEL_H diff --git a/app/qml.qrc b/app/qml.qrc new file mode 100644 index 0000000..bad4ade --- /dev/null +++ b/app/qml.qrc @@ -0,0 +1,6 @@ + + + main.qml + Onscreen.qml + + diff --git a/doc/parts/showOnscreen.svg b/doc/parts/showOnscreen.svg new file mode 100644 index 0000000..6f4d3ea --- /dev/null +++ b/doc/parts/showOnscreen.svg @@ -0,0 +1,84 @@ +show/hide onscreen phaseuseruserhomescreen-servicehomescreen-serviceAppApponscreenapponscreenappwindowmanagerwindowmanagershow onscreenthe operation request onscreenshowWindow(){"application_id": "onscreenapp","parameter": {"title": "onscreen title","type": "critical,exclamation,question,information","contents": "message contents","buttons": ["button_name1", "button_name2", "button_name3"]}}push showWindow event{"application_id": "onscreenapp","parameter": {"title": "onscreen title","type": "critical,exclamation,question,information","contents": "message contents","buttons": ["button_name1", "button_name2", "button_name3"],"replyto":"caller application id"}}get and save parameteractivateWindow("onscreeapp", "on_screen")alt[can show]push syncDraw eventendDraw("onscreeapp")show onscreen as request pattern[can't show]do nothinghide onscreentap onscreen's buttondeactivateWindow("onscreenapp");hide windowreplyShowWindow(){"application_id":"the application who called onscreenapp","parameter": {"buttonName": "VOLUME_UP"}}push replyShowWindow eventcall reply function \ No newline at end of file diff --git a/doc/readme.md b/doc/readme.md new file mode 100644 index 0000000..f9da853 --- /dev/null +++ b/doc/readme.md @@ -0,0 +1,32 @@ + +usage of onscreenapp +=== + +## dependence + +- Onscreenapp depend on libhomescreen add agl-service-homescreen as below: + - libhomescreen must have 'showWindow/hideWindow/replyShowWindow' event + and 'showWindow/hideWindow/replyShowWindow' interface. + - agl-service-homescreen must have 'showWindow/hideWindow/replyShowWindow' verbs. + +## sequence + +show/hide onscreen sequence. +- ![showOnscreen.svg](parts/showOnscreen.svg) + +## about sample 'onstestapp' +onstestapp is a sample to use onscreenapp. + +### compile & install +- compile + - when onscreenapp is compiled, this app's wgt file will exist at "onscreenapp/sample/package" which called onstestapp.wgt. + +- install + `afm-util install onstestapp.wgt;sync` + +### onstestapp usage +- start onstestapp in launcher +- select onscreen type in groupbox +- press "Post" button + +After clicked onscreen's button,you will see reply information at top area of onstestapp. diff --git a/onscreenapp.pro b/onscreenapp.pro new file mode 100644 index 0000000..73540cf --- /dev/null +++ b/onscreenapp.pro @@ -0,0 +1,25 @@ +# +# Copyright (c) 2019 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. + +TEMPLATE = subdirs + +load(configure) + +SUBDIRS += \ + package \ + app \ + sample + +package.depends += app diff --git a/package/config.xml b/package/config.xml new file mode 100644 index 0000000..7b151a3 --- /dev/null +++ b/package/config.xml @@ -0,0 +1,17 @@ + + + OnScreenApp + + + This is a demo OnScreen application + TOYOTA + APL 2.0 + + + + + + + + + diff --git a/package/icon.svg b/package/icon.svg new file mode 100644 index 0000000..91661a7 --- /dev/null +++ b/package/icon.svg @@ -0,0 +1,279 @@ + + + +image/svg+xmlMULTIMEDIA + \ No newline at end of file diff --git a/package/package.pro b/package/package.pro new file mode 100644 index 0000000..bb32c26 --- /dev/null +++ b/package/package.pro @@ -0,0 +1,18 @@ +DISTFILES = icon.svg config.xml + +copy_icon.target = $$OUT_PWD/root/icon.svg +copy_icon.depends = $$_PRO_FILE_PWD_/icon.svg +copy_icon.commands = $(COPY_FILE) \"$$replace(copy_icon.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_icon.target, /, $$QMAKE_DIR_SEP)\" +QMAKE_EXTRA_TARGETS += copy_icon +PRE_TARGETDEPS += $$copy_icon.target + +copy_config.target = $$OUT_PWD/root/config.xml +copy_config.depends = $$_PRO_FILE_PWD_/config.xml +copy_config.commands = $(COPY_FILE) \"$$replace(copy_config.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_config.target, /, $$QMAKE_DIR_SEP)\" +QMAKE_EXTRA_TARGETS += copy_config +PRE_TARGETDEPS += $$copy_config.target + +wgt.target = package +wgt.commands = wgtpkg-pack -f -o onscreenapp.wgt root + +QMAKE_EXTRA_TARGETS += wgt diff --git a/sample/app/app.pro b/sample/app/app.pro new file mode 100644 index 0000000..c72fd28 --- /dev/null +++ b/sample/app/app.pro @@ -0,0 +1,33 @@ +# +# Copyright (c) 2019 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. + +TARGET = onstestapp +QT = quick quickcontrols2 qml + +CONFIG += c++11 link_pkgconfig +PKGCONFIG += qlibwindowmanager qlibhomescreen +DESTDIR = $${OUT_PWD}/../package/root/bin + +SOURCES = main.cpp \ + eventhandler.cpp + +RESOURCES += \ + qml.qrc + +HEADERS += \ + eventhandler.h + +LIBS += -ljson-c + diff --git a/sample/app/eventhandler.cpp b/sample/app/eventhandler.cpp new file mode 100644 index 0000000..4e55619 --- /dev/null +++ b/sample/app/eventhandler.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2019 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. + */ + +#include +#include +#include +#include +#include +//#include +#include +#include +#include "eventhandler.h" + +void* EventHandler::myThis = 0; + +const char _drawing_name[] = "drawing_name"; + +EventHandler::EventHandler(QObject *parent) : + QObject(parent), + mp_hs(NULL), + mp_wm(NULL), + mp_qw(NULL) +{ + +} + +EventHandler::~EventHandler() +{ + if (mp_hs != NULL) { + delete mp_hs; + } + if (mp_wm != NULL) { + delete mp_wm; + } +} + +void EventHandler::init(int port, const char *token) +{ + myThis = this; + mp_wm = new QLibWindowmanager(); + mp_wm->init(port, token); + + mp_hs = new QLibHomeScreen(); + mp_hs->init(port, token); + + mp_hs->set_event_handler(QLibHomeScreen::Event_ShowWindow, [this](json_object *object){ + this->mp_wm->activateWindow(ROLE_NAME, "normal"); + HMI_DEBUG(APP_ID, "received showWindow event, end!, line=%d", __LINE__); + }); + + mp_hs->set_event_handler(QLibHomeScreen::Event_ReplyShowWindow, [this](json_object *object){ + HMI_DEBUG(APP_ID, "got Event_ReplyShowWindow!\n"); + const char* msg = json_object_to_json_string(object); + emit this->signalOnReplyShowWindow(msg); + }); + + if (mp_wm->requestSurface(ROLE_NAME) != 0) { + HMI_DEBUG(APP_ID, "!!!!LayoutHandler requestSurface Failed!!!!!"); + exit(EXIT_FAILURE); + } + + // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs + mp_wm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [this](json_object *object) { + HMI_DEBUG(APP_ID, "Surface got syncDraw!"); + this->mp_wm->endDraw(ROLE_NAME); + }); + + mp_wm->set_event_handler(QLibWindowmanager::Event_Visible, [this](json_object *object) { + struct json_object *value; + json_object_object_get_ex(object, _drawing_name, &value); + const char *name = json_object_get_string(value); + + HMI_DEBUG(APP_ID, "Event_Active kKeyDrawingName = %s", name); + }); + + mp_wm->set_event_handler(QLibWindowmanager::Event_Invisible, [this](json_object *object) { + struct json_object *value; + json_object_object_get_ex(object, _drawing_name, &value); + const char *name = json_object_get_string(value); + + HMI_DEBUG(APP_ID, "Event_Inactive kKeyDrawingName = %s", name); + }); + + HMI_DEBUG(APP_ID, "LayoutHander::init() finished."); +} + +void EventHandler::setQuickWindow(QQuickWindow *qw) +{ + mp_qw = qw; + QObject::connect(mp_qw, SIGNAL(frameSwapped()), mp_wm, SLOT(slotActivateSurface())); +} + +void EventHandler::showWindow(QString id, QString json) +{ + if(json.isNull()) + mp_hs->tapShortcut(id); + else + mp_hs->showWindow(id.toStdString().c_str(), json_tokener_parse(json.toStdString().c_str())); +} + +void EventHandler::hideWindow(QString id) +{ + mp_hs->hideWindow(id.toStdString().c_str()); +} diff --git a/sample/app/eventhandler.h b/sample/app/eventhandler.h new file mode 100644 index 0000000..af66644 --- /dev/null +++ b/sample/app/eventhandler.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2019 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. + */ + +#ifndef EVENTHANDLER_H +#define EVENTHANDLER_H + +#include +#include +#include + +#include +#include +#include "hmi-debug.h" + +#define ROLE_NAME "onstestapp" +#define APP_ID "onstestapp" + +using namespace std; + +class QQuickWindow; +class QQmlApplicationEngine; + +class EventHandler : public QObject +{ + Q_OBJECT +public: + explicit EventHandler(QObject *parent = 0); + ~EventHandler(); + + void init(int port, const char* token); + void setQuickWindow(QQuickWindow *qw); + static void* myThis; + + Q_INVOKABLE void showWindow(QString id, QString json); + Q_INVOKABLE void hideWindow(QString id); + +signals: + void signalOnReplyShowWindow(QVariant val); + +private: + QLibHomeScreen *mp_hs; + QLibWindowmanager* mp_wm; + QQuickWindow *mp_qw; +}; + +#endif // EVENTHANDLER_H diff --git a/sample/app/hmi-debug.h b/sample/app/hmi-debug.h new file mode 100644 index 0000000..5178aa5 --- /dev/null +++ b/sample/app/hmi-debug.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017 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. + */ + +#ifndef __HMI_DEBUG_H__ +#define __HMI_DEBUG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include + +enum LOG_LEVEL{ + LOG_LEVEL_NONE = 0, + LOG_LEVEL_ERROR, + LOG_LEVEL_WARNING, + LOG_LEVEL_NOTICE, + LOG_LEVEL_INFO, + LOG_LEVEL_DEBUG, + LOG_LEVEL_MAX = LOG_LEVEL_DEBUG +}; + +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) + +#define HMI_ERROR(prefix, args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, prefix, args, ##__VA_ARGS__) +#define HMI_WARNING(prefix, args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) +#define HMI_NOTICE(prefix, args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) +#define HMI_INFO(prefix, args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) +#define HMI_DEBUG(prefix, args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) + +static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}; + +static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...) +{ + const int log_level = (getenv("USE_HMI_DEBUG") == NULL)?LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG")); + if(log_level < level) + { + return; + } + + char *message; + struct timespec tp; + unsigned int time; + + clock_gettime(CLOCK_REALTIME, &tp); + time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); + + va_list args; + va_start(args, log); + if (log == NULL || vasprintf(&message, log, args) < 0) + message = NULL; + fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message); + va_end(args); + free(message); +} + +#ifdef __cplusplus +} +#endif +#endif //__HMI_DEBUG_H__ diff --git a/sample/app/main.cpp b/sample/app/main.cpp new file mode 100644 index 0000000..c47c869 --- /dev/null +++ b/sample/app/main.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2019 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "eventhandler.h" + + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + app.setApplicationName("onstestapp"); + app.setApplicationVersion(QStringLiteral("3.99.3")); + app.setOrganizationDomain(QStringLiteral("automotivelinux.org")); + app.setOrganizationName(QStringLiteral("AutomotiveGradeLinux")); + + QQuickStyle::setStyle("AGL"); + + QCommandLineParser parser; + parser.addPositionalArgument("port", app.translate("main", "port for binding")); + parser.addPositionalArgument("secret", app.translate("main", "secret for binding")); + parser.addHelpOption(); + parser.addVersionOption(); + parser.process(app); + QStringList positionalArguments = parser.positionalArguments(); + + QQmlApplicationEngine engine; + int port = 0; + QString secret; + if (positionalArguments.length() == 2) { + port = positionalArguments.takeFirst().toInt(); + secret = positionalArguments.takeFirst(); + } + + EventHandler *eventHandler = new EventHandler(); + eventHandler->init(port, secret.toStdString().c_str()); + engine.rootContext()->setContextProperty("eventHandler", eventHandler); + + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + if (engine.rootObjects().isEmpty()) { + HMI_DEBUG(APP_ID, "Fatal Error, rootObject is empty!"); + return -1; + } + + QObject *root = engine.rootObjects().first(); + QQuickWindow *window = qobject_cast(root); + QObject::connect(eventHandler, SIGNAL(signalOnReplyShowWindow(QVariant)), window, SLOT(qmlOnReplyShowWindow(QVariant))); + eventHandler->setQuickWindow(window); + + return app.exec(); +} diff --git a/sample/app/main.qml b/sample/app/main.qml new file mode 100644 index 0000000..b9f415b --- /dev/null +++ b/sample/app/main.qml @@ -0,0 +1,349 @@ +import QtQuick 2.7 +import QtQuick.Window 2.2 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 +import AGL.Demo.Controls 1.0 + +ApplicationWindow { + id: root + visible: true + width: 1080 + height: 1487 + + property string onsId: qsTr("onscreenapp") + property string onsTitle: qsTr("One Button title") + property string onsType: "critical" + property string onsContents: qsTr("An operating system is a program that manages a computer’s hardware.") + property string onsButton1: qsTr("Yes") + property string onsButton2: qsTr("") + property string onsButton3: qsTr("") + property string postmsg: qsTr("") + property string btndata: qsTr("") + + Label { + id: title + width: parent.width + height: 40 + text: "OnScreen Test App" + font.pixelSize: 40 + font.bold: true + color: "white" + } + + ColumnLayout { + spacing: 20 + anchors.top: title.bottom + anchors.topMargin: 40 + anchors.horizontalCenter: title.horizontalCenter + + // show received reply information area + Flickable { + id: flickable + width: 800 + height: 320 + Layout.alignment: Qt.AlignCenter + flickableDirection: Flickable.VerticalFlick + boundsBehavior: Flickable.StopAtBounds + + TextArea.flickable: TextArea { + id: output + text: "show received reply information area\n...\n...\n...\n...\n" + font.pixelSize: 24 + wrapMode: TextArea.Wrap + color: '#00ADDC' + } + + ScrollBar.vertical: ScrollBar { } + } + + // select onscreen type area + GroupBox { + label: Label { + text: qsTr("Please select send OnScreen Message") + font.pixelSize: 32 + font.bold: true + color: "white" + } + + width: 800 + height: 100 + Layout.alignment: Qt.AlignLeft + + RowLayout { + anchors.fill: parent + RadioButton { + text: qsTr("One Button") + font.pixelSize: 20 + checked: true + onClicked: { + selectOneButton(); + } + } + RadioButton { + text: qsTr("Two Buttons") + font.pixelSize: 20 + onClicked: { + selectTwoButtons(); + } + } + RadioButton { + text: qsTr("Three Buttons") + font.pixelSize: 20 + onClicked: { + selectThreeButtons(); + } + } + RadioButton { + text: qsTr("No Button") + font.pixelSize: 20 + onClicked: { + selectNoButton(); + } + } + } + } + + // edit post message area + GroupBox { + label: Label { + text: qsTr("Post Infomations") + font.pixelSize: 32 + font.bold: true + color: "white" + } + width: 800 + height: 400 + Layout.alignment: Qt.AlignLeft + Layout.maximumWidth: 800 + Layout.maximumHeight: 400 + + ColumnLayout { + spacing: 20 + RowLayout { + spacing: 20 + Label { + id: ons_title + anchors.left: parent.left + anchors.leftMargin: 30 + text: qsTr("ons_title:") + font.pixelSize: 20 + font.italic: true + color: '#00ADDC' + } + + Label { + id: ons_title_data + text: onsTitle + font.pixelSize: 20 + font.italic: true + anchors.left: ons_title.right + anchors.leftMargin: 20 + color: '#00ADDC' + Layout.maximumWidth: 600 + Layout.maximumHeight: 40 + maximumLineCount: 1 + wrapMode: Text.Wrap + elide: Text.ElideRight + horizontalAlignment: Label.AlignHCenter + verticalAlignment: Label.AlignVCenter + } + } + RowLayout { + spacing: 20 + Label { + id: ons_type + anchors.left: parent.left + anchors.leftMargin: 30 + text: qsTr("type:") + font.pixelSize: 20 + font.italic: true + color: '#00ADDC' + } + + Label { + id: ons_type_data + text: onsType + font.pixelSize: 20 + font.italic: true + anchors.left: ons_type.right + anchors.leftMargin: 20 + color: '#00ADDC' + } + } + RowLayout { + spacing: 20 + Label { + id: ons_contents + anchors.left: parent.left + anchors.leftMargin: 30 + text: qsTr("contents:") + font.pixelSize: 20 + font.italic: true + color: '#00ADDC' + } + Label { + id: ons_contents_data + text: onsContents + font.pixelSize: 20 + font.italic: true + anchors.left: ons_contents.right + anchors.leftMargin: 20 + color: '#00ADDC' + Layout.maximumWidth: 600 + Layout.maximumHeight: 200 + maximumLineCount: 4 + wrapMode: Text.Wrap + elide: Text.ElideRight + horizontalAlignment: Label.AlignLeft + verticalAlignment: Label.AlignVCenter + } + } + RowLayout { + spacing: 20 + Label { + id: btn1 + anchors.left: parent.left + anchors.leftMargin: 30 + text: qsTr("Button1") + font.pixelSize: 20 + font.italic: true + color: '#00ADDC' + } + + Label { + id: btn1_data + text: onsButton1 + font.pixelSize: 20 + font.italic: true + anchors.left: btn1.right + anchors.leftMargin: 20 + color: '#00ADDC' + } + } + RowLayout { + spacing: 20 + Label { + id: btn2 + anchors.left: parent.left + anchors.leftMargin: 30 + text: qsTr("Button2") + font.pixelSize: 20 + font.italic: true + color: '#00ADDC' + } + Label { + id: btn2_data + text: onsButton2 + font.pixelSize: 20 + font.italic: true + anchors.left: btn2.right + anchors.leftMargin: 20 + color: '#00ADDC' + } + } + RowLayout { + spacing: 20 + Label { + id: btn3 + anchors.left: parent.left + anchors.leftMargin: 30 + text: qsTr("Button3") + font.pixelSize: 20 + font.italic: true + color: '#00ADDC' + } + Label { + id: btn3_data + text: onsButton3 + font.pixelSize: 20 + font.italic: true + anchors.left: btn3.right + anchors.leftMargin: 20 + color: '#00ADDC' + } + } + } + } + + // post button + Button { + id: poster + text: "Post" + Layout.alignment: Qt.AlignCenter + onClicked: { + postMessage(); + } + } + } + + function selectOneButton() { + console.log("select one button!") + onsTitle = qsTr("One Button title") + onsType = qsTr("critical") + onsContents = qsTr("An operating system is a program that manages a computer’s hardware.") + onsButton1 = qsTr("Yes") + onsButton2 = qsTr("") + onsButton3 = qsTr("") + } + + function selectTwoButtons() { + console.log("select two buttons!") + onsTitle = qsTr("Two Buttons title") + onsType = qsTr("exclamation") + onsContents = qsTr("Beforewe can explore the details of computer system operation, we need to know something about system structure. We thus discuss the basic functions of system startup, I/O, and storage early in this chapter. We also describe the basic computer architecture that makes it possible to write a functional operating system.") + onsButton1 = qsTr("Yes") + onsButton2 = qsTr("No") + onsButton3 = qsTr("") + } + + function selectThreeButtons() { + console.log("select three buttons!") + onsTitle = qsTr("Three Buttons title") + onsType = qsTr("information") + onsContents = qsTr("We can also view a computer system as consisting of hardware, software,and data. The operating system provides the means for proper use of these resources in the operation of the computer system.") + onsButton1 = qsTr("Yes") + onsButton2 = qsTr("Abort") + onsButton3 = qsTr("No") + } + + function selectNoButton() { + console.log("select no button!") + onsTitle = qsTr("No Button title,very long title beyond screen wide which will show ellipsis at the end") + onsType = qsTr("question") + onsContents = qsTr("Recently, many varieties of mobile computers, such as smartphones and tablets, have come into fashion. Most mobile computers are standalone units for individual users. Quite often, they are connected to networks through cellular or other wireless technologies. Increasingly, these mobile devices are replacing desktop and laptop computers for people who are primarily interested in using computers for e-mail and web browsing. The user interface for mobile computers generally features a touch screen, where the user interacts with the system by pressing and swiping fingers across the screen rather than using a physical keyboard and mouse.") + onsButton1 = qsTr("") + onsButton2 = qsTr("") + onsButton3 = qsTr("") + } + + function postMessage() { + console.log("poster pressed") + btndata = "" + postmsg = "{\"title\": \"" + onsTitle + "\"," + "\"type\": \"" + onsType + "\"," + "\"contents\": \"" + onsContents + "\""; + if (onsButton1 != "") { + btndata = "\"" + onsButton1 + "\""; + } + if (onsButton2 != "") { + if (btndata != "") + btndata += ","; + btndata += "\"" + onsButton2 + "\""; + } + if (onsButton3 != "") { + if (btndata != "") + btndata += ","; + btndata += "\"" + onsButton3 + "\""; + } + + if(btndata != "") + postmsg += ",\"buttons\":[" + btndata + "]}" + else + postmsg += "}" + + eventHandler.showWindow(onsId, postmsg); + } + + function qmlOnReplyShowWindow(text) { + console.log("onstestapp received:",text); + output.text = text; + } +} diff --git a/sample/app/qml.qrc b/sample/app/qml.qrc new file mode 100644 index 0000000..5f6483a --- /dev/null +++ b/sample/app/qml.qrc @@ -0,0 +1,5 @@ + + + main.qml + + diff --git a/sample/package/config.xml b/sample/package/config.xml new file mode 100644 index 0000000..2d9a5a1 --- /dev/null +++ b/sample/package/config.xml @@ -0,0 +1,18 @@ + + + onstestapp + + + This is a demo onstestapp application + Qt + APL 2.0 + + + + + + + + + + diff --git a/sample/package/icon.svg b/sample/package/icon.svg new file mode 100644 index 0000000..411d130 --- /dev/null +++ b/sample/package/icon.svg @@ -0,0 +1,489 @@ + + + +image/svg+xmlHVAC + \ No newline at end of file diff --git a/sample/package/package.pro b/sample/package/package.pro new file mode 100644 index 0000000..faf285c --- /dev/null +++ b/sample/package/package.pro @@ -0,0 +1,19 @@ + +DISTFILES = icon.svg config.xml + +copy_icon.target = $$OUT_PWD/root/icon.svg +copy_icon.depends = $$_PRO_FILE_PWD_/icon.svg +copy_icon.commands = $(COPY_FILE) \"$$replace(copy_icon.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_icon.target, /, $$QMAKE_DIR_SEP)\" +QMAKE_EXTRA_TARGETS += copy_icon +PRE_TARGETDEPS += $$copy_icon.target + +copy_config.target = $$OUT_PWD/root/config.xml +copy_config.depends = $$_PRO_FILE_PWD_/config.xml +copy_config.commands = $(COPY_FILE) \"$$replace(copy_config.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_config.target, /, $$QMAKE_DIR_SEP)\" +QMAKE_EXTRA_TARGETS += copy_config +PRE_TARGETDEPS += $$copy_config.target + +wgt.target = package +wgt.commands = wgtpkg-pack -f -o onstestapp.wgt root + +QMAKE_EXTRA_TARGETS += wgt diff --git a/sample/qml/images/answer.png b/sample/qml/images/answer.png new file mode 100644 index 0000000..4707a23 Binary files /dev/null and b/sample/qml/images/answer.png differ diff --git a/sample/qml/images/disable.png b/sample/qml/images/disable.png new file mode 100644 index 0000000..8c08c03 Binary files /dev/null and b/sample/qml/images/disable.png differ diff --git a/sample/qml/images/heart_1079x400.png b/sample/qml/images/heart_1079x400.png new file mode 100644 index 0000000..e1fe683 Binary files /dev/null and b/sample/qml/images/heart_1079x400.png differ diff --git a/sample/qml/images/images.qrc b/sample/qml/images/images.qrc new file mode 100644 index 0000000..b75641f --- /dev/null +++ b/sample/qml/images/images.qrc @@ -0,0 +1,9 @@ + + + oval_1079x400.png + heart_1079x400.png + answer.png + reject.png + disable.png + + diff --git a/sample/qml/images/oval_1079x400.png b/sample/qml/images/oval_1079x400.png new file mode 100644 index 0000000..fb850df Binary files /dev/null and b/sample/qml/images/oval_1079x400.png differ diff --git a/sample/qml/images/reject.png b/sample/qml/images/reject.png new file mode 100644 index 0000000..d6586e1 Binary files /dev/null and b/sample/qml/images/reject.png differ diff --git a/sample/qml/msg.qml b/sample/qml/msg.qml new file mode 100644 index 0000000..f89ffa0 --- /dev/null +++ b/sample/qml/msg.qml @@ -0,0 +1,91 @@ +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 + +Item { + id: onScreenMsg + visible: true + width: 1079 + height: 400 + scale: screenInfo.scale_factor() + + function qmlOnScreenParameter(message) { + console.log(qsTr('OnScreenVICS:QML:System >>> qmlOnScreenMessage.'), message); + var message_json = JSON.parse (message); + data1.text = message_json.data1; + data2.text = message_json.data2; + data3.text = message_json.data3; + } + + RowLayout { + id: line1 + x: 40 + y: 72 + width: 1000 + height: 200 + spacing: 20 + Label { + id: data1 + color: "#eeeeec" + text: "show data1" + font.pixelSize: 20 + textFormat: Text.AutoText + font.wordSpacing: 0 + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + + Label { + id: data2 + color: "#eeeeec" + text: "show data2" + font.pixelSize: 20 + textFormat: Text.AutoText + font.wordSpacing: 0 + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + + Label { + id: data3 + color: "#eeeeec" + text: "show data3" + font.pixelSize: 20 + textFormat: Text.AutoText + font.wordSpacing: 0 + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + + } + + RowLayout { + anchors.top: line1.bottom + anchors.topMargin: 60 + anchors.horizontalCenter: parent.horizontalCenter + Button { + id: button1 + text: qsTr("Button1") + onClicked: { + eventHandler.onScreenReply("Button1"); + } + } + Button { + id: button2 + text: qsTr("Button2") + onClicked: { + eventHandler.onScreenReply("Button2"); + } + } + Button { + id: button3 + text: qsTr("Button3") + onClicked: { + eventHandler.onScreenReply("Button3"); + } + } + } + +} diff --git a/sample/qml/phone.qml b/sample/qml/phone.qml new file mode 100644 index 0000000..1b25ed3 --- /dev/null +++ b/sample/qml/phone.qml @@ -0,0 +1,118 @@ +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 + +Item { + id: onScreenPhone + visible: true + width: 1079 + height: 400 + scale: screenInfo.scale_factor() + property string messageText: "Incoming Call" + + function qmlOnScreenParameter(message) { + console.log(qsTr('OnScreenApp:QML:Phone >>> qmlOnScreenParameter.'), message); + var message_json = JSON.parse (message); + var text = message_json.status + + if(text === "incoming call") + { + messageText = "Incoming Call"; + answerButton.active = true; + answerButton.checked = false; + } + else if(text === "call answered") + { + messageText = "Call Answered"; + answerButton.active = false; + answerButton.checked = true; + } + else if(text === "call rejected") + { + messageText = "Call Rejected"; + answerButton.active = false; + answerButton.checked = true; + } + else { + messageText = text; + } + } + + Image { + id : background_image + anchors.fill: parent + anchors.topMargin: 0 + anchors.bottomMargin: 0 + source: "images/heart_1079x400.png" + } + + ToggleButton { + id: answerButton + x: 53 + y: 147 + width: 228 + height: 230 + onImage: 'images/disable.png' + offImage: 'images/answer.png' + property bool active: true + + onCheckedChanged: { + if(!checked && !active) { + checked = true; + } + if(active && checked) + { + messageText = "Call Answer" + eventHandler.onScreenReply("call answer"); + active = false; + } + } + } + + ImageButton { + id: rejectButton + x: 804 + y: 142 + width: 228 + height: 230 + offImage: 'images/reject.png' + + onClicked: { + messageText = "Call Reject" + eventHandler.onScreenReply("call reject"); + } + } + + Label { + x: 400 + y: 115 + width: 280 + height: 100 + color: "#000000" + text: messageText + textFormat: Text.AutoText + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 50 + font.weight: Font.ExtraBold + } + + Label { + x: 395 + y: 112 + width: 280 + height: 100 + color: "#6BFBFF" + text: messageText + textFormat: Text.AutoText + wrapMode: Text.WordWrap + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font.pixelSize: 50 + font.weight: Font.DemiBold + } + +} diff --git a/sample/qml/system.qml b/sample/qml/system.qml new file mode 100644 index 0000000..d42eeb7 --- /dev/null +++ b/sample/qml/system.qml @@ -0,0 +1,59 @@ +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 + +Item { + id: onScreenSystem + visible: true + width: 1079 + height: 400 + scale: screenInfo.scale_factor() + + function qmlOnScreenParameter(message) { + console.log(qsTr('OnScreenSys:QML:System >>> qmlOnScreenMessage.'), message); + var message_json = JSON.parse (message); + var text = message_json.text + label.text = text; + } + + Image { + id : background_image + anchors.fill: parent + anchors.topMargin: 0 + anchors.bottomMargin: 0 + source: "images/oval_1079x400.png" + } + + Label { + id: label + x: 40 + y: 72 + width: 1000 + height: 100 + color: "#eeeeec" + text: "system alert" + font.pixelSize: 50 + textFormat: Text.AutoText + font.wordSpacing: 0 + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + + Button { + id: button +// x: 490 +// y: 250 + anchors.top: label.bottom + anchors.topMargin: 100 + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("OK") + + onClicked: { +// label.text = "system reject" + eventHandler.onScreenReply("OK"); + } + } + +} diff --git a/sample/qml/vics.qml b/sample/qml/vics.qml new file mode 100644 index 0000000..2848fbc --- /dev/null +++ b/sample/qml/vics.qml @@ -0,0 +1,47 @@ +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 + +Item { + id: onScreenVICS + visible: true + width: 1079 + height: 400 + scale: screenInfo.scale_factor() + + function qmlOnScreenParameter(message) { + console.log(qsTr('OnScreenVICS:QML:System >>> qmlOnScreenMessage.'), message); + var message_json = JSON.parse (message); + vics_info.text = message_json.info; + } + + Label { + id: vics_info + x: 40 + y: 72 + width: 1000 + height: 200 + color: "#eeeeec" + text: "show vics inofo" + font.pixelSize: 50 + textFormat: Text.AutoText + font.wordSpacing: 0 + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + } + + Button { + id: button + anchors.top: vics_info.bottom + anchors.topMargin: 100 + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("OK") + + onClicked: { + eventHandler.onScreenReply("OK"); + } + } + +} diff --git a/sample/sample.pro b/sample/sample.pro new file mode 100644 index 0000000..f49af69 --- /dev/null +++ b/sample/sample.pro @@ -0,0 +1,18 @@ +# +# Copyright (c) 2019 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. + +TEMPLATE = subdirs +SUBDIRS = app package +package.depends += app