aboutsummaryrefslogtreecommitdiffstats
path: root/launcher/src/applicationmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/src/applicationmodel.cpp')
-rw-r--r--launcher/src/applicationmodel.cpp46
1 files changed, 16 insertions, 30 deletions
diff --git a/launcher/src/applicationmodel.cpp b/launcher/src/applicationmodel.cpp
index 42982d5..d54d171 100644
--- a/launcher/src/applicationmodel.cpp
+++ b/launcher/src/applicationmodel.cpp
@@ -1,19 +1,9 @@
+// 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"
@@ -40,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;
}
}
@@ -63,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";
}
@@ -196,18 +187,13 @@ void ApplicationModel::updateApplist(QStringList info)
endResetModel();
}
-void ApplicationModel::initAppList(QString data)
+void ApplicationModel::initAppList(QList<QMap<QString, QString>> &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();
}