mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Add unread notification color for user mentioned
When user is mentioned (via matrix 'highlight_count'), inactive rooms will use a different color for the notification circle than when only general unread messages exist.
This commit is contained in:
parent
d70bc94f61
commit
4185b8d121
9 changed files with 33 additions and 13 deletions
|
@ -90,6 +90,7 @@ RaisedButton {
|
|||
}
|
||||
|
||||
RoomInfoListItem {
|
||||
qproperty-mentionedColor: #a82353;
|
||||
qproperty-highlightedBackgroundColor: #4d84c7;
|
||||
qproperty-hoverBackgroundColor: rgba(230, 230, 230, 30);
|
||||
qproperty-backgroundColor: #2d3139;
|
||||
|
|
|
@ -87,6 +87,7 @@ RaisedButton {
|
|||
}
|
||||
|
||||
RoomInfoListItem {
|
||||
qproperty-mentionedColor: #a82353;
|
||||
qproperty-highlightedBackgroundColor: #38A3D8;
|
||||
qproperty-hoverBackgroundColor: rgba(200, 200, 200, 70);
|
||||
qproperty-hoverTitleColor: #f2f5f8;
|
||||
|
|
|
@ -86,6 +86,7 @@ QListWidget {
|
|||
}
|
||||
|
||||
RoomInfoListItem {
|
||||
qproperty-mentionedColor: palette(alternate-base);
|
||||
qproperty-highlightedBackgroundColor: palette(highlight);
|
||||
qproperty-hoverBackgroundColor: palette(base);
|
||||
qproperty-backgroundColor: palette(window);
|
||||
|
|
|
@ -546,7 +546,9 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
|||
|
||||
updateTypingUsers(room_id, room.second.ephemeral.typing);
|
||||
updateRoomNotificationCount(
|
||||
room_id, room.second.unread_notifications.notification_count);
|
||||
room_id,
|
||||
room.second.unread_notifications.notification_count,
|
||||
room.second.unread_notifications.highlight_count);
|
||||
|
||||
if (room.second.unread_notifications.notification_count > 0)
|
||||
hasNotifications = true;
|
||||
|
@ -908,9 +910,11 @@ ChatPage::setGroupViewState(bool isEnabled)
|
|||
}
|
||||
|
||||
void
|
||||
ChatPage::updateRoomNotificationCount(const QString &room_id, uint16_t notification_count)
|
||||
ChatPage::updateRoomNotificationCount(const QString &room_id,
|
||||
uint16_t notification_count,
|
||||
uint16_t highlight_count)
|
||||
{
|
||||
room_list_->updateUnreadMessageCount(room_id, notification_count);
|
||||
room_list_->updateUnreadMessageCount(room_id, notification_count, highlight_count);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -197,7 +197,9 @@ private:
|
|||
Memberships getMemberships(const std::vector<Collection> &events) const;
|
||||
|
||||
//! Update the room with the new notification count.
|
||||
void updateRoomNotificationCount(const QString &room_id, uint16_t notification_count);
|
||||
void updateRoomNotificationCount(const QString &room_id,
|
||||
uint16_t notification_count,
|
||||
uint16_t highlight_count);
|
||||
//! Send desktop notification for the received messages.
|
||||
void sendDesktopNotifications(const mtx::responses::Notifications &);
|
||||
|
||||
|
|
|
@ -101,6 +101,7 @@ RoomInfoListItem::RoomInfoListItem(QString room_id, RoomInfo info, QWidget *pare
|
|||
, roomName_{QString::fromStdString(std::move(info.name))}
|
||||
, isPressed_(false)
|
||||
, unreadMsgCount_(0)
|
||||
, unreadHighlightedMsgCount_(0)
|
||||
{
|
||||
init(parent);
|
||||
|
||||
|
@ -301,7 +302,11 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
|
|||
if (unreadMsgCount_ > 0) {
|
||||
QBrush brush;
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
brush.setColor(bubbleBgColor());
|
||||
if (unreadHighlightedMsgCount_ > 0) {
|
||||
brush.setColor(mentionedColor());
|
||||
} else {
|
||||
brush.setColor(bubbleBgColor());
|
||||
}
|
||||
|
||||
if (isPressed_)
|
||||
brush.setColor(bubbleFgColor());
|
||||
|
@ -354,9 +359,10 @@ RoomInfoListItem::paintEvent(QPaintEvent *event)
|
|||
}
|
||||
|
||||
void
|
||||
RoomInfoListItem::updateUnreadMessageCount(int count)
|
||||
RoomInfoListItem::updateUnreadMessageCount(int count, int highlightedCount)
|
||||
{
|
||||
unreadMsgCount_ = count;
|
||||
unreadMsgCount_ = count;
|
||||
unreadHighlightedMsgCount_ = highlightedCount;
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
@ -59,14 +59,15 @@ class RoomInfoListItem : public QWidget
|
|||
Q_PROPERTY(QColor hoverTitleColor READ hoverTitleColor WRITE setHoverTitleColor)
|
||||
Q_PROPERTY(QColor hoverSubtitleColor READ hoverSubtitleColor WRITE setHoverSubtitleColor)
|
||||
|
||||
Q_PROPERTY(QColor mentionedColor READ mentionedColor WRITE setMentionedColor)
|
||||
Q_PROPERTY(QColor btnColor READ btnColor WRITE setBtnColor)
|
||||
Q_PROPERTY(QColor btnTextColor READ btnTextColor WRITE setBtnTextColor)
|
||||
|
||||
public:
|
||||
RoomInfoListItem(QString room_id, RoomInfo info, QWidget *parent = 0);
|
||||
|
||||
void updateUnreadMessageCount(int count);
|
||||
void clearUnreadMessageCount() { updateUnreadMessageCount(0); };
|
||||
void updateUnreadMessageCount(int count, int highlightedCount);
|
||||
void clearUnreadMessageCount() { updateUnreadMessageCount(0, 0); };
|
||||
|
||||
QString roomId() { return roomId_; }
|
||||
bool isPressed() const { return isPressed_; }
|
||||
|
@ -97,6 +98,7 @@ public:
|
|||
|
||||
QColor bubbleFgColor() const { return bubbleFgColor_; }
|
||||
QColor bubbleBgColor() const { return bubbleBgColor_; }
|
||||
QColor mentionedColor() const { return mentionedFontColor_; }
|
||||
|
||||
void setHighlightedBackgroundColor(QColor &color) { highlightedBackgroundColor_ = color; }
|
||||
void setHoverBackgroundColor(QColor &color) { hoverBackgroundColor_ = color; }
|
||||
|
@ -120,6 +122,7 @@ public:
|
|||
|
||||
void setBubbleFgColor(QColor &color) { bubbleFgColor_ = color; }
|
||||
void setBubbleBgColor(QColor &color) { bubbleBgColor_ = color; }
|
||||
void setMentionedColor(QColor &color) { mentionedFontColor_ = color; }
|
||||
|
||||
void setRoomName(const QString &name) { roomName_ = name; }
|
||||
void setRoomType(bool isInvite)
|
||||
|
@ -184,7 +187,8 @@ private:
|
|||
bool isPressed_ = false;
|
||||
bool hasUnreadMessages_ = true;
|
||||
|
||||
int unreadMsgCount_ = 0;
|
||||
int unreadMsgCount_ = 0;
|
||||
int unreadHighlightedMsgCount_ = 0;
|
||||
|
||||
QColor highlightedBackgroundColor_;
|
||||
QColor hoverBackgroundColor_;
|
||||
|
@ -206,6 +210,7 @@ private:
|
|||
QRectF declineBtnRegion_;
|
||||
|
||||
// Fonts
|
||||
QColor mentionedFontColor_;
|
||||
QFont unreadCountFont_;
|
||||
int bubbleDiameter_;
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ RoomList::removeRoom(const QString &room_id, bool reset)
|
|||
}
|
||||
|
||||
void
|
||||
RoomList::updateUnreadMessageCount(const QString &roomid, int count)
|
||||
RoomList::updateUnreadMessageCount(const QString &roomid, int count, int highlightedCount)
|
||||
{
|
||||
if (!roomExists(roomid)) {
|
||||
nhlog::ui()->warn("updateUnreadMessageCount: unknown room_id {}",
|
||||
|
@ -151,7 +151,7 @@ RoomList::updateUnreadMessageCount(const QString &roomid, int count)
|
|||
return;
|
||||
}
|
||||
|
||||
rooms_[roomid]->updateUnreadMessageCount(count);
|
||||
rooms_[roomid]->updateUnreadMessageCount(count, highlightedCount);
|
||||
|
||||
calculateUnreadMessageCount();
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ signals:
|
|||
public slots:
|
||||
void updateRoomAvatar(const QString &roomid, const QPixmap &img);
|
||||
void highlightSelectedRoom(const QString &room_id);
|
||||
void updateUnreadMessageCount(const QString &roomid, int count);
|
||||
void updateUnreadMessageCount(const QString &roomid, int count, int highlightedCount);
|
||||
void updateRoomDescription(const QString &roomid, const DescInfo &info);
|
||||
void closeJoinRoomDialog(bool isJoining, QString roomAlias);
|
||||
void updateReadStatus(const std::map<QString, bool> &status);
|
||||
|
|
Loading…
Reference in a new issue