From fcd089040ce6a3860ab4abccc6f56afcd99baeed Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Tue, 26 Nov 2013 11:22:02 +0100 Subject: 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 --- examples/quick/quicknanobrowser/quickwindow.qml | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'examples/quick') 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.") -- cgit v1.2.3