Skip to content

Commit

Permalink
Generate icon paths for activities as just svg custom color image pro…
Browse files Browse the repository at this point in the history
…vider based urls with no colouring

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Nov 26, 2024
1 parent c03c652 commit 3b1ff86
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
};

const auto generateIconPath = [&]() {
auto colorIconPath = role == DarkIconRole ? QStringLiteral("image://svgimage-custom-color/%1/white") : QStringLiteral("image://svgimage-custom-color/%1/black");
auto colorIconPath = QStringLiteral("image://svgimage-custom-color/%1");
if (a._type == Activity::NotificationType && !a._talkNotificationData.userAvatar.isEmpty()) {
return QStringLiteral("image://svgimage-custom-color/talk-bordered.svg");
} else if (a._type == Activity::SyncResultType) {
Expand All @@ -250,24 +250,16 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
} 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() ? colorIconPath.arg("add.svg") : colorIconPath.arg("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() ? colorIconPath.arg("delete.svg") : colorIconPath.arg("delete-bordered.svg");
} else {
return a._previews.empty() ? colorIconPath.arg(QStringLiteral("change.svg"))
: QStringLiteral("image://svgimage-custom-color/change-bordered.svg/");
return a._previews.empty() ? colorIconPath.arg("change.svg") : colorIconPath.arg("change-bordered.svg");
}
}
} else {
// We have an activity
if (a._icon.isEmpty()) {
return colorIconPath.arg("activity.svg");
}

const QString basePath = QStringLiteral("image://tray-image-provider/") % a._icon % QStringLiteral("/");
return role == DarkIconRole ? QString(basePath + QStringLiteral("white")) : QString(basePath + QStringLiteral("black"));
return a._icon.isEmpty() ? colorIconPath.arg("activity.svg") : colorIconPath.arg(a._icon);
}
};

Expand Down

0 comments on commit 3b1ff86

Please sign in to comment.