From 7d93b0762aff8bcd9cb22f12ebc88beb242f2a97 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 19 Nov 2009 17:59:32 +1000 Subject: Remove extra semicolon. --- src/declarative/qml/qmlmetaproperty.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 QmlMetaProperties; -- cgit v0.12 From e111b77a1c1a02c3508db4981ae7daf4730f23dd Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 24 Nov 2009 12:56:46 +1000 Subject: Minor doc improvements --- doc/src/declarative/qmldocument.qdoc | 4 ++-- doc/src/declarative/qmlintro.qdoc | 24 ++++++++++++------------ doc/src/declarative/scope.qdoc | 20 ++++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/src/declarative/qmldocument.qdoc b/doc/src/declarative/qmldocument.qdoc index 2775ea6..453c023 100644 --- a/doc/src/declarative/qmldocument.qdoc +++ b/doc/src/declarative/qmldocument.qdoc @@ -44,9 +44,9 @@ \title QML Documents A QML document is a block of QML source code. QML documents generally correspond to files -stored on a disk or network resource, but can be constructed directly from text data. +stored on a disk or network resource, but can also be constructed directly from text data. -A simple QML document looks like this: +Here is a simple QML document: \code import Qt 4.6 diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc index f84d614..a97d0d1 100644 --- a/doc/src/declarative/qmlintro.qdoc +++ b/doc/src/declarative/qmlintro.qdoc @@ -48,7 +48,7 @@ \section1 What is QML? QML is a declarative language designed to describe the user interface of a -program: both what it looks like and how it behaves. In QML, a user +program: both what it looks like, and how it behaves. In QML, a user interface is specified as a tree of objects with properties. \section1 What should I know before starting? @@ -56,8 +56,8 @@ interface is specified as a tree of objects with properties. This introduction is meant for those with little or no programming experience. JavaScript is used as a scripting language in QML, so you may want to learn a bit more about it (\l{JavaScript: The Definitive Guide}) before diving -too deep into QML. It's also helpful to have a basic understanding of other web -technologies like HTML and CSS, but not required. +deeper into QML. It's also helpful to have a basic understanding of other web +technologies like HTML and CSS, but it's not required. \section1 Basic QML Syntax @@ -131,18 +131,18 @@ Item { } \endcode -In the example above, the Text2 object will display the same text as Text1. If Text1 is updated, -Text2 will be updated as well. +In the example above, the \c text2 object will display the same text as \c text1. If \c text1 is changed, +\c text2 is automatically changed to the same value. -Note that to refer to other objects, we use their \e id (more information on the id property can be -found in a following section). +Note that to refer to other objects, we use their \e id values. (See below for more +information on the \e id property.) \section1 QML Comments Commenting in QML is similar to JavaScript. \list -\o Single line comments begin with // and end at the end of the line. -\o Multiline comments begin with /* and end with *\/ +\o Single line comments start with // and finish at the end of the line. +\o Multiline comments start with /* and finish with *\/ \endlist \quotefile doc/src/snippets/declarative/comments.qml @@ -173,7 +173,7 @@ Properties begin with a lowercase letter (with the exception of \l{Attached Prop \section2 Property types -QML supports properties of many types (\l{Common QML Types}). The basic types include int, +QML supports properties of many types (see \l{Common QML Types}). The basic types include int, real, bool, string, color, and lists. \code @@ -186,12 +186,12 @@ Item { \endcode QML properties are what is known as \e typesafe. That is, they only allow you to assign a value that -matches the property type. For example, the scale property of item is a real, and if you try to assign +matches the property type. For example, the \c x property of item is a real, and if you try to assign a string to it you will get an error. \badcode Item { - scale: "hello" //illegal! + x: "hello" // illegal! } \endcode diff --git a/doc/src/declarative/scope.qdoc b/doc/src/declarative/scope.qdoc index fc678d1..f7f25f5 100644 --- a/doc/src/declarative/scope.qdoc +++ b/doc/src/declarative/scope.qdoc @@ -44,7 +44,7 @@ \title QML Scope \l {Property Binding}s and \l {ECMAScript Blocks} are executed in a scope chain automatically -established by QML when constructing a component instance. QML is a \e {dynamically scoped} +established by QML when a component instance is constructed. QML is a \e {dynamically scoped} language. Different object instances instantiated from the same component can exist in different scope chains. @@ -91,8 +91,8 @@ Text { \section1 QML Local Scope Most variables references are resolved in the local scope. The local scope is controlled by the -QML component in which the binding or script block was declarated. The following example shows -three different bindings, and the component that dictates their local scope. +QML component in which the binding or script block was defined. The following example shows +three different bindings, and the component that dictates each local scope. \table \row @@ -135,15 +135,15 @@ Rectangle { // Local scope component for binding 3 \endcode \endtable -Inside the local scope, four "sub-scopes" exist. Each "sub-scope" is searched in order when -resolving a name - names in a higher "sub-scopes" shadow those in lower sub-scopes. +Inside the local scope, four "sub-scopes" exist. Each sub-scope is searched in order when +resolving a name; names in higher sub-scopes shadow those in lower sub-scopes. \section2 IDs IDs present in the component take precendence over other names. The QML engine enforces uniqueness of IDs within a component, so their names cannot conflict with one another. -This is an example of using IDs within bindings. +Here is an example of using IDs within bindings: \code Item { @@ -192,7 +192,7 @@ scope object appear in the scope chain, immediately after \l {Script Methods}. In bindings and script blocks established explicitly in \l {QML Documents}, the scope object is always the element containing the binding or script block. The following example shows two bindings, one using grouped properties, and the corresponding scope object. These two bindings -use the scope object to resolve variable references - \c height is a property on \l Rectangle, +use the scope object to resolve variable references: \c height is a property on \l Rectangle, and \c parent is a property on \l Text. \code @@ -269,7 +269,7 @@ Item { \section1 QML Component chain When a QML component is instantiated it is given a parent component instance. The parent -component instance is immutable - it is not effected, for example, by changes in the instance's +component instance is immutable - it is not affected, for example, by changes in the instance's visual parent (in the case of visual elements). Should name resolution fail within the \l {QML Local Scope}, this parent chain is searched. @@ -283,8 +283,8 @@ For each component instance in the chain, the following are examined: This list is a sub-set of that in the \l {QML Local Scope}. -Sub-components used within a component have their parent component instance set to the component -instance that created them. In the following example, the two \c Button instances have the +A sub-component's parent component instance is set to the component that created it. +In the following example, the two \c Button instances have the \c main.qml instance as their parent component instance. If the \c Button type was used from within another QML file, it may have a difference parent component instance, and consequently the \c buttonClicked() method may resolve differently. -- cgit v0.12 From e3ec86e388a35b850573b8fd8b58c93113bb8bd3 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 24 Nov 2009 14:19:46 +1000 Subject: Prevent state changes within PropertyChanges. Task-number: QT-2358 --- src/declarative/util/qmlstategroup.cpp | 19 +++++++++++--- src/declarative/util/qmltransitionmanager.cpp | 5 +--- .../declarative/states/data/illegalTempState.qml | 21 ++++++++++++++++ .../declarative/states/data/legalTempState.qml | 23 +++++++++++++++++ tests/auto/declarative/states/tst_states.cpp | 29 ++++++++++++++++++++++ 5 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 tests/auto/declarative/states/data/illegalTempState.qml create mode 100644 tests/auto/declarative/states/data/legalTempState.qml 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 #include #include @@ -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 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(QObjectPrivate::get(newState))->complete(); } QmlState *QmlStateGroup::findState(const QString &name) const 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 &list, action.property.write(action.toValue); } } - if (!transition) { + if (!transition) d->applyBindings(); - if (d->state) - static_cast(QObjectPrivate::get(d->state))->complete(); - } } void QmlTransitionManager::cancel() diff --git a/tests/auto/declarative/states/data/illegalTempState.qml b/tests/auto/declarative/states/data/illegalTempState.qml new file mode 100644 index 0000000..2702be4 --- /dev/null +++ b/tests/auto/declarative/states/data/illegalTempState.qml @@ -0,0 +1,21 @@ +import Qt 4.6 + +Rectangle { + id: card + width: 100; height: 100 + + states: [ + State { + name: "placed" + PropertyChanges { target: card; state: "idle" } + }, + State { + name: "idle" + } + ] + + MouseRegion { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/declarative/states/data/legalTempState.qml b/tests/auto/declarative/states/data/legalTempState.qml new file mode 100644 index 0000000..54c97b9 --- /dev/null +++ b/tests/auto/declarative/states/data/legalTempState.qml @@ -0,0 +1,23 @@ +import Qt 4.6 + +Rectangle { + id: card + width: 100; height: 100 + + states: [ + State { + name: "placed" + onCompleted: card.state = "idle" + StateChangeScript { script: console.log("entering placed") } + }, + State { + name: "idle" + StateChangeScript { script: console.log("entering idle") } + } + ] + + MouseRegion { + anchors.fill: parent + onClicked: card.state = "placed" + } +} diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp index 4847535..17d9263 100644 --- a/tests/auto/declarative/states/tst_states.cpp +++ b/tests/auto/declarative/states/tst_states.cpp @@ -72,6 +72,8 @@ private slots: void incorrectRestoreBug(); void deletingChange(); void deletingState(); + void tempState(); + void illegalTempState(); }; void tst_states::basicChanges() @@ -803,6 +805,33 @@ void tst_states::deletingState() delete rect; } +void tst_states::tempState() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/legalTempState.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QTest::ignoreMessage(QtDebugMsg, "entering placed"); + QTest::ignoreMessage(QtDebugMsg, "entering idle"); + rect->setState("placed"); + QCOMPARE(rect->state(), QLatin1String("idle")); +} + +void tst_states::illegalTempState() +{ + QmlEngine engine; + + QmlComponent rectComponent(&engine, SRCDIR "/data/illegalTempState.qml"); + QmlGraphicsRectangle *rect = qobject_cast(rectComponent.create()); + QVERIFY(rect != 0); + + QTest::ignoreMessage(QtWarningMsg, "Can't apply a state change as part of a state definition. "); + rect->setState("placed"); + QCOMPARE(rect->state(), QLatin1String("placed")); +} + QTEST_MAIN(tst_states) #include "tst_states.moc" -- cgit v0.12 From b5b22e8f34c7fa51cc979e2554accc80847c7de9 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 24 Nov 2009 16:14:05 +1000 Subject: Fix doc example code --- .../graphicsitems/qmlgraphicsflipable.cpp | 46 +++++++++++++--------- 1 file changed, 28 insertions(+), 18 deletions(-) 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 -- cgit v0.12 From 148b3d9fd6f3fa11ded6a6c6ef44548b8422c0c4 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 24 Nov 2009 17:14:33 +1000 Subject: Doc --- doc/src/declarative/declarativeui.qdoc | 104 +++++++++++++++++++++++++++++++++ doc/src/declarative/qmlintro.qdoc | 11 +--- doc/src/declarative/qtdeclarative.qdoc | 54 ----------------- doc/src/index.qdoc | 2 +- 4 files changed, 108 insertions(+), 63 deletions(-) create mode 100644 doc/src/declarative/declarativeui.qdoc diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc new file mode 100644 index 0000000..7df87c5 --- /dev/null +++ b/doc/src/declarative/declarativeui.qdoc @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\title Declarative UI +\page declarativeui.html + +\brief The Qt Declarative module provides a declarative framework for building +highly dynamic, custom user interfaces. + +Qt Declarative aids programmers and designers in building the animation rich, +highly fluid user interfaces that are becoming common in portable consumer +electronics devices, such as mobile phones, media players, set-top boxes and +netbooks. The Qt Declarative module provides an engine for interpreting the +declarative QML language, and a rich set of \l {QML Elements}{QML elements} that can be used +from QML. + +QML is an extension to \l {http://www.ecma-international.org/publications/standards/Ecma-262.htm} +{ECMAScript}, that provides a mechanism to declaratively build an object tree +of QML elements. QML improves the integration between ECMAScript and Qt's +existing QObject based type system, adds support for automatic +\l {Property Binding}{property bindings} and provides \l {Network Transparency}{network transparency} at the language +level. + +The QML elements are a sophisticated set of graphical and behavioral building +blocks. These different elements are combined together in \l {QML Documents}{QML documents} to build components +ranging in complexity from simple buttons and sliders, to complete +internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo browser. + +Qt Declarative builds on \l {QML for Qt programmers}{Qt's existing strengths}. +QML can be be used to incrementally extend an existing application or to build +completely new applications. QML is fully \l {Extending QML}{extensible from C++}. + +\section1 Getting Started: +\list +\o \l {Introduction to the QML language} +\o \l {Tutorial}{Tutorial: 'Hello World'} +\o \l {advtutorial.html}{Tutorial: 'Same Game'} +\o \l {QML Examples and Walkthroughs} +\o \l {Using QML in C++ Applications} +\endlist + +\section1 Core QML Features: +\list +\o \l {QML Documents} +\o \l {Property Binding} +\o \l {ECMAScript Blocks} +\o \l {QML Scope} +\o \l {Network Transparency} +\o \l {qmlmodels}{Data Models} +\o \l {anchor-layout}{Anchor-based Layout} +\o \l {qmlstates}{States} +\o \l {qmlanimation.html}{Animation} +\o \l {qmlmodules.html}{Modules} +\o \l {qmlfocus}{Keyboard Focus} +\o \l {Extending types from QML} +\endlist + +\section1 Reference: +\list +\o \l {QML Elements} +\o \l {QML Global Object} +\o \l {Extending QML} +\o \l {QtDeclarative Module} +\endlist +*/ diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc index 2487a85..78462db 100644 --- a/doc/src/declarative/qmlintro.qdoc +++ b/doc/src/declarative/qmlintro.qdoc @@ -45,14 +45,10 @@ \tableofcontents -\section1 What is QML? - QML is a declarative language designed to describe the user interface of a program: both what it looks like, and how it behaves. In QML, a user interface is specified as a tree of objects with properties. -\section1 What should I know before starting? - This introduction is meant for those with little or no programming experience. JavaScript is used as a scripting language in QML, so you may want to learn a bit more about it (\l{JavaScript: The Definitive Guide}) before diving @@ -80,10 +76,9 @@ types always begin with a capital letter. In the above example, there are two objects, a \l Rectangle, and an \l Image. Between the braces, we can specify information about the object, such as its properties. -Properties are specified as \c {property: value} (much like CSS). In the above -example, we can see the Image has a property named \c source, which has been -assigned the value \c "pics/logo.png". The property and its value are -separated by a colon. +Properties are specified as \c {property: value}. In the above example, we +can see the Image has a property named \c source, which has been assigned the +value \c "pics/logo.png". The property and its value are separated by a colon. Properties can be specified one-per-line: diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc index e46cbab..5947429 100644 --- a/doc/src/declarative/qtdeclarative.qdoc +++ b/doc/src/declarative/qtdeclarative.qdoc @@ -47,58 +47,4 @@ \brief The Qt Declarative module provides a declarative framework for building highly dynamic, custom user interfaces. -Qt Declarative aids programmers and designers in building the animation rich, -highly fluid user interfaces that are becoming common in portable consumer -electronics devices, such as mobile phones, media players, set-top boxes and -netbooks. The Qt Declarative module provides an engine for interpreting the -declarative QML language, and a rich set of \l {QML Elements}{QML elements} that can be used -from QML. - -QML is an extension to \l {http://www.ecma-international.org/publications/standards/Ecma-262.htm} -{ECMAScript}, that provides a mechanism to declaratively build an object tree -of QML elements. QML improves the integration between ECMAScript and Qt's -existing QObject based type system, adds support for automatic -\l {Property Binding}{property bindings} and provides \l {Network Transparency}{network transparency} at the language -level. - -The QML elements are a sophisticated set of graphical and behavioral building -blocks. These different elements are combined together in \l {QML Documents}{QML documents} to build components -ranging in complexity from simple buttons and sliders, to complete -internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo browser. - -Qt Declarative builds on \l {QML for Qt programmers}{Qt's existing strengths}. -QML can be be used to incrementally extend an existing application or to build -completely new applications. QML is fully \l {Extending QML}{extensible from C++}. - -\section1 Getting Started: -\list -\o \l {Introduction to the QML language} -\o \l {Tutorial}{Tutorial: 'Hello World'} -\o \l {advtutorial.html}{Tutorial: 'Same Game'} -\o \l {QML Examples and Walkthroughs} -\o \l {Using QML in C++ Applications} -\endlist - -\section1 Core QML Features: -\list -\o \l {QML Documents} -\o \l {Property Binding} -\o \l {ECMAScript Blocks} -\o \l {QML Scope} -\o \l {Network Transparency} -\o \l {qmlmodels}{Data Models} -\o \l {anchor-layout}{Anchor-based Layout} -\o \l {qmlstates}{States} -\o \l {qmlanimation.html}{Animation} -\o \l {qmlmodules.html}{Modules} -\o \l {qmlfocus}{Keyboard Focus} -\o \l {Extending types from QML} -\endlist - -\section1 Reference: -\list -\o \l {QML Elements} -\o \l {QML Global Object} -\o \l {Extending QML} -\endlist */ diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 6b81936..762a900 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -103,7 +103,7 @@
  • Painting and Printing
  • Canvas UI with Graphics View
  • Integrating Web Content
  • -
  • Declarative UI
  • +
  • Declarative UI
  • -- cgit v0.12 From c711113555a815db293c7e0de9cfae9a9a07c681 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 24 Nov 2009 17:23:28 +1000 Subject: Fix GridView drag beyond end resistance. --- src/declarative/graphicsitems/qmlgraphicsflickable.cpp | 4 ++-- src/declarative/graphicsitems/qmlgraphicsgridview.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) 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/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) -- cgit v0.12 From 1f8085ce84dad88c27c8fffed84250baf20ee89c Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 24 Nov 2009 17:24:43 +1000 Subject: Docs. --- src/declarative/graphicsitems/qmlgraphicsimage.cpp | 9 +++++++++ src/declarative/graphicsitems/qmlgraphicslistview.cpp | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp index 42fd910..2161ed6 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); 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. -- cgit v0.12 From 368aa557ab3cf8a5c241890ff2f21e2b890df114 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 25 Nov 2009 11:14:04 +1000 Subject: Add NOTIFY signal for Image.pixmap --- src/declarative/graphicsitems/qmlgraphicsimage.cpp | 1 + src/declarative/graphicsitems/qmlgraphicsimage_p.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp index 2161ed6..9d59796 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp @@ -173,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); -- cgit v0.12 From 5271a2f1a1bbc7eae45824d3aa860d53e3879b79 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 25 Nov 2009 11:33:49 +1000 Subject: Doc improvements --- .../graphicsitems/qmlgraphicseffects.cpp | 27 ++++++++-------- .../graphicsitems/qmlgraphicstextedit.cpp | 2 +- src/declarative/util/qmlpropertychanges.cpp | 37 +++++++++++++++------- src/declarative/util/qmltimer.cpp | 25 ++++++++------- 4 files changed, 54 insertions(+), 37 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/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/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/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(). -- 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