aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-11-25 14:26:31 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-11-25 14:26:37 +0100
commit22769ac6a7667bf1d2d5b5e6421a15e4f6aadce1 (patch)
treedc76832e65fae17b99089d9cf7b41ef87aad1e7e /src
parenteba5b547e7f1c3817d172936293e03535225f8ee (diff)
parentac99683595e27b4157f9fd397fefa378955e275c (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/material/Drawer.qml19
-rw-r--r--src/imports/controls/material/qquickmaterialripple_p.h1
-rw-r--r--src/imports/templates/qtquicktemplates2plugin.cpp1
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp2
-rw-r--r--src/quicktemplates2/qquickswipe_p.h120
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp59
-rw-r--r--src/quicktemplates2/qquickswipedelegate_p.h61
-rw-r--r--src/quicktemplates2/qquickswipedelegate_p_p.h76
-rw-r--r--src/quicktemplates2/quicktemplates2.pri2
9 files changed, 258 insertions, 83 deletions
diff --git a/src/imports/controls/material/Drawer.qml b/src/imports/controls/material/Drawer.qml
index 855b5d88..55cabc9a 100644
--- a/src/imports/controls/material/Drawer.qml
+++ b/src/imports/controls/material/Drawer.qml
@@ -50,15 +50,32 @@ T.Drawer {
contentWidth: contentItem.implicitWidth || (contentChildren.length === 1 ? contentChildren[0].implicitWidth : 0)
contentHeight: contentItem.implicitHeight || (contentChildren.length === 1 ? contentChildren[0].implicitHeight : 0)
+ topPadding: !dim && edge === Qt.BottomEdge && Material.elevation === 0
+ leftPadding: !dim && edge === Qt.RightEdge && Material.elevation === 0
+ rightPadding: !dim && edge === Qt.LeftEdge && Material.elevation === 0
+ bottomPadding: !dim && edge === Qt.TopEdge && Material.elevation === 0
+
enter: Transition { SmoothedAnimation { velocity: 5 } }
exit: Transition { SmoothedAnimation { velocity: 5 } }
+ Material.elevation: 16
+
background: Rectangle {
color: control.Material.dialogColor
+ Rectangle {
+ readonly property bool horizontal: control.edge === Qt.LeftEdge || control.edge === Qt.RightEdge
+ width: horizontal ? 1 : parent.width
+ height: horizontal ? parent.height : 1
+ color: control.Material.dividerColor
+ x: control.edge === Qt.LeftEdge ? parent.width - 1 : 0
+ y: control.edge === Qt.TopEdge ? parent.height - 1 : 0
+ visible: !control.dim && control.Material.elevation === 0
+ }
+
layer.enabled: control.position > 0
layer.effect: ElevationEffect {
- elevation: 16
+ elevation: control.Material.elevation
fullHeight: true
}
}
diff --git a/src/imports/controls/material/qquickmaterialripple_p.h b/src/imports/controls/material/qquickmaterialripple_p.h
index 5b86fb2a..6fdcd28d 100644
--- a/src/imports/controls/material/qquickmaterialripple_p.h
+++ b/src/imports/controls/material/qquickmaterialripple_p.h
@@ -49,6 +49,7 @@
//
#include <QtQuick/qquickitem.h>
+#include <QtGui/qcolor.h>
QT_BEGIN_NAMESPACE
diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp
index 83bbb94a..57e8f88e 100644
--- a/src/imports/templates/qtquicktemplates2plugin.cpp
+++ b/src/imports/templates/qtquicktemplates2plugin.cpp
@@ -73,6 +73,7 @@
#include <QtQuickTemplates2/private/qquickslider_p.h>
#include <QtQuickTemplates2/private/qquickspinbox_p.h>
#include <QtQuickTemplates2/private/qquickstackview_p.h>
+#include <QtQuickTemplates2/private/qquickswipe_p.h>
#include <QtQuickTemplates2/private/qquickswipedelegate_p.h>
#include <QtQuickTemplates2/private/qquickswipeview_p.h>
#include <QtQuickTemplates2/private/qquickswitch_p.h>
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 350af84a..ffd8efa2 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -555,7 +555,7 @@ void QQuickAbstractButton::mouseReleaseEvent(QMouseEvent *event)
bool wasPressed = d->pressed;
setPressed(false);
- if (d->keepPressed || contains(event->pos()))
+ if (!d->wasHeld && (d->keepPressed || contains(event->pos())))
nextCheckState();
if (wasPressed) {
diff --git a/src/quicktemplates2/qquickswipe_p.h b/src/quicktemplates2/qquickswipe_p.h
new file mode 100644
index 00000000..c1a28819
--- /dev/null
+++ b/src/quicktemplates2/qquickswipe_p.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSWIPE_P_H
+#define QQUICKSWIPE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlComponent;
+class QQuickItem;
+class QQuickSwipeDelegate;
+class QQuickSwipePrivate;
+
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipe : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
+ Q_PROPERTY(bool complete READ isComplete NOTIFY completeChanged FINAL)
+ Q_PROPERTY(QQmlComponent *left READ left WRITE setLeft NOTIFY leftChanged FINAL)
+ Q_PROPERTY(QQmlComponent *behind READ behind WRITE setBehind NOTIFY behindChanged FINAL)
+ Q_PROPERTY(QQmlComponent *right READ right WRITE setRight NOTIFY rightChanged FINAL)
+ Q_PROPERTY(QQuickItem *leftItem READ leftItem NOTIFY leftItemChanged FINAL)
+ Q_PROPERTY(QQuickItem *behindItem READ behindItem NOTIFY behindItemChanged FINAL)
+ Q_PROPERTY(QQuickItem *rightItem READ rightItem NOTIFY rightItemChanged FINAL)
+
+public:
+ explicit QQuickSwipe(QQuickSwipeDelegate *control);
+
+ qreal position() const;
+ void setPosition(qreal position);
+
+ bool isComplete() const;
+ void setComplete(bool complete);
+
+ QQmlComponent *left() const;
+ void setLeft(QQmlComponent *left);
+
+ QQmlComponent *behind() const;
+ void setBehind(QQmlComponent *behind);
+
+ QQmlComponent *right() const;
+ void setRight(QQmlComponent *right);
+
+ QQuickItem *leftItem() const;
+ void setLeftItem(QQuickItem *item);
+
+ QQuickItem *behindItem() const;
+ void setBehindItem(QQuickItem *item);
+
+ QQuickItem *rightItem() const;
+ void setRightItem(QQuickItem *item);
+
+ Q_REVISION(1) Q_INVOKABLE void close();
+
+Q_SIGNALS:
+ void positionChanged();
+ void completeChanged();
+ /*Q_REVISION(1)*/ void completed();
+ void leftChanged();
+ void behindChanged();
+ void rightChanged();
+ void leftItemChanged();
+ void behindItemChanged();
+ void rightItemChanged();
+
+private:
+ Q_DISABLE_COPY(QQuickSwipe)
+ Q_DECLARE_PRIVATE(QQuickSwipe)
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSWIPE_P_H
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index fe678b80..5430a4de 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -35,6 +35,7 @@
****************************************************************************/
#include "qquickswipedelegate_p.h"
+#include "qquickswipedelegate_p_p.h"
#include "qquickcontrol_p_p.h"
#include "qquickitemdelegate_p_p.h"
#include "qquickvelocitycalculator_p_p.h"
@@ -148,6 +149,8 @@ public:
void warnAboutMixingDelegates();
void warnAboutSettingDelegatesWhileVisible();
+ bool hasDelegates() const;
+
QQuickSwipeDelegate *control;
// Same range as position, but is set before press events so that we can
// keep track of which direction the user must swipe when using left and right delegates.
@@ -348,6 +351,11 @@ void QQuickSwipePrivate::warnAboutSettingDelegatesWhileVisible()
qmlInfo(control) << "left/right/behind properties may only be set when swipe.position is 0";
}
+bool QQuickSwipePrivate::hasDelegates() const
+{
+ return left || right || behind;
+}
+
QQuickSwipe::QQuickSwipe(QQuickSwipeDelegate *control) :
QObject(*(new QQuickSwipePrivate(control)))
{
@@ -382,6 +390,8 @@ void QQuickSwipe::setLeft(QQmlComponent *left)
d->leftItem = nullptr;
}
+ d->control->setFiltersChildMouseEvents(d->hasDelegates());
+
emit leftChanged();
}
@@ -414,6 +424,8 @@ void QQuickSwipe::setBehind(QQmlComponent *behind)
d->behindItem = nullptr;
}
+ d->control->setFiltersChildMouseEvents(d->hasDelegates());
+
emit behindChanged();
}
@@ -446,6 +458,8 @@ void QQuickSwipe::setRight(QQmlComponent *right)
d->rightItem = nullptr;
}
+ d->control->setFiltersChildMouseEvents(d->hasDelegates());
+
emit rightChanged();
}
@@ -562,28 +576,18 @@ void QQuickSwipe::setComplete(bool complete)
void QQuickSwipe::close()
{
+ Q_D(QQuickSwipe);
setPosition(0);
setComplete(false);
+ d->wasComplete = false;
+ d->positionBeforePress = 0.0;
+ d->velocityCalculator.reset();
}
-class QQuickSwipeDelegatePrivate : public QQuickItemDelegatePrivate
+QQuickSwipeDelegatePrivate::QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *control) :
+ swipe(control)
{
- Q_DECLARE_PUBLIC(QQuickSwipeDelegate)
-
-public:
- QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *control) :
- swipe(control)
- {
- }
-
- bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event);
- bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event);
- bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event);
-
- void resizeContent() override;
-
- QQuickSwipe swipe;
-};
+}
bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *event)
{
@@ -594,6 +598,10 @@ bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseE
// events will go through the regular channels (mousePressEvent()) until then.
if (qFuzzyIsNull(swipePrivate->position)) {
q->mousePressEvent(event);
+ // The press point could be incorrect if the press happened over a child item,
+ // so we correct it after calling the base class' mousePressEvent(), rather
+ // than having to duplicate its code just so we can set the pressPoint.
+ pressPoint = item->mapToItem(q, event->pos());
return true;
}
@@ -704,6 +712,13 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv
swipe.setPosition(position);
}
+ } else {
+ // The swipe wasn't initiated.
+ if (event->pos().y() < 0 || event->pos().y() > height) {
+ // The mouse went outside the vertical bounds of the control, so
+ // we should no longer consider it pressed.
+ q->setPressed(false);
+ }
}
event->accept();
@@ -787,7 +802,6 @@ void QQuickSwipeDelegatePrivate::resizeContent()
QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) :
QQuickItemDelegate(*(new QQuickSwipeDelegatePrivate(this)), parent)
{
- setFiltersChildMouseEvents(true);
}
/*!
@@ -957,14 +971,17 @@ void QQuickSwipeDelegate::mousePressEvent(QMouseEvent *event)
void QQuickSwipeDelegate::mouseMoveEvent(QMouseEvent *event)
{
Q_D(QQuickSwipeDelegate);
- d->handleMouseMoveEvent(this, event);
+ if (filtersChildMouseEvents())
+ d->handleMouseMoveEvent(this, event);
+ else
+ QQuickItemDelegate::mouseMoveEvent(event);
}
void QQuickSwipeDelegate::mouseReleaseEvent(QMouseEvent *event)
{
Q_D(QQuickSwipeDelegate);
- QQuickItemDelegate::mouseReleaseEvent(event);
- d->handleMouseReleaseEvent(this, event);
+ if (!filtersChildMouseEvents() || !d->handleMouseReleaseEvent(this, event))
+ QQuickItemDelegate::mouseReleaseEvent(event);
}
void QQuickSwipeDelegate::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
diff --git a/src/quicktemplates2/qquickswipedelegate_p.h b/src/quicktemplates2/qquickswipedelegate_p.h
index ae23672b..16aa9837 100644
--- a/src/quicktemplates2/qquickswipedelegate_p.h
+++ b/src/quicktemplates2/qquickswipedelegate_p.h
@@ -52,8 +52,8 @@
QT_BEGIN_NAMESPACE
-class QQuickSwipeDelegatePrivate;
class QQuickSwipe;
+class QQuickSwipeDelegatePrivate;
class QQuickSwipeDelegateAttached;
class QQuickSwipeDelegateAttachedPrivate;
@@ -88,65 +88,6 @@ private:
Q_DECLARE_PRIVATE(QQuickSwipeDelegate)
};
-class QQuickSwipePrivate;
-
-class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipe : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
- Q_PROPERTY(bool complete READ isComplete NOTIFY completeChanged FINAL)
- Q_PROPERTY(QQmlComponent *left READ left WRITE setLeft NOTIFY leftChanged FINAL)
- Q_PROPERTY(QQmlComponent *behind READ behind WRITE setBehind NOTIFY behindChanged FINAL)
- Q_PROPERTY(QQmlComponent *right READ right WRITE setRight NOTIFY rightChanged FINAL)
- Q_PROPERTY(QQuickItem *leftItem READ leftItem NOTIFY leftItemChanged FINAL)
- Q_PROPERTY(QQuickItem *behindItem READ behindItem NOTIFY behindItemChanged FINAL)
- Q_PROPERTY(QQuickItem *rightItem READ rightItem NOTIFY rightItemChanged FINAL)
-
-public:
- explicit QQuickSwipe(QQuickSwipeDelegate *control);
-
- qreal position() const;
- void setPosition(qreal position);
-
- bool isComplete() const;
- void setComplete(bool complete);
-
- QQmlComponent *left() const;
- void setLeft(QQmlComponent *left);
-
- QQmlComponent *behind() const;
- void setBehind(QQmlComponent *behind);
-
- QQmlComponent *right() const;
- void setRight(QQmlComponent *right);
-
- QQuickItem *leftItem() const;
- void setLeftItem(QQuickItem *item);
-
- QQuickItem *behindItem() const;
- void setBehindItem(QQuickItem *item);
-
- QQuickItem *rightItem() const;
- void setRightItem(QQuickItem *item);
-
- Q_REVISION(1) Q_INVOKABLE void close();
-
-Q_SIGNALS:
- void positionChanged();
- void completeChanged();
- /*Q_REVISION(1)*/ void completed();
- void leftChanged();
- void behindChanged();
- void rightChanged();
- void leftItemChanged();
- void behindItemChanged();
- void rightItemChanged();
-
-private:
- Q_DISABLE_COPY(QQuickSwipe)
- Q_DECLARE_PRIVATE(QQuickSwipe)
-};
-
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeDelegateAttached : public QObject
{
Q_OBJECT
diff --git a/src/quicktemplates2/qquickswipedelegate_p_p.h b/src/quicktemplates2/qquickswipedelegate_p_p.h
new file mode 100644
index 00000000..0387ad70
--- /dev/null
+++ b/src/quicktemplates2/qquickswipedelegate_p_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKSWIPEDELEGATE_P_P_H
+#define QQUICKSWIPEDELEGATE_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickitemdelegate_p_p.h>
+#include <QtQuickTemplates2/private/qquickswipe_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickSwipeDelegate;
+
+class QQuickSwipeDelegatePrivate : public QQuickItemDelegatePrivate
+{
+ Q_DECLARE_PUBLIC(QQuickSwipeDelegate)
+
+public:
+ QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *control);
+
+ bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event);
+ bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event);
+ bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event);
+
+ void resizeContent() override;
+
+ QQuickSwipe swipe;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKSWIPEDELEGATE_P_P_H
diff --git a/src/quicktemplates2/quicktemplates2.pri b/src/quicktemplates2/quicktemplates2.pri
index 2c387aa4..fd92e9d1 100644
--- a/src/quicktemplates2/quicktemplates2.pri
+++ b/src/quicktemplates2/quicktemplates2.pri
@@ -59,7 +59,9 @@ HEADERS += \
$$PWD/qquickstacktransition_p_p.h \
$$PWD/qquickstackview_p.h \
$$PWD/qquickstackview_p_p.h \
+ $$PWD/qquickswipe_p.h \
$$PWD/qquickswipedelegate_p.h \
+ $$PWD/qquickswipedelegate_p_p.h \
$$PWD/qquickswipeview_p.h \
$$PWD/qquickswitch_p.h \
$$PWD/qquickswitchdelegate_p.h \