Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
d9b4dff2
Commit
d9b4dff2
authored
Nov 10, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(Utils): sort qml functions by name
parent
dec3dfa3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
110 deletions
+112
-110
utils.js
tests/ui/scripts/Utils/utils.js
+112
-110
No files found.
tests/ui/scripts/Utils/utils.js
View file @
d9b4dff2
...
...
@@ -10,6 +10,105 @@
// QML helpers.
// ===================================================================
// Destroy timeout.
function
clearTimeout
(
timer
)
{
timer
.
stop
()
// NECESSARY.
timer
.
destroy
()
}
// -------------------------------------------------------------------
// Connect a signal to a function only for one call.
function
connectOnce
(
signal
,
cb
)
{
var
func
=
function
()
{
signal
.
disconnect
(
func
)
cb
.
apply
(
this
,
arguments
)
}
signal
.
connect
(
func
)
return
func
}
// -------------------------------------------------------------------
function
encodeUrisToQmlFormat
(
text
,
options
)
{
var
images
=
''
if
(
options
==
null
)
{
options
=
{}
}
text
=
text
.
replace
(
/</g
,
'
\
u2063<
'
)
.
replace
(
/>/g
,
'
\
u2063>
'
)
.
replace
(
UriTools
.
URI_REGEX
,
function
(
match
)
{
// If it's a simple URL, transforms it in URI.
if
(
startsWith
(
match
,
'
www.
'
))
{
match
=
'
http://
'
+
match
}
var
ext
=
getExtension
(
match
)
if
(
includes
([
'
jpg
'
,
'
jpeg
'
,
'
gif
'
,
'
png
'
,
'
svg
'
],
ext
))
{
images
+=
'
<a href="
'
+
match
+
'
"><img
'
+
(
options
.
imagesWidth
!=
null
?
'
width="
'
+
options
.
imagesWidth
+
'
"
'
:
''
)
+
(
options
.
imagesHeight
!=
null
?
'
height="
'
+
options
.
imagesHeight
+
'
"
'
:
''
)
+
'
src="
'
+
match
+
'
" /></a>
'
}
return
'
<a href="
'
+
match
+
'
">
'
+
match
+
'
</a>
'
})
if
(
images
.
length
>
0
)
{
images
=
'
<div>
'
+
images
+
'
</div>
'
}
return
images
.
concat
(
'
<p>
'
+
text
+
'
</p>
'
)
}
// -------------------------------------------------------------------
// Returns the top (root) parent of one object.
function
getTopParent
(
object
,
useFakeParent
)
{
function
_getTopParent
(
object
,
useFakeParent
)
{
return
(
useFakeParent
&&
object
.
$parent
)
||
object
.
parent
}
var
parent
=
_getTopParent
(
object
,
useFakeParent
)
var
p
while
((
p
=
_getTopParent
(
parent
,
useFakeParent
))
!=
null
)
{
parent
=
p
}
return
parent
}
// -------------------------------------------------------------------
// Display a simple ConfirmDialog component.
// Wrap the openWindow function.
function
openConfirmDialog
(
parent
,
options
)
{
return
openWindow
(
'
import QtQuick 2.7;
'
+
'
import Common 1.0;
'
+
'
ConfirmDialog {
'
+
'
descriptionText:
\'
'
+
options
.
descriptionText
+
'
\'
;
'
+
'
title:
\'
'
+
options
.
title
+
'
\'
'
+
'
}
'
,
parent
,
{
isString
:
true
,
exitHandler
:
options
.
exitHandler
}
)
}
// -------------------------------------------------------------------
// Load by default a window in the ui/views folder.
// If options.isString is equals to true, a marshalling component can
// be used.
...
...
@@ -54,25 +153,6 @@ function openWindow (window, parent, options) {
// -------------------------------------------------------------------
// Display a simple ConfirmDialog component.
// Wrap the openWindow function.
function
openConfirmDialog
(
parent
,
options
)
{
return
openWindow
(
'
import QtQuick 2.7;
'
+
'
import Common 1.0;
'
+
'
ConfirmDialog {
'
+
'
descriptionText:
\'
'
+
options
.
descriptionText
+
'
\'
;
'
+
'
title:
\'
'
+
options
.
title
+
'
\'
'
+
'
}
'
,
parent
,
{
isString
:
true
,
exitHandler
:
options
.
exitHandler
}
)
}
// -------------------------------------------------------------------
// A copy of `Window.setTimeout` from js.
// delay is in milliseconds.
function
setTimeout
(
parent
,
delay
,
cb
)
{
...
...
@@ -88,41 +168,22 @@ function setTimeout (parent, delay, cb) {
return
timer
}
// Destroy timeout.
function
clearTimeout
(
timer
)
{
timer
.
stop
()
// NECESSARY.
timer
.
destroy
()
}
// -------------------------------------------------------------------
// Connect a signal to a function only for one call.
function
connectOnce
(
signal
,
cb
)
{
var
func
=
function
()
{
signal
.
disconnect
(
func
)
cb
.
apply
(
this
,
arguments
)
}
signal
.
connect
(
func
)
return
func
}
// -------------------------------------------------------------------
// Returns the top (root) parent of one object.
function
getTopParent
(
object
,
useFakeParent
)
{
function
_getTopParent
(
object
,
useFakeParent
)
{
return
(
useFakeParent
&&
object
.
$parent
)
||
object
.
parent
}
var
parent
=
_getTopParent
(
object
,
useFakeParent
)
var
p
while
((
p
=
_getTopParent
(
parent
,
useFakeParent
))
!=
null
)
{
parent
=
p
}
// Test if a point is in a item.
//
// `source` is the item that generated the point.
// `target` is the item to test.
// `point` is the point to test.
function
pointIsInItem
(
source
,
target
,
point
)
{
point
=
source
.
mapToItem
(
target
.
parent
,
point
.
x
,
point
.
y
)
return
parent
return
(
point
.
x
>=
target
.
x
&&
point
.
y
>=
target
.
y
&&
point
.
x
<
target
.
x
+
target
.
width
&&
point
.
y
<
target
.
y
+
target
.
height
)
}
// -------------------------------------------------------------------
...
...
@@ -142,65 +203,6 @@ function qmlTypeof (object, className) {
)
}
// -------------------------------------------------------------------
function
encodeUrisToQmlFormat
(
text
,
options
)
{
var
images
=
''
if
(
options
==
null
)
{
options
=
{}
}
text
=
text
.
replace
(
/</g
,
'
\
u2063<
'
)
.
replace
(
/>/g
,
'
\
u2063>
'
)
.
replace
(
UriTools
.
URI_REGEX
,
function
(
match
)
{
// If it's a simple URL, transforms it in URI.
if
(
startsWith
(
match
,
'
www.
'
))
{
match
=
'
http://
'
+
match
}
var
ext
=
getExtension
(
match
)
if
(
includes
([
'
jpg
'
,
'
jpeg
'
,
'
gif
'
,
'
png
'
,
'
svg
'
],
ext
))
{
images
+=
'
<a href="
'
+
match
+
'
"><img
'
+
(
options
.
imagesWidth
!=
null
?
'
width="
'
+
options
.
imagesWidth
+
'
"
'
:
''
)
+
(
options
.
imagesHeight
!=
null
?
'
height="
'
+
options
.
imagesHeight
+
'
"
'
:
''
)
+
'
src="
'
+
match
+
'
" /></a>
'
}
return
'
<a href="
'
+
match
+
'
">
'
+
match
+
'
</a>
'
})
if
(
images
.
length
>
0
)
{
images
=
'
<div>
'
+
images
+
'
</div>
'
}
return
images
.
concat
(
'
<p>
'
+
text
+
'
</p>
'
)
}
// -------------------------------------------------------------------
// Test if a point is in a item.
//
// `source` is the item that generated the point.
// `target` is the item to test.
// `point` is the point to test.
function
pointIsInItem
(
source
,
target
,
point
)
{
point
=
source
.
mapToItem
(
target
.
parent
,
point
.
x
,
point
.
y
)
return
(
point
.
x
>=
target
.
x
&&
point
.
y
>=
target
.
y
&&
point
.
x
<
target
.
x
+
target
.
width
&&
point
.
y
<
target
.
y
+
target
.
height
)
}
// ===================================================================
// GENERIC.
// ===================================================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment