diff options
author | Michal Klocek <michal.klocek@qt.io> | 2020-08-25 11:37:34 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2020-09-24 15:14:59 +0200 |
commit | f613095208911cfa6b8609f8b87b4984dc55e69c (patch) | |
tree | 09a25473d27a2b7d174966fb28594c07de8db510 /src/core/api/qwebenginescript.h | |
parent | e2e249b8bb399ef7bcf6fe3be0b4f2fc9fa18182 (diff) |
Reuse qwebenginescript in qml
Reuse core class and adopt api:
* add missing setUrlSource to c++ class
* fix typing for setRunsOnSubFrames
* remove all invokable from setters in qml,
we use properties for that anyway.
* remove invokable toString , since we have debug
stream operator in c++
[ChangeLog] In qml websetttings.runOnSubframes is now
websettings.runsOnSubFrames
Change-Id: Iba822a7aa6a59940484c972726d710a1b66cb20d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/api/qwebenginescript.h')
-rw-r--r-- | src/core/api/qwebenginescript.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/core/api/qwebenginescript.h b/src/core/api/qwebenginescript.h index 628e24ed5..42a98e3e2 100644 --- a/src/core/api/qwebenginescript.h +++ b/src/core/api/qwebenginescript.h @@ -41,9 +41,9 @@ #define QWEBENGINESCRIPT_H #include <QtWebEngineCore/qtwebenginecoreglobal.h> - -#include <QtCore/qshareddata.h> -#include <QtCore/qstring.h> +#include <QtCore/QUrl> +#include <QtCore/QObject> +#include <QtCore/QSharedDataPointer> namespace QtWebEngineCore { class UserScript; @@ -52,19 +52,33 @@ class UserScript; QT_BEGIN_NAMESPACE class Q_WEBENGINECORE_EXPORT QWebEngineScript { + + Q_GADGET + Q_PROPERTY(QString name READ name WRITE setName FINAL) + Q_PROPERTY(QUrl sourceUrl READ sourceUrl WRITE setSourceUrl FINAL) + Q_PROPERTY(QString sourceCode READ sourceCode WRITE setSourceCode FINAL) + Q_PROPERTY(InjectionPoint injectionPoint READ injectionPoint WRITE setInjectionPoint FINAL) + Q_PROPERTY(quint32 worldId READ worldId WRITE setWorldId FINAL) + Q_PROPERTY(bool runsOnSubFrames READ runsOnSubFrames WRITE setRunsOnSubFrames FINAL) + public: + enum InjectionPoint { Deferred, DocumentReady, DocumentCreation }; + Q_ENUM(InjectionPoint) + enum ScriptWorldId { MainWorld = 0, ApplicationWorld, UserWorld }; + Q_ENUM(ScriptWorldId) + QWebEngineScript(); QWebEngineScript(const QWebEngineScript &other); ~QWebEngineScript(); @@ -76,6 +90,9 @@ public: QString name() const; void setName(const QString &); + QUrl sourceUrl() const; + void setSourceUrl(const QUrl &url); + QString sourceCode() const; void setSourceCode(const QString &); @@ -93,8 +110,8 @@ public: { return !operator==(other); } void swap(QWebEngineScript &other) { qSwap(d, other.d); } - private: + friend class QQuickWebEngineScriptCollectionPrivate; friend class QWebEngineScriptCollectionPrivate; friend class QWebEngineScriptCollection; QWebEngineScript(const QtWebEngineCore::UserScript &); |