diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-25 03:09:04 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-25 03:09:04 (GMT) |
commit | e150b84c8069e47a9fc6a4a2ad6e5b71f7cfc24c (patch) | |
tree | 77be299e57b5653dc4f42af7b31dd6bdd518ccfb /src/declarative | |
parent | bb03160acc655d17f53f5ded04b1b8edfa213c59 (diff) | |
parent | 78ecb1477d2a4b5045c943cee6224625156b5f24 (diff) | |
download | Qt-e150b84c8069e47a9fc6a4a2ad6e5b71f7cfc24c.zip Qt-e150b84c8069e47a9fc6a4a2ad6e5b71f7cfc24c.tar.gz Qt-e150b84c8069e47a9fc6a4a2ad6e5b71f7cfc24c.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicseffects.cpp | 27 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsflickable.cpp | 4 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsflipable.cpp | 46 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsgridview.cpp | 12 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsimage.cpp | 10 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsimage_p.h | 3 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicslistview.cpp | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicstextedit.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetaproperty.h | 2 | ||||
-rw-r--r-- | src/declarative/util/qmlpropertychanges.cpp | 37 | ||||
-rw-r--r-- | src/declarative/util/qmlstategroup.cpp | 19 | ||||
-rw-r--r-- | src/declarative/util/qmltimer.cpp | 25 | ||||
-rw-r--r-- | src/declarative/util/qmltransitionmanager.cpp | 5 |
13 files changed, 124 insertions, 70 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicseffects.cpp b/src/declarative/graphicsitems/qmlgraphicseffects.cpp index 2f0aae7..0523fd5 100644 --- a/src/declarative/graphicsitems/qmlgraphicseffects.cpp +++ b/src/declarative/graphicsitems/qmlgraphicseffects.cpp @@ -51,10 +51,10 @@ QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect) \qmlclass Blur QGraphicsBlurEffect \brief The Blur object provides a blur effect. - A blur effect blurs the source item. This effect is useful for reducing details, - such as when the source loses focus and you want to draw attention to other - elements. The level of detail can be modified using the blurRadius property. - Use blurHint to choose the quality or performance blur hints. + A blur effect blurs the source item. This effect is useful for reducing details; + for example, when the a source loses focus and attention should be drawn to other + elements. Use blurRadius to control the level of detail and blurHint to control + the quality of the blur. By default, the blur radius is 5 pixels. @@ -64,21 +64,22 @@ QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect) /*! \qmlproperty real Blur::blurRadius - blurRadius controls how blurry an item will appear. - Using a smaller radius results in a sharper appearance, whereas a bigger - radius results in a more blurred appearance. + This controls how blurry an item will appear. - By default, the blur radius is 5 pixels. + A smaller radius produces a sharper appearance, and a larger radius produces + a more blurred appearance. + + The default radius is 5 pixels. */ /*! \qmlproperty enumeration Blur::blurHint - Use the Qt.PerformanceHint hint to say that you want a faster blur, - and the Qt.QualityHint hint to say that you prefer a higher quality blur. - - When animating the blur radius it's recommended to use Qt.PerformanceHint. + Use Qt.PerformanceHint to specify a faster blur or Qt.QualityHint hint + to specify a higher quality blur. + + If the blur radius is animated, it is recommended you use Qt.PerformanceHint. - By default, the blur hint is Qt.PerformanceHint. + The default hint is Qt.PerformanceHint. */ QML_DECLARE_TYPE(QGraphicsColorizeEffect) diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index b3a34ed..cc0f905 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -613,7 +613,7 @@ void QmlGraphicsFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent const qreal maxY = q->maxYExtent(); if (newY > minY) newY = minY + (newY - minY) / 2; - if (newY < maxY && maxY - minY < 0) + if (newY < maxY && maxY - minY <= 0) newY = maxY + (newY - maxY) / 2; if (!q->overShoot() && (newY > minY || newY < maxY)) { if (newY > minY) @@ -640,7 +640,7 @@ void QmlGraphicsFlickablePrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent const qreal maxX = q->maxXExtent(); if (newX > minX) newX = minX + (newX - minX) / 2; - if (newX < maxX && maxX - minX < 0) + if (newX < maxX && maxX - minX <= 0) newX = maxX + (newX - maxX) / 2; if (!q->overShoot() && (newX > minX || newX < maxX)) { if (newX > minX) diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp index 57d2ee1..9e48bf2 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp @@ -68,29 +68,39 @@ public: Flipable allows you to specify a front and a back and then flip between those sides. + Here's an example that flips between the front and back sides when clicked: + \qml -Flipable { - width: 40; height: 40 - - transform: Rotation { - id: rotation - origin.x: 20; origin.y: 120 - axis.x: 0; axis.y: 1; axis.z: 0 - angle: 0 - } - front: Image { source: "front.png" } - back: Image { source: "back.png" } + Flipable { + id: flipable + width: 250; height: 250 + property int angle: 0 - states: State { - name: "back" - SetProperties { target: rotation; angle: 180 } - } + transform: Rotation { + id: rotation + origin.x: flipable.width/2; origin.y: flipable.height/2 + axis.x: 0; axis.y: 1; axis.z: 0 // rotate around y-axis + angle: flipable.angle + } + + front: Image { source: "front.png" } + back: Image { source: "back.png" } - transitions: Transition { - NumberAnimation { easing: "easeInOutQuad"; matchProperties: "rotation" } + states: State { + name: "back" + PropertyChanges { target: flipable; angle: 180 } + } + + transitions: Transition { + NumberAnimation { matchProperties: "angle"; duration: 2000 } + } + + MouseRegion { + anchors.fill: parent + onClicked: flipable.state = (flipable.state == 'back' ? 'front' : 'back') + } } -} \endqml \image flipable.gif diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 7e2d983..e36ea50 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -1138,7 +1138,11 @@ qreal QmlGraphicsGridView::maxYExtent() const Q_D(const QmlGraphicsGridView); if (d->flow == QmlGraphicsGridView::TopToBottom) return QmlGraphicsFlickable::maxYExtent(); - return -(d->endPosition() - height()); + qreal extent = -(d->endPosition() - height()); + const qreal minY = minYExtent(); + if (extent > minY) + extent = minY; + return extent; } qreal QmlGraphicsGridView::minXExtent() const @@ -1154,7 +1158,11 @@ qreal QmlGraphicsGridView::maxXExtent() const Q_D(const QmlGraphicsGridView); if (d->flow == QmlGraphicsGridView::LeftToRight) return QmlGraphicsFlickable::maxXExtent(); - return -(d->endPosition() - width()); + qreal extent = -(d->endPosition() - width()); + const qreal minX = minXExtent(); + if (extent > minX) + extent = minX; + return extent; } void QmlGraphicsGridView::keyPressEvent(QKeyEvent *event) diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp index 42fd910..9d59796 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp @@ -141,6 +141,15 @@ QmlGraphicsImage::~QmlGraphicsImage() { } +/*! + \qmlproperty QPixmap Image::pixmap + + This property holds the QPixmap image to display. + + This is useful for displaying images provided by a C++ implementation, + for example, a model may provide a data role of type QPixmap. +*/ + QPixmap QmlGraphicsImage::pixmap() const { Q_D(const QmlGraphicsImage); @@ -164,6 +173,7 @@ void QmlGraphicsImagePrivate::setPixmap(const QPixmap &pixmap) q->setImplicitHeight(pix.height()); q->update(); + emit q->pixmapChanged(); } /*! diff --git a/src/declarative/graphicsitems/qmlgraphicsimage_p.h b/src/declarative/graphicsitems/qmlgraphicsimage_p.h index 76b8da5..81e10ab 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsimage_p.h @@ -56,7 +56,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsImage : public QmlGraphicsImageBase Q_OBJECT Q_ENUMS(FillMode) - Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap DESIGNABLE false) + Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap NOTIFY pixmapChanged DESIGNABLE false) Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged) public: @@ -74,6 +74,7 @@ public: Q_SIGNALS: void fillModeChanged(); + void pixmapChanged(); protected: QmlGraphicsImage(QmlGraphicsImagePrivate &dd, QmlGraphicsItem *parent); diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index c6291f2..e05ae66 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -1318,7 +1318,7 @@ void QmlGraphicsListView::setHighlightFollowsCurrentItem(bool autoHighlight) /*! \qmlproperty real ListView::preferredHighlightBegin \qmlproperty real ListView::preferredHighlightEnd - \qmlproperty bool ListView::highlightRangeMode + \qmlproperty enumeration ListView::highlightRangeMode These properties set the preferred range of the highlight (current item) within the view. diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp index 2588f7d..bec2ff8 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp @@ -563,7 +563,7 @@ QString QmlGraphicsTextEdit::selectedText() const \qmlproperty bool TextEdit::focusOnPress Whether the TextEdit should gain focus on a mouse press. By default this is - set to false; + set to false. */ bool QmlGraphicsTextEdit::focusOnPress() const { diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h index 6db99c6..4b343f0 100644 --- a/src/declarative/qml/qmlmetaproperty.h +++ b/src/declarative/qml/qmlmetaproperty.h @@ -133,7 +133,7 @@ public: int valueTypeCoreIndex() const; private: friend class QmlEnginePrivate; - friend class QmlMetaPropertyPrivate;; + friend class QmlMetaPropertyPrivate; QmlMetaPropertyPrivate *d; }; typedef QList<QmlMetaProperty> QmlMetaProperties; diff --git a/src/declarative/util/qmlpropertychanges.cpp b/src/declarative/util/qmlpropertychanges.cpp index 6a393ee..9ca6db8 100644 --- a/src/declarative/util/qmlpropertychanges.cpp +++ b/src/declarative/util/qmlpropertychanges.cpp @@ -56,19 +56,32 @@ QT_BEGIN_NAMESPACE \qmlclass PropertyChanges QmlPropertyChanges \brief The PropertyChanges element describes new property values for a state. - PropertyChanges changes the properties of an item. It allows you to specify the property - names and values for a state similar to how you normally would specify them for the - actual item: + PropertyChanges provides a state change that modifies the properties of an item. - \code - PropertyChanges { - target: myRect - x: 52 - y: 300 - width: 48 - } - \endcode + Here is a property change that modifies the text and color of a Text element + when it is clicked: + + \qml + Text { + id: myText + width: 100; height: 100 + text: "Hello" + color: "blue" + + states: State { + name: "myState" + + PropertyChanges { + target: myText + text: "Goodbye" + color: "red" + } + } + MouseRegion { anchors.fill: parent; onClicked: myText.state = 'myState' } + } + \endqml + State-specific script for signal handlers can also be specified: \qml @@ -92,7 +105,7 @@ QT_BEGIN_NAMESPACE /*! \qmlproperty Object PropertyChanges::target - This property holds the object that the properties to change belong to + This property holds the object which contains the properties to be changed. */ class QmlReplaceSignalHandler : public ActionEvent diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index d6ce191..4dfa34a 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -42,6 +42,7 @@ #include "private/qobject_p.h" #include "qmlstategroup_p.h" #include "qmltransition_p.h" +#include "qmlstate_p_p.h" #include <qmlbinding.h> #include <QtCore/qdebug.h> #include <private/qmlglobal_p.h> @@ -57,7 +58,8 @@ class QmlStateGroupPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QmlStateGroup) public: QmlStateGroupPrivate(QmlStateGroup *p) - : nullState(0), states(p), componentComplete(true), ignoreTrans(false) {} + : nullState(0), states(p), componentComplete(true), + ignoreTrans(false), applyingState(false) {} QString currentState; QmlState *nullState; @@ -78,6 +80,7 @@ public: QmlConcreteList<QmlTransition *> transitions; bool componentComplete; bool ignoreTrans; + bool applyingState; QmlTransition *findTransition(const QString &from, const QString &to); void setCurrentStateInternal(const QString &state, bool = false); @@ -212,9 +215,6 @@ void QmlStateGroup::setState(const QString &state) return; d->setCurrentStateInternal(state); - - d->currentState = state; - emit stateChanged(d->currentState); } void QmlStateGroup::classBegin() @@ -334,6 +334,13 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, if (!componentComplete) return; + if (applyingState) { + qWarning() << "Can't apply a state change as part of a state definition."; + return; + } + + applyingState = true; + QmlTransition *transition = (ignoreTrans || ignoreTrans) ? 0 : findTransition(currentState, state); if (stateChangeDebug()) { qWarning() << this << "Changing state. From" << currentState << ". To" << state; @@ -353,6 +360,7 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, } currentState = state; + emit q->stateChanged(currentState); QmlState *newState = 0; for (int ii = 0; ii < states.count(); ++ii) { @@ -369,6 +377,9 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, } newState->apply(q, transition, oldState); + applyingState = false; + if (!transition) + static_cast<QmlStatePrivate*>(QObjectPrivate::get(newState))->complete(); } QmlState *QmlStateGroup::findState(const QString &name) const diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp index 0be62f4..6ac4e32 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qmltimer.cpp @@ -72,6 +72,9 @@ public: A timer can be used to trigger an action either once, or repeatedly at a given interval. + Here is a timer that shows the current date and time, and updates + the text every 500 milliseconds: + \qml Timer { interval: 500; running: true; repeat: true @@ -101,7 +104,7 @@ QmlTimer::QmlTimer(QObject *parent) /*! \qmlproperty int Timer::interval - Sets the \a interval in milliseconds between triggering. + Sets the \a interval between triggers, in milliseconds. The default interval is 1000 milliseconds. */ @@ -124,7 +127,7 @@ int QmlTimer::interval() const \qmlproperty bool Timer::running If set to true, starts the timer; otherwise stops the timer. - For a non-repeating timer, \a running will be set to false after the + For a non-repeating timer, \a running is set to false after the timer has been triggered. \a running defaults to false. @@ -150,7 +153,7 @@ void QmlTimer::setRunning(bool running) /*! \qmlproperty bool Timer::repeat - If \a repeat is true the timer will be triggered repeatedly at the + If \a repeat is true the timer is triggered repeatedly at the specified interval; otherwise, the timer will trigger once at the specified interval and then stop (i.e. running will be set to false). @@ -176,15 +179,15 @@ void QmlTimer::setRepeating(bool repeating) /*! \qmlproperty bool Timer::triggeredOnStart - When the Timer is started the first trigger is normally after the specified - interval has elapsed. It is sometimes desireable to trigger immediately - when the timer is started, for example to establish an initial + When a timer is started, the first trigger is usually after the specified + interval has elapsed. It is sometimes desirable to trigger immediately + when the timer is started; for example, to establish an initial state. - If \a triggeredOnStart is true, the timer will be triggered immediately - when started, and subsequently at the specified interval. Note that for - a Timer with \e repeat set to false, this will result in the timer being - triggered twice; once on start, and again at the interval. + If \a triggeredOnStart is true, the timer is triggered immediately + when started, and subsequently at the specified interval. Note that if + \e repeat is set to false, the timer is triggered twice; once on start, + and again at the interval. \a triggeredOnStart defaults to false. @@ -219,7 +222,7 @@ void QmlTimer::start() /*! \qmlmethod Timer::stop() - \brief stops the timer. + \brief Stops the timer. If the timer is not running, calling this method has no effect. The \c running property will be false following a call to \c stop(). diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp index ba726db..1a164c7 100644 --- a/src/declarative/util/qmltransitionmanager.cpp +++ b/src/declarative/util/qmltransitionmanager.cpp @@ -236,11 +236,8 @@ void QmlTransitionManager::transition(const QList<Action> &list, action.property.write(action.toValue); } } - if (!transition) { + if (!transition) d->applyBindings(); - if (d->state) - static_cast<QmlStatePrivate*>(QObjectPrivate::get(d->state))->complete(); - } } void QmlTransitionManager::cancel() |