Commit 0d526abd authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/scripts/Utils/utils): provide a `getPathFromUri` function

parent 5f203eaa
......@@ -82,7 +82,7 @@ TextField {
}
onAccepted: {
textField.selectedFile = fileUrl.toString().substring(7)
textField.selectedFile = Utils.getPathFromUri(fileUrl)
textField.accepted(textField.selectedFile)
}
......
......@@ -155,6 +155,25 @@ function openWindow (window, parent, options) {
// -----------------------------------------------------------------------------
function getPathFromUri (uri) {
var str = uri.toString()
if (startsWith(str, 'file://')) {
str = str.substring(7)
// Absolute path.
if (str.charAt(0) === '/') {
var os = Qt.platform.os
return os === 'windows' || os === 'winrt'
? str.substring(1)
: str
}
}
return str
}
// -----------------------------------------------------------------------------
// Test if a point is in a item.
//
// `source` is the item that generated the point.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment