Skip to content

Commit

Permalink
Fix display of icons in dark/light theme.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Ayres <[email protected]>
  • Loading branch information
camilasan committed Sep 12, 2024
1 parent 2fdc382 commit b1cbb41
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,49 +226,44 @@ 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
|| a._syncFileItemStatus == SyncFileItem::FileLocked
|| 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("/");
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b1cbb41

Please sign in to comment.