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