add base URL in setHtml() to enable it access local files

This commit is contained in:
Le Tan 2018-01-21 15:32:27 +08:00
parent d630ff7bf2
commit cdf3eb537b
3 changed files with 7 additions and 5 deletions

View File

@ -60,7 +60,8 @@ void VTipsDialog::readFile(const QString &p_tipFile)
g_config->getMarkdownExtensions(), g_config->getMarkdownExtensions(),
toc); toc);
html = VUtils::generateSimpleHtmlTemplate(html); html = VUtils::generateSimpleHtmlTemplate(html);
m_viewer->setHtml(html); // Add a base URL to enable it to access local style files.
m_viewer->setHtml(html, QUrl("qrc:/resources"));
} }
void VTipsDialog::showEvent(QShowEvent *p_event) void VTipsDialog::showEvent(QShowEvent *p_event)

View File

@ -37,7 +37,8 @@ void VUpdater::setupUI()
m_descriptionWV = VUtils::getWebEngineView(); m_descriptionWV = VUtils::getWebEngineView();
m_descriptionWV->setContextMenuPolicy(Qt::NoContextMenu); m_descriptionWV->setContextMenuPolicy(Qt::NoContextMenu);
m_descriptionWV->setHtml(VUtils::generateSimpleHtmlTemplate(VNote::s_sloganTemplate)); m_descriptionWV->setHtml(VUtils::generateSimpleHtmlTemplate(VNote::s_sloganTemplate),
QUrl("qrc:/resources"));
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok); m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok);
m_btnBox->button(QDialogButtonBox::Ok)->setProperty("SpecialBtn", true); m_btnBox->button(QDialogButtonBox::Ok)->setProperty("SpecialBtn", true);
@ -180,6 +181,6 @@ void VUpdater::parseResult(const QByteArray &p_data)
g_config->getMarkdownExtensions(), g_config->getMarkdownExtensions(),
toc); toc);
html = VUtils::generateSimpleHtmlTemplate(html); html = VUtils::generateSimpleHtmlTemplate(html);
m_descriptionWV->setHtml(html); m_descriptionWV->setHtml(html, QUrl("qrc:/resources"));
m_proBar->hide(); m_proBar->hide();
} }

View File

@ -172,7 +172,7 @@ table tr th :last-child, table tr td :last-child {
div.mermaid-diagram { div.mermaid-diagram {
overflow-y: hidden; overflow-y: hidden;
background: #7D879B; background: #B0BEC5;
color: #6C6C6C; color: #6C6C6C;
} }
@ -182,7 +182,7 @@ pre.mermaid-diagram {
div.flowchart-diagram { div.flowchart-diagram {
overflow-y: hidden; overflow-y: hidden;
background: #7D879B; background: #B0BEC5;
color: #6C6C6C; color: #6C6C6C;
} }