diff --git a/graphicsview.cpp b/graphicsview.cpp index 4226ca4..af7bcab 100644 --- a/graphicsview.cpp +++ b/graphicsview.cpp @@ -35,10 +35,6 @@ void GraphicsView::showFileFromUrl(const QUrl &url, bool doRequestGallery) // TODO: remove this workaround when M$ change the "wsl$" hostname. if (Q_UNLIKELY(url.scheme() == QStringLiteral("qtbug-86277"))) { filePath = url.path(); - // Qt's QUrl won't work with such hostname anyway so the urls will - // still be the wrong one when requesting gallery. So we just don't - // request gallery here... - doRequestGallery = false; } #endif // Q_OS_WIN diff --git a/mainwindow.cpp b/mainwindow.cpp index e7597b4..f5868ae 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -238,9 +238,20 @@ void MainWindow::loadGalleryBySingleLocalFile(const QString &path) clearGallery(); for (int i = 0; i < entryList.count(); i++) { - const QString & oneEntry = entryList.at(i); - m_files.append(QUrl::fromLocalFile(dir.absoluteFilePath(oneEntry))); - if (oneEntry == currentFileName) { + const QString & fileName = entryList.at(i); + const QString & oneEntry = dir.absoluteFilePath(fileName); + QUrl url = QUrl::fromLocalFile(oneEntry); +#ifdef Q_OS_WIN + // TODO: remove this workaround when M$ change the "wsl$" hostname. + // Qt will convert path "\\wsl$\" to "//wsl$/"... + if (Q_UNLIKELY(oneEntry.startsWith(R"(//wsl$/)"))) { + url.clear(); + url.setScheme(QStringLiteral("qtbug-86277")); + url.setPath(oneEntry); + } +#endif // Q_OS_WIN + m_files.append(url); + if (fileName == currentFileName) { m_currentFileIndex = i; } }