diff --git a/src/mainview/components/CallViewContextMenu.qml b/src/mainview/components/CallViewContextMenu.qml index 12f2d6cb8bbb8ce59eb81f82561d7f2c3bdfafe7..a9b656e59001fad6034d36512fff71198554ac58 100644 --- a/src/mainview/components/CallViewContextMenu.qml +++ b/src/mainview/components/CallViewContextMenu.qml @@ -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: { diff --git a/src/messagesadapter.cpp b/src/messagesadapter.cpp index 7f2d85a0ee8850a28f5654eeca7b28548cc51389..8238f5cb806caf82e503a2364f7fc7bb213b2555 100644 --- a/src/messagesadapter.cpp +++ b/src/messagesadapter.cpp @@ -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); /* diff --git a/src/utilsadapter.cpp b/src/utilsadapter.cpp index c6de3971455084abccfe28afb52649cff37c96cf..dea883ed11fc57b3768108439e1deba28243525d 100644 --- a/src/utilsadapter.cpp +++ b/src/utilsadapter.cpp @@ -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