diff options
author | Szabolcs David <davidsz@inf.u-szeged.hu> | 2015-03-02 08:00:59 -0800 |
---|---|---|
committer | Szabolcs David <davidsz@inf.u-szeged.hu> | 2015-03-09 11:54:11 +0000 |
commit | 769b3a61f5d2abcb3f694ade95e1e8f1c505b75a (patch) | |
tree | 593d303493d3b771c32438cf12a44b34c4eff819 /examples | |
parent | 42c39d0545ee98feccf6d8059aee082c47a8e730 (diff) |
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 <andras.becsi@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/webengine/quicknanobrowser/BrowserWindow.qml | 48 |
1 files changed, 48 insertions, 0 deletions
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 } @@ -124,6 +138,13 @@ ApplicationWindow { } } 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() + } } } } |