From 7692f9f82aa7115956f477ed6bc1d53e7ce6c895 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sat, 2 Jan 2021 09:53:56 +0800 Subject: [PATCH] WebViewer: support link jump --- src/widgets/webpage.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/widgets/webpage.cpp b/src/widgets/webpage.cpp index 8390f6df..89754164 100644 --- a/src/widgets/webpage.cpp +++ b/src/widgets/webpage.cpp @@ -1,5 +1,9 @@ #include "webpage.h" +#include +#include +#include + using namespace vnotex; WebPage::WebPage(QWidget *p_parent) @@ -13,12 +17,17 @@ bool WebPage::acceptNavigationRequest(const QUrl &p_url, bool p_isMainFrame) { Q_UNUSED(p_type); - if (!p_isMainFrame) { + if (p_url.isLocalFile()) { + emit VNoteX::getInst().openFileRequested(p_url.toLocalFile(), + QSharedPointer::create()); + return false; + } if (!p_isMainFrame) { return true; } else if (p_url.scheme() == QStringLiteral("data")) { // Qt 5.12 and above will trigger this when calling QWebEngineView::setHtml(). return true; } + WidgetUtils::openUrlByDesktop(p_url); return false; }