mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-24 15:18:07 +00:00
feat(ui/scripts/Utils/utils): provide a getUriFromSystemPath function
This commit is contained in:
parent
796205cd58
commit
e059e36d87
4 changed files with 18 additions and 8 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue