summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/webengine/quicknanobrowser/BrowserWindow.qml48
-rw-r--r--src/webengine/api/qquickwebengineview.cpp45
-rw-r--r--src/webengine/api/qquickwebengineview_p.h20
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h5
-rw-r--r--src/webengine/plugin/plugin.cpp2
-rw-r--r--tests/auto/quick/publicapi/tst_publicapi.cpp7
-rw-r--r--tests/quicktestbrowser/BrowserWindow.qml33
7 files changed, 132 insertions, 28 deletions
diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml
index f451c8c0..f61bce26 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()
+ }
}
}
}
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 2fbf0ecb..f10ddbb0 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -427,12 +427,14 @@ void QQuickWebEngineViewPrivate::close()
void QQuickWebEngineViewPrivate::requestFullScreen(bool fullScreen)
{
- Q_EMIT e->fullScreenRequested(fullScreen);
+ Q_Q(QQuickWebEngineView);
+ QQuickWebEngineFullScreenRequest request(this, fullScreen);
+ Q_EMIT q->fullScreenRequested(request);
}
bool QQuickWebEngineViewPrivate::isFullScreen() const
{
- return e->isFullScreen();
+ return m_isFullScreen;
}
void QQuickWebEngineViewPrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID)
@@ -821,15 +823,11 @@ qreal QQuickWebEngineView::zoomFactor() const
return d->adapter->currentZoomFactor();
}
-void QQuickWebEngineViewExperimental::setIsFullScreen(bool fullscreen)
-{
- d_ptr->m_isFullScreen = fullscreen;
- emit isFullScreenChanged();
-}
-bool QQuickWebEngineViewExperimental::isFullScreen() const
+bool QQuickWebEngineView::isFullScreen() const
{
- return d_ptr->m_isFullScreen;
+ Q_D(const QQuickWebEngineView);
+ return d->m_isFullScreen;
}
void QQuickWebEngineViewExperimental::setExtraContextMenuEntriesComponent(QQmlComponent *contextMenuExtras)
@@ -947,6 +945,15 @@ void QQuickWebEngineView::goBackOrForward(int offset)
d->adapter->navigateToIndex(index);
}
+void QQuickWebEngineView::fullScreenCancelled()
+{
+ Q_D(QQuickWebEngineView);
+ if (d->m_isFullScreen) {
+ d->m_isFullScreen = false;
+ Q_EMIT isFullScreenChanged();
+ }
+}
+
void QQuickWebEngineView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
QQuickItem::geometryChanged(newGeometry, oldGeometry);
@@ -1010,6 +1017,26 @@ void QQuickWebEngineView::componentComplete()
d->ensureContentsAdapter();
}
+QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest()
+ : viewPrivate(0)
+ , m_toggleOn(false)
+{
+}
+
+QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, bool toggleOn)
+ : viewPrivate(viewPrivate)
+ , m_toggleOn(toggleOn)
+{
+}
+
+void QQuickWebEngineFullScreenRequest::accept()
+{
+ if (viewPrivate && viewPrivate->m_isFullScreen != m_toggleOn) {
+ viewPrivate->m_isFullScreen = m_toggleOn;
+ Q_EMIT viewPrivate->q_ptr->isFullScreenChanged();
+ }
+}
+
QQuickWebEngineViewExperimental::QQuickWebEngineViewExperimental(QQuickWebEngineViewPrivate *viewPrivate)
: q_ptr(0)
, d_ptr(viewPrivate)
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index d4a492ef..248ee62b 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -58,6 +58,20 @@ class QQuickWebEngineViewPrivate;
class QQuickWebEngineTestSupport;
#endif
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFullScreenRequest {
+ Q_GADGET
+ Q_PROPERTY(bool toggleOn READ toggleOn)
+public:
+ QQuickWebEngineFullScreenRequest();
+ QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, bool toggleOn);
+
+ Q_INVOKABLE void accept();
+ bool toggleOn() { return m_toggleOn; }
+
+private:
+ QQuickWebEngineViewPrivate *viewPrivate;
+ bool m_toggleOn;
+};
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_OBJECT
@@ -68,6 +82,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY urlChanged)
Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY urlChanged)
+ Q_PROPERTY(bool isFullScreen READ isFullScreen NOTIFY isFullScreenChanged REVISION 1)
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged REVISION 1)
Q_PROPERTY(QQuickWebEngineProfile *profile READ profile WRITE setProfile FINAL REVISION 1)
Q_PROPERTY(QQuickWebEngineSettings *settings READ settings REVISION 1)
@@ -99,6 +114,7 @@ public:
QString title() const;
bool canGoBack() const;
bool canGoForward() const;
+ bool isFullScreen() const;
qreal zoomFactor() const;
void setZoomFactor(qreal arg);
@@ -185,6 +201,7 @@ public Q_SLOTS:
void reload();
void stop();
Q_REVISION(1) void findText(const QString &subString, FindFlags options = 0, const QJSValue &callback = QJSValue());
+ Q_REVISION(1) void fullScreenCancelled();
Q_SIGNALS:
void titleChanged();
@@ -196,6 +213,8 @@ Q_SIGNALS:
void navigationRequested(QQuickWebEngineNavigationRequest *request);
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID);
Q_REVISION(1) void certificateError(QQuickWebEngineCertificateError *error);
+ Q_REVISION(1) void fullScreenRequested(const QQuickWebEngineFullScreenRequest &request);
+ Q_REVISION(1) void isFullScreenChanged();
Q_REVISION(1) void newViewRequested(QQuickWebEngineNewViewRequest *request);
Q_REVISION(1) void zoomFactorChanged(qreal arg);
Q_REVISION(1) void webChannelChanged();
@@ -220,5 +239,6 @@ private:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickWebEngineView)
+Q_DECLARE_METATYPE(QQuickWebEngineFullScreenRequest)
#endif // QQUICKWEBENGINEVIEW_P_H
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 6d9b16d7..36e590bf 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -83,7 +83,6 @@ 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)
Q_ENUMS(Feature)
public:
@@ -94,8 +93,6 @@ public:
Geolocation
};
- void setIsFullScreen(bool fullscreen);
- bool isFullScreen() const;
QQuickWebEngineViewport *viewport() const;
void setExtraContextMenuEntriesComponent(QQmlComponent *);
QQmlComponent *extraContextMenuEntriesComponent() const;
@@ -104,8 +101,6 @@ public Q_SLOTS:
void grantFeaturePermission(const QUrl &securityOrigin, Feature, bool granted);
Q_SIGNALS:
- void fullScreenRequested(bool fullScreen);
- void isFullScreenChanged();
void extraContextMenuEntriesComponentChanged();
void featurePermissionRequested(const QUrl &securityOrigin, Feature feature);
void loadVisuallyCommitted();
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index dc10a50a..c5ef11a5 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -81,6 +81,8 @@ public:
QObject::tr("Cannot create a separate instance of NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 1, "NavigationHistoryListModel",
QObject::tr("Cannot create a separate instance of NavigationHistory"));
+ qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest",
+ QObject::tr("Cannot create a separate instance of FullScreenRequest"));
}
};
diff --git a/tests/auto/quick/publicapi/tst_publicapi.cpp b/tests/auto/quick/publicapi/tst_publicapi.cpp
index 98e52352..a6d7321b 100644
--- a/tests/auto/quick/publicapi/tst_publicapi.cpp
+++ b/tests/auto/quick/publicapi/tst_publicapi.cpp
@@ -73,6 +73,7 @@ static QList<const QMetaObject *> typesToCheck = QList<const QMetaObject *>()
<< &QQuickWebEngineNewViewRequest::staticMetaObject
<< &QQuickWebEngineProfile::staticMetaObject
<< &QQuickWebEngineScript::staticMetaObject
+ << &QQuickWebEngineFullScreenRequest::staticMetaObject
;
static QList<const char *> knownEnumNames = QList<const char *>();
@@ -127,6 +128,7 @@ static QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.icon --> QUrl"
<< "QQuickWebEngineView.canGoBack --> bool"
<< "QQuickWebEngineView.canGoForward --> bool"
+ << "QQuickWebEngineView.isFullScreen --> bool"
<< "QQuickWebEngineView.loading --> bool"
<< "QQuickWebEngineView.loadProgress --> int"
<< "QQuickWebEngineView.titleChanged() --> void"
@@ -138,6 +140,9 @@ static QStringList expectedAPI = QStringList()
<< "QQuickWebEngineView.iconChanged() --> void"
<< "QQuickWebEngineView.linkHovered(QUrl) --> void"
<< "QQuickWebEngineView.navigationRequested(QQuickWebEngineNavigationRequest*) --> void"
+ << "QQuickWebEngineView.fullScreenRequested(QQuickWebEngineFullScreenRequest) --> void"
+ << "QQuickWebEngineView.isFullScreenChanged() --> void"
+ << "QQuickWebEngineView.fullScreenCancelled() --> void"
<< "QQuickWebEngineView.runJavaScript(QString,QJSValue) --> void"
<< "QQuickWebEngineView.runJavaScript(QString) --> void"
<< "QQuickWebEngineView.loadHtml(QString,QUrl) --> void"
@@ -233,6 +238,8 @@ static QStringList expectedAPI = QStringList()
<< "QQuickWebEngineScript.setWorldId(ScriptWorldId) --> void"
<< "QQuickWebEngineScript.setRunOnSubframes(bool) --> void"
<< "QQuickWebEngineScript.toString() --> QString"
+ << "QQuickWebEngineFullScreenRequest.toggleOn --> bool"
+ << "QQuickWebEngineFullScreenRequest.accept() --> void"
;
static bool isCheckedEnum(const QByteArray &typeName)
diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml
index cb7de84d..9e9f7364 100644
--- a/tests/quicktestbrowser/BrowserWindow.qml
+++ b/tests/quicktestbrowser/BrowserWindow.qml
@@ -54,12 +54,16 @@ ApplicationWindow {
id: browserWindow
property QtObject applicationRoot
property Item currentWebView: tabs.currentIndex < tabs.count ? tabs.getTab(tabs.currentIndex).item.webView : 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)
- currentWebView.state = isFullScreen ? "FullScreen" : ""
+ if (currentWebView && !isFullScreen) {
+ currentWebView.state = ""
+ if (currentWebView.isFullScreen)
+ currentWebView.fullScreenCancelled()
+ }
}
height: 600
@@ -89,7 +93,7 @@ ApplicationWindow {
offTheRecord: true
}
- // Make sure the Qt.WindowFullscreenButtonHint is set on Mac.
+ // Make sure the Qt.WindowFullscreenButtonHint is set on OS X.
Component.onCompleted: flags = flags | Qt.WindowFullscreenButtonHint
// Create a styleItem to determine the platform.
@@ -141,7 +145,7 @@ ApplicationWindow {
shortcut: "Escape"
onTriggered: {
if (browserWindow.isFullScreen)
- browserWindow.showNormal()
+ browserWindow.visibility = browserWindow.previousVisibility
}
}
Action {
@@ -380,18 +384,19 @@ ApplicationWindow {
}
}
- experimental {
- isFullScreen: webEngineView.state == "FullScreen" && browserWindow.isFullScreen
- onFullScreenRequested: {
- if (fullScreen) {
- webEngineView.state = "FullScreen"
- browserWindow.showFullScreen();
- } else {
- webEngineView.state = ""
- browserWindow.showNormal();
- }
+ onFullScreenRequested: {
+ if (request.toggleOn) {
+ webEngineView.state = "FullScreen"
+ browserWindow.previousVisibility = browserWindow.visibility
+ browserWindow.showFullScreen()
+ } else {
+ webEngineView.state = ""
+ browserWindow.visibility = browserWindow.previousVisibility
}
+ request.accept()
+ }
+ experimental {
onFeaturePermissionRequested: {
permBar.securityOrigin = securityOrigin;
permBar.requestedFeature = feature;