WebViewer: support link jump

This commit is contained in:
Le Tan 2021-01-02 09:53:56 +08:00
parent aaa8fe85e8
commit 7692f9f82a

View File

@ -1,5 +1,9 @@
#include "webpage.h" #include "webpage.h"
#include <utils/widgetutils.h>
#include <core/vnotex.h>
#include <core/fileopenparameters.h>
using namespace vnotex; using namespace vnotex;
WebPage::WebPage(QWidget *p_parent) WebPage::WebPage(QWidget *p_parent)
@ -13,12 +17,17 @@ bool WebPage::acceptNavigationRequest(const QUrl &p_url,
bool p_isMainFrame) bool p_isMainFrame)
{ {
Q_UNUSED(p_type); Q_UNUSED(p_type);
if (!p_isMainFrame) { if (p_url.isLocalFile()) {
emit VNoteX::getInst().openFileRequested(p_url.toLocalFile(),
QSharedPointer<FileOpenParameters>::create());
return false;
} if (!p_isMainFrame) {
return true; return true;
} else if (p_url.scheme() == QStringLiteral("data")) { } else if (p_url.scheme() == QStringLiteral("data")) {
// Qt 5.12 and above will trigger this when calling QWebEngineView::setHtml(). // Qt 5.12 and above will trigger this when calling QWebEngineView::setHtml().
return true; return true;
} }
WidgetUtils::openUrlByDesktop(p_url);
return false; return false;
} }