mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
bugfix: determine the base url by the file type
This commit is contained in:
parent
44257913f7
commit
05f7bcfcf0
@ -334,7 +334,25 @@ void VEditTab::setupMarkdownPreview()
|
||||
if (!extraFile.isEmpty()) {
|
||||
htmlTemplate.replace(extraHolder, extraFile);
|
||||
}
|
||||
webPreviewer->setHtml(htmlTemplate, QUrl::fromLocalFile(m_file->retriveBasePath() + QDir::separator()));
|
||||
|
||||
// Need to judge the path: Url, local file, resource file.
|
||||
QUrl baseUrl;
|
||||
QString basePath = m_file->retriveBasePath();
|
||||
QFileInfo pathInfo(basePath);
|
||||
if (pathInfo.exists()) {
|
||||
if (pathInfo.isNativePath()) {
|
||||
// Local file.
|
||||
baseUrl = QUrl::fromLocalFile(basePath + QDir::separator());
|
||||
} else {
|
||||
// Resource file.
|
||||
baseUrl = QUrl("qrc" + basePath + QDir::separator());
|
||||
}
|
||||
} else {
|
||||
// Url.
|
||||
baseUrl = QUrl(basePath + QDir::separator());
|
||||
}
|
||||
|
||||
webPreviewer->setHtml(htmlTemplate, baseUrl);
|
||||
addWidget(webPreviewer);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user