diff options
author | Matthieu Gallien <matthieu_gallien@yahoo.fr> | 2022-03-28 16:20:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-28 16:20:08 +0300 |
commit | c450c1f6a5277f8a71bf826e84e84250801c5311 (patch) | |
tree | 60da0556fe698a8cfc046ef12c5fb7f58a43ba2a /src/gui/tray/activitylistmodel.cpp | |
parent | 1d663851194b74364e9ccc5541c9070aea86e7a1 (diff) | |
parent | 3d086ae3053742b0493969ba0c0eaf1757d2e5b2 (diff) |
Merge pull request #4371 from nextcloud/bugfix/darkmode
Fix various dark mode bugs
Diffstat (limited to 'src/gui/tray/activitylistmodel.cpp')
-rw-r--r-- | src/gui/tray/activitylistmodel.cpp | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/src/gui/tray/activitylistmodel.cpp b/src/gui/tray/activitylistmodel.cpp index 63733b8be..ff50ae0d0 100644 --- a/src/gui/tray/activitylistmodel.cpp +++ b/src/gui/tray/activitylistmodel.cpp @@ -62,7 +62,8 @@ QHash<int, QByteArray> ActivityListModel::roleNames() const roles[LinkRole] = "link"; roles[MessageRole] = "message"; roles[ActionRole] = "type"; - roles[ActionIconRole] = "icon"; + roles[DarkIconRole] = "darkIcon"; + roles[LightIconRole] = "lightIcon"; roles[ActionTextRole] = "subject"; roles[ActionsLinksRole] = "links"; roles[ActionsLinksContextMenuRole] = "linksContextMenu"; @@ -192,31 +193,8 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const }); }; - switch (role) { - case DisplayPathRole: - return getDisplayPath(); - case PathRole: - return QFileInfo(getFilePath()).path(); - case DisplayLocationRole: - return displayLocation(); - case ActionsLinksRole: { - QList<QVariant> customList; - foreach (ActivityLink activityLink, a._links) { - customList << QVariant::fromValue(activityLink); - } - return customList; - } - - case ActionsLinksContextMenuRole: { - return ActivityListModel::convertLinksToMenuEntries(a); - } - - case ActionsLinksForActionButtonsRole: { - return ActivityListModel::convertLinksToActionButtons(a); - } - - case ActionIconRole: { - auto colorIconPath = QStringLiteral("qrc:///client/theme/__COLOR__/"); // We will replace __COLOR__ in QML + const auto generateIconPath = [&]() { + auto colorIconPath = role == DarkIconRole ? QStringLiteral("qrc:///client/theme/white/") : QStringLiteral("qrc:///client/theme/black/"); if (a._type == Activity::NotificationType) { colorIconPath.append("bell.svg"); return colorIconPath; @@ -255,14 +233,40 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const } } else { // We have an activity - if (a._icon.isEmpty()) { + if (a._darkIcon.isEmpty()) { colorIconPath.append("activity.svg"); return colorIconPath; } + return role == DarkIconRole ? a._darkIcon : a._lightIcon; + } + }; - return a._icon; + switch (role) { + case DisplayPathRole: + return getDisplayPath(); + case PathRole: + return QFileInfo(getFilePath()).path(); + case DisplayLocationRole: + return displayLocation(); + case ActionsLinksRole: { + QList<QVariant> customList; + foreach (ActivityLink activityLink, a._links) { + customList << QVariant::fromValue(activityLink); } + return customList; + } + + case ActionsLinksContextMenuRole: { + return ActivityListModel::convertLinksToMenuEntries(a); + } + + case ActionsLinksForActionButtonsRole: { + return ActivityListModel::convertLinksToActionButtons(a); } + + case DarkIconRole: + case LightIconRole: + return generateIconPath(); case ObjectTypeRole: return a._objectType; case ObjectIdRole: @@ -400,20 +404,6 @@ void ActivityListModel::ingestActivities(const QJsonArray &activities) auto a = Activity::fromActivityJson(json, _accountState->account()); - auto colorIconPath = QStringLiteral("qrc:///client/theme/__COLOR__/"); - if(a._icon.contains("change.svg")) { - colorIconPath.append("change.svg"); - a._icon = colorIconPath; - } else if(a._icon.contains("calendar.svg")) { - colorIconPath.append("calendar.svg"); - a._icon = colorIconPath; - } else if(a._icon.contains("personal.svg")) { - colorIconPath.append("user.svg"); - a._icon = colorIconPath; - } else if(a._icon.contains("core/img/actions")) { - a._icon.insert(a._icon.indexOf(".svg"), "__WHITE_GOES_HERE__"); - } - list.append(a); _currentItem = list.last()._id; |