diff options
author | Zeno Albisser <zeno.albisser@digia.com> | 2013-11-26 11:22:02 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-11 13:15:20 +0100 |
commit | fcd089040ce6a3860ab4abccc6f56afcd99baeed (patch) | |
tree | fb9b18d76b5a8072e93972fd38bb9abb1e0ce39a /examples | |
parent | 331b7fa11c84107e3300b14ece5fc5991cfc35e9 (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 'examples')
-rw-r--r-- | examples/quick/quicknanobrowser/quickwindow.qml | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/examples/quick/quicknanobrowser/quickwindow.qml b/examples/quick/quicknanobrowser/quickwindow.qml index 88fc9f8a0..d72c30021 100644 --- a/examples/quick/quicknanobrowser/quickwindow.qml +++ b/examples/quick/quicknanobrowser/quickwindow.qml @@ -44,6 +44,7 @@ import QtWebEngine.experimental 1.0 import QtQuick.Controls 1.0 import QtQuick.Controls.Styles 1.0 import QtQuick.Layouts 1.0 +import QtQuick.Window 2.1 import QtQuick.Controls.Private 1.0 ApplicationWindow { @@ -51,11 +52,21 @@ ApplicationWindow { function load(url) { tabs.currentView.url = url } function adoptHandle(viewHandle) { tabs.currentView.adoptHandle(viewHandle) } + property bool isFullScreen: visibility == Window.FullScreen + onIsFullScreenChanged: { + // This is for the case where the system forces us to leave fullscreen. + if (!isFullScreen && tabs.currentView.state == "FullScreen") + tabs.currentView.state = "" + } + height: 600 width: 800 visible: true title: tabs.currentView && tabs.currentView.title + // Make sure the Qt.WindowFullscreenButtonHint is set on Mac. + Component.onCompleted: flags = flags | Qt.WindowFullscreenButtonHint + // Create a styleItem to determine the platform. // When using style "mac", ToolButtons are not supposed to accept focus. StyleItem { id: styleItem } @@ -92,6 +103,14 @@ ApplicationWindow { } } + Action { + shortcut: "Escape" + onTriggered: { + if (browserWindow.isFullScreen) + browserWindow.showNormal() + } + } + toolBar: ToolBar { id: navigationBar RowLayout { @@ -174,11 +193,38 @@ ApplicationWindow { Component { id: tabComponent WebEngineView { + id: webEngineView function adoptHandle(viewHandle) { experimental.adoptHandle(viewHandle) } focus: true + states: [ + State { + name: "FullScreen" + PropertyChanges { + target: tabs + frameVisible: false + tabsVisible: false + } + PropertyChanges { + target: navigationBar + visible: false + } + } + ] + experimental { + isFullScreen: webEngineView.state == "FullScreen" && browserWindow.isFullScreen + onFullScreenRequested: { + if (fullScreen) { + webEngineView.state = "FullScreen" + browserWindow.showFullScreen(); + } else { + webEngineView.state = "" + browserWindow.showNormal(); + } + } + onCreateWindow: { if (newViewDisposition == "popup") print("Warning: Ignored a popup window.") |