19#include "../../qmlstaticdata.h"
34 return m_webEngineScript;
40 m_webEngineScript = script;
50 return m_webEngineScript.name();
53void QmlUserScript::setName(
const QString &name)
56 m_webEngineScript.setName(
name);
58 aboutToUpdateUnderlyingScript();
63 return m_webEngineScript.runsOnSubFrames();
66void QmlUserScript::setRunsOnSubFrames(
bool runsOnSubFrames)
71 aboutToUpdateUnderlyingScript();
76 return static_cast<int>(m_webEngineScript.worldId());
79void QmlUserScript::setWorldId(
int worldId)
83 case QWebEngineScript::MainWorld:
84 m_webEngineScript.setWorldId(QWebEngineScript::MainWorld);
86 case QWebEngineScript::ApplicationWorld:
87 m_webEngineScript.setWorldId(QWebEngineScript::ApplicationWorld);
89 case QWebEngineScript::UserWorld:
90 m_webEngineScript.setWorldId(QWebEngineScript::UserWorld);
96 aboutToUpdateUnderlyingScript();
101 return m_webEngineScript.sourceCode();
104void QmlUserScript::setSourceCode(
const QString &sourceCode)
109 aboutToUpdateUnderlyingScript();
114 return static_cast<InjectionPoint>(m_webEngineScript.injectionPoint());
117void QmlUserScript::setInjectionPoint(InjectionPoint injectionPoint)
120 switch (
static_cast<QWebEngineScript::InjectionPoint
>(
injectionPoint)) {
121 case QWebEngineScript::DocumentCreation:
122 m_webEngineScript.setInjectionPoint(QWebEngineScript::DocumentCreation);
124 case QWebEngineScript::DocumentReady:
125 m_webEngineScript.setInjectionPoint(QWebEngineScript::DocumentReady);
127 case QWebEngineScript::Deferred:
128 m_webEngineScript.setInjectionPoint(QWebEngineScript::Deferred);
134 aboutToUpdateUnderlyingScript();
137void QmlUserScript::timerEvent(QTimerEvent *e)
139 if (e->timerId() != m_basicTimer.timerId()) {
140 QObject::timerEvent(e);
147void QmlUserScript::aboutToUpdateUnderlyingScript()
149 if (!m_basicTimer.isActive()) {
153 m_basicTimer.start(0,
this);
QmlUserScripts * getUserScriptsSingleton()
static QmlStaticData & instance()
InjectionPoint injectionPoint
Injection point of the UserScript.
void nameChanged(const QString &name)
The signal emitted when the script name is changed.
bool runsOnSubFrames
Checks if the UserScript runs on sub frames.
bool null
Checks if the UserScript is null.
void sourceCodeChanged(const QString &sourceCode)
The signal emitted when source code of the script is changed.
int worldId
WorldId of the UserScript.
void runsOnSubFramesChanged(bool runsOnSubFrames)
The signal emitted when runsOnSubFrame property of the script is changed.
QString sourceCode
Source code of the UserScript.
void injectionPointChanged(int injectionPoint)
The signal emitted when injectionPoint property of the script is changed.
QWebEngineScript webEngineScript() const
QmlUserScript(QObject *parent=nullptr)
void worldIdChanged(int worldId)
The signal emitted when worldId property of the script is changed.
void setWebEngineScript(const QWebEngineScript &script)
QString name
Name of the UserScript.
InjectionPoint
The enum exposing QWebEngineScript::InjectionPoint.
~QmlUserScript() override
Q_INVOKABLE void remove(QObject *object) const
Removes a script from collection.
void insert(QObject *object)