Fix display of icons in dark/light theme.
authorCamila Ayres <hello@camilasan.com>
Thu, 12 Sep 2024 11:25:15 +0000 (13:25 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 13 Sep 2024 11:40:45 +0000 (11:40 +0000)
Signed-off-by: Camila Ayres <hello@camilasan.com>
src/gui/tray/activitylistmodel.cpp

index c35043807223decffa0768f74a0e2e0a8a8c2b47..2c3f368b793199520bfd39393d74feb75181d010 100644 (file)
@@ -226,19 +226,17 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
     };
 
     const auto generateIconPath = [&]() {
-        auto colorIconPath = role == DarkIconRole ? QStringLiteral("image://svgimage-custom-color/white/") : QStringLiteral("image://svgimage-custom-color/black/");
+        auto colorIconPath = role == DarkIconRole ? QStringLiteral("image://svgimage-custom-color/%1/white") : QStringLiteral("image://svgimage-custom-color/%1/black");
         if (a._type == Activity::NotificationType && !a._talkNotificationData.userAvatar.isEmpty()) {
             return QStringLiteral("image://svgimage-custom-color/talk-bordered.svg");
         } else if (a._type == Activity::SyncResultType) {
-            colorIconPath.append("state-error.svg");
-            return colorIconPath;
+            return colorIconPath.arg("state-error.svg");
         } else if (a._type == Activity::SyncFileItemType) {
             if (a._syncFileItemStatus == SyncFileItem::NormalError
                 || a._syncFileItemStatus == SyncFileItem::FatalError
                 || a._syncFileItemStatus == SyncFileItem::DetailError
                 || a._syncFileItemStatus == SyncFileItem::BlacklistedError) {
-                colorIconPath.append("state-error.svg");
-                return colorIconPath;
+                return colorIconPath.arg("state-error.svg");;
             } else if (a._syncFileItemStatus == SyncFileItem::SoftError
                 || a._syncFileItemStatus == SyncFileItem::Conflict
                 || a._syncFileItemStatus == SyncFileItem::Restoration
@@ -246,29 +244,26 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
                 || a._syncFileItemStatus == SyncFileItem::FileNameInvalid
                 || a._syncFileItemStatus == SyncFileItem::FileNameInvalidOnServer
                 || a._syncFileItemStatus == SyncFileItem::FileNameClash) {
-                colorIconPath.append("state-warning.svg");
-                return colorIconPath;
+                return colorIconPath.arg("state-warning.svg");;
             } else if (a._syncFileItemStatus == SyncFileItem::FileIgnored) {
-                colorIconPath.append("state-info.svg");
-                return colorIconPath;
+                return colorIconPath.arg("state-info.svg");
             } else {
                 // File sync successful
                 if (a._fileAction == "file_created") {
-                    return a._previews.empty() ? QStringLiteral("image://svgimage-custom-color/add.svg")
-                                               : QStringLiteral("image://svgimage-custom-color/add-bordered.svg");
+                    return a._previews.empty() ? QStringLiteral("image://svgimage-custom-color/add.svg/")
+                                               : QStringLiteral("image://svgimage-custom-color/add-bordered.svg/");
                 } else if (a._fileAction == "file_deleted") {
-                    return a._previews.empty() ? QStringLiteral("image://svgimage-custom-color/delete.svg")
-                                               : QStringLiteral("image://svgimage-custom-color/delete-bordered.svg");
+                    return a._previews.empty() ? QStringLiteral("image://svgimage-custom-color/delete.svg/")
+                                               : QStringLiteral("image://svgimage-custom-color/delete-bordered.svg/");
                 } else {
-                    return a._previews.empty() ? colorIconPath % QStringLiteral("change.svg")
-                                               : QStringLiteral("image://svgimage-custom-color/change-bordered.svg");
+                    return a._previews.empty() ? colorIconPath.arg(QStringLiteral("change.svg"))
+                                               : QStringLiteral("image://svgimage-custom-color/change-bordered.svg/");
                 }
             }
         } else {
             // We have an activity
             if (a._icon.isEmpty()) {
-                colorIconPath.append("activity.svg");
-                return colorIconPath;
+                return colorIconPath.arg("activity.svg");;
             }
 
             const QString basePath = QStringLiteral("image://tray-image-provider/") % a._icon % QStringLiteral("/");
@@ -302,8 +297,9 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
     }
 
     case DarkIconRole:
-    case LightIconRole:
+    case LightIconRole: {
         return generateIconPath();
+    }
     case ObjectTypeRole:
         return a._objectType;
     case ObjectIdRole:
@@ -511,7 +507,7 @@ void ActivityListModel::insertOrRemoveDummyFetchingActivity()
         _dummyFetchingActivities._objectType = dummyFetchingActivityObjectType;
         _dummyFetchingActivities._subject = tr("Fetching activities …");
         _dummyFetchingActivities._dateTime = QDateTime::currentDateTime();
-        _dummyFetchingActivities._icon = QLatin1String("image://svgimage-custom-color/change-bordered.svg");
+        _dummyFetchingActivities._icon = QLatin1String("image://svgimage-custom-color/change-bordered.svg/");
 
         addEntriesToActivityList({_dummyFetchingActivities});
     } else if (!_finalList.isEmpty() && _finalList.first()._objectType == dummyFetchingActivityObjectType) {