From 269d225511d6bbf7a237571dced5dad3e7d33f3c Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 22 Jun 2021 18:43:49 +0200 Subject: [PATCH 1/2] directly send the icon url for activities to teh qml component should allow usage of default cache from Image qml standard component Signed-off-by: Matthieu Gallien --- src/gui/tray/ActivityData.h | 1 - src/gui/tray/ActivityListModel.cpp | 21 +-------------------- src/gui/tray/ActivityListModel.h | 1 - 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/gui/tray/ActivityData.h b/src/gui/tray/ActivityData.h index f5d31e32c..11171bdfd 100644 --- a/src/gui/tray/ActivityData.h +++ b/src/gui/tray/ActivityData.h @@ -74,7 +74,6 @@ public: qint64 _expireAtMsecs = -1; QString _accName; QString _icon; - QString _iconData; // Stores information about the error int _status; diff --git a/src/gui/tray/ActivityListModel.cpp b/src/gui/tray/ActivityListModel.cpp index fb0b17e89..e22744b0c 100644 --- a/src/gui/tray/ActivityListModel.cpp +++ b/src/gui/tray/ActivityListModel.cpp @@ -178,11 +178,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const } } else { // We have an activity - if (!a._iconData.isEmpty()) { - const QString svgData = "data:image/svg+xml;utf8," + a._iconData; - return svgData; - } - return "qrc:///client/theme/black/activity.svg"; + return a._icon; } } case ObjectTypeRole: @@ -299,12 +295,6 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st a._dateTime = QDateTime::fromString(json.value("datetime").toString(), Qt::ISODate); a._icon = json.value("icon").toString(); - if (!a._icon.isEmpty()) { - auto *iconJob = new IconJob(QUrl(a._icon)); - iconJob->setProperty("activityId", a._id); - connect(iconJob, &IconJob::jobFinished, this, &ActivityListModel::slotIconDownloaded); - } - list.append(a); _currentItem = list.last()._id; @@ -325,15 +315,6 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st combineActivityLists(); } -void ActivityListModel::slotIconDownloaded(QByteArray iconData) -{ - for (auto i = 0; i < _activityLists.count(); i++) { - if (_activityLists[i]._id == sender()->property("activityId").toLongLong()) { - _activityLists[i]._iconData = iconData; - } - } -} - void ActivityListModel::addErrorToActivityList(Activity activity) { qCInfo(lcActivity) << "Error successfully added to the notification list: " << activity._subject; diff --git a/src/gui/tray/ActivityListModel.h b/src/gui/tray/ActivityListModel.h index d58c34cd7..554ac320f 100644 --- a/src/gui/tray/ActivityListModel.h +++ b/src/gui/tray/ActivityListModel.h @@ -84,7 +84,6 @@ public slots: private slots: void slotActivitiesReceived(const QJsonDocument &json, int statusCode); - void slotIconDownloaded(QByteArray iconData); signals: void activityJobStatusCode(int statusCode); From c27fc1be4a3cbae3b0b1fc29fa681184d54a3842 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 22 Jun 2021 21:44:22 +0200 Subject: [PATCH 2/2] use fallback icons for activities without icons Signed-off-by: Matthieu Gallien --- src/gui/tray/ActivityListModel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/tray/ActivityListModel.cpp b/src/gui/tray/ActivityListModel.cpp index e22744b0c..1a9a7578a 100644 --- a/src/gui/tray/ActivityListModel.cpp +++ b/src/gui/tray/ActivityListModel.cpp @@ -178,6 +178,10 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const } } else { // We have an activity + if (a._icon.isEmpty()) { + return "qrc:///client/theme/black/activity.svg"; + } + return a._icon; } }