Commit e059e36d authored by Ronan Abhamon's avatar Ronan Abhamon

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

parent 796205cd
......@@ -75,14 +75,11 @@ TextField {
return ''
}
var folder = Utils.dirname(textField.selectedFile)
return !Utils.startsWith(folder, 'file:')
? 'file:' + folder
: folder
return Utils.getUriFromSystemPath(Utils.dirname(textField.selectedFile))
}
onAccepted: {
textField.selectedFile = Utils.getPathFromUri(fileUrl)
textField.selectedFile = Utils.getSystemPathFromUri(fileUrl)
textField.accepted(textField.selectedFile)
}
......
......@@ -29,7 +29,7 @@ Item {
// Filtering files, other urls are forbidden.
files = files.reduce(function (files, file) {
if (file.startsWith('file:')) {
files.push(Utils.getPathFromUri(file))
files.push(Utils.getSystemPathFromUri(file))
}
return files
......
......@@ -71,7 +71,7 @@ Notification {
hoverEnabled: true
onClicked: notification._close(function () {
Qt.openUrlExternally('file://' + Utils.dirname(notification._fileUri))
Qt.openUrlExternally(Utils.getUriFromSystemPath(Utils.dirname(notification._fileUri)))
})
}
}
......
......@@ -155,7 +155,7 @@ function openWindow (window, parent, options) {
// -----------------------------------------------------------------------------
function getPathFromUri (uri) {
function getSystemPathFromUri (uri) {
var str = uri.toString()
if (startsWith(str, 'file://')) {
str = str.substring(7)
......@@ -172,6 +172,19 @@ function getPathFromUri (uri) {
return str
}
function getUriFromSystemPath (path) {
if (path.startsWith('file://')) {
return path
}
var os = Qt.platform.os
if (os === 'windows' || os === 'winrt') {
return 'file://' + (/^[^:]+:/.exec(path) ? '' : '/')
}
return 'file://' + path
}
// -----------------------------------------------------------------------------
// Test if a point is in a item.
......
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