Skip to content

Commit

Permalink
Replace dark/light icon roles with a single icon role in activity lis…
Browse files Browse the repository at this point in the history
…t model

We can just colour the relevant activity icon from QML based on the
palette text colour

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Nov 26, 2024
1 parent 3b1ff86 commit 5c54529
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/gui/tray/ActivityItemContent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ RowLayout {

cache: true
fillMode: Image.PreserveAspectFit
source: Style.darkMode ? model.darkIcon : model.lightIcon
source: model.icon + "/" + palette.text
sourceSize.height: 64
sourceSize.width: 64
mipmap: true // Addresses grainy downscale
Expand Down
7 changes: 2 additions & 5 deletions src/gui/tray/activitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ QHash<int, QByteArray> ActivityListModel::roleNames() const
roles[LinkRole] = "link";
roles[MessageRole] = "message";
roles[ActionRole] = "type";
roles[DarkIconRole] = "darkIcon";
roles[LightIconRole] = "lightIcon";
roles[IconRole] = "icon";
roles[ActionTextRole] = "subject";
roles[ActionsLinksRole] = "links";
roles[ActionsLinksContextMenuRole] = "linksContextMenu";
Expand Down Expand Up @@ -288,10 +287,8 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
return ActivityListModel::convertLinksToActionButtons(a);
}

case DarkIconRole:
case LightIconRole: {
case IconRole:
return generateIconPath();
}
case ObjectTypeRole:
return a._objectType;
case ObjectIdRole:
Expand Down
3 changes: 1 addition & 2 deletions src/gui/tray/activitylistmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class ActivityListModel : public QAbstractListModel

public:
enum DataRole {
DarkIconRole = Qt::UserRole + 1,
LightIconRole,
IconRole = Qt::UserRole + 1,
AccountRole,
ObjectTypeRole,
ObjectIdRole,
Expand Down
3 changes: 1 addition & 2 deletions test/testactivitylistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ private slots:

QVERIFY(!index.data(OCC::ActivityListModel::AccountRole).toString().isEmpty());
QVERIFY(!index.data(OCC::ActivityListModel::ActionTextColorRole).toString().isEmpty());
QVERIFY(!index.data(OCC::ActivityListModel::DarkIconRole).toString().isEmpty());
QVERIFY(!index.data(OCC::ActivityListModel::LightIconRole).toString().isEmpty());
QVERIFY(!index.data(OCC::ActivityListModel::IconRole).toString().isEmpty());
QVERIFY(!index.data(OCC::ActivityListModel::PointInTimeRole).toString().isEmpty());

QVERIFY(index.data(OCC::ActivityListModel::ObjectTypeRole).canConvert<int>());
Expand Down

0 comments on commit 5c54529

Please sign in to comment.