diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-03 07:58:19 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-03 10:23:11 +0200 |
commit | e9855d8ac8afed5371330f4f83f7b7dd51d9026f (patch) | |
tree | c1f70cbc64d9fe5d07911601880c571b4d3cd8f0 | |
parent | 508bb6ddde831fb0d0b7065b39d99be01b4e4771 (diff) | |
parent | 1b7b2d7ddb6a02fd2ccd1f29a431005b9e693723 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Also update expected line numbers in tst_swipedelegate.
Conflicts:
.qmake.conf
src/quicktemplates2/qquicktextarea.cpp
src/quicktemplates2/qquicktextarea_p.h
tests/auto/controls/data/tst_swipedelegate.qml
Change-Id: I36323e3a633c1c750d23014e56a7c881963a1a30
-rw-r--r-- | LICENSE.GPLv3 | 2 | ||||
-rw-r--r-- | LICENSE.LGPLv3 | 2 | ||||
-rw-r--r-- | examples/quickcontrols2/gallery/pages/SpinBoxPage.qml | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickswipedelegate.cpp | 16 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktextarea.cpp | 8 | ||||
-rw-r--r-- | src/quicktemplates2/qquicktextarea_p.h | 2 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_swipedelegate.qml | 81 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_textarea.qml | 24 |
8 files changed, 133 insertions, 3 deletions
diff --git a/LICENSE.GPLv3 b/LICENSE.GPLv3 index 4e49b122..71c4ad49 100644 --- a/LICENSE.GPLv3 +++ b/LICENSE.GPLv3 @@ -3,7 +3,7 @@ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd. Contact: http://www.qt.io/licensing/ - You may use, distribute and copy the Qt GUI Toolkit under the terms of + You may use, distribute and copy the Qt Toolkit under the terms of GNU Lesser General Public License version 3. That license references the General Public License version 3, that is displayed below. Other portions of the Qt Toolkit may be licensed directly under this license. diff --git a/LICENSE.LGPLv3 b/LICENSE.LGPLv3 index 87be995c..e200fb5b 100644 --- a/LICENSE.LGPLv3 +++ b/LICENSE.LGPLv3 @@ -3,7 +3,7 @@ The Qt Toolkit is Copyright (C) 2015 The Qt Company Ltd. Contact: http://www.qt.io/licensing/ - You may use, distribute and copy the Qt GUI Toolkit under the terms of + You may use, distribute and copy the Qt Toolkit under the terms of GNU Lesser General Public License version 3, which is displayed below. This license makes reference to the version 3 of the GNU General Public License, which you can find in the LICENSE.GPLv3 file. diff --git a/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml b/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml index 85d9477d..b8b42b49 100644 --- a/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml +++ b/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml @@ -63,6 +63,7 @@ Pane { value: 50 width: itemWidth anchors.horizontalCenter: parent.horizontalCenter + editable: true } } } diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp index 6cd7abf4..d266ca86 100644 --- a/src/quicktemplates2/qquickswipedelegate.cpp +++ b/src/quicktemplates2/qquickswipedelegate.cpp @@ -750,8 +750,24 @@ bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *item, QMous return hadGrabbedMouse; } +static void warnIfHorizontallyAnchored(QQuickItem *item, const QString &itemName) +{ + if (!item) + return; + + QQuickAnchors *anchors = QQuickItemPrivate::get(item)->_anchors; + if (anchors && (anchors->fill() || anchors->centerIn() || anchors->left().item || anchors->right().item) + && !item->property("_q_QQuickSwipeDelegate_warned").toBool()) { + qmlInfo(item) << QString::fromLatin1("SwipeDelegate: cannot use horizontal anchors with %1; unable to layout the item.").arg(itemName); + item->setProperty("_q_QQuickSwipeDelegate_warned", true); + } +} + void QQuickSwipeDelegatePrivate::resizeContent() { + warnIfHorizontallyAnchored(background, QStringLiteral("background")); + warnIfHorizontallyAnchored(contentItem, QStringLiteral("contentItem")); + // If the background and contentItem are repositioned due to a swipe, // we don't want to call QQuickControlPrivate's implementation of this function, // as it repositions the contentItem to be visible. diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 754f59f7..0f78413e 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -545,6 +545,14 @@ void QQuickTextArea::setHoverEnabled(bool enabled) emit hoverEnabledChanged(); } +bool QQuickTextArea::contains(const QPointF &point) const +{ + Q_D(const QQuickTextArea); + if (d->flickable && !d->flickable->contains(d->flickable->mapFromItem(this, point))) + return false; + return QQuickTextEdit::contains(point); +} + void QQuickTextArea::classBegin() { Q_D(QQuickTextArea); diff --git a/src/quicktemplates2/qquicktextarea_p.h b/src/quicktemplates2/qquicktextarea_p.h index 56346514..20500ee6 100644 --- a/src/quicktemplates2/qquicktextarea_p.h +++ b/src/quicktemplates2/qquicktextarea_p.h @@ -94,6 +94,8 @@ public: bool isHoverEnabled() const; void setHoverEnabled(bool enabled); + bool contains(const QPointF &point) const override; + Q_SIGNALS: void fontChanged(); void implicitWidthChanged3(); diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml index 17aab877..255c1d6d 100644 --- a/tests/auto/controls/data/tst_swipedelegate.qml +++ b/tests/auto/controls/data/tst_swipedelegate.qml @@ -1161,4 +1161,85 @@ TestCase { control.destroy(); } + + Component { + id: backgroundFillComponent + SwipeDelegate { + background: Item { anchors.fill: parent } + } + } + + Component { + id: backgroundCenterInComponent + SwipeDelegate { + background: Item { anchors.centerIn: parent } + } + } + + Component { + id: backgroundLeftComponent + SwipeDelegate { + background: Item { anchors.left: parent.left } + } + } + + Component { + id: backgroundRightComponent + SwipeDelegate { + background: Item { anchors.right: parent.right } + } + } + + Component { + id: contentItemFillComponent + SwipeDelegate { + contentItem: Item { anchors.fill: parent } + } + } + + Component { + id: contentItemCenterInComponent + SwipeDelegate { + contentItem: Item { anchors.centerIn: parent } + } + } + + Component { + id: contentItemLeftComponent + SwipeDelegate { + contentItem: Item { anchors.left: parent.left } + } + } + + Component { + id: contentItemRightComponent + SwipeDelegate { + contentItem: Item { anchors.right: parent.right } + } + } + + function test_horizontalAnchors_data() { + return [ + { tag: "background, fill", component: backgroundFillComponent, itemName: "background", warningLocation: ":1168:25" }, + { tag: "background, centerIn", component: backgroundCenterInComponent, itemName: "background", warningLocation: ":1175:25" }, + { tag: "background, left", component: backgroundLeftComponent, itemName: "background", warningLocation: ":1182:25" }, + { tag: "background, right", component: backgroundRightComponent, itemName: "background", warningLocation: ":1189:25" }, + { tag: "contentItem, fill", component: contentItemFillComponent, itemName: "contentItem", warningLocation: ":1196:26" }, + { tag: "contentItem, centerIn", component: contentItemCenterInComponent, itemName: "contentItem", warningLocation: ":1203:26" }, + { tag: "contentItem, left", component: contentItemLeftComponent, itemName: "contentItem", warningLocation: ":1210:26" }, + { tag: "contentItem, right", component: contentItemRightComponent, itemName: "contentItem", warningLocation: ":1217:26" } + ]; + } + + function test_horizontalAnchors(data) { + var warningMessage = Qt.resolvedUrl("tst_swipedelegate.qml") + data.warningLocation + + ": QML : SwipeDelegate: cannot use horizontal anchors with " + data.itemName + "; unable to layout the item." + + ignoreWarning(warningMessage); + + var control = data.component.createObject(testCase); + verify(control.contentItem); + + control.destroy(); + } } diff --git a/tests/auto/controls/data/tst_textarea.qml b/tests/auto/controls/data/tst_textarea.qml index 1c5c5cc8..5d3e8d55 100644 --- a/tests/auto/controls/data/tst_textarea.qml +++ b/tests/auto/controls/data/tst_textarea.qml @@ -154,7 +154,7 @@ TestCase { } function test_flickable() { - var control = flickable.createObject(testCase, {text:"line0"}) + var control = flickable.createObject(testCase, {text:"line0", selectByMouse: true}) verify(control) var textArea = control.TextArea.flickable @@ -169,6 +169,28 @@ TestCase { compare(control.contentWidth, textArea.contentWidth + textArea.leftPadding + textArea.rightPadding) compare(control.contentHeight, textArea.contentHeight + textArea.topPadding + textArea.bottomPadding) + compare(textArea.cursorPosition, 0) + + var center = textArea.positionAt(control.width / 2, control.height / 2) + verify(center > 0) + mouseClick(textArea, control.width / 2, control.height / 2) + compare(textArea.cursorPosition, center) + + // click inside text area, but below flickable + var below = textArea.positionAt(control.width / 2, control.height + 1) + verify(below > center) + mouseClick(textArea, control.width / 2, control.height + 1) + compare(textArea.cursorPosition, center) // no change + + // scroll down + control.contentY = -(control.contentHeight - control.height) / 2 + + // click inside textarea, but above flickable + var above = textArea.positionAt(control.width / 2, textArea.topPadding) + verify(above > 0 && above < center) + mouseClick(textArea, control.width / 2, 0) + compare(textArea.cursorPosition, center) // no change + control.destroy() } |