mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 03:26:05 -04:00
Introduce QWebEngine Javascript Infrastructure
Setup for header anchor injection
This commit is contained in:
parent
b1f02ec89c
commit
02e213920c
@ -232,6 +232,7 @@ RESOURCES += \
|
||||
resources/translations.qrc \
|
||||
resources/contentmanager.qrc \
|
||||
resources/settingsmanager.qrc \
|
||||
resources/style.qrc
|
||||
resources/style.qrc \
|
||||
resources/js.qrc
|
||||
|
||||
RC_ICONS = resources/icons/kiwix/app_icon.ico
|
||||
|
5
resources/js.qrc
Normal file
5
resources/js.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>js/headerAnchor.js</file>
|
||||
</qresource>
|
||||
</RCC>
|
0
resources/js/headerAnchor.js
Normal file
0
resources/js/headerAnchor.js
Normal file
@ -4,6 +4,26 @@
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QWebEngineSettings>
|
||||
#include <QWebEngineScript>
|
||||
#include <QWebEngineScriptCollection>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
QWebEngineScript getScript(QString filename,
|
||||
QWebEngineScript::InjectionPoint point = QWebEngineScript::DocumentReady)
|
||||
{
|
||||
QWebEngineScript script;
|
||||
script.setInjectionPoint(point);
|
||||
script.setWorldId(QWebEngineScript::UserWorld);
|
||||
|
||||
QFile scriptFile(filename);
|
||||
scriptFile.open(QIODevice::ReadOnly);
|
||||
script.setSourceCode(scriptFile.readAll());
|
||||
return script;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString askForSaveFilePath(const QString& suggestedName)
|
||||
{
|
||||
@ -36,6 +56,8 @@ KProfile::KProfile(QObject *parent) :
|
||||
#else // Qt 5.13 and later
|
||||
setUrlRequestInterceptor(new ExternalReqInterceptor(this));
|
||||
#endif
|
||||
|
||||
scripts()->insert(getScript(":/js/headerAnchor.js"));
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user