Make rooms in the room list bold when there's unread messages
This used to be a feature but kinda broke/changed when we switched to focusing on context-aware or notable events. Basically instead of only notable events making a room bold in the room list, it's any unread messages now.
This commit is contained in:
@@ -119,7 +119,7 @@ void RoomListModel::connectRoomSignals(NeoChatRoom *room)
|
|||||||
refresh(room, {DisplayNameRole});
|
refresh(room, {DisplayNameRole});
|
||||||
});
|
});
|
||||||
connect(room, &Room::unreadStatsChanged, this, [this, room] {
|
connect(room, &Room::unreadStatsChanged, this, [this, room] {
|
||||||
refresh(room, {ContextNotificationCountRole, HasHighlightNotificationsRole});
|
refresh(room, {ContextNotificationCountRole, HasHighlightNotificationsRole, NotificationCountRole});
|
||||||
});
|
});
|
||||||
connect(room, &Room::notificationCountChanged, this, [this, room] {
|
connect(room, &Room::notificationCountChanged, this, [this, room] {
|
||||||
refresh(room);
|
refresh(room);
|
||||||
@@ -271,6 +271,9 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
|
|||||||
if (role == IsDirectChat) {
|
if (role == IsDirectChat) {
|
||||||
return room->isDirectChat();
|
return room->isDirectChat();
|
||||||
}
|
}
|
||||||
|
if (role == NotificationCountRole) {
|
||||||
|
return room->notificationCount();
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@@ -304,6 +307,7 @@ QHash<int, QByteArray> RoomListModel::roleNames() const
|
|||||||
roles[RoomIdRole] = "roomId";
|
roles[RoomIdRole] = "roomId";
|
||||||
roles[IsChildSpaceRole] = "isChildSpace";
|
roles[IsChildSpaceRole] = "isChildSpace";
|
||||||
roles[IsDirectChat] = "isDirectChat";
|
roles[IsDirectChat] = "isDirectChat";
|
||||||
|
roles[NotificationCountRole] = "notificationCount";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public:
|
|||||||
IsChildSpaceRole, /**< Whether this space is a child of a different space. */
|
IsChildSpaceRole, /**< Whether this space is a child of a different space. */
|
||||||
ReplacementIdRole, /**< The room id of the room replacing this one, if any. */
|
ReplacementIdRole, /**< The room id of the room replacing this one, if any. */
|
||||||
IsDirectChat, /**< Whether this room is a direct chat. */
|
IsDirectChat, /**< Whether this room is a direct chat. */
|
||||||
|
NotificationCountRole, /**< Count of all notifications that also include non-notable events like unread messages. */
|
||||||
};
|
};
|
||||||
Q_ENUM(EventRoles)
|
Q_ENUM(EventRoles)
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ Delegates.RoundedItemDelegate {
|
|||||||
required property url avatar
|
required property url avatar
|
||||||
required property string subtitleText
|
required property string subtitleText
|
||||||
required property string displayName
|
required property string displayName
|
||||||
|
required property int notificationCount
|
||||||
|
|
||||||
property bool openOnClick: true
|
property bool openOnClick: true
|
||||||
property bool openOnDrag: false
|
property bool openOnDrag: false
|
||||||
@@ -28,7 +29,8 @@ Delegates.RoundedItemDelegate {
|
|||||||
|
|
||||||
property bool collapsed: false
|
property bool collapsed: false
|
||||||
|
|
||||||
readonly property bool hasNotifications: contextNotificationCount > 0
|
readonly property bool hasNotableNotifications: contextNotificationCount > 0
|
||||||
|
readonly property bool hasUnreadMessages: notificationCount > 0
|
||||||
|
|
||||||
dropAreaHovered: dropArea.containsDrag
|
dropAreaHovered: dropArea.containsDrag
|
||||||
|
|
||||||
@@ -86,7 +88,7 @@ Delegates.RoundedItemDelegate {
|
|||||||
|
|
||||||
notificationCount: root.contextNotificationCount
|
notificationCount: root.contextNotificationCount
|
||||||
notificationHighlight: root.hasHighlightNotifications
|
notificationHighlight: root.hasHighlightNotifications
|
||||||
showNotificationLabel: root.hasNotifications && root.collapsed
|
showNotificationLabel: root.hasNotableNotifications && root.collapsed
|
||||||
asynchronous: true
|
asynchronous: true
|
||||||
|
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
@@ -104,7 +106,7 @@ Delegates.RoundedItemDelegate {
|
|||||||
|
|
||||||
text: root.displayName
|
text: root.displayName
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font.weight: root.hasNotifications ? Font.Bold : Font.Normal
|
font.weight: root.hasUnreadMessages ? Font.Bold : Font.Normal
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
@@ -117,7 +119,7 @@ Delegates.RoundedItemDelegate {
|
|||||||
text: root.subtitleText
|
text: root.subtitleText
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font: Kirigami.Theme.smallFont
|
font: Kirigami.Theme.smallFont
|
||||||
opacity: root.hasNotifications ? 0.9 : 0.7
|
opacity: root.hasUnreadMessages ? 0.9 : 0.7
|
||||||
visible: !NeoChatConfig.compactRoomList && text.length > 0
|
visible: !NeoChatConfig.compactRoomList && text.length > 0
|
||||||
textFormat: Text.PlainText
|
textFormat: Text.PlainText
|
||||||
|
|
||||||
@@ -140,12 +142,12 @@ Delegates.RoundedItemDelegate {
|
|||||||
id: notificationCountLabel
|
id: notificationCountLabel
|
||||||
|
|
||||||
text: root.contextNotificationCount
|
text: root.contextNotificationCount
|
||||||
visible: root.hasNotifications && !root.collapsed
|
visible: root.hasNotableNotifications && !root.collapsed
|
||||||
color: Kirigami.Theme.textColor
|
color: Kirigami.Theme.textColor
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
visible: root.hasNotifications
|
visible: root.hasNotableNotifications
|
||||||
Kirigami.Theme.colorSet: Kirigami.Theme.Button
|
Kirigami.Theme.colorSet: Kirigami.Theme.Button
|
||||||
Kirigami.Theme.inherit: false
|
Kirigami.Theme.inherit: false
|
||||||
color: root.hasHighlightNotifications > 0 ? Kirigami.Theme.positiveTextColor : Kirigami.Theme.backgroundColor
|
color: root.hasHighlightNotifications > 0 ? Kirigami.Theme.positiveTextColor : Kirigami.Theme.backgroundColor
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ void RoomTreeModel::connectRoomSignals(NeoChatRoom *room)
|
|||||||
refreshRoomRoles(room, {DisplayNameRole});
|
refreshRoomRoles(room, {DisplayNameRole});
|
||||||
});
|
});
|
||||||
connect(room, &Room::unreadStatsChanged, this, [this, room] {
|
connect(room, &Room::unreadStatsChanged, this, [this, room] {
|
||||||
refreshRoomRoles(room, {ContextNotificationCountRole, HasHighlightNotificationsRole});
|
refreshRoomRoles(room, {ContextNotificationCountRole, HasHighlightNotificationsRole, NotificationCountRole});
|
||||||
if (room->isServerNoticeRoom()) {
|
if (room->isServerNoticeRoom()) {
|
||||||
Q_EMIT invalidateSort();
|
Q_EMIT invalidateSort();
|
||||||
}
|
}
|
||||||
@@ -294,6 +294,7 @@ QHash<int, QByteArray> RoomTreeModel::roleNames() const
|
|||||||
roles[DelegateTypeRole] = "delegateType";
|
roles[DelegateTypeRole] = "delegateType";
|
||||||
roles[IconRole] = "icon";
|
roles[IconRole] = "icon";
|
||||||
roles[RoomTypeRole] = "roomType";
|
roles[RoomTypeRole] = "roomType";
|
||||||
|
roles[NotificationCountRole] = "notificationCount";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,6 +397,9 @@ QVariant RoomTreeModel::data(const QModelIndex &index, int role) const
|
|||||||
return room->creation()->contentPart<QString>("type"_L1);
|
return room->creation()->contentPart<QString>("type"_L1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (role == NotificationCountRole) {
|
||||||
|
return room->notificationCount();
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
DelegateTypeRole,
|
DelegateTypeRole,
|
||||||
IconRole,
|
IconRole,
|
||||||
RoomTypeRole, /**< The room's type. */
|
RoomTypeRole, /**< The room's type. */
|
||||||
|
NotificationCountRole, /**< Count of all notifications that also include non-notable events like unread messages. */
|
||||||
};
|
};
|
||||||
Q_ENUM(EventRoles)
|
Q_ENUM(EventRoles)
|
||||||
explicit RoomTreeModel(QObject *parent = nullptr);
|
explicit RoomTreeModel(QObject *parent = nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user