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
90e9a36a
Commit
90e9a36a
authored
1 year ago
by
Sébastien Blin
Browse files
Options
Downloads
Patches
Plain Diff
datatransfer: allow to download a cancelled file
Change-Id: If94c5e1c24d1a90f7a20f29bafc087d26782fe67 GitLab:
#1523
parent
95e36ef8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/commoncomponents/DataTransferMessageDelegate.qml
+39
-61
39 additions, 61 deletions
src/app/commoncomponents/DataTransferMessageDelegate.qml
tests/qml/src/tst_DataTransferMessageDelegate.qml
+48
-0
48 additions, 0 deletions
tests/qml/src/tst_DataTransferMessageDelegate.qml
with
87 additions
and
61 deletions
src/app/commoncomponents/DataTransferMessageDelegate.qml
+
39
−
61
View file @
90e9a36a
...
...
@@ -34,17 +34,19 @@ Loader {
property
bool
showTime
property
bool
showDay
property
int
timestamp
:
Timestamp
property
string
formattedTime
:
MessagesAdapter
.
getFormattedTime
(
T
imestamp
)
property
string
formattedDay
:
MessagesAdapter
.
getFormattedDay
(
T
imestamp
)
property
string
formattedTime
:
MessagesAdapter
.
getFormattedTime
(
root
.
t
imestamp
)
property
string
formattedDay
:
MessagesAdapter
.
getFormattedDay
(
root
.
t
imestamp
)
property
int
seq
:
MsgSeq
.
single
property
string
author
:
Author
property
string
body
:
Body
property
var
status
:
Status
width
:
ListView
.
view
?
ListView
.
view
.
width
:
0
sourceComponent
:
{
if
(
S
tatus
===
Interaction
.
Status
.
TRANSFER_FINISHED
)
{
mediaInfo
=
MessagesAdapter
.
getMediaInfo
(
B
ody
)
if
(
root
.
s
tatus
===
Interaction
.
Status
.
TRANSFER_FINISHED
)
{
mediaInfo
=
MessagesAdapter
.
getMediaInfo
(
root
.
b
ody
)
if
(
Object
.
keys
(
mediaInfo
).
length
!==
0
&&
WITH_WEBENGINE
)
return
localMediaMsgComp
}
...
...
@@ -61,8 +63,9 @@ Loader {
SBSMessageBase
{
id
:
dataTransferItem
property
var
transferStats
:
MessagesAdapter
.
getTransferStats
(
Id
,
Status
)
property
bool
canOpen
:
Status
===
Interaction
.
Status
.
TRANSFER_FINISHED
||
isOutgoing
transferId
:
Id
property
var
transferStats
:
MessagesAdapter
.
getTransferStats
(
transferId
,
root
.
Status
)
property
bool
canOpen
:
root
.
status
===
Interaction
.
Status
.
TRANSFER_FINISHED
||
isOutgoing
property
real
maxMsgWidth
:
root
.
width
-
senderMargin
-
2
*
hPadding
-
avatarBlockWidth
-
buttonsLoader
.
width
-
24
-
6
-
24
...
...
@@ -73,7 +76,6 @@ Loader {
author
:
Author
location
:
Body
transferName
:
TransferName
transferId
:
Id
readers
:
Readers
timestamp
:
root
.
timestamp
formattedTime
:
root
.
formattedTime
...
...
@@ -90,7 +92,7 @@ Loader {
enabled
:
canOpen
onHoveredChanged
:
{
if
(
enabled
&&
hovered
)
{
dataTransferItem
.
hoveredLink
=
UtilsAdapter
.
urlFromLocalPath
(
Body
)
dataTransferItem
.
hoveredLink
=
UtilsAdapter
.
urlFromLocalPath
(
location
)
}
else
{
dataTransferItem
.
hoveredLink
=
""
}
...
...
@@ -101,33 +103,30 @@ Loader {
}
Loader
{
id
:
buttonsLoader
objectName
:
"
buttonsLoader
"
property
string
iconSourceA
property
string
iconSourceB
property
string
iconSource
Layout.margins
:
8
sourceComponent
:
{
switch
(
Status
)
{
switch
(
root
.
status
)
{
case
Interaction
.
Status
.
TRANSFER_CREATED
:
case
Interaction
.
Status
.
TRANSFER_FINISHED
:
iconSource
=
JamiResources
.
link_black_24dp_svg
return
terminatedComp
case
Interaction
.
Status
.
TRANSFER_CANCELED
:
case
Interaction
.
Status
.
TRANSFER_ERROR
:
case
Interaction
.
Status
.
TRANSFER_UNJOINABLE_PEER
:
case
Interaction
.
Status
.
TRANSFER_TIMEOUT_EXPIRED
:
iconSourceA
=
JamiResources
.
error_outline_black_24dp_svg
return
terminatedComp
case
Interaction
.
Status
.
TRANSFER_CREATED
:
case
Interaction
.
Status
.
TRANSFER_FINISHED
:
iconSourceA
=
JamiResources
.
link_black_24dp_svg
return
terminatedComp
case
Interaction
.
Status
.
TRANSFER_AWAITING_HOST
:
iconSourceA
=
JamiResources
.
download_black_24dp_svg
iconSourceB
=
JamiResources
.
close_black_24dp_svg
iconSource
=
JamiResources
.
download_black_24dp_svg
return
optionsComp
case
Interaction
.
Status
.
TRANSFER_ONGOING
:
iconSource
A
=
JamiResources
.
close_black_24dp_svg
iconSource
=
JamiResources
.
close_black_24dp_svg
return
optionsComp
default
:
iconSource
A
=
JamiResources
.
error_outline_black_24dp_svg
iconSource
=
JamiResources
.
error_outline_black_24dp_svg
return
terminatedComp
}
}
...
...
@@ -146,41 +145,22 @@ Loader {
}
contentItem
:
ResponsiveImage
{
source
:
buttonsLoader
.
iconSource
A
source
:
buttonsLoader
.
iconSource
color
:
UtilsAdapter
.
luma
(
bubble
.
color
)
?
JamiTheme
.
fileIconLightColor
:
JamiTheme
.
fileIconDarkColor
}
}
}
Component
{
id
:
optionsComp
ColumnLayout
{
Layout.leftMargin
:
12
PushButton
{
source
:
buttonsLoader
.
iconSourceA
normalColor
:
JamiTheme
.
chatviewBgColor
imageColor
:
JamiTheme
.
chatviewButtonColor
onClicked
:
{
switch
(
Status
)
{
case
Interaction
.
Status
.
TRANSFER_ONGOING
:
return
MessagesAdapter
.
cancelFile
(
Id
)
case
Interaction
.
Status
.
TRANSFER_AWAITING_HOST
:
return
MessagesAdapter
.
acceptFile
(
Id
)
default
:
break
}
}
}
PushButton
{
visible
:
!
CurrentConversation
.
isSwarm
height
:
visible
*
implicitHeight
source
:
buttonsLoader
.
iconSourceB
normalColor
:
JamiTheme
.
chatviewBgColor
imageColor
:
JamiTheme
.
chatviewButtonColor
onClicked
:
{
switch
(
Status
)
{
case
Interaction
.
Status
.
TRANSFER_AWAITING_HOST
:
return
MessagesAdapter
.
cancelFile
(
Id
)
default
:
break
}
PushButton
{
source
:
buttonsLoader
.
iconSource
normalColor
:
JamiTheme
.
chatviewBgColor
imageColor
:
JamiTheme
.
chatviewButtonColor
onClicked
:
{
if
(
root
.
status
===
Interaction
.
Status
.
TRANSFER_ONGOING
)
{
return
MessagesAdapter
.
cancelFile
(
transferId
)
}
else
{
return
MessagesAdapter
.
acceptFile
(
transferId
)
}
}
}
...
...
@@ -190,13 +170,11 @@ Loader {
Layout.rightMargin
:
24
spacing
:
4
TextEdit
{
id
:
transferName
width
:
Math
.
min
(
implicitWidth
,
maxMsgWidth
)
topPadding
:
10
text
:
CurrentConversation
.
isSwarm
?
T
ransferName
:
Body
t
ransferName
:
location
wrapMode
:
Label
.
WrapAtWordBoundaryOrAnywhere
font.pointSize
:
11
renderType
:
Text
.
NativeRendering
...
...
@@ -211,7 +189,7 @@ Loader {
Qt
.
ArrowCursor
onClicked
:
function
(
mouse
)
{
if
(
canOpen
)
{
dataTransferItem
.
hoveredLink
=
UtilsAdapter
.
urlFromLocalPath
(
Body
)
dataTransferItem
.
hoveredLink
=
UtilsAdapter
.
urlFromLocalPath
(
location
)
Qt
.
openUrlExternally
(
new
Url
(
dataTransferItem
.
hoveredLink
))
}
else
{
dataTransferItem
.
hoveredLink
=
""
...
...
@@ -248,7 +226,7 @@ Loader {
,
ProgressBar
{
id
:
progressBar
visible
:
S
tatus
===
Interaction
.
Status
.
TRANSFER_ONGOING
visible
:
root
.
s
tatus
===
Interaction
.
Status
.
TRANSFER_ONGOING
height
:
visible
*
implicitHeight
value
:
transferStats
.
progress
/
transferStats
.
totalSize
width
:
transferItem
.
width
...
...
@@ -265,16 +243,16 @@ Loader {
id
:
localMediaMsgItem
isOutgoing
:
Author
===
CurrentAccount
.
uri
property
var
transferStats
:
MessagesAdapter
.
getTransferStats
(
Id
,
Status
)
transferId
:
Id
property
var
transferStats
:
MessagesAdapter
.
getTransferStats
(
transferId
,
root
.
status
)
showTime
:
root
.
showTime
seq
:
root
.
seq
author
:
Author
location
:
Body
transferName
:
TransferName
transferId
:
Id
readers
:
Readers
formattedTime
:
MessagesAdapter
.
getFormattedTime
(
T
imestamp
)
formattedDay
:
MessagesAdapter
.
getFormattedDay
(
T
imestamp
)
formattedTime
:
MessagesAdapter
.
getFormattedTime
(
root
.
t
imestamp
)
formattedDay
:
MessagesAdapter
.
getFormattedDay
(
root
.
t
imestamp
)
property
real
contentWidth
...
...
@@ -420,7 +398,7 @@ Loader {
readonly
property
real
aspectRatio
:
paintedWidth
/
paintedHeight
readonly
property
real
idealWidth
:
innerContent
.
width
-
senderMargin
onStatusChanged
:
{
if
(
status
==
Image
.
Ready
&&
aspectRatio
)
{
if
(
root
.
status
==
Image
.
Ready
&&
aspectRatio
)
{
height
=
Qt
.
binding
(()
=>
JamiQmlUtils
.
clamp
(
idealWidth
/
aspectRatio
,
64
,
256
))
width
=
Qt
.
binding
(()
=>
height
*
aspectRatio
)
...
...
This diff is collapsed.
Click to expand it.
tests/qml/src/tst_DataTransferMessageDelegate.qml
0 → 100644
+
48
−
0
View file @
90e9a36a
/*
* Copyright (C) 2024 Savoir-faire Linux Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import
QtQuick
import
QtTest
import
net
.
jami
.
Adapters
1.1
import
net
.
jami
.
Models
1.1
import
net
.
jami
.
Constants
1.1
import
net
.
jami
.
Enums
1.1
import
"
../../../src/app/
"
import
"
../../../src/app/mainview
"
import
"
../../../src/app/mainview/components
"
import
"
../../../src/app/commoncomponents
"
DataTransferMessageDelegate
{
id
:
uut
timestamp
:
0
status
:
Interaction
.
Status
.
TRANSFER_FINISHED
author
:
""
body
:
""
TestCase
{
name
:
"
Check basic visibility for header buttons
"
function
test_checkBasicVisibility
()
{
var
buttonsLoader
=
findChild
(
uut
,
"
buttonsLoader
"
)
uut
.
status
=
Interaction
.
Status
.
TRANSFER_AWAITING_HOST
compare
(
buttonsLoader
.
iconSource
,
JamiResources
.
download_black_24dp_svg
)
uut
.
status
=
Interaction
.
Status
.
TRANSFER_FINISHED
compare
(
buttonsLoader
.
iconSource
,
JamiResources
.
link_black_24dp_svg
)
}
}
}
\ No newline at end of file
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