diff options
-rw-r--r-- | src/declarative/fx/qfxwebview.cpp | 28 | ||||
-rw-r--r-- | src/declarative/fx/qfxwebview.h | 5 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index dc7f60e..d5dc874 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -48,6 +48,7 @@ #include <QGraphicsSceneMouseEvent> #include <QtWebKit/QWebPage> #include <QtWebKit/QWebFrame> +#include <QtWebKit/QWebElement> #include "qml.h" #include "qmlbindablevalue.h" @@ -787,7 +788,7 @@ QPixmap QFxWebView::icon() const /*! \qmlproperty real WebView::textSizeMultiplier - This property holds multiplier used to scale the text in a Web page + This property holds the multiplier used to scale the text in a Web page */ /*! Sets the value of the multiplier used to scale the text in a Web page to @@ -806,6 +807,31 @@ qreal QFxWebView::textSizeMultiplier() const return page()->mainFrame()->textSizeMultiplier(); } +/*! + \qmlproperty real WebView::zoomFactor + This property holds the multiplier used to scale the contents of a Web page. +*/ +void QFxWebView::setZoomFactor(qreal factor) +{ + Q_D(QFxWebView); + if (factor == page()->mainFrame()->zoomFactor()) + return; + + //reset viewport size so we resize correctly + page()->setViewportSize(QSize( + d->idealwidth>0 ? d->idealwidth : -1, + d->idealheight>0 ? d->idealheight : -1)); + + page()->mainFrame()->setZoomFactor(factor); + expandToWebPage(); + emit zoomFactorChanged(); +} + +qreal QFxWebView::zoomFactor() const +{ + return page()->mainFrame()->zoomFactor(); +} + void QFxWebView::setStatusBarMessage(const QString& s) { Q_D(QFxWebView); diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index f30fd0d..e9b6d37 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -81,6 +81,7 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxPaintedItem Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged) Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false) + Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged) Q_PROPERTY(QString status READ status NOTIFY statusChanged) Q_PROPERTY(int mouseX READ mouseX) @@ -118,6 +119,9 @@ public: qreal textSizeMultiplier() const; void setTextSizeMultiplier(qreal); + qreal zoomFactor() const; + void setZoomFactor(qreal); + bool interactive() const; void setInteractive(bool); @@ -170,6 +174,7 @@ Q_SIGNALS: void titleChanged(const QString&); void iconChanged(); void statusChanged(); + void zoomFactorChanged(); void loadStarted(); void loadFinished(); |