Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-client-qt
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
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
savoirfairelinux
jami-client-qt
Commits
be9dd0d0
Commit
be9dd0d0
authored
3 years ago
by
Kateryna Kostiuk
Browse files
Options
Downloads
Patches
Plain Diff
conversation: fix long loading time for images
Change-Id: Id88cfbd571f4b504f258758bd13b4e4a91bf1b49
parent
168165a1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/commoncomponents/DataTransferMessageDelegate.qml
+49
-3
49 additions, 3 deletions
src/commoncomponents/DataTransferMessageDelegate.qml
src/messagesadapter.cpp
+16
-4
16 additions, 4 deletions
src/messagesadapter.cpp
src/messagesadapter.h
+1
-1
1 addition, 1 deletion
src/messagesadapter.h
with
66 additions
and
8 deletions
src/commoncomponents/DataTransferMessageDelegate.qml
+
49
−
3
View file @
be9dd0d0
...
...
@@ -252,10 +252,11 @@ Loader {
Loader
{
id
:
localMediaCompLoader
anchors.right
:
isOutgoing
?
parent
.
right
:
undefined
asynchronous
:
true
width
:
sourceComponent
.
width
height
:
sourceComponent
.
height
sourceComponent
:
mediaInfo
.
isImage
!==
undefined
?
imageComp
:
imageComp
:
mediaInfo
.
isAnimatedImage
!==
undefined
?
animatedImageComp
:
avComp
Component
{
id
:
avComp
...
...
@@ -302,9 +303,9 @@ Loader {
}
}
Component
{
id
:
i
mageComp
id
:
animatedI
mageComp
AnimatedImage
{
id
:
i
mg
id
:
animatedI
mg
anchors.right
:
isOutgoing
?
parent
.
right
:
undefined
property
real
minSize
:
192
property
real
maxSize
:
256
...
...
@@ -327,6 +328,51 @@ Loader {
anchors.fill
:
parent
}
layer.enabled
:
true
layer.effect
:
OpacityMask
{
maskSource
:
MessageBubble
{
out
:
isOutgoing
type
:
seq
width
:
animatedImg
.
width
height
:
animatedImg
.
height
radius
:
msgRadius
}
}
HoverHandler
{
target
:
parent
onHoveredChanged
:
{
localMediaMsgItem
.
hoveredLink
=
hovered
?
animatedImg
.
source
:
""
}
cursorShape
:
Qt
.
PointingHandCursor
}
}
}
Component
{
id
:
imageComp
Image
{
id
:
img
anchors.right
:
isOutgoing
?
parent
.
right
:
undefined
property
real
minSize
:
192
property
real
maxSize
:
256
cache
:
true
fillMode
:
Image
.
PreserveAspectCrop
mipmap
:
true
antialiasing
:
true
autoTransform
:
false
asynchronous
:
true
source
:
"
file:///
"
+
Body
property
real
aspectRatio
:
implicitWidth
/
implicitHeight
property
real
adjustedWidth
:
Math
.
min
(
maxSize
,
Math
.
max
(
minSize
,
innerContent
.
width
-
senderMargin
))
width
:
adjustedWidth
height
:
Math
.
ceil
(
adjustedWidth
/
aspectRatio
)
Rectangle
{
color
:
JamiTheme
.
previewImageBackgroundColor
z
:
-
1
anchors.fill
:
parent
}
layer.enabled
:
true
layer.effect
:
OpacityMask
{
maskSource
:
MessageBubble
{
out
:
isOutgoing
...
...
This diff is collapsed.
Click to expand it.
src/messagesadapter.cpp
+
16
−
4
View file @
be9dd0d0
...
...
@@ -458,13 +458,24 @@ MessagesAdapter::conversationTypersUrlToName(const QSet<QString>& typersSet)
return
nameList
;
}
bool
QVariantMap
MessagesAdapter
::
isLocalImage
(
const
QString
&
msg
)
{
QImageReader
reader
;
reader
.
setDecideFormatFromContent
(
true
);
reader
.
setFileName
(
msg
);
return
!
reader
.
read
().
isNull
();
QByteArray
fileFormat
=
reader
.
format
();
if
(
fileFormat
==
"gif"
)
{
return
{{
"isAnimatedImage"
,
true
}};
}
QList
<
QByteArray
>
supportedFormats
=
reader
.
supportedImageFormats
();
auto
iterator
=
std
::
find_if
(
supportedFormats
.
begin
(),
supportedFormats
.
end
(),
[
fileFormat
](
QByteArray
format
)
{
return
format
==
fileFormat
;
});
if
(
iterator
!=
supportedFormats
.
end
())
{
return
{{
"isImage"
,
true
}};
}
return
{{
"isImage"
,
false
}};
}
QVariantMap
...
...
@@ -476,8 +487,9 @@ MessagesAdapter::getMediaInfo(const QString& msg)
"<%1 style='width:100%;height:%2;outline:none;background-color:#f1f3f4;"
"object-fit:cover;' "
"controls controlsList='nodownload' src='file://%3' type='%4'/></body>"
;
if
(
isLocalImage
(
msg
))
{
return
{{
"isImage"
,
true
}};
QVariantMap
fileInfo
=
isLocalImage
(
msg
);
if
(
fileInfo
[
"isImage"
].
toBool
()
||
fileInfo
[
"isAnimatedImage"
].
toBool
())
{
return
fileInfo
;
}
QRegularExpression
vPattern
(
"[^
\\
s]+(.*?)
\\
.(avi|mov|webm|webp|rmvb)$"
,
QRegularExpression
::
CaseInsensitiveOption
);
...
...
This diff is collapsed.
Click to expand it.
src/messagesadapter.h
+
1
−
1
View file @
be9dd0d0
...
...
@@ -101,7 +101,7 @@ protected:
Q_INVOKABLE
void
deleteInteraction
(
const
QString
&
interactionId
);
Q_INVOKABLE
void
copyToDownloads
(
const
QString
&
interactionId
,
const
QString
&
displayName
);
Q_INVOKABLE
void
userIsComposing
(
bool
isComposing
);
Q_INVOKABLE
bool
isLocalImage
(
const
QString
&
msg
);
Q_INVOKABLE
QVariantMap
isLocalImage
(
const
QString
&
msg
);
Q_INVOKABLE
QVariantMap
getMediaInfo
(
const
QString
&
msg
);
Q_INVOKABLE
bool
isRemoteImage
(
const
QString
&
msg
);
Q_INVOKABLE
QString
getFormattedTime
(
const
quint64
timestamp
);
...
...
This diff is collapsed.
Click to expand it.
Maxim Cournoyer
@mcournoyer
mentioned in issue
#649 (closed)
·
3 years ago
mentioned in issue
#649 (closed)
mentioned in issue #649
Toggle commit list
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