aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-07-09 08:25:38 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-07-09 08:26:10 +0200
commit1db5df5a73d9cc7dfe24c07ea4f4d30ed377861b (patch)
treeff1d62ff1043a43484d6b069a7bbadfe26a5719f
parentcbfa64fd84cab95d909371a5e44146928e403c05 (diff)
parent38f7d855f2485cfb6a3a4328c1d31bac44ee0ae0 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
-rw-r--r--examples/quickcontrols2/gallery/pages/FramePage.qml2
-rw-r--r--examples/quickcontrols2/gallery/pages/GroupBoxPage.qml2
-rw-r--r--src/imports/calendar/qquickmonthgrid.cpp24
-rw-r--r--src/imports/controls/doc/snippets/qtquickcontrols2-pageindicator-custom.qml3
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp2
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp11
-rw-r--r--src/quicktemplates2/qquickpopup.cpp2
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp12
-rw-r--r--src/quicktemplates2/qquicktooltip.cpp10
-rw-r--r--tests/auto/controls/data/tst_combobox.qml29
-rw-r--r--tests/auto/controls/data/tst_swipedelegate.qml24
-rw-r--r--tests/auto/drawer/tst_drawer.cpp25
12 files changed, 133 insertions, 13 deletions
diff --git a/examples/quickcontrols2/gallery/pages/FramePage.qml b/examples/quickcontrols2/gallery/pages/FramePage.qml
index 51d49d22..579e7e2d 100644
--- a/examples/quickcontrols2/gallery/pages/FramePage.qml
+++ b/examples/quickcontrols2/gallery/pages/FramePage.qml
@@ -62,7 +62,7 @@ Pane {
Column {
spacing: 20
- width: itemWidth
+ width: pane.itemWidth
RadioButton {
text: "First"
diff --git a/examples/quickcontrols2/gallery/pages/GroupBoxPage.qml b/examples/quickcontrols2/gallery/pages/GroupBoxPage.qml
index aea64a4f..52676721 100644
--- a/examples/quickcontrols2/gallery/pages/GroupBoxPage.qml
+++ b/examples/quickcontrols2/gallery/pages/GroupBoxPage.qml
@@ -63,7 +63,7 @@ Pane {
Column {
spacing: 20
- width: itemWidth
+ width: pane.itemWidth
RadioButton {
text: "First"
diff --git a/src/imports/calendar/qquickmonthgrid.cpp b/src/imports/calendar/qquickmonthgrid.cpp
index 5227e7d5..d03067ff 100644
--- a/src/imports/calendar/qquickmonthgrid.cpp
+++ b/src/imports/calendar/qquickmonthgrid.cpp
@@ -73,6 +73,30 @@ QT_BEGIN_NAMESPACE
\sa DayOfWeekRow, WeekNumberColumn, CalendarModel
*/
+/*!
+ \qmlsignal Qt.labs.calendar::MonthGrid::pressed(date date)
+
+ This signal is emitted when \a date is pressed.
+*/
+
+/*!
+ \qmlsignal Qt.labs.calendar::MonthGrid::released(date date)
+
+ This signal is emitted when \a date is released.
+*/
+
+/*!
+ \qmlsignal Qt.labs.calendar::MonthGrid::clicked(date date)
+
+ This signal is emitted when \a date is clicked.
+*/
+
+/*!
+ \qmlsignal Qt.labs.calendar::MonthGrid::pressAndHold(date date)
+
+ This signal is emitted when \a date is pressed and held down.
+*/
+
class QQuickMonthGridPrivate : public QQuickControlPrivate
{
Q_DECLARE_PUBLIC(QQuickMonthGrid)
diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-pageindicator-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-pageindicator-custom.qml
index c8fe4c14..225ba423 100644
--- a/src/imports/controls/doc/snippets/qtquickcontrols2-pageindicator-custom.qml
+++ b/src/imports/controls/doc/snippets/qtquickcontrols2-pageindicator-custom.qml
@@ -30,6 +30,7 @@ import QtQuick 2.6
import QtQuick.Controls 2.1
PageIndicator {
+ id: control
count: 5
currentIndex: 2
@@ -40,7 +41,7 @@ PageIndicator {
radius: width / 2
color: "#21be2b"
- opacity: index === currentIndex ? 0.95 : pressed ? 0.7 : 0.45
+ opacity: index === control.currentIndex ? 0.95 : pressed ? 0.7 : 0.45
Behavior on opacity {
OpacityAnimator {
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index cba6850a..c4b2b6f0 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -95,7 +95,7 @@ static const int AUTO_REPEAT_INTERVAL = 100;
/*!
\qmlsignal QtQuick.Controls::AbstractButton::pressAndHold()
- This signal is emitted when the button is interactively perssed and held down by the user.
+ This signal is emitted when the button is interactively pressed and held down by the user.
*/
/*!
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 836d6806..cce61509 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -669,9 +669,16 @@ void QQuickComboBox::setPopup(QQuickPopup *popup)
QString QQuickComboBox::textAt(int index) const
{
Q_D(const QQuickComboBox);
- if (!d->delegateModel || index < 0 || index >= d->delegateModel->count() || !d->delegateModel->object(index))
+ if (!d->delegateModel || index < 0 || index >= d->delegateModel->count())
return QString();
- return d->delegateModel->stringValue(index, d->textRole.isEmpty() ? QStringLiteral("modelData") : d->textRole);
+
+ QString text;
+ QObject *object = d->delegateModel->object(index);
+ if (object) {
+ text = d->delegateModel->stringValue(index, d->textRole.isEmpty() ? QStringLiteral("modelData") : d->textRole);
+ d->delegateModel->release(object);
+ }
+ return text;
}
/*!
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 25ab2b42..2c661a1b 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -231,8 +231,8 @@ void QQuickPopupPrivate::finalizeEnterTransition()
void QQuickPopupPrivate::finalizeExitTransition(bool hide)
{
Q_Q(QQuickPopup);
- positioner.setParentItem(nullptr);
if (hide) {
+ positioner.setParentItem(nullptr);
popupItem->setParentItem(nullptr);
popupItem->setVisible(false);
}
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index 140dd728..1edc5018 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -545,7 +545,7 @@ bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseE
{
Q_Q(QQuickSwipeDelegate);
QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe);
- // If the position is 0, we want to handle events ourself - we don't want child items to steal them.
+ // If the position is 0, we want to handle events ourselves - we don't want child items to steal them.
// This code will only get called when a child item has been created;
// events will go through the regular channels (mousePressEvent()) until then.
if (qFuzzyIsNull(swipePrivate->position)) {
@@ -618,7 +618,7 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv
// If the control was exposed before the drag begun, the distance should be inverted.
// For example, if the control had been swiped to the right, the position would be 1.0.
- // If the control was then swiped the left by a distance of -20 pixels, the normalized
+ // If the control was then swiped to the left by a distance of -20 pixels, the normalized
// distance might be -0.2, for example, which cannot be used as the position; the swipe
// started from the right, so we account for that by adding the position.
if (qFuzzyIsNull(normalizedDistance)) {
@@ -658,6 +658,9 @@ bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *, QMouseEve
QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe);
swipePrivate->velocityCalculator.stopMeasuring(event->pos(), event->timestamp());
+ const bool hadGrabbedMouse = q->keepMouseGrab();
+ q->setKeepMouseGrab(false);
+
// The control can be exposed by either swiping past the halfway mark, or swiping fast enough.
const qreal swipeVelocity = swipePrivate->velocityCalculator.velocity().x();
if (swipePrivate->position > 0.5 ||
@@ -676,9 +679,8 @@ bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *, QMouseEve
swipePrivate->wasComplete = false;
}
- q->setKeepMouseGrab(false);
-
- return true;
+ // Only consume child events if we had grabbed the mouse.
+ return hadGrabbedMouse;
}
void QQuickSwipeDelegatePrivate::resizeContent()
diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp
index 09c07778..9cc9a0d9 100644
--- a/src/quicktemplates2/qquicktooltip.cpp
+++ b/src/quicktemplates2/qquicktooltip.cpp
@@ -195,6 +195,8 @@ void QQuickToolTip::setText(const QString &text)
This property holds the delay (milliseconds) after which the tool tip is
shown. A tooltip with a negative delay is shown immediately. The default
value is \c 0.
+
+ \sa {Delay and Timeout}
*/
int QQuickToolTip::delay() const
{
@@ -218,6 +220,8 @@ void QQuickToolTip::setDelay(int delay)
This property holds the timeout (milliseconds) after which the tool tip is
hidden. A tooltip with a negative timeout does not hide automatically. The
default value is \c -1.
+
+ \sa {Delay and Timeout}
*/
int QQuickToolTip::timeout() const
{
@@ -346,7 +350,7 @@ QQuickToolTipAttached::QQuickToolTipAttached(QQuickItem *item) :
/*!
\qmlattachedproperty string QtQuick.Controls::ToolTip::text
- This attached property holds the text of the shared tool tip instance.
+ This attached property holds the text of the shared tool tip.
The property can be attached to any item.
*/
QString QQuickToolTipAttached::text() const
@@ -373,6 +377,8 @@ void QQuickToolTipAttached::setText(const QString &text)
This attached property holds the delay (milliseconds) of the shared tool tip.
The property can be attached to any item.
+
+ \sa {Delay and Timeout}
*/
int QQuickToolTipAttached::delay() const
{
@@ -395,6 +401,8 @@ void QQuickToolTipAttached::setDelay(int delay)
This attached property holds the timeout (milliseconds) of the shared tool tip.
The property can be attached to any item.
+
+ \sa {Delay and Timeout}
*/
int QQuickToolTipAttached::timeout() const
{
diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml
index 09c49ccb..4697eea9 100644
--- a/tests/auto/controls/data/tst_combobox.qml
+++ b/tests/auto/controls/data/tst_combobox.qml
@@ -811,4 +811,33 @@ TestCase {
control.destroy()
}
+
+ ListModel {
+ id: resetmodel
+ ListElement { text: "First" }
+ ListElement { text: "Second" }
+ ListElement { text: "Third" }
+ }
+
+ // QTBUG-54573
+ function test_modelReset() {
+ var control = comboBox.createObject(testCase, {model: resetmodel})
+ verify(control)
+ control.popup.open()
+
+ var listview = control.popup.contentItem
+ verify(listview)
+
+ waitForRendering(listview)
+ compare(listview.contentItem.children.length, resetmodel.count + 1) // + highlight item
+
+ resetmodel.clear()
+ resetmodel.append({text: "Fourth"})
+ resetmodel.append({text: "Fifth"})
+
+ waitForRendering(listview)
+ compare(listview.contentItem.children.length, resetmodel.count + 1) // + highlight item
+
+ control.destroy()
+ }
}
diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml
index 7230406d..ead697d6 100644
--- a/tests/auto/controls/data/tst_swipedelegate.qml
+++ b/tests/auto/controls/data/tst_swipedelegate.qml
@@ -426,25 +426,49 @@ TestCase {
}
}
+ Component {
+ id: signalSpyComponent
+
+ SignalSpy {}
+ }
+
function test_eventsToLeftAndRight() {
var control = swipeDelegateWithButtonComponent.createObject(testCase);
verify(control);
// The button should be pressed instead of the SwipeDelegate.
mouseDrag(control, control.width / 2, control.height / 2, -control.width, 0);
+ // Mouse has been released by this stage.
verify(!control.pressed);
compare(control.swipe.position, -1.0);
verify(control.swipe.rightItem);
verify(control.swipe.rightItem.visible);
compare(control.swipe.rightItem.parent, control);
+ var buttonPressedSpy = signalSpyComponent.createObject(control, { target: control.swipe.rightItem, signalName: "pressed" });
+ verify(buttonPressedSpy);
+ verify(buttonPressedSpy.valid);
+ var buttonReleasedSpy = signalSpyComponent.createObject(control, { target: control.swipe.rightItem, signalName: "released" });
+ verify(buttonReleasedSpy);
+ verify(buttonReleasedSpy.valid);
+ var buttonClickedSpy = signalSpyComponent.createObject(control, { target: control.swipe.rightItem, signalName: "clicked" });
+ verify(buttonClickedSpy);
+ verify(buttonClickedSpy.valid);
+
+ // Now press the button.
mousePress(control, control.width / 2, control.height / 2);
verify(!control.pressed);
var button = control.swipe.rightItem;
verify(button.pressed);
+ compare(buttonPressedSpy.count, 1);
+ compare(buttonReleasedSpy.count, 0);
+ compare(buttonClickedSpy.count, 0);
mouseRelease(control, control.width / 2, control.height / 2);
verify(!button.pressed);
+ compare(buttonPressedSpy.count, 1);
+ compare(buttonReleasedSpy.count, 1);
+ compare(buttonClickedSpy.count, 1);
// Returning back to a position of 0 and pressing on the control should
// result in the control being pressed.
diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp
index 6a19af91..062b430a 100644
--- a/tests/auto/drawer/tst_drawer.cpp
+++ b/tests/auto/drawer/tst_drawer.cpp
@@ -56,6 +56,8 @@ private slots:
void dragMargin_data();
void dragMargin();
+
+ void reposition();
};
void tst_Drawer::position_data()
@@ -150,6 +152,29 @@ void tst_Drawer::dragMargin()
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - drawer->width() * 0.75, drawer->height() / 2));
}
+void tst_Drawer::reposition()
+{
+ QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml"));
+
+ QQuickApplicationWindow *window = helper.window;
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ QQuickDrawer *drawer = helper.window->property("drawer").value<QQuickDrawer*>();
+ QVERIFY(drawer);
+ drawer->setEdge(Qt::RightEdge);
+
+ drawer->open();
+ QTRY_COMPARE(drawer->popupItem()->x(), window->width() - drawer->width());
+
+ drawer->close();
+ QTRY_COMPARE(drawer->popupItem()->x(), static_cast<qreal>(window->width()));
+
+ window->setWidth(window->width() + 100);
+ QTRY_COMPARE(drawer->popupItem()->x(), static_cast<qreal>(window->width()));
+}
+
QTEST_MAIN(tst_Drawer)
#include "tst_drawer.moc"