diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-06-20 21:32:04 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-06-20 21:32:29 +0200 |
commit | f5bee820aec44b22843299c25c5bd03e090c60bb (patch) | |
tree | 3c486bcc3f5031565ebae626bbec613625f29bd6 /src | |
parent | a2ab56bc3d778c7a5e30f58d0d29116ec6da793a (diff) | |
parent | c75ca309916ae1fec31ab37f25a7ddf9ea3c150a (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
src/quicktemplates2/qquickcontainer.cpp
Change-Id: I7c41619a81b4fdd0d8ccaa4f0bb489a9b84e3865
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/controls/TextField.qml | 2 | ||||
-rw-r--r-- | src/imports/controls/doc/qtquickcontrols2.qdocconf | 2 | ||||
-rw-r--r-- | src/imports/controls/doc/src/qtquickcontrols2-containers.qdoc | 2 | ||||
-rw-r--r-- | src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc | 3 | ||||
-rw-r--r-- | src/imports/controls/material/SpinBox.qml | 2 | ||||
-rw-r--r-- | src/imports/controls/plugins.qmltypes | 168 | ||||
-rw-r--r-- | src/quicktemplates2/qquickcontainer.cpp | 120 | ||||
-rw-r--r-- | src/quicktemplates2/qquickslider.cpp | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickstackview.cpp | 8 |
9 files changed, 130 insertions, 179 deletions
diff --git a/src/imports/controls/TextField.qml b/src/imports/controls/TextField.qml index aea83dde..2234646f 100644 --- a/src/imports/controls/TextField.qml +++ b/src/imports/controls/TextField.qml @@ -75,7 +75,7 @@ T.TextField { implicitWidth: 200 implicitHeight: 40 border.width: control.activeFocus ? 2 : 1 - color: control.enabled ? "transparent" : "#353637" + color: control.enabled ? "#ffffff" : "#353637" border.color: control.activeFocus ? "#0066ff" : (control.enabled ? "#bdbebf" : "transparent") } //! [background] diff --git a/src/imports/controls/doc/qtquickcontrols2.qdocconf b/src/imports/controls/doc/qtquickcontrols2.qdocconf index 563fb771..f61fc77d 100644 --- a/src/imports/controls/doc/qtquickcontrols2.qdocconf +++ b/src/imports/controls/doc/qtquickcontrols2.qdocconf @@ -83,7 +83,7 @@ macro.endstylemethod = "\\br" macro.stylecolor.HTML = "<div style=\"padding:10px;color:#fff;background:\1;\">\1 \2</div>" macro.nbsp.HTML = " " -macro.labs = "\\note \\e{Types in the Qt.labs module are not guaranteed to remain compatible in future versions.}" +macro.labs = "\\note \\e{Types in Qt.labs modules are not guaranteed to remain compatible in future versions.}" #Add output suffix to the html filenames outputsuffixes = QML diff --git a/src/imports/controls/doc/src/qtquickcontrols2-containers.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-containers.qdoc index c7a68968..d19cff5a 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-containers.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-containers.qdoc @@ -28,6 +28,8 @@ /*! \page qtquickcontrols2-containers.html \title Container Controls + \ingroup qtquickcontrols2-guidelines + \brief Guidelines for container controls Qt Quick Controls 2 offers a selection of container-like controls. diff --git a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc index 31c8b196..39213458 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc @@ -255,6 +255,9 @@ \li \l [QML QtQuickControls] {Menu} \li \l [QML QtQuickControls2] {Menu} \row + \li \l [QML QtQuickControls] {MenuBar} + \li \mdash + \row \li \l [QML QtQuickControls] {MenuItem} \li \l [QML QtQuickControls2] {MenuItem} \row diff --git a/src/imports/controls/material/SpinBox.qml b/src/imports/controls/material/SpinBox.qml index bd3a2867..8be0d432 100644 --- a/src/imports/controls/material/SpinBox.qml +++ b/src/imports/controls/material/SpinBox.qml @@ -68,7 +68,7 @@ T.SpinBox { text: control.textFromValue(control.value, control.locale) font: control.font - color: control.Material.primaryTextColor + color: enabled ? control.Material.primaryTextColor : control.Material.hintTextColor selectionColor: control.Material.textSelectionColor selectedTextColor: control.Material.primaryTextColor horizontalAlignment: Qt.AlignHCenter diff --git a/src/imports/controls/plugins.qmltypes b/src/imports/controls/plugins.qmltypes index 95f5aa15..e661056c 100644 --- a/src/imports/controls/plugins.qmltypes +++ b/src/imports/controls/plugins.qmltypes @@ -7,7 +7,7 @@ import QtQuick.tooling 1.2 // 'qmlplugindump -nonrelocatable QtQuick.Controls 2.0 -merge ..\templates\plugins.qmltypes -dependencies dep.json' Module { - dependencies: ["QtQuick.Templates 2.0", "QtQuick.Window 2.2"] + dependencies: ["QtQuick.Templates 2.0", "QtQuick.Window 2.2", "QtQuick 2.7"] Component { name: "QQuickAbstractAnimation" prototype: "QObject" @@ -750,172 +750,6 @@ Module { Signal { name: "implicitHeightChanged2"; revision: 1 } } Component { - name: "QQuickItem" - defaultProperty: "data" - prototype: "QObject" - Enum { - name: "TransformOrigin" - values: { - "TopLeft": 0, - "Top": 1, - "TopRight": 2, - "Left": 3, - "Center": 4, - "Right": 5, - "BottomLeft": 6, - "Bottom": 7, - "BottomRight": 8 - } - } - Property { name: "parent"; type: "QQuickItem"; isPointer: true } - Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } - Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true } - Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true } - Property { name: "x"; type: "double" } - Property { name: "y"; type: "double" } - Property { name: "z"; type: "double" } - Property { name: "width"; type: "double" } - Property { name: "height"; type: "double" } - Property { name: "opacity"; type: "double" } - Property { name: "enabled"; type: "bool" } - Property { name: "visible"; type: "bool" } - Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true } - Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true } - Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true } - Property { name: "state"; type: "string" } - Property { name: "childrenRect"; type: "QRectF"; isReadonly: true } - Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true } - Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true } - Property { name: "baselineOffset"; type: "double" } - Property { name: "clip"; type: "bool" } - Property { name: "focus"; type: "bool" } - Property { name: "activeFocus"; type: "bool"; isReadonly: true } - Property { name: "activeFocusOnTab"; revision: 1; type: "bool" } - Property { name: "rotation"; type: "double" } - Property { name: "scale"; type: "double" } - Property { name: "transformOrigin"; type: "TransformOrigin" } - Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true } - Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true } - Property { name: "smooth"; type: "bool" } - Property { name: "antialiasing"; type: "bool" } - Property { name: "implicitWidth"; type: "double" } - Property { name: "implicitHeight"; type: "double" } - Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true } - Signal { - name: "childrenRectChanged" - Parameter { type: "QRectF" } - } - Signal { - name: "baselineOffsetChanged" - Parameter { type: "double" } - } - Signal { - name: "stateChanged" - Parameter { type: "string" } - } - Signal { - name: "focusChanged" - Parameter { type: "bool" } - } - Signal { - name: "activeFocusChanged" - Parameter { type: "bool" } - } - Signal { - name: "activeFocusOnTabChanged" - revision: 1 - Parameter { type: "bool" } - } - Signal { - name: "parentChanged" - Parameter { type: "QQuickItem"; isPointer: true } - } - Signal { - name: "transformOriginChanged" - Parameter { type: "TransformOrigin" } - } - Signal { - name: "smoothChanged" - Parameter { type: "bool" } - } - Signal { - name: "antialiasingChanged" - Parameter { type: "bool" } - } - Signal { - name: "clipChanged" - Parameter { type: "bool" } - } - Signal { - name: "windowChanged" - revision: 1 - Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } - } - Method { name: "update" } - Method { - name: "grabToImage" - revision: 2 - type: "bool" - Parameter { name: "callback"; type: "QJSValue" } - Parameter { name: "targetSize"; type: "QSize" } - } - Method { - name: "grabToImage" - revision: 2 - type: "bool" - Parameter { name: "callback"; type: "QJSValue" } - } - Method { - name: "contains" - type: "bool" - Parameter { name: "point"; type: "QPointF" } - } - Method { - name: "mapToGlobal" - revision: 7 - type: "QPointF" - Parameter { name: "point"; type: "QPointF" } - } - Method { - name: "mapFromGlobal" - revision: 7 - type: "QPointF" - Parameter { name: "point"; type: "QPointF" } - } - Method { - name: "mapFromItem" - Parameter { type: "QQmlV4Function"; isPointer: true } - } - Method { - name: "mapToItem" - Parameter { type: "QQmlV4Function"; isPointer: true } - } - Method { name: "forceActiveFocus" } - Method { - name: "forceActiveFocus" - Parameter { name: "reason"; type: "Qt::FocusReason" } - } - Method { - name: "nextItemInFocusChain" - revision: 1 - type: "QQuickItem*" - Parameter { name: "forward"; type: "bool" } - } - Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" } - Method { - name: "childAt" - type: "QQuickItem*" - Parameter { name: "x"; type: "double" } - Parameter { name: "y"; type: "double" } - } - } - Component { name: "QQuickItemDelegate" defaultProperty: "data" prototype: "QQuickAbstractButton" diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp index 55e27887..be70f540 100644 --- a/src/quicktemplates2/qquickcontainer.cpp +++ b/src/quicktemplates2/qquickcontainer.cpp @@ -50,7 +50,86 @@ QT_BEGIN_NAMESPACE \ingroup qtquickcontrols2-containers \brief A container control base type. - Container is the base type of container-like user interface controls. + Container is the base type of container-like user interface controls that + allow dynamic insertion and removal of items. + + \section2 Using Containers + + Container provides API to \l {addItem}{add}, \l {insertItem}{insert}, + \l {moveItem}{move} and \l {removeItem}{remove} items dynamically. The + items in a container can be accessed using \l itemAt() or \l contentChildren. + + Most containers have a concept of a "current" item. The current item is + specified via the \l currentIndex property, and can be accessed using the + read-only \l currentItem property. + + The following example illustrates dynamic insertion of items to a \l TabBar, + which is one of the concrete implementations of Container. + + \code + Row { + TabBar { + id: tabBar + + currentIndex: 0 + width: parent.width - addButton.width + + TabButton { text: "TabButton" } + } + + Component { + id: tabButton + TabButton { text: "TabButton" } + } + + Button { + id: addButton + text: "+" + flat: true + onClicked: { + tabBar.addItem(tabButton.createObject(tabBar)) + console.log("added:", tabBar.itemAt(tabBar.count - 1)) + } + } + } + \endcode + + \section2 Implementing Containers + + Container does not provide any default visualization. It is used to implement + such containers as \l SwipeView and \l TabBar. When implementing a custom + container, the most important part of the API is \l contentModel, which provides + the contained items in a way that it can be used as a delegate model for item + views and repeaters. + + \code + Container { + id: container + + contentItem: ListView { + model: container.contentModel + snapMode: ListView.SnapOneItem + orientation: ListView.Horizontal + } + + Text { + text: "Page 1" + width: container.width + height: container.height + } + + Text { + text: "Page 2" + width: container.width + height: container.height + } + } + \endcode + + Notice how the sizes of the page items are set by hand. This is because the + example uses a plain Container, which does not make any assumptions on the + visual layout. It is typically not necessary to specify sizes for items in + concrete Container implementations, such as \l SwipeView and \l TabBar. \sa {Container Controls} */ @@ -391,6 +470,20 @@ void QQuickContainer::removeItem(int index) \readonly This property holds the content model of items. + + The content model is provided for visualization purposes. It can be assigned + as a model to a content item that presents the contents of the container. + + \code + Container { + id: container + contentItem: ListView { + model: container.contentModel + } + } + \endcode + + \sa contentData, contentChildren */ QVariant QQuickContainer::contentModel() const { @@ -404,7 +497,14 @@ QVariant QQuickContainer::contentModel() const This property holds the list of content data. - \sa Item::data + The list contains all objects that have been declared in QML as children + of the container, and also items that have been dynamically added or + inserted using the \l addItem() and \l insertItem() methods, respectively. + + \note Unlike \c contentChildren, \c contentData does include non-visual QML + objects. It is not re-ordered when items are inserted or moved. + + \sa Item::data, contentChildren */ QQmlListProperty<QObject> QQuickContainer::contentData() { @@ -421,7 +521,14 @@ QQmlListProperty<QObject> QQuickContainer::contentData() This property holds the list of content children. - \sa Item::children + The list contains all items that have been declared in QML as children + of the container, and also items that have been dynamically added or + inserted using the \l addItem() and \l insertItem() methods, respectively. + + \note Unlike \c contentData, \c contentChildren does not include non-visual + QML objects. It is re-ordered when items are inserted or moved. + + \sa Item::children, contentData */ QQmlListProperty<QQuickItem> QQuickContainer::contentChildren() { @@ -436,9 +543,9 @@ QQmlListProperty<QQuickItem> QQuickContainer::contentChildren() /*! \qmlproperty int QtQuick.Controls::Container::currentIndex - This property holds the index of the current item in the container. + This property holds the index of the current item. - \sa incrementCurrentIndex(), decrementCurrentIndex() + \sa currentItem, incrementCurrentIndex(), decrementCurrentIndex() */ int QQuickContainer::currentIndex() const { @@ -489,8 +596,11 @@ void QQuickContainer::decrementCurrentIndex() /*! \qmlproperty Item QtQuick.Controls::Container::currentItem + \readonly This property holds the current item. + + \sa currentIndex */ QQuickItem *QQuickContainer::currentItem() const { diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index d54a47e5..2a89ab4f 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -102,7 +102,7 @@ public: qreal QQuickSliderPrivate::snapPosition(qreal position) const { - const qreal range = from + (to - from); + const qreal range = to - from; if (qFuzzyIsNull(range)) return position; diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp index d75dfc23..597cc358 100644 --- a/src/quicktemplates2/qquickstackview.cpp +++ b/src/quicktemplates2/qquickstackview.cpp @@ -525,10 +525,12 @@ void QQuickStackView::pop(QQmlV4Function *args) QV4::ScopedValue value(scope, (*args)[0]); if (value->isNull()) { enter = d->elements.value(0); - } else if (!value->isUndefined() && !value->isInt32()) { - enter = d->findElement(value); + } else if (const QV4::QObjectWrapper *o = value->as<QV4::QObjectWrapper>()) { + QQuickItem *item = qobject_cast<QQuickItem *>(o->object()); + enter = d->findElement(item); if (!enter) { - qmlInfo(this) << "pop: unknown argument: " << value->toQString(); // TODO: safe? + if (item != d->currentItem) + qmlInfo(this) << "pop: unknown argument: " << value->toQString(); // TODO: safe? args->setReturnValue(QV4::Encode::null()); d->elements.push(exit); // restore return; |