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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-client-qt
Commits
d9e22642
Commit
d9e22642
authored
Dec 21, 2022
by
Nicolas Vengeon
Committed by
Sébastien Blin
Dec 27, 2022
Browse files
Options
Downloads
Patches
Plain Diff
locationSharing: add label next to positions
Change-Id: I5da15da915153b7309b5a1741dbdf9c3172d50ce GitLab:
#909
parent
d06902e3
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/positionmanager.cpp
+23
-1
23 additions, 1 deletion
src/app/positionmanager.cpp
src/app/webengine/map/MapPosition.qml
+3
-2
3 additions, 2 deletions
src/app/webengine/map/MapPosition.qml
src/app/webengine/map/map.js
+32
-7
32 additions, 7 deletions
src/app/webengine/map/map.js
with
58 additions
and
10 deletions
src/app/positionmanager.cpp
+
23
−
1
View file @
d9e22642
...
@@ -389,7 +389,13 @@ PositionManager::showNotification(const QString& accountId,
...
@@ -389,7 +389,13 @@ PositionManager::showNotification(const QString& accountId,
const
QString
&
convId
,
const
QString
&
convId
,
const
QString
&
from
)
const
QString
&
from
)
{
{
auto
bestName
=
lrcInstance_
->
getAccountInfo
(
accountId
).
contactModel
->
bestNameForContact
(
from
);
QString
bestName
;
if
(
from
==
lrcInstance_
->
getAccountInfo
(
accountId
).
profileInfo
.
uri
)
bestName
=
lrcInstance_
->
getAccountInfo
(
accountId
).
accountModel
->
bestNameForAccount
(
accountId
);
else
bestName
=
lrcInstance_
->
getAccountInfo
(
accountId
).
contactModel
->
bestNameForContact
(
from
);
auto
body
=
tr
(
"%1 is sharing it's location"
).
arg
(
bestName
);
auto
body
=
tr
(
"%1 is sharing it's location"
).
arg
(
bestName
);
#ifdef Q_OS_LINUX
#ifdef Q_OS_LINUX
auto
contactPhoto
=
Utils
::
contactPhoto
(
lrcInstance_
,
from
,
QSize
(
50
,
50
),
accountId
);
auto
contactPhoto
=
Utils
::
contactPhoto
(
lrcInstance_
,
from
,
QSize
(
50
,
50
),
accountId
);
...
@@ -469,6 +475,22 @@ PositionManager::addPositionToMap(PositionKey key, QVariantMap position)
...
@@ -469,6 +475,22 @@ PositionManager::addPositionToMap(PositionKey key, QVariantMap position)
{
{
// avatar only sent one time to qml, when a new position is added
// avatar only sent one time to qml, when a new position is added
position
[
"avatar"
]
=
getAvatar
(
key
.
first
,
key
.
second
);
position
[
"avatar"
]
=
getAvatar
(
key
.
first
,
key
.
second
);
auto
accountId
=
key
.
first
;
auto
uri
=
key
.
second
;
auto
&
accountInfo
=
lrcInstance_
->
getAccountInfo
(
accountId
);
QString
bestName
;
if
(
uri
==
accountInfo
.
profileInfo
.
uri
)
{
bestName
=
accountInfo
.
accountModel
->
bestNameForAccount
(
accountId
);
}
else
bestName
=
accountInfo
.
contactModel
->
bestNameForContact
(
uri
);
QString
shorterAuthorName
=
bestName
;
shorterAuthorName
.
truncate
(
10
);
if
(
bestName
!=
shorterAuthorName
)
{
shorterAuthorName
=
shorterAuthorName
+
"…"
;
}
position
[
"authorName"
]
=
shorterAuthorName
;
Q_EMIT
positionShareAdded
(
position
);
Q_EMIT
positionShareAdded
(
position
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/app/webengine/map/MapPosition.qml
+
3
−
2
View file @
d9e22642
...
@@ -178,7 +178,8 @@ Item {
...
@@ -178,7 +178,8 @@ Item {
if
(
shareInfo
.
account
===
attachedAccountId
)
{
if
(
shareInfo
.
account
===
attachedAccountId
)
{
var
curLong
=
shareInfo
.
long
var
curLong
=
shareInfo
.
long
var
curLat
=
shareInfo
.
lat
var
curLat
=
shareInfo
.
lat
webView
.
runJavaScript
(
"
newPosition([
"
+
curLong
+
"
,
"
+
curLat
+
"
], '
"
+
shareInfo
.
author
+
"
', '
"
+
shareInfo
.
avatar
+
"
' )
"
);
webView
.
runJavaScript
(
"
newPosition([
"
+
curLong
+
"
,
"
+
curLat
+
"
], '
"
+
shareInfo
.
author
+
"
', '
"
+
shareInfo
.
avatar
+
"
', '
"
+
shareInfo
.
authorName
+
"
' )
"
);
webView
.
runJavaScript
(
"
zoomTolayersExtent()
"
);
webView
.
runJavaScript
(
"
zoomTolayersExtent()
"
);
}
}
}
}
...
@@ -214,7 +215,7 @@ Item {
...
@@ -214,7 +215,7 @@ Item {
attachedAccountId
=
CurrentAccount
.
id
attachedAccountId
=
CurrentAccount
.
id
runJavaScript
(
UtilsAdapter
.
getStyleSheet
(
"
olcss
"
,
UtilsAdapter
.
qStringFromFile
(
olCss
)))
runJavaScript
(
UtilsAdapter
.
getStyleSheet
(
"
olcss
"
,
UtilsAdapter
.
qStringFromFile
(
olCss
)))
webView
.
isLoaded
=
true
webView
.
isLoaded
=
true
runJavaScript
(
"
setMapView([
"
+
0
+
"
,
"
+
0
+
"
],
"
+
1
+
"
);
"
);
webView
.
runJavaScript
(
"
setMapView([
"
+
0
+
"
,
"
+
0
+
"
],
"
+
1
+
"
);
"
);
PositionManager
.
startPositioning
()
PositionManager
.
startPositioning
()
//load locations that were received before this conversation was opened
//load locations that were received before this conversation was opened
PositionManager
.
loadPreviousLocations
(
attachedAccountId
);
PositionManager
.
loadPreviousLocations
(
attachedAccountId
);
...
...
This diff is collapsed.
Click to expand it.
src/app/webengine/map/map.js
+
32
−
7
View file @
d9e22642
...
@@ -61,7 +61,7 @@ var proj = new ol.proj.Projection({
...
@@ -61,7 +61,7 @@ var proj = new ol.proj.Projection({
extent
:
extent
extent
:
extent
})
})
function
setSource
(
coordos
,
avatar
)
{
function
setSource
(
coordos
,
avatar
,
authorName
)
{
var
coord
=
ol
.
proj
.
fromLonLat
(
coordos
)
var
coord
=
ol
.
proj
.
fromLonLat
(
coordos
)
var
pointFeature
=
new
ol
.
Feature
({
var
pointFeature
=
new
ol
.
Feature
({
geometry
:
new
ol
.
geom
.
Point
(
coord
),
geometry
:
new
ol
.
geom
.
Point
(
coord
),
...
@@ -71,14 +71,14 @@ function setSource (coordos, avatar) {
...
@@ -71,14 +71,14 @@ function setSource (coordos, avatar) {
var
preStyle
=
new
ol
.
style
.
Icon
({
var
preStyle
=
new
ol
.
style
.
Icon
({
src
:
"
data:image/png;base64,
"
+
avatar
})
src
:
"
data:image/png;base64,
"
+
avatar
})
//resize the image to
35
px
//resize the image to
40
px
var
image
=
preStyle
.
getImage
()
var
image
=
preStyle
.
getImage
()
if
(
!
image
.
width
)
{
if
(
!
image
.
width
)
{
image
.
addEventListener
(
'
load
'
,
function
()
{
image
.
addEventListener
(
'
load
'
,
function
()
{
preStyle
.
setScale
([
35
/
image
.
width
,
35
/
image
.
height
])
preStyle
.
setScale
([
40
/
image
.
width
,
40
/
image
.
height
])
})
})
}
else
{
}
else
{
preStyle
.
setScale
([
35
/
image
.
width
,
35
/
image
.
height
])
preStyle
.
setScale
([
40
/
image
.
width
,
40
/
image
.
height
])
}
}
var
iconStyle
=
new
ol
.
style
.
Style
({
var
iconStyle
=
new
ol
.
style
.
Style
({
...
@@ -86,21 +86,45 @@ function setSource (coordos, avatar) {
...
@@ -86,21 +86,45 @@ function setSource (coordos, avatar) {
})
})
pointFeature
.
setStyle
(
iconStyle
)
pointFeature
.
setStyle
(
iconStyle
)
// create a text label
var
textLabel
=
new
ol
.
Feature
({
geometry
:
new
ol
.
geom
.
Point
(
coord
),
text
:
authorName
});
// set the style for the text label
textLabel
.
setStyle
(
new
ol
.
style
.
Style
({
text
:
new
ol
.
style
.
Text
({
text
:
textLabel
.
get
(
'
text
'
),
font
:
'
20px Arial
'
,
fill
:
new
ol
.
style
.
Fill
({
color
:
'
black
'
}),
stroke
:
new
ol
.
style
.
Stroke
({
color
:
'
white
'
,
width
:
3
}),
offsetY
:
30
})
}));
var
vectorSource
=
new
ol
.
source
.
Vector
({
var
vectorSource
=
new
ol
.
source
.
Vector
({
features
:
[
pointFeature
],
features
:
[
pointFeature
,
textLabel
],
})
})
return
vectorSource
return
vectorSource
}
}
function
newPosition
(
coordos
,
authorUri
,
avatar
)
{
function
newPosition
(
coordos
,
authorUri
,
avatar
,
authorName
)
{
var
layerArray
=
map
.
getLayers
().
getArray
();
var
layerArray
=
map
.
getLayers
().
getArray
();
for
(
var
i
=
0
;
i
<
layerArray
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
layerArray
.
length
;
i
++
){
if
(
layerArray
[
i
].
layer_type
===
authorUri
)
{
if
(
layerArray
[
i
].
layer_type
===
authorUri
)
{
return
return
}
}
}
}
vectorSource
=
setSource
(
coordos
,
avatar
)
vectorSource
=
setSource
(
coordos
,
avatar
,
authorName
)
var
iconLayer
=
new
ol
.
layer
.
Vector
({
source
:
vectorSource
})
var
iconLayer
=
new
ol
.
layer
.
Vector
({
source
:
vectorSource
})
iconLayer
.
layer_type
=
authorUri
iconLayer
.
layer_type
=
authorUri
map
.
addLayer
(
iconLayer
)
map
.
addLayer
(
iconLayer
)
...
@@ -112,6 +136,7 @@ function updatePosition (coordos, authorUri) {
...
@@ -112,6 +136,7 @@ function updatePosition (coordos, authorUri) {
for
(
var
i
=
0
;
i
<
layerArray
.
length
;
i
++
){
for
(
var
i
=
0
;
i
<
layerArray
.
length
;
i
++
){
if
(
layerArray
[
i
].
layer_type
===
authorUri
)
{
if
(
layerArray
[
i
].
layer_type
===
authorUri
)
{
layerArray
[
i
].
getSource
().
getFeatures
()[
0
].
getGeometry
().
setCoordinates
(
coord
)
layerArray
[
i
].
getSource
().
getFeatures
()[
0
].
getGeometry
().
setCoordinates
(
coord
)
layerArray
[
i
].
getSource
().
getFeatures
()[
1
].
getGeometry
().
setCoordinates
(
coord
)
return
return
}
}
}
}
...
...
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