summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@digia.com>2013-11-26 11:22:02 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-11 13:15:20 +0100
commitfcd089040ce6a3860ab4abccc6f56afcd99baeed (patch)
treefb9b18d76b5a8072e93972fd38bb9abb1e0ce39a /src/webengine
parent331b7fa11c84107e3300b14ece5fc5991cfc35e9 (diff)
Implement requestFullscreen for QQuickWebEngineView.
This patch adds a property isFullScreen and a signal fullScreenRequested to QQuickWebEngineViewExperimental. The signal fullScreenRequested is emitted when some web content requests fullscreen through the javascript API. The property isFullScreen is supposed to be set programmatically when the view is being shown fullscreen. This information is then available to the WebContentsDelegateQt when checking if the fullscreen request has been accepted. Change-Id: I04cbb45f263a188d26cc87d70ac53b0fbab63936 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebengineview.cpp22
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h10
2 files changed, 32 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 2f5d868e..e91f2ee7 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -70,6 +70,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
, loadProgress(0)
, inspectable(false)
, m_isLoading(false)
+ , m_isFullScreen(false)
, devicePixelRatio(QGuiApplication::primaryScreen()->devicePixelRatio())
, m_dpiScale(1.0)
{
@@ -324,6 +325,16 @@ void QQuickWebEngineViewPrivate::close()
Q_UNREACHABLE();
}
+void QQuickWebEngineViewPrivate::requestFullScreen(bool fullScreen)
+{
+ Q_EMIT e->fullScreenRequested(fullScreen);
+}
+
+bool QQuickWebEngineViewPrivate::isFullScreen() const
+{
+ return e->isFullScreen();
+}
+
void QQuickWebEngineViewPrivate::javaScriptConsoleMessage(int level, const QString& message, int lineNumber, const QString& sourceID)
{
Q_Q(QQuickWebEngineView);
@@ -438,6 +449,17 @@ void QQuickWebEngineView::setInspectable(bool enable)
d->adapter->enableInspector(enable);
}
+void QQuickWebEngineViewExperimental::setIsFullScreen(bool fullscreen)
+{
+ d_ptr->m_isFullScreen = fullscreen;
+ emit isFullScreenChanged();
+}
+
+bool QQuickWebEngineViewExperimental::isFullScreen() const
+{
+ return d_ptr->m_isFullScreen;
+}
+
void QQuickWebEngineViewExperimental::setExtraContextMenuEntriesComponent(QQmlComponent *contextMenuExtras)
{
if (d_ptr->contextMenuExtraItems == contextMenuExtras)
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 3de59746..d35758d7 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -93,8 +93,13 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineViewExperimental : public QObjec
Q_OBJECT
Q_PROPERTY(QQuickWebEngineViewport *viewport READ viewport)
Q_PROPERTY(QQmlComponent *extraContextMenuEntriesComponent READ extraContextMenuEntriesComponent WRITE setExtraContextMenuEntriesComponent NOTIFY extraContextMenuEntriesComponentChanged)
+ Q_PROPERTY(bool isFullScreen READ isFullScreen WRITE setIsFullScreen NOTIFY isFullScreenChanged)
public:
+ void setIsFullScreen(bool fullscreen);
+ bool isFullScreen() const;
+
+public Q_SLOTS:
QQuickWebEngineViewport *viewport() const;
Q_INVOKABLE void adoptHandle(QQuickWebEngineViewHandle *viewHandle);
void setExtraContextMenuEntriesComponent(QQmlComponent *);
@@ -102,6 +107,8 @@ public:
Q_SIGNALS:
void createWindow(const QJSValue &newViewHandle, const QString &newViewDisposition);
+ void fullScreenRequested(bool fullScreen);
+ void isFullScreenChanged();
void extraContextMenuEntriesComponentChanged();
private:
@@ -135,6 +142,8 @@ public:
virtual void focusContainer() Q_DECL_OVERRIDE;
virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, const QRect &) Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;
+ virtual void requestFullScreen(bool) Q_DECL_OVERRIDE;
+ virtual bool isFullScreen() const Q_DECL_OVERRIDE;
virtual bool contextMenuRequested(const WebEngineContextMenuData &) Q_DECL_OVERRIDE;
virtual void javascriptDialog(QSharedPointer<JavaScriptDialogController>) Q_DECL_OVERRIDE;
virtual void runFileChooser(FileChooserMode, const QString &defaultFileName, const QStringList &acceptedMimeTypes) Q_DECL_OVERRIDE;
@@ -154,6 +163,7 @@ public:
int loadProgress;
bool inspectable;
bool m_isLoading;
+ bool m_isFullScreen;
qreal devicePixelRatio;
private: