diff options
Diffstat (limited to 'src/declarative/fx')
-rw-r--r-- | src/declarative/fx/qfxcomponentinstance.cpp | 5 | ||||
-rw-r--r-- | src/declarative/fx/qfxflipable.cpp | 133 | ||||
-rw-r--r-- | src/declarative/fx/qfxflipable.h | 10 | ||||
-rw-r--r-- | src/declarative/fx/qfxhighlightfilter.cpp | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfxhighlightfilter.h | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfximage.h | 2 | ||||
-rw-r--r-- | src/declarative/fx/qfxparticles.cpp | 6 | ||||
-rw-r--r-- | src/declarative/fx/qfxparticles.h | 6 | ||||
-rw-r--r-- | src/declarative/fx/qfxtransform.cpp | 25 | ||||
-rw-r--r-- | src/declarative/fx/qfxwebview.cpp | 91 | ||||
-rw-r--r-- | src/declarative/fx/qfxwebview.h | 3 |
11 files changed, 257 insertions, 28 deletions
diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp index 951c25d..5343f7d 100644 --- a/src/declarative/fx/qfxcomponentinstance.cpp +++ b/src/declarative/fx/qfxcomponentinstance.cpp @@ -51,15 +51,14 @@ QML_DEFINE_TYPE(QFxComponentInstance,ComponentInstance); /*! \internal - \class QFxComponentInstance - \qmlclass ComponentInstance + \class QFxComponentInstance ComponentInstance \brief The QFxComponentInstance class provides a way to instantiate an item from a component. */ /*! \qmlclass ComponentInstance QFxComponentInstance - \brief The ComponentInstance element allows you to instantiate an arbitrary component. + \brief The ComponentInstance element allows you to instantiate a \l{qml-component.html} {Component}. \code <Item> diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp index 9db0b57..1d15827 100644 --- a/src/declarative/fx/qfxflipable.cpp +++ b/src/declarative/fx/qfxflipable.cpp @@ -49,11 +49,17 @@ QML_DEFINE_TYPE(QFxFlipable,Flipable); class QFxFlipablePrivate : public QFxItemPrivate { public: - QFxFlipablePrivate() : current(QFxFlipable::Front), front(0), back(0) {} + QFxFlipablePrivate() : current(QFxFlipable::Front), front(0), back(0), axis(0), rotation(0) {} + + void setBackTransform(); + void _q_updateAxis(); QFxFlipable::Side current; QFxItem *front; QFxItem *back; + QFxAxis *axis; + QFxRotation axisRotation; + qreal rotation; }; /*! @@ -65,18 +71,18 @@ public: \code <Flipable id="flipable" width="40" height="40"> - <transform> - <Axis id="axis" xStart="20" xEnd="20" yStart="20" yEnd="0" /> - </transform> + <axis> + <Axis startX="20" startY="0" endX="20" endY="40" /> + </axis> <front> - <Image file="front.png"/> + <Image src="front.png"/> </front> <back> - <Image file="back.png"/> + <Image src="back.png"/> </back> <states> <State name="back"> - <SetProperty target="{axis}" property="rotation" value="180" /> + <SetProperty target="{flipable}" property="rotation" value="180" /> </State> </states> <transitions> @@ -153,6 +159,114 @@ void QFxFlipable::setBack(QFxItem *back) children()->append(d->back); if (Front == d->current) d->back->setOpacity(0.); + d->setBackTransform(); +} + +/*! + \qmlproperty Axis Flipable::axis + + The axis to flip around. See the \l Axis documentation for more + information on specifying an axis. +*/ + +QFxAxis *QFxFlipable::axis() +{ + Q_D(QFxFlipable); + return d->axis; +} + +void QFxFlipable::setAxis(QFxAxis *axis) +{ + Q_D(QFxFlipable); + //### disconnect if we are already connected? + if (d->axis) + disconnect(d->axis, SIGNAL(updated()), this, SLOT(_q_updateAxis())); + d->axis = axis; + connect(d->axis, SIGNAL(updated()), this, SLOT(_q_updateAxis())); + d->_q_updateAxis(); +} + +void QFxFlipablePrivate::_q_updateAxis() +{ + axisRotation.axis()->setStartX(axis->startX()); + axisRotation.axis()->setStartY(axis->startY()); + axisRotation.axis()->setEndX(axis->endX()); + axisRotation.axis()->setEndY(axis->endY()); + axisRotation.axis()->setEndZ(axis->endZ()); + + setBackTransform(); +} + +void QFxFlipablePrivate::setBackTransform() +{ + if (!back) + return; + + QPointF p1(0, 0); + QPointF p2(1, 0); + QPointF p3(1, 1); + + axisRotation.setAngle(180); + p1 = axisRotation.transform().map(p1); + p2 = axisRotation.transform().map(p2); + p3 = axisRotation.transform().map(p3); + axisRotation.setAngle(rotation); + + QSimpleCanvas::Matrix mat; +#ifdef QFX_RENDER_OPENGL + mat.translate(back->width()/2,back->height()/2, 0); + if (back->width() && p1.x() >= p2.x()) + mat.rotate(180, 0, 1, 0); + if (back->height() && p2.y() >= p3.y()) + mat.rotate(180, 1, 0, 0); + mat.translate(-back->width()/2,-back->height()/2, 0); +#else + mat.translate(back->width()/2,back->height()/2); + if (back->width() && p1.x() >= p2.x()) + mat.rotate(180, Qt::YAxis); + if (back->height() && p2.y() >= p3.y()) + mat.rotate(180, Qt::XAxis); + mat.translate(-back->width()/2,-back->height()/2); +#endif + back->setTransform(mat); +} + +/*! + \qmlproperty real Flipable::rotation + The angle to rotate the flipable. For example, to show the back side of the flipable + you can set the rotation to 180. +*/ +qreal QFxFlipable::rotation() const +{ + Q_D(const QFxFlipable); + return d->rotation; +} + +void QFxFlipable::setRotation(qreal angle) +{ + Q_D(QFxFlipable); + d->rotation = angle; + d->axisRotation.setAngle(angle); + setTransform(d->axisRotation.transform()); + + + int simpleAngle = int(angle) % 360; + + Side newSide; + if (simpleAngle < 91 || simpleAngle > 270) { + newSide = Front; + } else { + newSide = Back; + } + + if (newSide != d->current) { + d->current = newSide; + if (d->front) + d->front->setOpacity((d->current==Front)?1.:0.); + if (d->back) + d->back->setOpacity((d->current==Back)?1.:0.); + emit sideChanged(); + } } /*! @@ -167,6 +281,9 @@ QFxFlipable::Side QFxFlipable::side() const return d->current; } +//in some cases the user may want to specify a more complex transformation. +//in that case, we still allow the generic use of transform. +//(the logic here should be kept in sync with setBackTransform and setRotation) void QFxFlipable::transformChanged(const QSimpleCanvas::Matrix &trans) { Q_D(QFxFlipable); @@ -218,3 +335,5 @@ void QFxFlipable::transformChanged(const QSimpleCanvas::Matrix &trans) } QT_END_NAMESPACE + +#include "moc_qfxflipable.cpp" diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h index 2c6c849..ef1832e 100644 --- a/src/declarative/fx/qfxflipable.h +++ b/src/declarative/fx/qfxflipable.h @@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +class QFxAxis; class QFxFlipablePrivate; class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem { @@ -63,6 +64,8 @@ class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem Q_ENUMS(Side); Q_PROPERTY(QFxItem *front READ front WRITE setFront) Q_PROPERTY(QFxItem *back READ back WRITE setBack) + Q_PROPERTY(QFxAxis *axis READ axis WRITE setAxis) + Q_PROPERTY(qreal rotation READ rotation WRITE setRotation) Q_PROPERTY(Side side READ side NOTIFY sideChanged) public: QFxFlipable(QFxItem *parent=0); @@ -74,6 +77,12 @@ public: QFxItem *back(); void setBack(QFxItem *); + QFxAxis *axis(); + void setAxis(QFxAxis *axis); + + qreal rotation() const; + void setRotation(qreal angle); + enum Side { Front, Back }; Side side() const; @@ -84,6 +93,7 @@ Q_SIGNALS: void sideChanged(); private: + Q_PRIVATE_SLOT(d_func(), void _q_updateAxis()) Q_DISABLE_COPY(QFxFlipable) Q_DECLARE_PRIVATE(QFxFlipable) }; diff --git a/src/declarative/fx/qfxhighlightfilter.cpp b/src/declarative/fx/qfxhighlightfilter.cpp index ab0512c..70b50cd 100644 --- a/src/declarative/fx/qfxhighlightfilter.cpp +++ b/src/declarative/fx/qfxhighlightfilter.cpp @@ -119,7 +119,7 @@ QFxHighlightFilter::~QFxHighlightFilter() */ /*! - \property QFxHighlightFilter::src + \property QFxHighlightFilter::source \brief the URL of the image to be used as the highlight. */ QString QFxHighlightFilter::source() const diff --git a/src/declarative/fx/qfxhighlightfilter.h b/src/declarative/fx/qfxhighlightfilter.h index 6204242..218f4e1 100644 --- a/src/declarative/fx/qfxhighlightfilter.h +++ b/src/declarative/fx/qfxhighlightfilter.h @@ -56,7 +56,7 @@ class Q_DECLARATIVE_EXPORT QFxHighlightFilter : public QSimpleCanvasFilter { Q_OBJECT - Q_PROPERTY(QString src READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(bool tiled READ tiled WRITE setTiled NOTIFY tiledChanged) Q_PROPERTY(int xOffset READ xOffset WRITE setXOffset NOTIFY offsetChanged) Q_PROPERTY(int yOffset READ yOffset WRITE setYOffset NOTIFY offsetChanged) diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 4eed0ef..37fe5be 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -57,7 +57,7 @@ class Q_DECLARATIVE_EXPORT QFxImage : public QFxItem Q_ENUMS(Status) Q_PROPERTY(Status status READ status NOTIFY statusChanged) - Q_PROPERTY(QString src READ source WRITE setSource NOTIFY sourceChanged) + Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(QFxScaleGrid *scaleGrid READ scaleGrid) Q_PROPERTY(bool tile READ isTiled WRITE setTiled) diff --git a/src/declarative/fx/qfxparticles.cpp b/src/declarative/fx/qfxparticles.cpp index 309ebe8..16b3570 100644 --- a/src/declarative/fx/qfxparticles.cpp +++ b/src/declarative/fx/qfxparticles.cpp @@ -573,10 +573,10 @@ QFxParticles::~QFxParticles() */ /*! - \property QFxParticles::src + \property QFxParticles::source \brief the URL of the particle image. */ -QString QFxParticles::url() const +QString QFxParticles::source() const { Q_D(const QFxParticles); return d->source; @@ -593,7 +593,7 @@ void QFxParticles::imageLoaded() update(); } -void QFxParticles::setUrl(const QString &name) +void QFxParticles::setSource(const QString &name) { Q_D(QFxParticles); diff --git a/src/declarative/fx/qfxparticles.h b/src/declarative/fx/qfxparticles.h index d9c810d..0696e60 100644 --- a/src/declarative/fx/qfxparticles.h +++ b/src/declarative/fx/qfxparticles.h @@ -153,7 +153,7 @@ class Q_DECLARATIVE_EXPORT QFxParticles : public QFxItem { Q_OBJECT - Q_PROPERTY(QString src READ url WRITE setUrl); + Q_PROPERTY(QString source READ source WRITE setSource); Q_PROPERTY(int count READ count WRITE setCount); Q_PROPERTY(int lifeSpan READ lifeSpan WRITE setLifeSpan); Q_PROPERTY(int lifeSpanDeviation READ lifeSpanDeviation WRITE setLifeSpanDeviation); @@ -172,8 +172,8 @@ public: QFxParticles(QFxItem *parent=0); ~QFxParticles(); - QString url() const; - void setUrl(const QString &); + QString source() const; + void setSource(const QString &); int count() const; void setCount(int cnt); diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp index 9f18413..c355158 100644 --- a/src/declarative/fx/qfxtransform.cpp +++ b/src/declarative/fx/qfxtransform.cpp @@ -85,7 +85,16 @@ void QFxTransform::update() /*! \qmlclass Axis - \brief An axis that can be used for rotation or translation. + \brief The Axis element defines an axis that can be used for rotation or translation. + + An axis is specified by 2 points in 3D space: a start point and + an end point. While technically the axis is the line running through these two points + (and thus many different sets of two points could define the same axis), the distance + between the points does matter for translation along an axis. + + \code + <Axis startX="0" startY="0" endX="20" endY="30"/> + \endcode */ QML_DEFINE_TYPE(QFxAxis, Axis); @@ -99,6 +108,13 @@ QFxAxis::~QFxAxis() { } +/*! + \qmlproperty real Axis::startX + \qmlproperty real Axis::startY + + The start point of the axis. The z-position of the start point is assumed to be 0, and cannot + be changed. +*/ qreal QFxAxis::startX() const { return _startX; @@ -121,6 +137,13 @@ void QFxAxis::setStartY(qreal y) emit updated(); } +/*! + \qmlproperty real Axis::endX + \qmlproperty real Axis::endY + \qmlproperty real Axis::endZ + + The end point of the axis. +*/ qreal QFxAxis::endX() const { return _endX; diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index a6210e5..7c05088 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -75,6 +75,73 @@ QML_DEFINE_TYPE(QFxWebView,WebView); static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system +class QFxWebSettings : public QObject { + Q_OBJECT + /* + StandardFont, + FixedFont, + SerifFont, + SansSerifFont, + CursiveFont, + FantasyFont + + MinimumFontSize, + MinimumLogicalFontSize, + DefaultFontSize, + DefaultFixedFontSize + */ + + Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages) + Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled) + Q_PROPERTY(bool javaEnabled READ javaEnabled WRITE setJavaEnabled) + Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled) + Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled) + Q_PROPERTY(bool javascriptCanOpenWindows READ javascriptCanOpenWindows WRITE setJavascriptCanOpenWindows) + Q_PROPERTY(bool javascriptCanAccessClipboard READ javascriptCanAccessClipboard WRITE setJavascriptCanAccessClipboard) + Q_PROPERTY(bool developerExtrasEnabled READ developerExtrasEnabled WRITE setDeveloperExtrasEnabled) + Q_PROPERTY(bool linksIncludedInFocusChain READ linksIncludedInFocusChain WRITE setLinksIncludedInFocusChain) + Q_PROPERTY(bool zoomTextOnly READ zoomTextOnly WRITE setZoomTextOnly) + Q_PROPERTY(bool printElementBackgrounds READ printElementBackgrounds WRITE setPrintElementBackgrounds) + Q_PROPERTY(bool offlineStorageDatabaseEnabled READ offlineStorageDatabaseEnabled WRITE setOfflineStorageDatabaseEnabled) + Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled) + Q_PROPERTY(bool localStorageDatabaseEnabled READ localStorageDatabaseEnabled WRITE setLocalStorageDatabaseEnabled) + +public: + QFxWebSettings() {} + + bool autoLoadImages() const { return s->testAttribute(QWebSettings::AutoLoadImages); } + void setAutoLoadImages(bool on) { s->setAttribute(QWebSettings::AutoLoadImages, on); } + bool javascriptEnabled() const { return s->testAttribute(QWebSettings::JavascriptEnabled); } + void setJavascriptEnabled(bool on) { s->setAttribute(QWebSettings::JavascriptEnabled, on); } + bool javaEnabled() const { return s->testAttribute(QWebSettings::JavaEnabled); } + void setJavaEnabled(bool on) { s->setAttribute(QWebSettings::JavaEnabled, on); } + bool pluginsEnabled() const { return s->testAttribute(QWebSettings::PluginsEnabled); } + void setPluginsEnabled(bool on) { s->setAttribute(QWebSettings::PluginsEnabled, on); } + bool privateBrowsingEnabled() const { return s->testAttribute(QWebSettings::PrivateBrowsingEnabled); } + void setPrivateBrowsingEnabled(bool on) { s->setAttribute(QWebSettings::PrivateBrowsingEnabled, on); } + bool javascriptCanOpenWindows() const { return s->testAttribute(QWebSettings::JavascriptCanOpenWindows); } + void setJavascriptCanOpenWindows(bool on) { s->setAttribute(QWebSettings::JavascriptCanOpenWindows, on); } + bool javascriptCanAccessClipboard() const { return s->testAttribute(QWebSettings::JavascriptCanAccessClipboard); } + void setJavascriptCanAccessClipboard(bool on) { s->setAttribute(QWebSettings::JavascriptCanAccessClipboard, on); } + bool developerExtrasEnabled() const { return s->testAttribute(QWebSettings::DeveloperExtrasEnabled); } + void setDeveloperExtrasEnabled(bool on) { s->setAttribute(QWebSettings::DeveloperExtrasEnabled, on); } + bool linksIncludedInFocusChain() const { return s->testAttribute(QWebSettings::LinksIncludedInFocusChain); } + void setLinksIncludedInFocusChain(bool on) { s->setAttribute(QWebSettings::LinksIncludedInFocusChain, on); } + bool zoomTextOnly() const { return s->testAttribute(QWebSettings::ZoomTextOnly); } + void setZoomTextOnly(bool on) { s->setAttribute(QWebSettings::ZoomTextOnly, on); } + bool printElementBackgrounds() const { return s->testAttribute(QWebSettings::PrintElementBackgrounds); } + void setPrintElementBackgrounds(bool on) { s->setAttribute(QWebSettings::PrintElementBackgrounds, on); } + bool offlineStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::OfflineStorageDatabaseEnabled); } + void setOfflineStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, on); } + bool offlineWebApplicationCacheEnabled() const { return s->testAttribute(QWebSettings::OfflineWebApplicationCacheEnabled); } + void setOfflineWebApplicationCacheEnabled(bool on) { s->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, on); } + bool localStorageDatabaseEnabled() const { return s->testAttribute(QWebSettings::LocalStorageDatabaseEnabled); } + void setLocalStorageDatabaseEnabled(bool on) { s->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, on); } + + QWebSettings *s; +}; + + class QFxWebViewPrivate : public QFxItemPrivate { Q_DECLARE_PUBLIC(QFxWebView) @@ -131,6 +198,7 @@ public: QUrl pending_url; QString pending_string; QByteArray pending_data; + mutable QFxWebSettings settings; }; @@ -866,9 +934,6 @@ QWebPage *QFxWebView::page() const wp->setNetworkAccessManager(qmlEngine(this)->networkAccessManager()); - // XXX settable from QML? - wp->settings()->setAttribute(QWebSettings::PluginsEnabled, true); - self->setPage(wp); return wp; @@ -877,6 +942,13 @@ QWebPage *QFxWebView::page() const return d->page; } +// The QObject interface to settings(). +QObject *QFxWebView::settingsObject() const +{ + Q_D(const QFxWebView); + d->settings.s = page()->settings(); + return &d->settings; +} void QFxWebView::setPage(QWebPage *page) { @@ -946,11 +1018,11 @@ QString QFxWebView::html() const void QFxWebView::setHtml(const QString &html, const QUrl &baseUrl) { Q_D(QFxWebView); - d->page->setViewportSize(QSize( + page()->setViewportSize(QSize( d->idealwidth>0 ? d->idealwidth : width(), d->idealheight>0 ? d->idealheight : height())); if (isComponentComplete()) - d->page->mainFrame()->setHtml(html, baseUrl); + page()->mainFrame()->setHtml(html, baseUrl); else { d->pending = d->PendingHtml; d->pending_url = baseUrl; @@ -961,12 +1033,12 @@ void QFxWebView::setHtml(const QString &html, const QUrl &baseUrl) void QFxWebView::setContent(const QByteArray &data, const QString &mimeType, const QUrl &baseUrl) { Q_D(QFxWebView); - d->page->setViewportSize(QSize( + page()->setViewportSize(QSize( d->idealwidth>0 ? d->idealwidth : width(), d->idealheight>0 ? d->idealheight : height())); if (isComponentComplete()) - d->page->mainFrame()->setContent(data,mimeType,baseUrl); + page()->mainFrame()->setContent(data,mimeType,baseUrl); else { d->pending = d->PendingContent; d->pending_url = baseUrl; @@ -1031,7 +1103,10 @@ public: QmlEngine *engine = qmlEngine(webview); component = new QmlComponent(engine, url, this); item = 0; - connect(engine, SIGNAL(statusChanged(Status)), this, SLOT(qmlLoaded())); + if (component->isReady()) + qmlLoaded(); + else + connect(component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(qmlLoaded())); } public Q_SLOTS: diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index 1eede52..6ba4601 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -103,6 +103,8 @@ class Q_DECLARATIVE_EXPORT QFxWebView : public QFxItem Q_PROPERTY(QObject* forward READ forwardAction) Q_PROPERTY(QObject* stop READ stopAction) + Q_PROPERTY(QObject* settings READ settingsObject) + public: QFxWebView(QFxItem *parent=0); ~QFxWebView(); @@ -164,6 +166,7 @@ public: QWebHistory *history() const; QWebSettings *settings() const; + QObject *settingsObject() const; QString status() const; |