From 3509b9b5036a3c7d7512c7f0f3f98b2af4227fc2 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 24 Nov 2009 16:36:06 +1000 Subject: Fix memory leak QTBUG-6156 --- src/declarative/graphicsitems/qmlgraphicspainteditem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp index 2f467e7..948f69a 100644 --- a/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspainteditem.cpp @@ -289,7 +289,7 @@ void QmlGraphicsPaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem * } cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height(); uncached += d->imagecache[oldest]->area; - d->imagecache.removeAt(oldest); + delete d->imagecache.takeAt(oldest); } const QRegion bigger = QRegion(biggerrect) & uncached; const QVector rects = bigger.rects(); @@ -366,7 +366,7 @@ void QmlGraphicsPaintedItem::setPixelCacheSize(int pixels) } } cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height(); - d->imagecache.removeAt(oldest); + delete d->imagecache.takeAt(oldest); } } d->max_imagecache_size = pixels; -- cgit v0.12 From 93ca74ebc54db90416538c78df9f9cc1ea1b006e Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 25 Nov 2009 11:34:42 +1000 Subject: cleanup progressbar example --- doc/src/declarative/example-slideswitch.qdoc | 2 +- examples/declarative/progressbar/ProgressBar.qml | 36 --------------------- .../progressbar/content/ProgressBar.qml | 36 +++++++++++++++++++++ .../declarative/progressbar/content/background.png | Bin 0 -> 426 bytes .../declarative/progressbar/images/lineedit-bg.png | Bin 426 -> 0 bytes examples/declarative/progressbar/main.qml | 23 ------------- examples/declarative/progressbar/progressbars.qml | 24 ++++++++++++++ 7 files changed, 61 insertions(+), 60 deletions(-) delete mode 100644 examples/declarative/progressbar/ProgressBar.qml create mode 100644 examples/declarative/progressbar/content/ProgressBar.qml create mode 100644 examples/declarative/progressbar/content/background.png delete mode 100644 examples/declarative/progressbar/images/lineedit-bg.png delete mode 100644 examples/declarative/progressbar/main.qml create mode 100644 examples/declarative/progressbar/progressbars.qml diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc index c942918..a8376eb 100644 --- a/doc/src/declarative/example-slideswitch.qdoc +++ b/doc/src/declarative/example-slideswitch.qdoc @@ -127,7 +127,7 @@ For more information on scripts see \l{qmlecmascript.html}{ECMAScript Blocks}. \snippet examples/declarative/slideswitch/content/Switch.qml 7 At this point, when the switch toggles between the two states the knob will instantly change its \c x position between 1 and 78. -In order for the the knob to move smoothly we add a transistion that will animate the \c x property with an easing curve for a duration of 200ms. +In order for the the knob to move smoothly we add a transition that will animate the \c x property with an easing curve for a duration of 200ms. For more information on transitions see \l{state-transitions}{QML Transitions}. diff --git a/examples/declarative/progressbar/ProgressBar.qml b/examples/declarative/progressbar/ProgressBar.qml deleted file mode 100644 index 302caa9..0000000 --- a/examples/declarative/progressbar/ProgressBar.qml +++ /dev/null @@ -1,36 +0,0 @@ -import Qt 4.6 - -Item { - id: progressbar - width: 250; height: 23; clip: true - - property int minimum: 0 - property int maximum: 100 - property int value: 0 - property alias color: g1.color - property alias secondColor: g2.color - - BorderImage { - source: "images/lineedit-bg.png" - width: parent.width; height: parent.height - border.left: 4; border.top: 4; border.right: 4; border.bottom: 4 - } - - Rectangle { - property int widthDest: (progressbar.width * (value - minimum)) / (maximum - minimum) - 6 - id: highlight; radius: 2 - anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom - anchors.leftMargin: 3; anchors.topMargin: 3; anchors.bottomMargin: 3 - width: EaseFollow { source: highlight.widthDest; duration: 1000 } - gradient: Gradient { - GradientStop { id: g1; position: 0.0 } - GradientStop { id: g2; position: 1.0 } - } - } - Text { - anchors.right: highlight.right; anchors.rightMargin: 6 - color: "white"; font.bold: true - anchors.verticalCenter: parent.verticalCenter - text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' - } -} diff --git a/examples/declarative/progressbar/content/ProgressBar.qml b/examples/declarative/progressbar/content/ProgressBar.qml new file mode 100644 index 0000000..bfc801c --- /dev/null +++ b/examples/declarative/progressbar/content/ProgressBar.qml @@ -0,0 +1,36 @@ +import Qt 4.6 + +Item { + id: progressbar + width: 250; height: 23; clip: true + + property int minimum: 0 + property int maximum: 100 + property int value: 0 + property alias color: g1.color + property alias secondColor: g2.color + + BorderImage { + source: "background.png" + width: parent.width; height: parent.height + border.left: 4; border.top: 4; border.right: 4; border.bottom: 4 + } + + Rectangle { + property int widthDest: ((progressbar.width * (value - minimum)) / (maximum - minimum) - 6) + id: highlight; radius: 1 + anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom + anchors.leftMargin: 3; anchors.topMargin: 3; anchors.bottomMargin: 3 + width: EaseFollow { source: highlight.widthDest; velocity: 1200 } + gradient: Gradient { + GradientStop { id: g1; position: 0.0 } + GradientStop { id: g2; position: 1.0 } + } + } + Text { + anchors.right: highlight.right; anchors.rightMargin: 6 + color: "white"; font.bold: true + anchors.verticalCenter: parent.verticalCenter + text: Math.floor((value - minimum) / (maximum - minimum) * 100) + '%' + } +} diff --git a/examples/declarative/progressbar/content/background.png b/examples/declarative/progressbar/content/background.png new file mode 100644 index 0000000..9044226 Binary files /dev/null and b/examples/declarative/progressbar/content/background.png differ diff --git a/examples/declarative/progressbar/images/lineedit-bg.png b/examples/declarative/progressbar/images/lineedit-bg.png deleted file mode 100644 index 9044226..0000000 Binary files a/examples/declarative/progressbar/images/lineedit-bg.png and /dev/null differ diff --git a/examples/declarative/progressbar/main.qml b/examples/declarative/progressbar/main.qml deleted file mode 100644 index 32353fc..0000000 --- a/examples/declarative/progressbar/main.qml +++ /dev/null @@ -1,23 +0,0 @@ -import Qt 4.6 - -Rectangle { - id: main - width: 800; height: 580; color: "#edecec" - - Flickable { - anchors.fill: parent; viewportHeight: column.height - Column { - id: column; spacing: 4 - Repeater { - model: 50 - ProgressBar { - property int r: Math.floor(Math.random() * 4000 + 1000) - width: main.width - value: NumberAnimation { duration: r; from: 0; to: 100; running: true; repeat: true } - color: ColorAnimation { duration: r; from: "lightsteelblue"; to: "thistle"; running: true; repeat: true } - secondColor: ColorAnimation { duration: r; from: "steelblue"; to: "#CD96CD"; running: true; repeat: true } - } - } - } - } -} diff --git a/examples/declarative/progressbar/progressbars.qml b/examples/declarative/progressbar/progressbars.qml new file mode 100644 index 0000000..6de8ecf --- /dev/null +++ b/examples/declarative/progressbar/progressbars.qml @@ -0,0 +1,24 @@ +import Qt 4.6 +import "content" + +Rectangle { + id: main + width: 600; height: 405; color: "#edecec" + + Flickable { + anchors.fill: parent; viewportHeight: column.height + 20 + Column { + id: column; x: 10; y: 10; spacing: 10 + Repeater { + model: 25 + ProgressBar { + property int r: Math.floor(Math.random() * 5000 + 1000) + width: main.width - 20 + value: NumberAnimation { duration: r; from: 0; to: 100; running: true; repeat: true } + color: ColorAnimation { duration: r; from: "lightsteelblue"; to: "thistle"; running: true; repeat: true } + secondColor: ColorAnimation { duration: r; from: "steelblue"; to: "#CD96CD"; running: true; repeat: true } + } + } + } + } +} -- cgit v0.12 From 84f405aa315dfec7c3d26d40a50185046d30164a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 25 Nov 2009 13:02:56 +1000 Subject: Allow dragging be press and hold, in which case don't let Flickable take the drag. When not press-and-hold, don't pass drags to WebKit. --- .../graphicsitems/qmlgraphicswebview.cpp | 52 +++++++++++++++++++--- .../graphicsitems/qmlgraphicswebview_p.h | 3 +- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index aedf787..e21bda3 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -79,6 +79,7 @@ public: : QmlGraphicsPaintedItemPrivate(), page(0), preferredwidth(0), preferredheight(0), progress(1.0), status(QmlGraphicsWebView::Null), pending(PendingNone), newWindowComponent(0), newWindowParent(0), + pressTime(400), windowObjects(this), rendering(true) { @@ -99,6 +100,11 @@ public: QmlComponent *newWindowComponent; QmlGraphicsItem *newWindowParent; + QBasicTimer pressTimer; + QPoint pressPoint; + int pressTime; // milliseconds before it's a "hold" XXX not currently settable + static const int pressDragLength = 15; // XXX #pixels before it's no longer a "hold"; device-specific + void updateWindowObjects(); class WindowObjectList : public QmlConcreteList { @@ -613,8 +619,15 @@ bool QmlGraphicsWebView::heuristicZoom(int clickX, int clickY, qreal maxzoom) void QmlGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) { + Q_D(QmlGraphicsWebView); + setFocus (true); QMouseEvent *me = sceneMouseEventToMouseEvent(event); + + d->pressPoint = me->pos(); + d->pressTimer.start(d->pressTime,this); + setKeepMouseGrab(false); + page()->event(me); event->setAccepted( /* @@ -636,8 +649,11 @@ void QmlGraphicsWebView::mousePressEvent(QGraphicsSceneMouseEvent *event) void QmlGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { + Q_D(QmlGraphicsWebView); + QMouseEvent *me = sceneMouseEventToMouseEvent(event); page()->event(me); + d->pressTimer.stop(); event->setAccepted( /* It is not correct to send the press event upwards, if it is not accepted by WebKit @@ -653,24 +669,45 @@ void QmlGraphicsWebView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (!event->isAccepted()) { QmlGraphicsPaintedItem::mouseReleaseEvent(event); } + setKeepMouseGrab(false); + ungrabMouse(); +} + +void QmlGraphicsWebView::timerEvent(QTimerEvent *event) +{ + Q_D(QmlGraphicsWebView); + if (event->timerId() == d->pressTimer.timerId()) { + d->pressTimer.stop(); + grabMouse(); + setKeepMouseGrab(true); + } } void QmlGraphicsWebView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { + Q_D(QmlGraphicsWebView); + QMouseEvent *me = sceneMouseEventToMouseEvent(event); - page()->event(me); - event->setAccepted( + if (d->pressTimer.isActive()) { + if ((me->pos() - d->pressPoint).manhattanLength() > d->pressDragLength) { + d->pressTimer.stop(); + } + } + if (keepMouseGrab()) { + page()->event(me); + event->setAccepted( /* It is not correct to send the press event upwards, if it is not accepted by WebKit e.g. push button does not work, if done so as QGraphicsScene will not send the release event at all to WebKit Might be a bug in WebKit, though */ #if 1 // QT_VERSION <= 0x040500 // XXX see bug 230835 - true + true #else - me->isAccepted() + me->isAccepted() #endif - ); + ); + } delete me; if (!event->isAccepted()) QmlGraphicsPaintedItem::mouseMoveEvent(event); @@ -722,7 +759,6 @@ bool QmlGraphicsWebView::sceneEvent(QEvent *event) } - /*! \qmlproperty action WebView::back This property holds the action for causing the previous URL in the history to be displayed. @@ -1161,6 +1197,8 @@ void QmlGraphicsWebPage::javaScriptConsoleMessage(const QString& message, int li QString QmlGraphicsWebPage::chooseFile(QWebFrame *originatingFrame, const QString& oldFile) { // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(oldFile) return oldFile; } @@ -1172,6 +1210,8 @@ void QmlGraphicsWebPage::javaScriptAlert(QWebFrame *originatingFrame, const QStr bool QmlGraphicsWebPage::javaScriptConfirm(QWebFrame *originatingFrame, const QString& msg) { // Not supported (it's modal) + Q_UNUSED(originatingFrame) + Q_UNUSED(msg) return false; } diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index 17546c1..7ff51f3 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -89,7 +89,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsWebView : public QmlGraphicsPaintedItem { Q_OBJECT - Q_ENUMS(Status) + Q_ENUMS(Status SelectionMode) Q_PROPERTY(QString title READ title NOTIFY titleChanged) Q_PROPERTY(QPixmap icon READ icon NOTIFY iconChanged) @@ -220,6 +220,7 @@ protected: void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); + void timerEvent(QTimerEvent *event); void hoverMoveEvent (QGraphicsSceneHoverEvent * event); void keyPressEvent(QKeyEvent* event); void keyReleaseEvent(QKeyEvent* event); -- cgit v0.12 From bb03160acc655d17f53f5ded04b1b8edfa213c59 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 25 Nov 2009 13:08:22 +1000 Subject: If zooming on nothing, zoom 2x rather than doing nothing. --- demos/declarative/webbrowser/webbrowser.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index bfc0749..105bb07 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -222,6 +222,8 @@ Item { onDoubleClick: { if (!heuristicZoom(clickX,clickY,2.5)) { var zf = flickable.width > 980 ? 1 : flickable.width/980; + if (zf > zoomFactor) + zf = 2.0 // zoom in (else zooming out) doZoom(zf,clickX/zoomFactor*zf,clickY/zoomFactor*zf) } } -- cgit v0.12 From 3c5f26079d20ffb6bac924e3686e717f499afbf7 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 25 Nov 2009 14:07:15 +1000 Subject: Fix changing Timer interval while running. Task-number: QTBUG-6201 --- src/declarative/util/qmltimer.cpp | 30 +++++++++++++-------- src/declarative/util/qmltimer_p.h | 2 +- tests/auto/declarative/qmltimer/tst_qmltimer.cpp | 34 ++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp index 0be62f4..d2198f2 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qmltimer.cpp @@ -55,7 +55,7 @@ class QmlTimerPrivate : public QObjectPrivate public: QmlTimerPrivate() : interval(1000), running(false), repeating(false), triggeredOnStart(false) - , classBegun(false), componentComplete(false) {} + , classBegun(false), componentComplete(false), firstTick(true) {} int interval; QPauseAnimation pause; bool running : 1; @@ -63,6 +63,7 @@ public: bool triggeredOnStart : 1; bool classBegun : 1; bool componentComplete : 1; + bool firstTick : 1; }; /*! @@ -85,6 +86,12 @@ public: QmlTimer is synchronized with the animation timer. Since the animation timer is usually set to 60fps, the resolution of QmlTimer will be at best 16ms. + + If the Timer is running and one of its properties is changed, the + elapsed time will be reset. For example, if a Timer with interval of + 1000ms has its \e repeat property changed 500ms after starting, the + elapsed time will be reset to 0, and the Timer will be triggered + 1000ms later. */ QmlTimer::QmlTimer(QObject *parent) @@ -92,8 +99,7 @@ QmlTimer::QmlTimer(QObject *parent) { Q_D(QmlTimer); connect(&d->pause, SIGNAL(currentLoopChanged(int)), this, SLOT(ticked())); - connect(&d->pause, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State)) - , this, SLOT(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + connect(&d->pause, SIGNAL(finished()), this, SLOT(finished())); d->pause.setLoopCount(1); d->pause.setDuration(d->interval); } @@ -142,6 +148,7 @@ void QmlTimer::setRunning(bool running) Q_D(QmlTimer); if (d->running != running) { d->running = running; + d->firstTick = true; emit runningChanged(); update(); } @@ -236,10 +243,11 @@ void QmlTimer::update() return; d->pause.stop(); if (d->running) { + d->pause.setCurrentTime(0); d->pause.setLoopCount(d->repeating ? -1 : 1); d->pause.setDuration(d->interval); d->pause.start(); - if (d->triggeredOnStart) { + if (d->triggeredOnStart && d->firstTick) { QCoreApplication::removePostedEvents(this, QEvent::MetaCall); QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection); } @@ -267,18 +275,18 @@ void QmlTimer::componentComplete() void QmlTimer::ticked() { Q_D(QmlTimer); - if (d->running) + if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick))) emit triggered(); + d->firstTick = false; } -void QmlTimer::stateChanged(QAbstractAnimation::State state, QAbstractAnimation::State) +void QmlTimer::finished() { Q_D(QmlTimer); - if (d->running && state != QAbstractAnimation::Running) { - d->running = false; - emit triggered(); - emit runningChanged(); - } + if (d->repeating || !d->running) + return; + emit triggered(); + d->firstTick = false; } QT_END_NAMESPACE diff --git a/src/declarative/util/qmltimer_p.h b/src/declarative/util/qmltimer_p.h index bd96d4a..56ef7a6 100644 --- a/src/declarative/util/qmltimer_p.h +++ b/src/declarative/util/qmltimer_p.h @@ -95,7 +95,7 @@ private: private Q_SLOTS: void ticked(); - void stateChanged(QAbstractAnimation::State,QAbstractAnimation::State); + void finished(); }; QT_END_NAMESPACE diff --git a/tests/auto/declarative/qmltimer/tst_qmltimer.cpp b/tests/auto/declarative/qmltimer/tst_qmltimer.cpp index cf54647..620d53e 100644 --- a/tests/auto/declarative/qmltimer/tst_qmltimer.cpp +++ b/tests/auto/declarative/qmltimer/tst_qmltimer.cpp @@ -42,6 +42,7 @@ #include #include #include +#include class tst_qmltimer : public QObject { @@ -56,6 +57,7 @@ private slots: void noTriggerIfNotRunning(); void triggeredOnStart(); void triggeredOnStartRepeat(); + void changeDuration(); }; class TimerHelper : public QObject @@ -123,6 +125,8 @@ void tst_qmltimer::notRepeatingStart() QCOMPARE(helper.count, 1); QTest::qWait(TIMEOUT_TIMEOUT); QCOMPARE(helper.count, 1); + + delete timer; } void tst_qmltimer::repeat() @@ -147,6 +151,8 @@ void tst_qmltimer::repeat() timer->stop(); QTest::qWait(TIMEOUT_TIMEOUT); QVERIFY(helper.count == oldCount); + + delete timer; } void tst_qmltimer::triggeredOnStart() @@ -166,6 +172,8 @@ void tst_qmltimer::triggeredOnStart() QCOMPARE(helper.count, 2); QTest::qWait(TIMEOUT_TIMEOUT); QCOMPARE(helper.count, 2); + + delete timer; } void tst_qmltimer::triggeredOnStartRepeat() @@ -185,6 +193,8 @@ void tst_qmltimer::triggeredOnStartRepeat() int oldCount = helper.count; QTest::qWait(TIMEOUT_TIMEOUT); QVERIFY(helper.count > oldCount); + + delete timer; } void tst_qmltimer::noTriggerIfNotRunning() @@ -201,6 +211,30 @@ void tst_qmltimer::noTriggerIfNotRunning() QVERIFY(item != 0); QTest::qWait(TIMEOUT_TIMEOUT); QCOMPARE(item->property("ok").toBool(), true); + + delete item; +} + +void tst_qmltimer::changeDuration() +{ + QmlEngine engine; + QmlComponent component(&engine, QByteArray("import Qt 4.6\nTimer { interval: 200; repeat: true; running: true }"), QUrl("file://")); + QmlTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(500); + QCOMPARE(helper.count, 2); + + timer->setInterval(500); + + QTest::qWait(600); + QCOMPARE(helper.count, 3); + + delete timer; } QTEST_MAIN(tst_qmltimer) -- cgit v0.12 From b5dc7443889313acfa12cb83239cdf00f7a0e009 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 25 Nov 2009 14:33:05 +1000 Subject: Make sure initial state gets set correctly. Fixes regression introduced by 3ec86e388a35b850573b8fd8b58c93113bb8bd3. --- src/declarative/util/qmlstategroup.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index 4dfa34a..f206f5c 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -331,8 +331,10 @@ void QmlStateGroupPrivate::setCurrentStateInternal(const QString &state, bool ignoreTrans) { Q_Q(QmlStateGroup); - if (!componentComplete) + if (!componentComplete) { + currentState = state; return; + } if (applyingState) { qWarning() << "Can't apply a state change as part of a state definition."; -- cgit v0.12 From 14877e418b3223ab7eacf49523eed2b10ce7721b Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 25 Nov 2009 14:36:19 +1000 Subject: Add NOTIFYs for anchor properties. Requested for Bauhaus. --- .../graphicsitems/qmlgraphicsanchors.cpp | 39 ++++++++++++++++------ .../graphicsitems/qmlgraphicsanchors_p.h | 27 ++++++++++----- .../graphicsitems/qmlgraphicsanchors_p_p.h | 7 ++++ 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp index 61b6ecc..f26fbf5 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp @@ -349,6 +349,9 @@ QmlGraphicsItem *QmlGraphicsAnchors::fill() const void QmlGraphicsAnchors::setFill(QmlGraphicsItem *f) { Q_D(QmlGraphicsAnchors); + if (d->fill == f) + return; + if (!f) { d->remDepend(d->fill); d->fill = f; @@ -361,7 +364,7 @@ void QmlGraphicsAnchors::setFill(QmlGraphicsItem *f) d->remDepend(d->fill); d->fill = f; d->addDepend(d->fill); - + emit fillChanged(); d->fillChanged(); } @@ -374,6 +377,9 @@ QmlGraphicsItem *QmlGraphicsAnchors::centerIn() const void QmlGraphicsAnchors::setCenterIn(QmlGraphicsItem* c) { Q_D(QmlGraphicsAnchors); + if (d->centerIn == c) + return; + if (!c) { d->remDepend(d->centerIn); d->centerIn = c; @@ -387,7 +393,7 @@ void QmlGraphicsAnchors::setCenterIn(QmlGraphicsItem* c) d->remDepend(d->centerIn); d->centerIn = c; d->addDepend(d->centerIn); - + emit centerInChanged(); d->centerInChanged(); } @@ -553,7 +559,7 @@ QmlGraphicsAnchorLine QmlGraphicsAnchors::top() const void QmlGraphicsAnchors::setTop(const QmlGraphicsAnchorLine &edge) { Q_D(QmlGraphicsAnchors); - if (!d->checkVAnchorValid(edge)) + if (!d->checkVAnchorValid(edge) || d->top == edge) return; d->usedAnchors |= HasTopAnchor; @@ -566,6 +572,7 @@ void QmlGraphicsAnchors::setTop(const QmlGraphicsAnchorLine &edge) d->remDepend(d->top.item); d->top = edge; d->addDepend(d->top.item); + emit topChanged(); d->updateVerticalAnchors(); } @@ -575,6 +582,7 @@ void QmlGraphicsAnchors::resetTop() d->usedAnchors &= ~HasTopAnchor; d->remDepend(d->top.item); d->top = QmlGraphicsAnchorLine(); + emit topChanged(); d->updateVerticalAnchors(); } @@ -587,7 +595,7 @@ QmlGraphicsAnchorLine QmlGraphicsAnchors::bottom() const void QmlGraphicsAnchors::setBottom(const QmlGraphicsAnchorLine &edge) { Q_D(QmlGraphicsAnchors); - if (!d->checkVAnchorValid(edge)) + if (!d->checkVAnchorValid(edge) || d->bottom == edge) return; d->usedAnchors |= HasBottomAnchor; @@ -600,6 +608,7 @@ void QmlGraphicsAnchors::setBottom(const QmlGraphicsAnchorLine &edge) d->remDepend(d->bottom.item); d->bottom = edge; d->addDepend(d->bottom.item); + emit bottomChanged(); d->updateVerticalAnchors(); } @@ -609,6 +618,7 @@ void QmlGraphicsAnchors::resetBottom() d->usedAnchors &= ~HasBottomAnchor; d->remDepend(d->bottom.item); d->bottom = QmlGraphicsAnchorLine(); + emit bottomChanged(); d->updateVerticalAnchors(); } @@ -621,7 +631,7 @@ QmlGraphicsAnchorLine QmlGraphicsAnchors::verticalCenter() const void QmlGraphicsAnchors::setVerticalCenter(const QmlGraphicsAnchorLine &edge) { Q_D(QmlGraphicsAnchors); - if (!d->checkVAnchorValid(edge)) + if (!d->checkVAnchorValid(edge) || d->vCenter == edge) return; d->usedAnchors |= HasVCenterAnchor; @@ -634,6 +644,7 @@ void QmlGraphicsAnchors::setVerticalCenter(const QmlGraphicsAnchorLine &edge) d->remDepend(d->vCenter.item); d->vCenter = edge; d->addDepend(d->vCenter.item); + emit verticalCenterChanged(); d->updateVerticalAnchors(); } @@ -643,6 +654,7 @@ void QmlGraphicsAnchors::resetVerticalCenter() d->usedAnchors &= ~HasVCenterAnchor; d->remDepend(d->vCenter.item); d->vCenter = QmlGraphicsAnchorLine(); + emit verticalCenterChanged(); d->updateVerticalAnchors(); } @@ -655,7 +667,7 @@ QmlGraphicsAnchorLine QmlGraphicsAnchors::baseline() const void QmlGraphicsAnchors::setBaseline(const QmlGraphicsAnchorLine &edge) { Q_D(QmlGraphicsAnchors); - if (!d->checkVAnchorValid(edge)) + if (!d->checkVAnchorValid(edge) || d->baseline == edge) return; d->usedAnchors |= HasBaselineAnchor; @@ -668,6 +680,7 @@ void QmlGraphicsAnchors::setBaseline(const QmlGraphicsAnchorLine &edge) d->remDepend(d->baseline.item); d->baseline = edge; d->addDepend(d->baseline.item); + emit baselineChanged(); d->updateVerticalAnchors(); } @@ -677,6 +690,7 @@ void QmlGraphicsAnchors::resetBaseline() d->usedAnchors &= ~HasBaselineAnchor; d->remDepend(d->baseline.item); d->baseline = QmlGraphicsAnchorLine(); + emit baselineChanged(); d->updateVerticalAnchors(); } @@ -689,7 +703,7 @@ QmlGraphicsAnchorLine QmlGraphicsAnchors::left() const void QmlGraphicsAnchors::setLeft(const QmlGraphicsAnchorLine &edge) { Q_D(QmlGraphicsAnchors); - if (!d->checkHAnchorValid(edge)) + if (!d->checkHAnchorValid(edge) || d->left == edge) return; d->usedAnchors |= HasLeftAnchor; @@ -702,6 +716,7 @@ void QmlGraphicsAnchors::setLeft(const QmlGraphicsAnchorLine &edge) d->remDepend(d->left.item); d->left = edge; d->addDepend(d->left.item); + emit leftChanged(); d->updateHorizontalAnchors(); } @@ -711,6 +726,7 @@ void QmlGraphicsAnchors::resetLeft() d->usedAnchors &= ~HasLeftAnchor; d->remDepend(d->left.item); d->left = QmlGraphicsAnchorLine(); + emit leftChanged(); d->updateHorizontalAnchors(); } @@ -723,7 +739,7 @@ QmlGraphicsAnchorLine QmlGraphicsAnchors::right() const void QmlGraphicsAnchors::setRight(const QmlGraphicsAnchorLine &edge) { Q_D(QmlGraphicsAnchors); - if (!d->checkHAnchorValid(edge)) + if (!d->checkHAnchorValid(edge) || d->right == edge) return; d->usedAnchors |= HasRightAnchor; @@ -736,7 +752,7 @@ void QmlGraphicsAnchors::setRight(const QmlGraphicsAnchorLine &edge) d->remDepend(d->right.item); d->right = edge; d->addDepend(d->right.item); - + emit rightChanged(); d->updateHorizontalAnchors(); } @@ -746,6 +762,7 @@ void QmlGraphicsAnchors::resetRight() d->usedAnchors &= ~HasRightAnchor; d->remDepend(d->right.item); d->right = QmlGraphicsAnchorLine(); + emit rightChanged(); d->updateHorizontalAnchors(); } @@ -758,7 +775,7 @@ QmlGraphicsAnchorLine QmlGraphicsAnchors::horizontalCenter() const void QmlGraphicsAnchors::setHorizontalCenter(const QmlGraphicsAnchorLine &edge) { Q_D(QmlGraphicsAnchors); - if (!d->checkHAnchorValid(edge)) + if (!d->checkHAnchorValid(edge) || d->hCenter == edge) return; d->usedAnchors |= HasHCenterAnchor; @@ -771,6 +788,7 @@ void QmlGraphicsAnchors::setHorizontalCenter(const QmlGraphicsAnchorLine &edge) d->remDepend(d->hCenter.item); d->hCenter = edge; d->addDepend(d->hCenter.item); + emit horizontalCenterChanged(); d->updateHorizontalAnchors(); } @@ -780,6 +798,7 @@ void QmlGraphicsAnchors::resetHorizontalCenter() d->usedAnchors &= ~HasHCenterAnchor; d->remDepend(d->hCenter.item); d->hCenter = QmlGraphicsAnchorLine(); + emit horizontalCenterChanged(); d->updateHorizontalAnchors(); } diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p.h index bdddafe..e432428 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p.h @@ -58,13 +58,13 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsAnchors : public QObject { Q_OBJECT - Q_PROPERTY(QmlGraphicsAnchorLine left READ left WRITE setLeft RESET resetLeft) - Q_PROPERTY(QmlGraphicsAnchorLine right READ right WRITE setRight RESET resetRight) - Q_PROPERTY(QmlGraphicsAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter) - Q_PROPERTY(QmlGraphicsAnchorLine top READ top WRITE setTop RESET resetTop) - Q_PROPERTY(QmlGraphicsAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom) - Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter) - Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline) + Q_PROPERTY(QmlGraphicsAnchorLine left READ left WRITE setLeft RESET resetLeft NOTIFY leftChanged) + Q_PROPERTY(QmlGraphicsAnchorLine right READ right WRITE setRight RESET resetRight NOTIFY rightChanged) + Q_PROPERTY(QmlGraphicsAnchorLine horizontalCenter READ horizontalCenter WRITE setHorizontalCenter RESET resetHorizontalCenter NOTIFY horizontalCenterChanged) + Q_PROPERTY(QmlGraphicsAnchorLine top READ top WRITE setTop RESET resetTop NOTIFY topChanged) + Q_PROPERTY(QmlGraphicsAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged) + Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged) + Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged) Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged()) @@ -72,8 +72,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsAnchors : public QObject Q_PROPERTY(qreal bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) Q_PROPERTY(qreal verticalCenterOffset READ verticalCenterOffset WRITE setVerticalCenterOffset NOTIFY verticalCenterOffsetChanged()) Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged()) - Q_PROPERTY(QmlGraphicsItem *fill READ fill WRITE setFill) - Q_PROPERTY(QmlGraphicsItem *centerIn READ centerIn WRITE setCenterIn) + Q_PROPERTY(QmlGraphicsItem *fill READ fill WRITE setFill NOTIFY fillChanged) + Q_PROPERTY(QmlGraphicsItem *centerIn READ centerIn WRITE setCenterIn NOTIFY centerInChanged) public: QmlGraphicsAnchors(QObject *parent=0); @@ -155,6 +155,15 @@ public: void componentComplete(); Q_SIGNALS: + void leftChanged(); + void rightChanged(); + void topChanged(); + void bottomChanged(); + void verticalCenterChanged(); + void horizontalCenterChanged(); + void baselineChanged(); + void fillChanged(); + void centerInChanged(); void leftMarginChanged(); void rightMarginChanged(); void topMarginChanged(); diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h index d21d9c5..2156565 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h @@ -80,9 +80,16 @@ public: QmlGraphicsItem *item; AnchorLine anchorLine; + + bool operator==(const QmlGraphicsAnchorLine& other) const + { + return item == other.item && anchorLine == other.anchorLine; + } }; Q_DECLARE_METATYPE(QmlGraphicsAnchorLine) + + class QmlGraphicsAnchorsPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlGraphicsAnchors) -- cgit v0.12 From 4e8ee5429339ec3c56656858ec7edc8ca726bd5c Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 25 Nov 2009 14:41:25 +1000 Subject: Test for pixmap property of Image. --- src/declarative/graphicsitems/qmlgraphicsimage.cpp | 1 + .../qmlgraphicsimage/tst_qmlgraphicsimage.cpp | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp index 9d59796..38df0c7 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp @@ -171,6 +171,7 @@ void QmlGraphicsImagePrivate::setPixmap(const QPixmap &pixmap) q->setImplicitWidth(pix.width()); q->setImplicitHeight(pix.height()); + status = pix.isNull() ? QmlGraphicsImageBase::Null : QmlGraphicsImageBase::Ready; q->update(); emit q->pixmapChanged(); diff --git a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp index 784ad42..c8a2d3f 100644 --- a/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp +++ b/tests/auto/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp @@ -81,6 +81,7 @@ private slots: void clearSource(); void resized(); void smooth(); + void pixmap(); private: QmlEngine engine; @@ -207,6 +208,35 @@ void tst_qmlgraphicsimage::smooth() delete obj; } +void tst_qmlgraphicsimage::pixmap() +{ + QString componentStr = "import Qt 4.6\nImage { pixmap: testPixmap }"; + + QPixmap pixmap; + QmlContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("testPixmap", pixmap); + + QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://")); + + QmlGraphicsImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QCOMPARE(obj->source(), QUrl()); + QVERIFY(obj->status() == QmlGraphicsImage::Null); + QCOMPARE(obj->width(), 0.); + QCOMPARE(obj->height(), 0.); + QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch); + QCOMPARE(obj->progress(), 0.0); + QVERIFY(obj->pixmap().isNull()); + + pixmap = QPixmap(SRCDIR "/data/colors.png"); + ctxt->setContextProperty("testPixmap", pixmap); + QCOMPARE(obj->width(), 120.); + QCOMPARE(obj->height(), 120.); + QVERIFY(obj->status() == QmlGraphicsImage::Ready); + + delete obj; +} + QTEST_MAIN(tst_qmlgraphicsimage) #include "tst_qmlgraphicsimage.moc" -- cgit v0.12 From 120433c1eac10ba431204a0cfa464bcbfe41a07d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 25 Nov 2009 14:54:26 +1000 Subject: Add Timer reset() method. --- src/declarative/util/qmltimer.cpp | 14 +++++++++++++ src/declarative/util/qmltimer_p.h | 1 + tests/auto/declarative/qmltimer/tst_qmltimer.cpp | 26 ++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/src/declarative/util/qmltimer.cpp b/src/declarative/util/qmltimer.cpp index 0a2448a..da60193 100644 --- a/src/declarative/util/qmltimer.cpp +++ b/src/declarative/util/qmltimer.cpp @@ -239,6 +239,20 @@ void QmlTimer::stop() setRunning(false); } +/*! + \qmlmethod Timer::restart() + \brief Restarts the timer. + + If the Timer is not running it will be started, otherwise it will be + stopped, reset to initial state and started. The \c running property + will be true following a call to \c restart(). +*/ +void QmlTimer::restart() +{ + setRunning(false); + setRunning(true); +} + void QmlTimer::update() { Q_D(QmlTimer); diff --git a/src/declarative/util/qmltimer_p.h b/src/declarative/util/qmltimer_p.h index 56ef7a6..50cae2b 100644 --- a/src/declarative/util/qmltimer_p.h +++ b/src/declarative/util/qmltimer_p.h @@ -85,6 +85,7 @@ protected: public Q_SLOTS: void start(); void stop(); + void restart(); Q_SIGNALS: void triggered(); diff --git a/tests/auto/declarative/qmltimer/tst_qmltimer.cpp b/tests/auto/declarative/qmltimer/tst_qmltimer.cpp index 620d53e..63a9a09 100644 --- a/tests/auto/declarative/qmltimer/tst_qmltimer.cpp +++ b/tests/auto/declarative/qmltimer/tst_qmltimer.cpp @@ -58,6 +58,7 @@ private slots: void triggeredOnStart(); void triggeredOnStartRepeat(); void changeDuration(); + void restart(); }; class TimerHelper : public QObject @@ -237,6 +238,31 @@ void tst_qmltimer::changeDuration() delete timer; } +void tst_qmltimer::restart() +{ + QmlEngine engine; + QmlComponent component(&engine, QByteArray("import Qt 4.6\nTimer { interval: 500; repeat: true; running: true }"), QUrl("file://")); + QmlTimer *timer = qobject_cast(component.create()); + QVERIFY(timer != 0); + + TimerHelper helper; + connect(timer, SIGNAL(triggered()), &helper, SLOT(timeout())); + QCOMPARE(helper.count, 0); + + QTest::qWait(600); + QCOMPARE(helper.count, 1); + + QTest::qWait(300); + + timer->restart(); + + QTest::qWait(700); + + QCOMPARE(helper.count, 2); + + delete timer; +} + QTEST_MAIN(tst_qmltimer) #include "tst_qmltimer.moc" -- cgit v0.12 From 9eb6102693c3d73259a236becb6701a0787bb4e3 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 25 Nov 2009 14:58:35 +1000 Subject: use right type --- examples/declarative/tutorials/helloworld/Cell.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/tutorials/helloworld/Cell.qml b/examples/declarative/tutorials/helloworld/Cell.qml index ab6e565..c38b40e 100644 --- a/examples/declarative/tutorials/helloworld/Cell.qml +++ b/examples/declarative/tutorials/helloworld/Cell.qml @@ -8,7 +8,7 @@ Item { property alias color: rectangle.color //![4] //![5] - signal clicked(string color) + signal clicked(color color) //![5] width: 40; height: 25 -- cgit v0.12 From 0e1883e4c4a6d5b3b14d5cf37862fee651da16d3 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 25 Nov 2009 14:59:14 +1000 Subject: add target --- doc/src/declarative/extending.qdoc | 39 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 7a9de60..d0beafc 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -531,7 +531,7 @@ in the bind engine for allowing an object to access the binding directly. If a binding is assigned to a property with a type of QmlBinding pointer (ie. \c {QmlBinding *}), each time the binding value changes, -a QmlBinding instance is assigned to that property. The QmlBinding instance +a QmlBinding instance is assigned to that property. The QmlBinding instance allows the object to read the binding and to evaluate the binding's current value. \section1 Extension Objects @@ -548,16 +548,16 @@ directly, if this is either not possible or is complicated by some other concerns, extension objects allow limited extension possibilities without direct modifications. -Extension objects are used to add additional properties to an existing type. -Extension objects can only add properties, not signals or methods. An extended -type definition allows the programmer to supply an additional type - known as the -extension type - when registering the target class whose properties are +Extension objects are used to add additional properties to an existing type. +Extension objects can only add properties, not signals or methods. An extended +type definition allows the programmer to supply an additional type - known as the +extension type - when registering the target class whose properties are transparently merged with the original target class when used from within QML. -An extension class is a regular QObject, with a constructor that takes a QObject -pointer. When needed (extension classes are delay created until the first extended -property is accessed) the extension class is created and the target object is -passed in as the parent. When an extended property on the original is accessed, +An extension class is a regular QObject, with a constructor that takes a QObject +pointer. When needed (extension classes are delay created until the first extended +property is accessed) the extension class is created and the target object is +passed in as the parent. When an extended property on the original is accessed, the appropriate property on the extension object is used instead. When an extended type is installed, one of the @@ -565,22 +565,22 @@ When an extended type is installed, one of the #define QML_DEFINE_EXTENDED_TYPE(URI, VMAJ, VFROM, VTO, QmlName,T, ExtendedT) #define QML_DEFINE_EXTENDED_NOCREATE_TYPE(T, ExtendedT) \endcode -macros should be used instead of the regular \c QML_DEFINE_TYPE or -\c QML_DEFINE_NOCREATE_TYPE. The arguments are identical to the corresponding -non-extension object macro, except for the ExtendedT parameter which is the type +macros should be used instead of the regular \c QML_DEFINE_TYPE or +\c QML_DEFINE_NOCREATE_TYPE. The arguments are identical to the corresponding +non-extension object macro, except for the ExtendedT parameter which is the type of the extension object. \section1 Optimization -Often to develop high performance elements it is helpful to know more about the -status of the QML engine. For example, it might be beneficial to delay -initializing some costly data structures until after all the properties have been +Often to develop high performance elements it is helpful to know more about the +status of the QML engine. For example, it might be beneficial to delay +initializing some costly data structures until after all the properties have been set. The QML engine defines an interface class called QmlParserStatus, which contains a -number of virtual methods that are invoked at various stages during component -instantiation. To receive these notifications, an element implementation inherits -QmlParserStatus and notifies the Qt meta system using the Q_INTERFACES() macro. +number of virtual methods that are invoked at various stages during component +instantiation. To receive these notifications, an element implementation inherits +QmlParserStatus and notifies the Qt meta system using the Q_INTERFACES() macro. For example, @@ -691,6 +691,7 @@ controls the color of the inner rectangle. } \endcode +\target qml-property-aliases \section2 Property aliases Property aliases are a more advanced form of property declaration. Unlike a @@ -718,7 +719,7 @@ An alias reference takes one of the following forms \endcode where must refer to an object id within the same component as the type -declaring the alias, and, optionally, refers to a property on that object. +declaring the alias, and, optionally, refers to a property on that object. Here is the property definition example rewritten to use property aliases. \code -- cgit v0.12 From 03de177e4f4d028ac75c2100060ab5d7389d3a2c Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Wed, 25 Nov 2009 15:00:05 +1000 Subject: slideswitch example fixes --- doc/src/declarative/example-slideswitch.qdoc | 3 +++ examples/declarative/slideswitch/slideswitch.qml | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc index a8376eb..492a8ea 100644 --- a/doc/src/declarative/example-slideswitch.qdoc +++ b/doc/src/declarative/example-slideswitch.qdoc @@ -131,4 +131,7 @@ In order for the the knob to move smoothly we add a transition that will animate For more information on transitions see \l{state-transitions}{QML Transitions}. +\section1 Usage +The switch can be used in a QML file, like this: +\snippet examples/declarative/slideswitch/slideswitch.qml 0 */ diff --git a/examples/declarative/slideswitch/slideswitch.qml b/examples/declarative/slideswitch/slideswitch.qml index 9b46cd1..396749f 100644 --- a/examples/declarative/slideswitch/slideswitch.qml +++ b/examples/declarative/slideswitch/slideswitch.qml @@ -5,7 +5,7 @@ Rectangle { color: "white" width: 400; height: 250 - Switch { - anchors.centerIn: parent - } +//![0] + Switch { anchors.centerIn: parent; on: false } +//![0] } -- cgit v0.12