Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
3b2f47c5
Unverified
Commit
3b2f47c5
authored
2 years ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Show changes in image packs in timeline
parent
7138c7a4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#3047
passed
2 years ago
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
resources/qml/delegates/MessageDelegate.qml
+2
-2
2 additions, 2 deletions
resources/qml/delegates/MessageDelegate.qml
src/timeline/TimelineModel.cpp
+69
-0
69 additions, 0 deletions
src/timeline/TimelineModel.cpp
src/timeline/TimelineModel.h
+1
-0
1 addition, 0 deletions
src/timeline/TimelineModel.h
with
72 additions
and
2 deletions
resources/qml/delegates/MessageDelegate.qml
+
2
−
2
View file @
3b2f47c5
...
...
@@ -284,11 +284,12 @@ Item {
isOnlyEmoji
:
false
isReply
:
d
.
isReply
isStateEvent
:
d
.
isStateEvent
formatted
:
qsTr
(
"
%1 changed the stickers and emotes in this room.
"
).
arg
(
d
.
userName
)
formatted
:
d
.
relatedEventCacheBuster
,
room
.
formatImagePackEvent
(
d
.
eventId
)
}
}
DelegateChoice
{
roleValue
:
MtxEvent
.
CanonicalAlias
...
...
@@ -390,7 +391,6 @@ Item {
}
DelegateChoice
{
// TODO: make a more complex formatter for the power levels.
roleValue
:
MtxEvent
.
PowerLevels
NoticeMessage
{
...
...
This diff is collapsed.
Click to expand it.
src/timeline/TimelineModel.cpp
+
69
−
0
View file @
3b2f47c5
...
...
@@ -197,6 +197,12 @@ qml_mtx_events::toRoomEventType(mtx::events::EventType e)
return
qml_mtx_events
::
EventType
::
SpaceParent
;
case
EventType
::
SpaceChild
:
return
qml_mtx_events
::
EventType
::
SpaceChild
;
case
EventType
::
ImagePackInRoom
:
return
qml_mtx_events
::
ImagePackInRoom
;
case
EventType
::
ImagePackInAccountData
:
return
qml_mtx_events
::
ImagePackInAccountData
;
case
EventType
::
ImagePackRooms
:
return
qml_mtx_events
::
ImagePackRooms
;
case
EventType
::
Unsupported
:
return
qml_mtx_events
::
EventType
::
Unsupported
;
default:
...
...
@@ -2201,6 +2207,69 @@ TimelineModel::formatPowerLevelEvent(const QString &id)
}
}
QString
TimelineModel
::
formatImagePackEvent
(
const
QString
&
id
)
{
mtx
::
events
::
collections
::
TimelineEvents
*
e
=
events
.
get
(
id
.
toStdString
(),
""
);
if
(
!
e
)
return
{};
auto
event
=
std
::
get_if
<
mtx
::
events
::
StateEvent
<
mtx
::
events
::
msc2545
::
ImagePack
>>
(
e
);
if
(
!
event
)
return
{};
mtx
::
events
::
StateEvent
<
mtx
::
events
::
msc2545
::
ImagePack
>
*
prevEvent
=
nullptr
;
if
(
!
event
->
unsigned_data
.
replaces_state
.
empty
())
{
auto
tempPrevEvent
=
events
.
get
(
event
->
unsigned_data
.
replaces_state
,
event
->
event_id
);
if
(
tempPrevEvent
)
{
prevEvent
=
std
::
get_if
<
mtx
::
events
::
StateEvent
<
mtx
::
events
::
msc2545
::
ImagePack
>>
(
tempPrevEvent
);
}
}
const
auto
&
newImages
=
event
->
content
.
images
;
const
auto
oldImages
=
prevEvent
?
prevEvent
->
content
.
images
:
decltype
(
newImages
){};
auto
ascent
=
QFontMetrics
(
UserSettings
::
instance
()
->
font
()).
ascent
();
auto
calcChange
=
[
ascent
](
const
std
::
map
<
std
::
string
,
mtx
::
events
::
msc2545
::
PackImage
>
&
newI
,
const
std
::
map
<
std
::
string
,
mtx
::
events
::
msc2545
::
PackImage
>
&
oldI
)
{
QStringList
added
;
for
(
const
auto
&
[
shortcode
,
img
]
:
newI
)
{
if
(
!
oldI
.
count
(
shortcode
))
added
.
push_back
(
QStringLiteral
(
"<img data-mx-emoticon height=%1 src=
\"
%2
\"
> (~%3)"
)
.
arg
(
ascent
)
.
arg
(
QString
::
fromStdString
(
img
.
url
)
.
replace
(
"mxc://"
,
"image://mxcImage/"
)
.
toHtmlEscaped
(),
QString
::
fromStdString
(
shortcode
)));
}
return
added
;
};
auto
added
=
calcChange
(
newImages
,
oldImages
);
auto
removed
=
calcChange
(
oldImages
,
newImages
);
auto
sender
=
utils
::
replaceEmoji
(
displayName
(
QString
::
fromStdString
(
event
->
sender
)));
QString
msg
;
if
(
!
removed
.
isEmpty
())
{
msg
=
tr
(
"%1 removed the following images from the pack:<br>%2"
)
.
arg
(
sender
,
removed
.
join
(
", "
));
}
if
(
!
added
.
isEmpty
())
{
if
(
!
msg
.
isEmpty
())
msg
+=
"<br>"
;
msg
+=
tr
(
"%1 added the following images to the pack:<br>%2"
).
arg
(
sender
,
added
.
join
(
", "
));
}
if
(
msg
.
isEmpty
())
return
tr
(
"%1 changed the sticker and emotes in this room."
).
arg
(
sender
);
else
return
msg
;
}
QVariantMap
TimelineModel
::
formatRedactedEvent
(
const
QString
&
id
)
{
...
...
This diff is collapsed.
Click to expand it.
src/timeline/TimelineModel.h
+
1
−
0
View file @
3b2f47c5
...
...
@@ -262,6 +262,7 @@ public:
Q_INVOKABLE
QString
formatHistoryVisibilityEvent
(
const
QString
&
id
);
Q_INVOKABLE
QString
formatGuestAccessEvent
(
const
QString
&
id
);
Q_INVOKABLE
QString
formatPowerLevelEvent
(
const
QString
&
id
);
Q_INVOKABLE
QString
formatImagePackEvent
(
const
QString
&
id
);
Q_INVOKABLE
QVariantMap
formatRedactedEvent
(
const
QString
&
id
);
Q_INVOKABLE
void
viewRawMessage
(
const
QString
&
id
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment