aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-07-15 16:21:46 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-07-15 16:23:25 +0200
commitb55c1dd1e16f39a0e8b78571acc3f117c1f18d88 (patch)
tree03793fa0ccf9b08f0ecba768589b598a85562113 /src
parentd9726cbd58fe9329dd450586ae51117f8ac054eb (diff)
parente9becf6931e9ff12b8912ddb79e4b2cbdd2d530a (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: src/quicktemplates2/qquickswipedelegate.cpp tests/auto/controls/data/tst_swipedelegate.qml tests/auto/controls/data/tst_textarea.qml tests/auto/controls/data/tst_textfield.qml Change-Id: I244f4ead4d14238c41db0bd965d7a2938f2ea8fc
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/doc/src/includes/qquickswipedelegate-interaction.qdocinc5
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp6
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp18
-rw-r--r--src/quicktemplates2/qquickstackview.cpp16
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp64
-rw-r--r--src/quicktemplates2/qquickswipedelegate_p.h2
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp10
-rw-r--r--src/quicktemplates2/qquicktextarea_p.h1
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp10
-rw-r--r--src/quicktemplates2/qquicktextfield_p.h1
10 files changed, 118 insertions, 15 deletions
diff --git a/src/imports/controls/doc/src/includes/qquickswipedelegate-interaction.qdocinc b/src/imports/controls/doc/src/includes/qquickswipedelegate-interaction.qdocinc
new file mode 100644
index 00000000..05aeadb6
--- /dev/null
+++ b/src/imports/controls/doc/src/includes/qquickswipedelegate-interaction.qdocinc
@@ -0,0 +1,5 @@
+Both interactive and non-interactive items can be used here. Normal
+event handling rules apply; if an interactive control like \l Button
+is used, interaction signals of SwipeDelegate such as
+\l {AbstractButton::}{clicked()} will not get emitted if the button
+is clicked.
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index c9220826..0e2154e7 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -72,6 +72,12 @@ QT_BEGIN_NAMESPACE
\image qtquickcontrols2-control.png
+ All controls, except non-interactive indicators, do not let clicks and
+ touches through to items below them. For example, if \l Pane is used as the
+ \l {ApplicationWindow::}{header} or \l {ApplicationWindow::}{footer} of
+ \l ApplicationWindow, items underneath it will not get mouse or touch
+ events.
+
\sa ApplicationWindow, Container
*/
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index cfb58902..2cc76947 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -244,10 +244,20 @@ bool QQuickDrawerPrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEvent *ev
// larger threshold to avoid being too eager to steal touch (QTBUG-50045)
int threshold = qMax(20, QGuiApplication::styleHints()->startDragDistance() + 5);
bool overThreshold = false;
- if (edge == Qt::LeftEdge || edge == Qt::RightEdge)
- overThreshold = dragOverThreshold(movePoint.x() - pressPoint.x(), Qt::XAxis, event, threshold);
- else
- overThreshold = dragOverThreshold(movePoint.y() - pressPoint.y(), Qt::YAxis, event, threshold);
+ if (position > 0 || dragMargin > 0) {
+ if (edge == Qt::LeftEdge || edge == Qt::RightEdge)
+ overThreshold = dragOverThreshold(movePoint.x() - pressPoint.x(), Qt::XAxis, event, threshold);
+ else
+ overThreshold = dragOverThreshold(movePoint.y() - pressPoint.y(), Qt::YAxis, event, threshold);
+ }
+
+ // Don't be too eager to steal presses outside the drawer (QTBUG-53929)
+ if (overThreshold && qFuzzyCompare(position, qreal(1.0)) && !popupItem->contains(popupItem->mapFromScene(movePoint))) {
+ if (edge == Qt::LeftEdge || edge == Qt::RightEdge)
+ overThreshold = qAbs(movePoint.x() - q->width()) < dragMargin;
+ else
+ overThreshold = qAbs(movePoint.y() - q->height()) < dragMargin;
+ }
if (overThreshold) {
QQuickItem *grabber = window->mouseGrabberItem();
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index 6fd681c5..2aff2c38 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -399,6 +399,14 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
an \l Item, \l Component, or a \l [QML] url. Returns the item that became
current.
+ StackView creates an instance automatically if the pushed item is a \l Component,
+ or a \l [QML] url. The optional \a properties argument specifies a map of initial
+ property values for the pushed item. For dynamically created items, these values
+ are applied before the creation is finalized. This is more efficient than setting
+ property values after creation, particularly where large sets of property values
+ are defined, and also allows property bindings to be set up (using \l{Qt::binding}
+ {Qt.binding()}) before the item is created.
+
Pushing a single item:
\code
stackView.push(rect)
@@ -587,6 +595,14 @@ void QQuickStackView::pop(QQmlV4Function *args)
item will be replaced. If \a target is \c null, all items in the stack
will be replaced. If not specified, only the top item will be replaced.
+ StackView creates an instance automatically if the replacing item is a \l Component,
+ or a \l [QML] url. The optional \a properties argument specifies a map of initial
+ property values for the replacing item. For dynamically created items, these values
+ are applied before the creation is finalized. This is more efficient than setting
+ property values after creation, particularly where large sets of property values
+ are defined, and also allows property bindings to be set up (using \l{Qt::binding}
+ {Qt.binding()}) before the item is created.
+
Replace the top item:
\code
stackView.replace(rect)
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index 2b50b717..6cd7abf4 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -103,6 +103,11 @@ namespace {
Attached *attachedObject(QQuickItem *item) {
return qobject_cast<Attached*>(qmlAttachedPropertiesObject<QQuickSwipeDelegate>(item, false));
}
+
+ enum PositionAnimation {
+ DontAnimatePosition,
+ AnimatePosition
+ };
}
class QQuickSwipePrivate : public QObjectPrivate
@@ -130,6 +135,7 @@ public:
QQuickItem *createDelegateItem(QQmlComponent *component);
QQuickItem *showRelevantItemForPosition(qreal position);
QQuickItem *createRelevantItemForDistance(qreal distance);
+ void reposition(PositionAnimation animationPolicy);
void createLeftItem();
void createBehindItem();
void createRightItem();
@@ -247,6 +253,27 @@ QQuickItem *QQuickSwipePrivate::createRelevantItemForDistance(qreal distance)
return nullptr;
}
+void QQuickSwipePrivate::reposition(PositionAnimation animationPolicy)
+{
+ QQuickItem *relevantItem = showRelevantItemForPosition(position);
+ const qreal relevantWidth = relevantItem ? relevantItem->width() : 0.0;
+ const qreal contentItemX = position * relevantWidth + control->leftPadding();
+
+ // "Behavior on x" relies on the property system to know when it should update,
+ // so we can prevent it from animating by setting the x position directly.
+ if (animationPolicy == AnimatePosition) {
+ if (QQuickItem *contentItem = control->contentItem())
+ contentItem->setProperty("x", contentItemX);
+ if (QQuickItem *background = control->background())
+ background->setProperty("x", position * relevantWidth);
+ } else {
+ if (QQuickItem *contentItem = control->contentItem())
+ contentItem->setX(contentItemX);
+ if (QQuickItem *background = control->background())
+ background->setX(position * relevantWidth);
+ }
+}
+
void QQuickSwipePrivate::createLeftItem()
{
if (!leftItem) {
@@ -509,13 +536,7 @@ void QQuickSwipe::setPosition(qreal position)
return;
d->position = adjustedPosition;
-
- QQuickItem *relevantItem = d->showRelevantItemForPosition(d->position);
- const qreal relevantWidth = relevantItem ? relevantItem->width() : 0.0;
- d->control->contentItem()->setProperty("x", d->position * relevantWidth + d->control->leftPadding());
- if (QQuickItem *background = d->control->background())
- background->setProperty("x", d->position * relevantWidth);
-
+ d->reposition(AnimatePosition);
emit positionChanged();
}
@@ -731,13 +752,17 @@ bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *item, QMous
void QQuickSwipeDelegatePrivate::resizeContent()
{
- // If the background and contentItem are outside the visible bounds
- // of the control (we clip anything outside the bounds), we don't want
- // to call QQuickControlPrivate's implementation of this function,
+ // 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.
+ // However, we still want to resize the control vertically.
QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe);
if (!swipePrivate->complete) {
- QQuickAbstractButtonPrivate::resizeContent();
+ QQuickItemDelegatePrivate::resizeContent();
+ } else if (contentItem) {
+ Q_Q(QQuickSwipeDelegate);
+ contentItem->setY(q->topPadding());
+ contentItem->setHeight(q->availableHeight());
}
}
@@ -783,6 +808,8 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
The left delegate sits behind both \l {Control::}{contentItem} and
\l {Control::}{background}. When the SwipeDelegate is swiped to the right,
this item will be gradually revealed.
+
+ \include qquickswipedelegate-interaction.qdocinc
\row
\li behind
\li This property holds the delegate that is shown when the
@@ -792,6 +819,8 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
\l {Control::}{contentItem} and \l {Control::}{background}. However, a
SwipeDelegate whose \c behind has been set can be continuously swiped
from either side, and will always show the same item.
+
+ \include qquickswipedelegate-interaction.qdocinc
\row
\li right
\li This property holds the right delegate.
@@ -799,6 +828,8 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
The right delegate sits behind both \l {Control::}{contentItem} and
\l {Control::}{background}. When the SwipeDelegate is swiped to the left,
this item will be gradually revealed.
+
+ \include qquickswipedelegate-interaction.qdocinc
\row
\li leftItem
\li This property holds the item instantiated from the \c left component.
@@ -915,6 +946,17 @@ void QQuickSwipeDelegate::mouseReleaseEvent(QMouseEvent *event)
d->handleMouseReleaseEvent(this, event);
}
+void QQuickSwipeDelegate::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
+{
+ Q_D(QQuickSwipeDelegate);
+ QQuickControl::geometryChanged(newGeometry, oldGeometry);
+
+ if (!qFuzzyCompare(newGeometry.width(), oldGeometry.width())) {
+ QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&d->swipe);
+ swipePrivate->reposition(DontAnimatePosition);
+ }
+}
+
QFont QQuickSwipeDelegate::defaultFont() const
{
return QQuickControlPrivate::themeFont(QPlatformTheme::ListViewFont);
diff --git a/src/quicktemplates2/qquickswipedelegate_p.h b/src/quicktemplates2/qquickswipedelegate_p.h
index 7ef995d1..49f6c939 100644
--- a/src/quicktemplates2/qquickswipedelegate_p.h
+++ b/src/quicktemplates2/qquickswipedelegate_p.h
@@ -75,6 +75,8 @@ protected:
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
+ void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
+
QFont defaultFont() const override;
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index a45a1a6b..754f59f7 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -677,6 +677,16 @@ void QQuickTextArea::mouseReleaseEvent(QMouseEvent *event)
}
}
+void QQuickTextArea::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ Q_D(QQuickTextArea);
+ if (d->pressHandler.delayedMousePressEvent) {
+ QQuickTextEdit::mousePressEvent(d->pressHandler.delayedMousePressEvent);
+ d->pressHandler.clearDelayedMouseEvent();
+ }
+ QQuickTextEdit::mouseDoubleClickEvent(event);
+}
+
void QQuickTextArea::timerEvent(QTimerEvent *event)
{
Q_D(QQuickTextArea);
diff --git a/src/quicktemplates2/qquicktextarea_p.h b/src/quicktemplates2/qquicktextarea_p.h
index 92c24bfc..56346514 100644
--- a/src/quicktemplates2/qquicktextarea_p.h
+++ b/src/quicktemplates2/qquicktextarea_p.h
@@ -122,6 +122,7 @@ protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
void timerEvent(QTimerEvent *event) override;
private:
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index cfaf3783..bc77317b 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -537,6 +537,16 @@ void QQuickTextField::mouseReleaseEvent(QMouseEvent *event)
}
}
+void QQuickTextField::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ Q_D(QQuickTextField);
+ if (d->pressHandler.delayedMousePressEvent) {
+ QQuickTextInput::mousePressEvent(d->pressHandler.delayedMousePressEvent);
+ d->pressHandler.clearDelayedMouseEvent();
+ }
+ QQuickTextInput::mouseDoubleClickEvent(event);
+}
+
void QQuickTextField::timerEvent(QTimerEvent *event)
{
Q_D(QQuickTextField);
diff --git a/src/quicktemplates2/qquicktextfield_p.h b/src/quicktemplates2/qquicktextfield_p.h
index 83b0d341..5ef7a02d 100644
--- a/src/quicktemplates2/qquicktextfield_p.h
+++ b/src/quicktemplates2/qquicktextfield_p.h
@@ -119,6 +119,7 @@ protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
void timerEvent(QTimerEvent *event) override;
private: