Highlight higlight tweaks in the timeline

fixes #400
fixes #1136
This commit is contained in:
Nicolas Werner 2022-11-01 23:26:21 +01:00
parent 231bebba44
commit 40ac55ddd9
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
5 changed files with 40 additions and 0 deletions

View file

@ -415,6 +415,7 @@ Item {
required property string callType required property string callType
required property var reactions required property var reactions
required property int trustlevel required property int trustlevel
required property int notificationlevel
required property int encryptionError required property int encryptionError
required property var timestamp required property var timestamp
required property int status required property int status
@ -482,6 +483,7 @@ Item {
callType: wrapper.callType callType: wrapper.callType
reactions: wrapper.reactions reactions: wrapper.reactions
trustlevel: wrapper.trustlevel trustlevel: wrapper.trustlevel
notificationlevel: wrapper.notificationlevel
encryptionError: wrapper.encryptionError encryptionError: wrapper.encryptionError
timestamp: wrapper.timestamp timestamp: wrapper.timestamp
status: wrapper.status status: wrapper.status

View file

@ -41,6 +41,7 @@ AbstractButton {
required property string callType required property string callType
required property var reactions required property var reactions
required property int trustlevel required property int trustlevel
required property int notificationlevel
required property int encryptionError required property int encryptionError
required property int duration required property int duration
required property var timestamp required property var timestamp
@ -117,6 +118,8 @@ AbstractButton {
property color bgColor: Nheko.colors.base property color bgColor: Nheko.colors.base
color: (Settings.bubbles && !isStateEvent) ? Qt.tint(bgColor, Qt.hsla(userColor.hslHue, 0.5, userColor.hslLightness, 0.2)) : "#00000000" color: (Settings.bubbles && !isStateEvent) ? Qt.tint(bgColor, Qt.hsla(userColor.hslHue, 0.5, userColor.hslLightness, 0.2)) : "#00000000"
radius: 4 radius: 4
border.width: r.notificationlevel == MtxEvent.Highlight ? 2 : 0
border.color: Nheko.theme.red
GridLayout { GridLayout {
anchors { anchors {

View file

@ -78,6 +78,11 @@ public:
//! Check if the given room is currently open. //! Check if the given room is currently open.
bool isRoomActive(const QString &room_id); bool isRoomActive(const QString &room_id);
const std::unique_ptr<mtx::pushrules::PushRuleEvaluator> &pushruleEvaluator() const
{
return pushrules;
}
public slots: public slots:
bool handleMatrixUri(QString uri); bool handleMatrixUri(QString uri);
bool handleMatrixUri(const QUrl &uri); bool handleMatrixUri(const QUrl &uri);

View file

@ -526,6 +526,7 @@ TimelineModel::roleNames() const
{IsEncrypted, "isEncrypted"}, {IsEncrypted, "isEncrypted"},
{IsStateEvent, "isStateEvent"}, {IsStateEvent, "isStateEvent"},
{Trustlevel, "trustlevel"}, {Trustlevel, "trustlevel"},
{Notificationlevel, "notificationlevel"},
{EncryptionError, "encryptionError"}, {EncryptionError, "encryptionError"},
{ReplyTo, "replyTo"}, {ReplyTo, "replyTo"},
{ThreadId, "threadId"}, {ThreadId, "threadId"},
@ -737,6 +738,26 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
return crypto::Trust::Unverified; return crypto::Trust::Unverified;
} }
case Notificationlevel: {
const auto &push = ChatPage::instance()->pushruleEvaluator();
if (push) {
auto actions = push->evaluate({event}, pushrulesRoomContext());
if (std::find(actions.begin(),
actions.end(),
mtx::pushrules::actions::Action{
mtx::pushrules::actions::set_tweak_highlight{}}) != actions.end()) {
return qml_mtx_events::NotificationLevel::Highlight;
}
if (std::find(actions.begin(),
actions.end(),
mtx::pushrules::actions::Action{mtx::pushrules::actions::notify{}}) !=
actions.end()) {
return qml_mtx_events::NotificationLevel::Notify;
}
}
return qml_mtx_events::NotificationLevel::Nothing;
}
case EncryptionError: case EncryptionError:
return events.decryptionError(event_id(event)); return events.decryptionError(event_id(event));

View file

@ -151,6 +151,14 @@ enum EventState
Empty, Empty,
}; };
Q_ENUM_NS(EventState) Q_ENUM_NS(EventState)
enum NotificationLevel
{
Nothing,
Notify,
Highlight,
};
Q_ENUM_NS(NotificationLevel)
} }
class StateKeeper class StateKeeper
@ -242,6 +250,7 @@ public:
IsEncrypted, IsEncrypted,
IsStateEvent, IsStateEvent,
Trustlevel, Trustlevel,
Notificationlevel,
EncryptionError, EncryptionError,
ReplyTo, ReplyTo,
ThreadId, ThreadId,