diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-03-13 08:43:32 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-03-13 08:43:32 +0100 |
commit | 57aa9580f07307c5e277e52362943e7efd1f9ac9 (patch) | |
tree | b638b0637283fe00a1f9a173a8d2a03adab9e0d2 | |
parent | 5b18141e1165e24d2f3909548772916bea5faf10 (diff) | |
parent | 5c2b1bee5258981800c623dc3f054b15d7875484 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I32562a4aa6ca3090b28f624d675024f6b717bedb
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 11 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdial.cpp | 16 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdial_p.h | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickrangeslider.cpp | 13 | ||||
-rw-r--r-- | src/quicktemplates2/qquickrangeslider_p.h | 1 | ||||
-rw-r--r-- | src/quicktemplates2/qquickslider.cpp | 13 | ||||
-rw-r--r-- | src/quicktemplates2/qquickslider_p.h | 1 | ||||
-rw-r--r-- | tests/auto/controls/data/SignalSequenceSpy.qml | 11 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 54 | ||||
-rw-r--r-- | tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 10 |
10 files changed, 80 insertions, 51 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 6aef6391..28d3506f 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -581,9 +581,14 @@ void QQuickComboBoxPrivate::setHighlightedIndex(int index, Highlighting highligh void QQuickComboBoxPrivate::keySearch(const QString &text) { - int index = match(currentIndex + 1, text, Qt::MatchStartsWith | Qt::MatchWrap); - if (index != -1) - setCurrentIndex(index, Activate); + const int startIndex = isPopupVisible() ? highlightedIndex : currentIndex; + const int index = match(startIndex + 1, text, Qt::MatchStartsWith | Qt::MatchWrap); + if (index != -1) { + if (isPopupVisible()) + setHighlightedIndex(index, Highlight); + else + setCurrentIndex(index, Activate); + } } int QQuickComboBoxPrivate::match(int start, const QString &text, Qt::MatchFlags flags) const diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index b5957069..03aee27e 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -679,21 +679,7 @@ void QQuickDial::mousePressEvent(QMouseEvent *event) Q_D(QQuickDial); QQuickControl::mousePressEvent(event); d->handleMove(event->localPos()); -} - -void QQuickDial::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QQuickDial); - if (!keepMouseGrab()) { - bool overXDragThreshold = QQuickWindowPrivate::dragOverThreshold(event->localPos().x() - d->pressPoint.x(), Qt::XAxis, event); - setKeepMouseGrab(overXDragThreshold); - - if (!overXDragThreshold) { - bool overYDragThreshold = QQuickWindowPrivate::dragOverThreshold(event->localPos().y() - d->pressPoint.y(), Qt::YAxis, event); - setKeepMouseGrab(overYDragThreshold); - } - } - QQuickControl::mouseMoveEvent(event); + setKeepMouseGrab(true); } #if QT_CONFIG(quicktemplates2_multitouch) diff --git a/src/quicktemplates2/qquickdial_p.h b/src/quicktemplates2/qquickdial_p.h index d7bab0ad..d2caccfc 100644 --- a/src/quicktemplates2/qquickdial_p.h +++ b/src/quicktemplates2/qquickdial_p.h @@ -139,7 +139,6 @@ protected: void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; #if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; #endif diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 7205f26b..36d8ca02 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -1047,18 +1047,7 @@ void QQuickRangeSlider::mousePressEvent(QMouseEvent *event) Q_D(QQuickRangeSlider); QQuickControl::mousePressEvent(event); d->handleMove(event->localPos()); -} - -void QQuickRangeSlider::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QQuickRangeSlider); - if (!keepMouseGrab()) { - if (d->orientation == Qt::Horizontal) - setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->localPos().x() - d->pressPoint.x(), Qt::XAxis, event)); - else - setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->localPos().y() - d->pressPoint.y(), Qt::YAxis, event)); - } - QQuickControl::mouseMoveEvent(event); + setKeepMouseGrab(true); } #if QT_CONFIG(quicktemplates2_multitouch) diff --git a/src/quicktemplates2/qquickrangeslider_p.h b/src/quicktemplates2/qquickrangeslider_p.h index a6326441..45de6bbb 100644 --- a/src/quicktemplates2/qquickrangeslider_p.h +++ b/src/quicktemplates2/qquickrangeslider_p.h @@ -126,7 +126,6 @@ protected: void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; #if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; #endif diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 9b922215..86e2445a 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -717,18 +717,7 @@ void QQuickSlider::mousePressEvent(QMouseEvent *event) Q_D(QQuickSlider); QQuickControl::mousePressEvent(event); d->handleMove(event->localPos()); -} - -void QQuickSlider::mouseMoveEvent(QMouseEvent *event) -{ - Q_D(QQuickSlider); - if (!keepMouseGrab()) { - if (d->orientation == Qt::Horizontal) - setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->localPos().x() - d->pressPoint.x(), Qt::XAxis, event)); - else - setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(event->localPos().y() - d->pressPoint.y(), Qt::YAxis, event)); - } - QQuickControl::mouseMoveEvent(event); + setKeepMouseGrab(true); } #if QT_CONFIG(quicktemplates2_multitouch) diff --git a/src/quicktemplates2/qquickslider_p.h b/src/quicktemplates2/qquickslider_p.h index 4aac6e2c..847e15ec 100644 --- a/src/quicktemplates2/qquickslider_p.h +++ b/src/quicktemplates2/qquickslider_p.h @@ -152,7 +152,6 @@ protected: void keyPressEvent(QKeyEvent *event) override; void keyReleaseEvent(QKeyEvent *event) override; void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; #if QT_CONFIG(quicktemplates2_multitouch) void touchEvent(QTouchEvent *event) override; #endif diff --git a/tests/auto/controls/data/SignalSequenceSpy.qml b/tests/auto/controls/data/SignalSequenceSpy.qml index fe47a3c1..d14a5ee6 100644 --- a/tests/auto/controls/data/SignalSequenceSpy.qml +++ b/tests/auto/controls/data/SignalSequenceSpy.qml @@ -72,10 +72,15 @@ QtObject { property var __connections: [] onExpectedSequenceChanged: reset() - onTargetChanged: __setup() - onSignalsChanged: __setup() - function __setup() { + // We may call __setup from onTargetChanged and as we would read the signals property + // inside __setup, we may be initializing the binding for signals for the first time, which + // will write the value to the property and trigger onSignalsChanged and call __setup + // again. One easy way to protect against it is to evaluate those two dependencies upfront + onTargetChanged: __setup(target, signals) + onSignalsChanged: __setup(target, signals) + + function __setup(target, signals) { if (__oldTarget) { __connections.forEach(function (cx) { __oldTarget[cx.name].disconnect(cx.method) diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 5389a04a..30d6a93c 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -629,36 +629,90 @@ TestCase { compare(control.currentIndex, 0) compare(control.currentText, "Banana") + compare(control.highlightedIndex, -1) keyPress(Qt.Key_C) compare(control.currentIndex, 1) compare(control.currentText, "Coco") + compare(control.highlightedIndex, -1) // no match keyPress(Qt.Key_N) compare(control.currentIndex, 1) compare(control.currentText, "Coco") + compare(control.highlightedIndex, -1) keyPress(Qt.Key_C) compare(control.currentIndex, 2) compare(control.currentText, "Coconut") + compare(control.highlightedIndex, -1) keyPress(Qt.Key_C) compare(control.currentIndex, 4) compare(control.currentText, "Cocomuffin") + compare(control.highlightedIndex, -1) // wrap keyPress(Qt.Key_C) compare(control.currentIndex, 1) compare(control.currentText, "Coco") + compare(control.highlightedIndex, -1) keyPress(Qt.Key_A) compare(control.currentIndex, 3) compare(control.currentText, "Apple") + compare(control.highlightedIndex, -1) keyPress(Qt.Key_B) compare(control.currentIndex, 0) compare(control.currentText, "Banana") + compare(control.highlightedIndex, -1) + + // popup + control.popup.open() + tryCompare(control.popup, "opened", true) + + compare(control.currentIndex, 0) + compare(control.highlightedIndex, 0) + + keyClick(Qt.Key_C) + compare(control.highlightedIndex, 1) // "Coco" + compare(control.currentIndex, 0) + + // no match + keyClick(Qt.Key_N) + compare(control.highlightedIndex, 1) + compare(control.currentIndex, 0) + + keyClick(Qt.Key_C) + compare(control.highlightedIndex, 2) // "Coconut" + compare(control.currentIndex, 0) + + keyClick(Qt.Key_C) + compare(control.highlightedIndex, 4) // "Cocomuffin" + compare(control.currentIndex, 0) + + // wrap + keyClick(Qt.Key_C) + compare(control.highlightedIndex, 1) // "Coco" + compare(control.currentIndex, 0) + + keyClick(Qt.Key_B) + compare(control.highlightedIndex, 0) // "Banana" + compare(control.currentIndex, 0) + + keyClick(Qt.Key_A) + compare(control.highlightedIndex, 3) // "Apple" + compare(control.currentIndex, 0) + + verify(control.popup.visible) + + // accept + keyClick(Qt.Key_Return) + tryCompare(control.popup, "visible", false) + compare(control.currentIndex, 3) + compare(control.currentText, "Apple") + compare(control.highlightedIndex, -1) } function test_popup() { diff --git a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp index bba1cf45..e3a6ccf2 100644 --- a/tests/auto/qquickdrawer/tst_qquickdrawer.cpp +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -1263,13 +1263,17 @@ void tst_QQuickDrawer::nonModal() void tst_QQuickDrawer::slider_data() { QTest::addColumn<bool>("mouse"); - QTest::newRow("mouse") << true; - QTest::newRow("touch") << false; + QTest::addColumn<int>("delta"); + + QTest::newRow("mouse") << true << 2; + QTest::newRow("touch") << false << 2; + QTest::newRow("mouse,delta") << true << 296 / 8; } void tst_QQuickDrawer::slider() { QFETCH(bool, mouse); + QFETCH(int, delta); QQuickApplicationHelper helper(this, QStringLiteral("slider.qml")); QQuickWindow *window = helper.window; @@ -1295,7 +1299,7 @@ void tst_QQuickDrawer::slider() QTest::touchEvent(window, touchDevice.data()).press(0, from); int distance = qAbs(from.x() - to.x()); - for (int dx = 2; dx < distance; dx += 2) { + for (int dx = delta; dx <= distance; dx += delta) { if (mouse) QTest::mouseMove(window, from - QPoint(dx, 0)); else |