X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=launcher%2Fsrc%2Fapplicationmodel.cpp;h=d54d171eb38aae699594c119c5d1ba1da584c92b;hb=5e828161fc1571323e2812a344f6714ae9331b2c;hp=261e43e12b4a4db6483a04d675ab198bea636ca8;hpb=259a07d696b455f22b13edcae107de67079036f3;p=apps%2Flauncher.git diff --git a/launcher/src/applicationmodel.cpp b/launcher/src/applicationmodel.cpp index 261e43e..d54d171 100644 --- a/launcher/src/applicationmodel.cpp +++ b/launcher/src/applicationmodel.cpp @@ -1,32 +1,20 @@ +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (C) 2016 The Qt Company Ltd. * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH * Copyright (c) 2018,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. + * Copyright (C) 2022 Konsulko Group */ #include "applicationmodel.h" #include "appinfo.h" -#include "hmi-debug.h" - -#include -#include - -#include "afm_user_daemon_proxy.h" +#include +#include +#include +#include -extern org::AGL::afm::user *afm_user_daemon_proxy; +#include "hmi-debug.h" class ApplicationModel::Private { @@ -42,13 +30,10 @@ public: namespace { QString get_icon_name(QJsonObject const &i) { - QString icon = i["name"].toString().toLower(); - - if ( !QFile::exists(QString(":/images/%1_active.svg").arg(icon)) || - !QFile::exists(QString(":/images/%1_inactive.svg").arg(icon)) ) - { + QString icon = i["icon"].toString(); + fprintf(stderr, "Looking for icon %s\n", icon.toLocal8Bit().data()); + if ( !QFile::exists(icon) ) icon = "blank"; - } return icon; } } @@ -65,9 +50,13 @@ void ApplicationModel::Private::addApp(QString icon, QString name, QString id) return; } - QString _icon = name.toLower(); - if ( !QFile::exists(QString(":/images/%1_active.svg").arg(_icon)) || - !QFile::exists(QString(":/images/%1_inactive.svg").arg(_icon)) ) + QString _icon; + if ( QFile::exists(icon) ) + { + _icon = QString("file:%1").arg(icon); + fprintf(stderr, "using icon '%s'\n", _icon.toLocal8Bit().data()); + } + else { _icon = "blank"; } @@ -198,18 +187,13 @@ void ApplicationModel::updateApplist(QStringList info) endResetModel(); } -void ApplicationModel::initAppList(QString data) +void ApplicationModel::initAppList(QList> &apps) { HMI_DEBUG("launcher","init application list."); beginResetModel(); - QJsonDocument japps = QJsonDocument::fromJson(data.toUtf8()); - for (auto const &app : japps.array()) { - QJsonObject const &jso = app.toObject(); - auto const name = jso["name"].toString(); - auto const id = jso["id"].toString(); - auto const icon = get_icon_name(jso); - - d->addApp(icon, name, id); + qDebug() << "ApplicationModel::initAppList: got " << apps.size() << " apps"; + for (int i = 0; i < apps.size(); i++) { + d->addApp(apps[i]["icon_path"], apps[i]["name"], apps[i]["id"]); } endResetModel(); }