From 769b3a61f5d2abcb3f694ade95e1e8f1c505b75a Mon Sep 17 00:00:00 2001 From: Szabolcs David Date: Mon, 2 Mar 2015 08:00:59 -0800 Subject: Promote fullscreen API to 5.5 public Introduce a new FullScreenRequest object as the parameter of the fullScreenRequested signal and expose the isFullScreen property as read-only. This makes the API harder to misuse. Change-Id: Ibb072ec93843e6df265bd930e8721d244bc2f4bc Reviewed-by: Andras Becsi --- .../webengine/quicknanobrowser/BrowserWindow.qml | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'examples/webengine') diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml index f451c8c07..f61bce268 100644 --- a/examples/webengine/quicknanobrowser/BrowserWindow.qml +++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml @@ -52,12 +52,26 @@ ApplicationWindow { id: browserWindow property QtObject applicationRoot property Item currentWebView: tabs.currentIndex < tabs.count ? tabs.getTab(tabs.currentIndex).item : null + property int previousVisibility: Window.Windowed + + property bool isFullScreen: visibility == Window.FullScreen + onIsFullScreenChanged: { + // This is for the case where the system forces us to leave fullscreen. + if (currentWebView && !isFullScreen) { + currentWebView.state = "" + if (currentWebView.isFullScreen) + currentWebView.fullScreenCancelled() + } + } width: 1300 height: 900 visible: true title: currentWebView && currentWebView.title + // Make sure the Qt.WindowFullscreenButtonHint is set on OS X. + 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 } @@ -123,6 +137,13 @@ ApplicationWindow { tabs.removeTab(tabs.currentIndex) } } + Action { + shortcut: "Escape" + onTriggered: { + if (browserWindow.isFullScreen) + browserWindow.visibility = browserWindow.previousVisibility + } + } Action { shortcut: "Ctrl+0" onTriggered: currentWebView.zoomFactor = 1.0; @@ -289,6 +310,21 @@ ApplicationWindow { } } + states: [ + State { + name: "FullScreen" + PropertyChanges { + target: tabs + frameVisible: false + tabsVisible: false + } + PropertyChanges { + target: navigationBar + visible: false + } + } + ] + onCertificateError: { error.defer() sslDialog.enqueue(error) @@ -308,6 +344,18 @@ ApplicationWindow { request.openIn(window.currentWebView) } } + + onFullScreenRequested: { + if (request.toggleOn) { + webEngineView.state = "FullScreen" + browserWindow.previousVisibility = browserWindow.visibility + browserWindow.showFullScreen() + } else { + webEngineView.state = "" + browserWindow.visibility = browserWindow.previousVisibility + } + request.accept() + } } } } -- cgit v1.2.3