From d1c328de1acd2423cf346151fb7e3582ebe946b5 Mon Sep 17 00:00:00 2001 From: Alexandra Betouni Date: Wed, 6 Jun 2018 18:06:41 +0200 Subject: [sysui] Renamed IntentsInterface & related components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Renamed to ApplicationRequesHandler Change-Id: Ia8ed48383c870ed2a09150f05d0af08ddd375960 Reviewed-by: Lukáš Tinkl Reviewed-by: Bramastyo Harimukti Santoso --- apps/com.pelagicore.music/stores/MusicStore.qml | 10 +- apps/com.pelagicore.tuner/stores/TunerStore.qml | 12 +- imports/system/intents/IntentsInterface.qml | 150 --------------------- imports/system/intents/qmldir | 1 - .../system/models/application/ApplicationModel.qml | 10 +- .../system/requests/ApplicationRequestHandler.qml | 150 +++++++++++++++++++++ imports/system/requests/qmldir | 1 + sysui/display/Display.qml | 2 +- sysui/ipc/MusicAppRequestsIPC.qml | 107 +++++++++++++++ sysui/ipc/MusicIntentsIPC.qml | 107 --------------- sysui/ipc/qmldir | 2 +- 11 files changed, 276 insertions(+), 276 deletions(-) delete mode 100644 imports/system/intents/IntentsInterface.qml delete mode 100644 imports/system/intents/qmldir create mode 100644 imports/system/requests/ApplicationRequestHandler.qml create mode 100644 imports/system/requests/qmldir create mode 100644 sysui/ipc/MusicAppRequestsIPC.qml delete mode 100644 sysui/ipc/MusicIntentsIPC.qml diff --git a/apps/com.pelagicore.music/stores/MusicStore.qml b/apps/com.pelagicore.music/stores/MusicStore.qml index e31102fa..eb8f054f 100644 --- a/apps/com.pelagicore.music/stores/MusicStore.qml +++ b/apps/com.pelagicore.music/stores/MusicStore.qml @@ -130,8 +130,8 @@ Store { property Item ipc: Item { ApplicationInterfaceExtension { - id: musicIntentsInterface - name: "neptune.musicintents.interface" + id: musicApplicationRequestIPC + name: "neptune.musicapprequests.interface" Component.onCompleted: { if (object.webradioInstalled) { musicSourcesModel.append({"text" : "Web radio"}); @@ -143,10 +143,10 @@ Store { } Connections { - target: musicIntentsInterface.object + target: musicApplicationRequestIPC.object onSpotifyInstalledChanged: { - if (musicIntentsInterface.object.spotifyInstalled) { + if (musicApplicationRequestIPC.object.spotifyInstalled) { musicSourcesModel.append({"text" : "Spotify"}); } else { for (var i = 0; i < musicSourcesModel.count; i++) { @@ -157,7 +157,7 @@ Store { } } onWebradioInstalledChanged: { - if (musicIntentsInterface.object.webradioInstalled) { + if (musicApplicationRequestIPC.object.webradioInstalled) { musicSourcesModel.append({"text" : "Web radio"}); } else { for (var i = 0; i < musicSourcesModel.count; i++) { diff --git a/apps/com.pelagicore.tuner/stores/TunerStore.qml b/apps/com.pelagicore.tuner/stores/TunerStore.qml index 811ef78c..1062335a 100644 --- a/apps/com.pelagicore.tuner/stores/TunerStore.qml +++ b/apps/com.pelagicore.tuner/stores/TunerStore.qml @@ -83,9 +83,9 @@ Store { } property var ipc: QtObject { - property var musicIntentsInterface: ApplicationInterfaceExtension { - id: musicIntentsInterface - name: "neptune.musicintents.interface" + property var musicApplicationRequestIPC: ApplicationInterfaceExtension { + id: musicApplicationRequestIPC + name: "neptune.musicapprequests.interface" Component.onCompleted: { if (object.webradioInstalled) { musicSourcesModel.append({"text" : "Web radio"}); @@ -97,10 +97,10 @@ Store { } property var ipcConx: Connections { - target: musicIntentsInterface.object + target: musicApplicationRequestIPC.object onSpotifyInstalledChanged: { - if (musicIntentsInterface.object.spotifyInstalled) { + if (musicApplicationRequestIPC.object.spotifyInstalled) { musicSourcesModel.append({"text" : "Spotify"}); } else { for (var i = 0; i < musicSourcesModel.count; i++) { @@ -111,7 +111,7 @@ Store { } } onWebradioInstalledChanged: { - if (musicIntentsInterface.object.webradioInstalled) { + if (musicApplicationRequestIPC.object.webradioInstalled) { musicSourcesModel.append({"text" : "Web radio"}); } else { for (var i = 0; i < musicSourcesModel.count; i++) { diff --git a/imports/system/intents/IntentsInterface.qml b/imports/system/intents/IntentsInterface.qml deleted file mode 100644 index 52b33bb6..00000000 --- a/imports/system/intents/IntentsInterface.qml +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Neptune 3 IVI UI. -** -** $QT_BEGIN_LICENSE:GPL-QTAS$ -** Commercial License Usage -** Licensees holding valid commercial Qt Automotive Suite licenses may use -** this file in accordance with the commercial license agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and The Qt Company. For -** licensing terms and conditions see https://www.qt.io/terms-conditions. -** For further information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** SPDX-License-Identifier: GPL-3.0 -** -****************************************************************************/ -import QtQuick 2.10 -import QtApplicationManager 1.0 - -/*! - \qmltype IntentsInterface - \inqmlmodule intent - \inherits QtObject - \since 5.11 - \brief An object used to perform actions. - - The IntentsInterface is not meant to be used as is in the system, instead it is - acting as the receiver of the requests coming from the applications using the - Qt.openUrlExternally function as shown in the example below. - - \section2 Example Usage - - \qml - - Button { - id: openTunerApp - onClicked: { - Qt.openUrlExternally("x-tuner://"); - } - } - - Button { - id: openPhoneAppBluetoothMenu - onClicked: { - Qt.openUrlExternally("x-phone://settings/bluetooth"); - } - } - - \endqml - - The interface to act on Intent requests. An intent request is used to request an - application to just open or open in a certain state. That said, the action should - be possible to be performed from wherever in the system. An application could call - the Qt.openUrlExternally() function passing as parameter the mime-type of the - application that is intended to be opened, followed by the desired url indicating what - the application should do when opening. For this to be successful, the respective mime-Types - should be added accordingly to the applications' info.yaml files (example: mimeTypes: - [ 'x-scheme-handler/x-tuner' ]) The ApplicationManager will then consult its internal - database of applications looking for a match with x-scheme-handler/x-mimeType. If there - is a successful match, then the openUrlRequested signal will be emitted and its receiver - (IntentsInterface) can then either acknowledge the request by calling acknowledgeOpenUrlRequest - function or reject (rejectOpenUrlRequest). If then the application is started, the url is - supplied to the application as a document through the signal openDocument(string - documentUrl, string mimeType) via its ApplicationInterface. -*/ - -QtObject { - id: root - - /*! - \qmlproperty string IntentsInterface::activeAppId - - This property holds the active application id. It is used to store the active application id - before an intent request is submitted in order to be able to navigate back to it accordingly. - */ - - property string activeAppId: "" - - /*! - \qmlproperty var IntentsInterface::history - - This property holds the history of activities started and it's used for a sequential - navigation back to the initial state - */ - - - property var history: [] - - /*! - \qmlproperty var IntentsInterface::appManConns - \readonly - - This property is used to listen to the ApplicationManager and get the request from other - applications. - */ - - readonly property var appManConns: Connections { - target: ApplicationManager - onOpenUrlRequested: { - sendRequest(requestId, possibleAppIds); - } - } - - /*! - \qmlmethod IntentsInterface::sendRequest(id, params) - - Requests the action to be taken in the UI. It uses the Application Managers' acknowledgeOpenUrlRequest - function to open the requested application passing the given url to it. It also keeps and - updates the history with all the steps performed each time the function is called. - */ - - function sendRequest(reqId, id) { - //store in history previous app id - history.push(activeAppId); - ApplicationManager.acknowledgeOpenUrlRequest(reqId, id); - //store in history new app id - history.push(id); - } - - /*! - \qmlmethod IntentsInterface::goBack() - - The goBack function returns to the previous state from a requested action based on the history. - It also takes care of updating the history accordingly. - */ - - function goBack() { - if (history.length >= 1) { - history.pop(); - ApplicationManager.startApplication(history[history.length - 1]); - if (history.length === 1) { - history = []; - } - } - } -} diff --git a/imports/system/intents/qmldir b/imports/system/intents/qmldir deleted file mode 100644 index 5ed2d57d..00000000 --- a/imports/system/intents/qmldir +++ /dev/null @@ -1 +0,0 @@ -IntentsInterface 1.0 IntentsInterface.qml diff --git a/imports/system/models/application/ApplicationModel.qml b/imports/system/models/application/ApplicationModel.qml index e65af69b..463d4c09 100644 --- a/imports/system/models/application/ApplicationModel.qml +++ b/imports/system/models/application/ApplicationModel.qml @@ -31,7 +31,7 @@ import QtQuick 2.8 import QtApplicationManager 1.0 as AM -import intents 1.0 +import requests 1.0 /* A list of ApplicationInfo objects. @@ -77,8 +77,8 @@ ListModel { function goBack() { //if an intent is requested - if (d.intentsInterface.history.length > 1) { - d.intentsInterface.goBack(); + if (d.applicationRequestHandler.history.length > 1) { + d.applicationRequestHandler.goBack(); } else { //else return to home goHome(); @@ -103,8 +103,8 @@ ListModel { property var activeAppInfo: null property var instrumentClusterAppInfo: null property var populating: true - property IntentsInterface intentsInterface: IntentsInterface { - id: intentsInterface + property ApplicationRequestHandler applicationRequestHandler: ApplicationRequestHandler { + id: applicationRequestHandler activeAppId: activeAppInfo ? activeAppInfo.id : "" } readonly property var logCat: LoggingCategory { diff --git a/imports/system/requests/ApplicationRequestHandler.qml b/imports/system/requests/ApplicationRequestHandler.qml new file mode 100644 index 00000000..0dcf85a3 --- /dev/null +++ b/imports/system/requests/ApplicationRequestHandler.qml @@ -0,0 +1,150 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ +import QtQuick 2.10 +import QtApplicationManager 1.0 + +/*! + \qmltype ApplicationRequestHandler + \inqmlmodule requests + \inherits QtObject + \since 5.11 + \brief An object used to perform actions. + + The ApplicationRequestHandler is not meant to be used as is in the system, instead it is + acting as the receiver of the requests coming from the applications using the + Qt.openUrlExternally function as shown in the example below. + + \section2 Example Usage + + \qml + + Button { + id: openTunerApp + onClicked: { + Qt.openUrlExternally("x-tuner://"); + } + } + + Button { + id: openPhoneAppBluetoothMenu + onClicked: { + Qt.openUrlExternally("x-phone://settings/bluetooth"); + } + } + + \endqml + + The interface to act on application requests. A request is used to instruct an + application to just open or open in a certain state. That said, the action should + be possible to be performed from wherever in the system. An application could call + the Qt.openUrlExternally() function passing as parameter the mime-type of the + application that is intended to be opened, followed by the desired url indicating what + the application should do when opening. For this to be successful, the respective mime-Types + should be added accordingly to the applications' info.yaml files (example: mimeTypes: + [ 'x-scheme-handler/x-tuner' ]) The ApplicationManager will then consult its internal + database of applications looking for a match with x-scheme-handler/x-mimeType. If there + is a successful match, then the openUrlRequested signal will be emitted and its receiver + (ApplicationRequestHandler) can then either acknowledge the request by calling + acknowledgeOpenUrlRequest function or reject (rejectOpenUrlRequest). If then the application + is started, the url is supplied to the application as a document through the signal + openDocument(string documentUrl, string mimeType) via its ApplicationInterface. +*/ + +QtObject { + id: root + + /*! + \qmlproperty string ApplicationRequestHandler ::activeAppId + + This property holds the active application id. It is used to store the active application id + before an intent request is submitted in order to be able to navigate back to it accordingly. + */ + + property string activeAppId: "" + + /*! + \qmlproperty var ApplicationRequestHandler::history + + This property holds the history of activities started and it's used for a sequential + navigation back to the initial state + */ + + + property var history: [] + + /*! + \qmlproperty var ApplicationRequestHandler::appManConns + \readonly + + This property is used to listen to the ApplicationManager and get the request from other + applications. + */ + + readonly property var appManConns: Connections { + target: ApplicationManager + onOpenUrlRequested: { + sendRequest(requestId, possibleAppIds); + } + } + + /*! + \qmlmethod ApplicationRequestHandler::sendRequest(id, params) + + Requests the action to be taken in the UI. It uses the Application Managers' acknowledgeOpenUrlRequest + function to open the requested application passing the given url to it. It also keeps and + updates the history with all the steps performed each time the function is called. + */ + + function sendRequest(reqId, id) { + //store in history previous app id + history.push(activeAppId); + ApplicationManager.acknowledgeOpenUrlRequest(reqId, id); + //store in history new app id + history.push(id); + } + + /*! + \qmlmethod ApplicationRequestHandler::goBack() + + The goBack function returns to the previous state from a requested action based on the history. + It also takes care of updating the history accordingly. + */ + + function goBack() { + if (history.length >= 1) { + history.pop(); + ApplicationManager.startApplication(history[history.length - 1]); + if (history.length === 1) { + history = []; + } + } + } +} diff --git a/imports/system/requests/qmldir b/imports/system/requests/qmldir new file mode 100644 index 00000000..4853352e --- /dev/null +++ b/imports/system/requests/qmldir @@ -0,0 +1 @@ +ApplicationRequestHandler 1.0 ApplicationRequestHandler.qml diff --git a/sysui/display/Display.qml b/sysui/display/Display.qml index 2c1d2848..325276a3 100644 --- a/sysui/display/Display.qml +++ b/sysui/display/Display.qml @@ -90,7 +90,7 @@ Item { localeCode: Style.languageLocale } - property var musicIntentsIPC: MusicIntentsIPC { } + property var musicAppRequestsIPC: MusicAppRequestsIPC { } signal screenshotRequested() diff --git a/sysui/ipc/MusicAppRequestsIPC.qml b/sysui/ipc/MusicAppRequestsIPC.qml new file mode 100644 index 00000000..2489e100 --- /dev/null +++ b/sysui/ipc/MusicAppRequestsIPC.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Pelagicore AG +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Neptune 3 IVI UI. +** +** $QT_BEGIN_LICENSE:GPL-QTAS$ +** Commercial License Usage +** Licensees holding valid commercial Qt Automotive Suite licenses may use +** this file in accordance with the commercial license agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and The Qt Company. For +** licensing terms and conditions see https://www.qt.io/terms-conditions. +** For further information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 or (at your option) any later version +** approved by the KDE Free Qt Foundation. The licenses are as published by +** the Free Software Foundation and appearing in the file LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +** SPDX-License-Identifier: GPL-3.0 +** +****************************************************************************/ + +import QtQuick 2.0 +import QtApplicationManager 1.0 + +/*! + \qmltype MusicAppRequestsIPC + \inqmlmodule service + \inherits ApplicationIPCInterface + \since 5.11 + \brief An IPC for music application requests + + The MusicaAppRequestsIPC is meant to be used only for the music requests use case, enabling music, + tuner and webradio apps to know whether spotify and/or webradio are installed from the appstore, + or added / removed. This interface can be accessed only from the mentioned apps. +*/ + +ApplicationIPCInterface { + id: root + + /*! + \qmlproperty rect MusicAppRequestsIPC::spotifyInstalled + + This property holds whether spotify application is installed or not in Neptune 3. + */ + + property bool spotifyInstalled: false + + /*! + \qmlproperty rect MusicAppRequestsIPC::webradioInstalled + + This property holds whether web radio application is installed or not in Neptune 3. + */ + + property bool webradioInstalled: false + + /*! + \qmlproperty rect MusicAppRequestsIPC::appmanCnx + + This property is used to listen to the ApplicationManager to get the status of + external application in Neptune 3. + */ + + property var appmanCnx: Connections { + target: ApplicationManager + onApplicationAdded: { + if (id === "com.pelagicore.spotify") { + root.spotifyInstalled = true; + } + if (id === "com.pelagicore.webradio") { + root.webradioInstalled = true; + } + } + onApplicationAboutToBeRemoved: { + if (id === "com.pelagicore.spotify") { + root.spotifyInstalled = false; + } + if (id === "com.pelagicore.webradio") { + root.webradioInstalled = false; + } + } + } + + Component.onCompleted: { + ApplicationIPCManager.registerInterface(root, "neptune.musicapprequests.interface", + { "applicationIds": [ "com.pelagicore.music", + "com.pelagicore.tuner", + "com.pelagicore.webradio" ] }) + + if (ApplicationManager.applicationIds().indexOf("com.pelagicore.spotify") >= 0) { + root.spotifyInstalled = true; + } + + if (ApplicationManager.applicationIds().indexOf("com.pelagicore.webradio") >= 0) { + root.webradioInstalled = true; + } + } +} diff --git a/sysui/ipc/MusicIntentsIPC.qml b/sysui/ipc/MusicIntentsIPC.qml deleted file mode 100644 index 8c44cbeb..00000000 --- a/sysui/ipc/MusicIntentsIPC.qml +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Neptune 3 IVI UI. -** -** $QT_BEGIN_LICENSE:GPL-QTAS$ -** Commercial License Usage -** Licensees holding valid commercial Qt Automotive Suite licenses may use -** this file in accordance with the commercial license agreement provided -** with the Software or, alternatively, in accordance with the terms -** contained in a written agreement between you and The Qt Company. For -** licensing terms and conditions see https://www.qt.io/terms-conditions. -** For further information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -** SPDX-License-Identifier: GPL-3.0 -** -****************************************************************************/ - -import QtQuick 2.0 -import QtApplicationManager 1.0 - -/*! - \qmltype MusicIntentsIPC - \inqmlmodule service - \inherits ApplicationIPCInterface - \since 5.11 - \brief An IPC for music intents - - The MusicIntentsIPC is meant to be used only for the music intents use case, enabling music, - tuner and webradio apps to know whether spotify and/or webradio are installed from the appstore, - or added / removed. This interface can be accessed only from the mentioned apps. -*/ - -ApplicationIPCInterface { - id: root - - /*! - \qmlproperty rect MusicIntentsIPC::spotifyInstalled - - This property holds whether spotify application is installed or not in Neptune 3. - */ - - property bool spotifyInstalled: false - - /*! - \qmlproperty rect MusicIntentsIPC::webradioInstalled - - This property holds whether web radio application is installed or not in Neptune 3. - */ - - property bool webradioInstalled: false - - /*! - \qmlproperty rect MusicIntentsIPC::appmanCnx - - This property is used to listen to the ApplicationManager to get the status of - external application in Neptune 3. - */ - - property var appmanCnx: Connections { - target: ApplicationManager - onApplicationAdded: { - if (id === "com.pelagicore.spotify") { - root.spotifyInstalled = true; - } - if (id === "com.pelagicore.webradio") { - root.webradioInstalled = true; - } - } - onApplicationAboutToBeRemoved: { - if (id === "com.pelagicore.spotify") { - root.spotifyInstalled = false; - } - if (id === "com.pelagicore.webradio") { - root.webradioInstalled = false; - } - } - } - - Component.onCompleted: { - ApplicationIPCManager.registerInterface(root, "neptune.musicintents.interface", - { "applicationIds": [ "com.pelagicore.music", - "com.pelagicore.tuner", - "com.pelagicore.webradio" ] }) - - if (ApplicationManager.applicationIds().indexOf("com.pelagicore.spotify") >= 0) { - root.spotifyInstalled = true; - } - - if (ApplicationManager.applicationIds().indexOf("com.pelagicore.webradio") >= 0) { - root.webradioInstalled = true; - } - } -} diff --git a/sysui/ipc/qmldir b/sysui/ipc/qmldir index dd9bb2c1..953551e5 100644 --- a/sysui/ipc/qmldir +++ b/sysui/ipc/qmldir @@ -1 +1 @@ -MusicIntentsIPC 1.0 MusicIntentsIPC.qml +MusicAppRequestsIPC 1.0 MusicAppRequestsIPC.qml -- cgit v1.2.3