Commit c13410b0 authored by Igor Kushnir's avatar Igor Kushnir
Browse files

Register "qthelp" Web Engine URL scheme

From the documentation for QWebEngineUrlScheme::registerScheme():
  It is recommended that all custom URL schemes are first registered
  with this function at application startup, even if the default options
  are to be used.
  Warning: This function must be called early at application startup,
  before creating any WebEngine classes. Late calls will be ignored.
=> register the scheme early at KDevelop's start to ensure it is not
ignored. DocumentationController's constructor is called once and before
plugins (which may create WebEngine classes) are loaded.

This gets rid of the following warning in KDevelop's output:
  Please register the custom scheme 'qthelp' via
  QWebEngineUrlScheme::registerScheme() before installing the custom
  scheme handler.

Don't set the scheme syntax or flags. I have tried to set syntax to Host
and flags to LocalScheme|LocalAccessAllowed, but haven't noticed any
effect. In particular, the following type of warning in KDevelop's
output wasn't eliminated by such tentative changes:
  js: Not allowed to load local resource: file:///tmp/kdevelop.qWHueg

!108 first
tried to register this scheme more than two years ago, but the
registering was reverted as unrelated to the topic of the merge request.
Note that the comment "Needs some ifqtversion>=5.12, same for #include"
from that merge request is no longer relevant as KDevelop requires
Qt 5.15.0 or later.
parent 9bd579b2
Pipeline #192611 passed with stage
in 18 minutes and 23 seconds
......@@ -30,6 +30,7 @@
#include <QWebEngineView>
#include <QWebEnginePage>
#include <QWebEngineSettings>
#include <QWebEngineUrlScheme>
#include <QWebEngineUrlSchemeHandler>
#include <QWebEngineUrlRequestJob>
#include <QWebEngineProfile>
......@@ -38,6 +39,9 @@
using namespace KDevelop;
namespace {
auto qtHelpSchemeName() { return QByteArrayLiteral("qthelp"); }
class StandardDocumentationPage : public QWebEnginePage
......@@ -66,8 +70,18 @@ private:
KDevelop::StandardDocumentationView* const m_view;
bool m_isDelegating = false;
} // unnamed namespace
void StandardDocumentationView::registerCustomUrlSchemes()
QWebEngineUrlScheme scheme(qtHelpSchemeName());
class KDevelop::StandardDocumentationViewPrivate
......@@ -346,7 +360,7 @@ void KDevelop::StandardDocumentationView::setNetworkAccessManager(QNetworkAccess
d->m_view->page()->profile()->installUrlSchemeHandler("qthelp", new CustomSchemeHandler(manager, this));
d->m_view->page()->profile()->installUrlSchemeHandler(qtHelpSchemeName(), new CustomSchemeHandler(manager, this));
......@@ -28,6 +28,8 @@ class KDEVPLATFORMDOCUMENTATION_EXPORT StandardDocumentationView : public QWidge
static void registerCustomUrlSchemes();
explicit StandardDocumentationView(DocumentationFindWidget* findWidget, QWidget* parent = nullptr );
~StandardDocumentationView() override;
......@@ -33,6 +33,7 @@
#include <language/duchain/types/identifiedtype.h>
#include <language/duchain/types/typeutils.h>
#include <documentation/documentationview.h>
#include <documentation/standarddocumentationview.h>
using namespace KDevelop;
......@@ -107,6 +108,8 @@ private:
DocumentationController::DocumentationController(Core* core)
: m_factory(new DocumentationViewFactory)
m_showDocumentation = core->uiController()->activeMainWindow()->actionCollection()->addAction(QStringLiteral("showDocumentation"));
m_showDocumentation->setText(i18nc("@action", "Show Documentation"));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment