filetransfer: adjust the url decoding for qml component file urls

Gitlab: #92
Change-Id: I10ae359b26c70cacdb1e1168658678f3f5b2a96e
This commit is contained in:
Andreas Traczyk
2020-09-18 16:14:23 -04:00
parent 2cb4921779
commit 21b0e5eeb3
3 changed files with 9 additions and 9 deletions

View File

@@ -149,10 +149,7 @@ Item {
mode: JamiFileDialog.Mode.OpenFile
onAccepted: {
// No need to trim file:///.
AvAdapter.shareFile(jamiFileDialog.file)
}
onAccepted: AvAdapter.shareFile(jamiFileDialog.file)
}
Component.onCompleted: {

View File

@@ -264,9 +264,9 @@ MessagesAdapter::sendImage(const QString& message)
QString msg(message);
#ifdef Q_OS_WIN
msg = msg.replace("file:///", "");
msg = msg.replace("file://", "");
#else
msg = msg.replace("file:///", "/");
msg = msg.replace("file://", "/");
#endif
QFileInfo fi(msg);
QString fileName = fi.fileName();
@@ -337,7 +337,7 @@ MessagesAdapter::deleteInteraction(const QString& arg)
void
MessagesAdapter::openFile(const QString& arg)
{
QUrl fileUrl("file:///" + arg);
QUrl fileUrl("file://" + arg);
if (!QDesktopServices::openUrl(fileUrl)) {
qDebug() << "Couldn't open file: " << fileUrl;
}
@@ -399,9 +399,9 @@ MessagesAdapter::pasteKeyDetected()
*/
for (int i = 0; i < urlList.size(); ++i) {
/*
* Trim file:/// from url.
* Trim file:// from url.
*/
QString filePath = urlList.at(i).toString().remove(0, 8);
QString filePath = urlList.at(i).toString().remove("file://");
QByteArray imageFormat = QImageReader::imageFormat(filePath);
/*

View File

@@ -353,6 +353,9 @@ UtilsAdapter::toFileAbsolutepath(QString inputFileName)
QString
UtilsAdapter::getAbsPath(QString path)
{
// Note: this function is used on urls returned from qml-FileDialogs which
// contain 'file:///' for reasons we don't understand.
// TODO: this logic can be refactored into the JamiFileDialog component.
#ifdef Q_OS_WIN
return path.replace("file:///", "").replace("\n", "").replace("\r", "");
#else