summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2014-10-03 17:02:43 +0200
committerPierre Rossi <pierre.rossi@gmail.com>2014-10-13 14:46:48 +0200
commitd69e0bb0d2fade75c31e57047c03746d694a6113 (patch)
tree2bf71354afd2a7268bcce91d7c448b6ceaf3fe39 /src/webengine
parent9e6a94e5e1882e012f0a97943f0e77f976739fc3 (diff)
Implement programatic zooming for QtQuick
and add shortcuts in the examples (with a basic UI in the test browser) Change-Id: I237a04cf0b1fce2e0c6f8a19891ff3cb51727a40 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebengineview.cpp17
-rw-r--r--src/webengine/api/qquickwebengineview_p.h4
2 files changed, 21 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index b466c8566..6f216fda9 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -554,6 +554,17 @@ void QQuickWebEngineView::stop()
d->adapter->stop();
}
+void QQuickWebEngineView::setZoomFactor(qreal arg)
+{
+ Q_D(QQuickWebEngineView);
+ qreal oldFactor = d->adapter->currentZoomFactor();
+ d->adapter->setZoomFactor(arg);
+ if (qFuzzyCompare(oldFactor, d->adapter->currentZoomFactor()))
+ return;
+
+ emit zoomFactorChanged(arg);
+}
+
void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVariant &result)
{
Q_Q(QQuickWebEngineView);
@@ -617,6 +628,12 @@ QQuickWebEngineViewExperimental *QQuickWebEngineView::experimental() const
return d->e.data();
}
+qreal QQuickWebEngineView::zoomFactor() const
+{
+ Q_D(const QQuickWebEngineView);
+ return d->adapter->currentZoomFactor();
+}
+
bool QQuickWebEngineViewExperimental::inspectable() const
{
Q_D(const QQuickWebEngineView);
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index 402c2ce65..d2f262a9b 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -56,6 +56,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY loadingChanged)
Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY loadingChanged)
+ Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged)
Q_ENUMS(NavigationRequestAction);
Q_ENUMS(NavigationType);
Q_ENUMS(LoadStatus);
@@ -75,6 +76,7 @@ public:
QString title() const;
bool canGoBack() const;
bool canGoForward() const;
+ qreal zoomFactor() const;
QQuickWebEngineViewExperimental *experimental() const;
@@ -133,6 +135,7 @@ public Q_SLOTS:
void goForward();
void reload();
void stop();
+ void setZoomFactor(qreal arg);
Q_SIGNALS:
void titleChanged();
@@ -143,6 +146,7 @@ Q_SIGNALS:
void linkHovered(const QUrl &hoveredUrl);
void navigationRequested(QQuickWebEngineNavigationRequest *request);
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID);
+ void zoomFactorChanged(qreal arg);
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);