fix/pdf_name_ascii (#2341)

* fix/pdf_name_ascii

* adj

* Update src/widgets/pdfviewwindow.cpp

---------

Co-authored-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
chendapao 2023-01-29 22:55:54 +08:00 committed by GitHub
parent f1a03554f0
commit 075380749c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,7 +119,8 @@ void PdfViewWindow::syncEditorFromBuffer()
auto buffer = getBuffer();
if (buffer) {
const auto url = PathUtils::pathToUrl(buffer->getContentPath());
const auto urlStr = url.toString(QUrl::EncodeSpaces);
// Solution to ASCII problems, like these file names with these symbols # + &.
const auto urlStr = QUrl::toPercentEncoding(url.toString(QUrl::FullyDecoded));
auto templateUrl = PathUtils::pathToUrl(HtmlTemplateHelper::getPdfViewerTemplatePath());
templateUrl.setQuery("file=" + urlStr);
m_viewer->setHtml(HtmlTemplateHelper::getPdfViewerTemplate(), templateUrl);