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
4572a3b9
Commit
4572a3b9
authored
Jun 07, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ui/scripts/Utils/utils): provide a `runOnWindows` function
parent
dc7e920c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
60 deletions
+61
-60
utils.js
linphone-desktop/ui/scripts/Utils/utils.js
+61
-60
No files found.
linphone-desktop/ui/scripts/Utils/utils.js
View file @
4572a3b9
...
...
@@ -34,6 +34,39 @@ function clearTimeout (timer) {
// -----------------------------------------------------------------------------
function
createObject
(
source
,
parent
,
options
)
{
if
(
options
&&
options
.
isString
)
{
var
object
=
Qt
.
createQmlObject
(
source
,
parent
)
var
properties
=
options
&&
options
.
properties
if
(
properties
)
{
for
(
var
key
in
properties
)
{
object
[
key
]
=
properties
[
key
]
}
}
return
object
}
var
component
=
Qt
.
createComponent
(
source
)
if
(
component
.
status
!==
QtQuick
.
Component
.
Ready
)
{
console
.
debug
(
'
Component not ready.
'
)
if
(
component
.
status
===
QtQuick
.
Component
.
Error
)
{
console
.
debug
(
'
Error:
'
+
component
.
errorString
())
}
return
// Error.
}
var
object
=
component
.
createObject
(
parent
,
(
options
&&
options
.
properties
)
||
{})
if
(
!
object
)
{
console
.
debug
(
'
Error: unable to create dynamic object.
'
)
}
return
object
}
// -----------------------------------------------------------------------------
function
encodeTextToQmlRichFormat
(
text
,
options
)
{
var
images
=
''
...
...
@@ -79,56 +112,6 @@ function extractFirstUri (str) {
// -----------------------------------------------------------------------------
// 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
}
// -----------------------------------------------------------------------------
function
createObject
(
source
,
parent
,
options
)
{
if
(
options
&&
options
.
isString
)
{
var
object
=
Qt
.
createQmlObject
(
source
,
parent
)
var
properties
=
options
&&
options
.
properties
if
(
properties
)
{
for
(
var
key
in
properties
)
{
object
[
key
]
=
properties
[
key
]
}
}
return
object
}
var
component
=
Qt
.
createComponent
(
source
)
if
(
component
.
status
!==
QtQuick
.
Component
.
Ready
)
{
console
.
debug
(
'
Component not ready.
'
)
if
(
component
.
status
===
QtQuick
.
Component
.
Error
)
{
console
.
debug
(
'
Error:
'
+
component
.
errorString
())
}
return
// Error.
}
var
object
=
component
.
createObject
(
parent
,
(
options
&&
options
.
properties
)
||
{})
if
(
!
object
)
{
console
.
debug
(
'
Error: unable to create dynamic object.
'
)
}
return
object
}
// -----------------------------------------------------------------------------
// Load by default a window in the ui/views folder.
// If options.isString is equals to true, a marshalling component can
// be used.
...
...
@@ -162,10 +145,7 @@ function getSystemPathFromUri (uri) {
// Absolute path.
if
(
str
.
charAt
(
0
)
===
'
/
'
)
{
var
os
=
Qt
.
platform
.
os
return
os
===
'
windows
'
||
os
===
'
winrt
'
?
str
.
substring
(
1
)
:
str
return
runOnWindows
()
?
str
.
substring
(
1
)
:
str
}
}
...
...
@@ -177,8 +157,7 @@ function getUriFromSystemPath (path) {
return
path
}
var
os
=
Qt
.
platform
.
os
if
(
os
===
'
windows
'
||
os
===
'
winrt
'
)
{
if
(
runOnWindows
())
{
return
'
file://
'
+
(
/^
\w
:/
.
exec
(
path
)
?
'
/
'
:
''
)
+
path
}
...
...
@@ -187,6 +166,30 @@ function getUriFromSystemPath (path) {
// -----------------------------------------------------------------------------
// 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
}
// -----------------------------------------------------------------------------
function
runOnWindows
()
{
var
os
=
Qt
.
platform
.
os
return
os
===
'
windows
'
||
os
===
'
winrt
'
}
// -----------------------------------------------------------------------------
// Test if a point is in a item.
//
// `source` is the item that generated the point.
...
...
@@ -284,8 +287,7 @@ function assert (condition, message) {
// -----------------------------------------------------------------------------
function
basename
(
str
)
{
var
os
=
Qt
.
platform
.
os
if
(
os
===
'
windows
'
||
os
===
'
winrt
'
)
{
if
(
runOnWindows
())
{
str
=
str
.
replace
(
/
\\
/g
,
'
/
'
)
}
...
...
@@ -308,8 +310,7 @@ function capitalizeFirstLetter (str) {
// -----------------------------------------------------------------------------
function
dirname
(
str
)
{
var
os
=
Qt
.
platform
.
os
if
(
os
===
'
windows
'
||
os
===
'
winrt
'
)
{
if
(
runOnWindows
())
{
str
=
str
.
replace
(
/
\\
/g
,
'
/
'
)
}
...
...
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