aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-06 18:52:28 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-06 20:27:00 +0200
commit86180aed5008779b1b94731d9b4c6b1fdac8f3d3 (patch)
treec1c4ac6daa87042196fa66a92ea56737930c0920 /src/quicktemplates2
parent9a55b34e292c725a4fa394a71e0a3d851e4e488f (diff)
parent9ae57848671419b2622e254af8642fef7b1b7c33 (diff)
Merge remote-tracking branch 'origin/5.7' into 5.8
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp11
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp229
-rw-r--r--src/quicktemplates2/qquickdrawer_p.h2
-rw-r--r--src/quicktemplates2/qquickdrawer_p_p.h93
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp266
-rw-r--r--src/quicktemplates2/qquickoverlay_p.h7
-rw-r--r--src/quicktemplates2/qquickoverlay_p_p.h98
-rw-r--r--src/quicktemplates2/qquickpopup.cpp109
-rw-r--r--src/quicktemplates2/qquickpopup_p.h1
-rw-r--r--src/quicktemplates2/qquickpopup_p_p.h16
-rw-r--r--src/quicktemplates2/qquickswitch.cpp6
-rw-r--r--src/quicktemplates2/quicktemplates2.pri2
12 files changed, 530 insertions, 310 deletions
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index af14ba6f..7f466fd7 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -158,12 +158,6 @@ void QQuickApplicationWindowPrivate::relayout()
content->setWidth(q->width());
content->setHeight(q->height() - hh - fh);
- if (overlay) {
- overlay->setWidth(q->width());
- overlay->setHeight(q->height());
- overlay->stackAfter(content);
- }
-
if (header) {
header->setY(-hh);
QQuickItemPrivate *p = QQuickItemPrivate::get(header);
@@ -489,9 +483,12 @@ QQuickItem *QQuickApplicationWindow::activeFocusControl() const
QQuickOverlay *QQuickApplicationWindow::overlay() const
{
QQuickApplicationWindowPrivate *d = const_cast<QQuickApplicationWindowPrivate *>(d_func());
+ if (!d) // being deleted
+ return nullptr;
+
if (!d->overlay) {
d->overlay = new QQuickOverlay(QQuickWindow::contentItem());
- d->relayout();
+ d->overlay->stackAfter(QQuickApplicationWindow::contentItem());
}
return d->overlay;
}
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index bb68320d..a64b5f4e 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -35,8 +35,7 @@
****************************************************************************/
#include "qquickdrawer_p.h"
-#include "qquickpopup_p_p.h"
-#include "qquickvelocitycalculator_p_p.h"
+#include "qquickdrawer_p_p.h"
#include <QtGui/qstylehints.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -114,33 +113,11 @@ QT_BEGIN_NAMESPACE
\sa SwipeView, {Customizing Drawer}, {Navigation Controls}, {Popup Controls}
*/
-class QQuickDrawerPrivate : public QQuickPopupPrivate
+QQuickDrawerPrivate::QQuickDrawerPrivate()
+ : edge(Qt::LeftEdge), offset(0), position(0),
+ dragMargin(QGuiApplication::styleHints()->startDragDistance())
{
- Q_DECLARE_PUBLIC(QQuickDrawer)
-
-public:
- QQuickDrawerPrivate() : edge(Qt::LeftEdge), offset(0), position(0),
- dragMargin(QGuiApplication::styleHints()->startDragDistance()) { }
-
- qreal positionAt(const QPointF &point) const;
- void reposition() override;
-
- bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event);
- bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event);
- bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event);
-
- void prepareEnterTransition(bool notify = true) override;
- void prepareExitTransition() override;
- void finalizeEnterTransition() override;
- void finalizeExitTransition(bool hide = true) override;
-
- Qt::Edge edge;
- qreal offset;
- qreal position;
- qreal dragMargin;
- QPointF pressPoint;
- QQuickVelocityCalculator velocityCalculator;
-};
+}
qreal QQuickDrawerPrivate::positionAt(const QPointF &point) const
{
@@ -191,96 +168,73 @@ static bool dragOverThreshold(qreal d, Qt::Axis axis, QMouseEvent *event, int th
return QQuickWindowPrivate::dragOverThreshold(d, axis, event, threshold);
}
-bool QQuickDrawerPrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *event)
+bool QQuickDrawerPrivate::startDrag(QQuickWindow *window, QMouseEvent *event)
{
- pressPoint = event->windowPos();
- offset = 0;
-
- QQuickWindow *window = item->window();
- if (!window)
+ if (!window || dragMargin < 0.0 || qFuzzyIsNull(dragMargin))
return false;
- if (qFuzzyIsNull(position)) {
- // only accept pressing at drag margins when fully closed
- switch (edge) {
- case Qt::LeftEdge:
- event->setAccepted(dragMargin > 0 && !dragOverThreshold(event->windowPos().x(), Qt::XAxis, event, dragMargin));
- break;
- case Qt::RightEdge:
- event->setAccepted(dragMargin > 0 && !dragOverThreshold(window->width() - event->windowPos().x(), Qt::XAxis, event, dragMargin));
- break;
- case Qt::TopEdge:
- event->setAccepted(dragMargin > 0 && !dragOverThreshold(event->windowPos().y(), Qt::YAxis, event, dragMargin));
- break;
- case Qt::BottomEdge:
- event->setAccepted(dragMargin > 0 && !dragOverThreshold(window->height() - event->windowPos().y(), Qt::YAxis, event, dragMargin));
- break;
- }
- } else {
- if (modal)
- event->setAccepted(item->isAncestorOf(popupItem));
- else
- event->setAccepted(false);
+ bool drag = false;
+ switch (edge) {
+ case Qt::LeftEdge:
+ drag = !dragOverThreshold(event->windowPos().x(), Qt::XAxis, event, dragMargin);
+ break;
+ case Qt::RightEdge:
+ drag = !dragOverThreshold(window->width() - event->windowPos().x(), Qt::XAxis, event, dragMargin);
+ break;
+ case Qt::TopEdge:
+ drag = !dragOverThreshold(event->windowPos().y(), Qt::YAxis, event, dragMargin);
+ break;
+ case Qt::BottomEdge:
+ drag = !dragOverThreshold(window->height() - event->windowPos().y(), Qt::YAxis, event, dragMargin);
+ break;
+ default:
+ break;
}
- velocityCalculator.startMeasuring(pressPoint, event->timestamp());
+ if (drag) {
+ prepareEnterTransition();
+ reposition();
+ handleMousePressEvent(window->contentItem(), event);
+ }
- return event->isAccepted();
+ return drag;
}
-bool QQuickDrawerPrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event)
+bool QQuickDrawerPrivate::grabMouse(QMouseEvent *event)
{
Q_Q(QQuickDrawer);
- QQuickWindow *window = item->window();
- if (!window)
+ if (!window || popupItem->keepMouseGrab())
return false;
- QPointF movePoint = event->windowPos();
-
- if (!popupItem->keepMouseGrab()) {
- // Flickable uses a hard-coded threshold of 15 for flicking, and
- // QStyleHints::startDragDistance for dragging. Drawer uses a bit
- // larger threshold to avoid being too eager to steal touch (QTBUG-50045)
- int threshold = qMax(20, QGuiApplication::styleHints()->startDragDistance() + 5);
- bool overThreshold = false;
- 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;
- }
+ const QPointF movePoint = event->windowPos();
- if (overThreshold) {
- QQuickItem *grabber = window->mouseGrabberItem();
- if (!grabber || !grabber->keepMouseGrab()) {
- popupItem->grabMouse();
- popupItem->setKeepMouseGrab(overThreshold);
- offset = qMin<qreal>(0.0, positionAt(movePoint) - position);
- }
- }
+ // Flickable uses a hard-coded threshold of 15 for flicking, and
+ // QStyleHints::startDragDistance for dragging. Drawer uses a bit
+ // larger threshold to avoid being too eager to steal touch (QTBUG-50045)
+ const int threshold = qMax(20, QGuiApplication::styleHints()->startDragDistance() + 5);
+ bool overThreshold = false;
+ 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);
}
- if (popupItem->keepMouseGrab())
- q->setPosition(positionAt(movePoint) - offset);
- event->accept();
+ // 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;
+ }
- return popupItem->keepMouseGrab();
+ return overThreshold;
}
static const qreal openCloseVelocityThreshold = 300;
-bool QQuickDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event)
+bool QQuickDrawerPrivate::ungrabMouse(QMouseEvent *event)
{
- Q_UNUSED(item);
-
bool wasGrabbed = popupItem->keepMouseGrab();
if (wasGrabbed) {
const QPointF releasePoint = event->windowPos();
@@ -335,10 +289,54 @@ bool QQuickDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent
break;
}
}
- popupItem->setKeepMouseGrab(false);
}
+ return wasGrabbed;
+}
+
+bool QQuickDrawerPrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *event)
+{
+ offset = 0;
+ pressPoint = event->windowPos();
+ velocityCalculator.startMeasuring(pressPoint, event->timestamp());
+
+ // don't block press events a) outside a non-modal drawer, or b) to drawer children
+ event->setAccepted(modal && !popupItem->isAncestorOf(item));
+ return event->isAccepted();
+}
+
+bool QQuickDrawerPrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event)
+{
+ Q_Q(QQuickDrawer);
+ Q_UNUSED(item);
+
+ const QPointF movePoint = event->windowPos();
+
+ if (grabMouse(event)) {
+ QQuickItem *grabber = window->mouseGrabberItem();
+ if (!grabber || !grabber->keepMouseGrab()) {
+ popupItem->grabMouse();
+ popupItem->setKeepMouseGrab(true);
+ offset = qMin<qreal>(0.0, positionAt(movePoint) - position);
+ }
+ }
+
+ if (popupItem->keepMouseGrab())
+ q->setPosition(positionAt(movePoint) - offset);
+ event->accept();
+
+ return popupItem->keepMouseGrab();
+}
+
+bool QQuickDrawerPrivate::handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event)
+{
+ Q_UNUSED(item);
+
+ const bool wasGrabbed = ungrabMouse(event);
+
+ popupItem->setKeepMouseGrab(false);
pressPoint = QPoint();
event->accept();
+
return wasGrabbed;
}
@@ -362,28 +360,18 @@ static QList<QQuickStateAction> prepareTransition(QQuickDrawer *drawer, QQuickTr
return actions;
}
-void QQuickDrawerPrivate::prepareEnterTransition(bool notify)
+bool QQuickDrawerPrivate::prepareEnterTransition()
{
Q_Q(QQuickDrawer);
enterActions = prepareTransition(q, enter, 1.0);
- QQuickPopupPrivate::prepareEnterTransition(notify);
+ return QQuickPopupPrivate::prepareEnterTransition();
}
-void QQuickDrawerPrivate::prepareExitTransition()
+bool QQuickDrawerPrivate::prepareExitTransition()
{
Q_Q(QQuickDrawer);
exitActions = prepareTransition(q, exit, 0.0);
- QQuickPopupPrivate::prepareExitTransition();
-}
-
-void QQuickDrawerPrivate::finalizeEnterTransition()
-{
- QQuickPopupPrivate::finalizeEnterTransition();
-}
-
-void QQuickDrawerPrivate::finalizeExitTransition(bool hide)
-{
- QQuickPopupPrivate::finalizeExitTransition(hide = false);
+ return QQuickPopupPrivate::prepareExitTransition();
}
QQuickDrawer::QQuickDrawer(QObject *parent) :
@@ -447,12 +435,8 @@ void QQuickDrawer::setPosition(qreal position)
d->position = position;
if (isComponentComplete())
d->reposition();
- if (d->dimmer) {
+ if (d->dimmer)
d->dimmer->setOpacity(position);
- // TODO: check QStyleHints::useHoverEffects in Qt 5.8
- d->dimmer->setAcceptHoverEvents(d->modal && position > 0.0);
- // d->dimmer->setAcceptHoverEvents(d->modal && position > 0.0 && QGuiApplication::styleHints()->useHoverEffects());
- }
emit positionChanged();
}
@@ -547,15 +531,4 @@ bool QQuickDrawer::overlayEvent(QQuickItem *item, QEvent *event)
}
}
-void QQuickDrawer::componentComplete()
-{
- Q_D(QQuickDrawer);
- QQuickPopup::componentComplete();
- if (d->window) {
- bool notify = false;
- d->prepareEnterTransition(notify);
- d->reposition();
- }
-}
-
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickdrawer_p.h b/src/quicktemplates2/qquickdrawer_p.h
index 23c5c2ab..e694e27b 100644
--- a/src/quicktemplates2/qquickdrawer_p.h
+++ b/src/quicktemplates2/qquickdrawer_p.h
@@ -87,8 +87,6 @@ protected:
void mouseUngrabEvent() override;
bool overlayEvent(QQuickItem *item, QEvent *event) override;
- void componentComplete() override;
-
private:
Q_DISABLE_COPY(QQuickDrawer)
Q_DECLARE_PRIVATE(QQuickDrawer)
diff --git a/src/quicktemplates2/qquickdrawer_p_p.h b/src/quicktemplates2/qquickdrawer_p_p.h
new file mode 100644
index 00000000..f14c36dd
--- /dev/null
+++ b/src/quicktemplates2/qquickdrawer_p_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** 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 QQUICKDRAWER_P_P_H
+#define QQUICKDRAWER_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 "qquickdrawer_p.h"
+#include "qquickpopup_p_p.h"
+#include "qquickvelocitycalculator_p_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QQuickDrawerPrivate : public QQuickPopupPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickDrawer)
+
+public:
+ QQuickDrawerPrivate();
+
+ static QQuickDrawerPrivate *get(QQuickDrawer *drawer)
+ {
+ return drawer->d_func();
+ }
+
+ qreal positionAt(const QPointF &point) const;
+ void reposition() override;
+
+ bool startDrag(QQuickWindow *window, QMouseEvent *event);
+ bool grabMouse(QMouseEvent *event);
+ bool ungrabMouse(QMouseEvent *event);
+
+ bool handleMousePressEvent(QQuickItem *item, QMouseEvent *event);
+ bool handleMouseMoveEvent(QQuickItem *item, QMouseEvent *event);
+ bool handleMouseReleaseEvent(QQuickItem *item, QMouseEvent *event);
+
+ bool prepareEnterTransition() override;
+ bool prepareExitTransition() override;
+
+ Qt::Edge edge;
+ qreal offset;
+ qreal position;
+ qreal dragMargin;
+ QPointF pressPoint;
+ QQuickVelocityCalculator velocityCalculator;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKDRAWER_P_P_H
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 5dd92a26..172307e1 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -35,40 +35,17 @@
****************************************************************************/
#include "qquickoverlay_p.h"
+#include "qquickoverlay_p_p.h"
#include "qquickpopup_p_p.h"
-#include "qquickdrawer_p.h"
+#include "qquickdrawer_p_p.h"
+#include "qquickapplicationwindow_p.h"
#include <QtQml/qqmlinfo.h>
#include <QtQml/qqmlproperty.h>
#include <QtQml/qqmlcomponent.h>
-#include <QtQuick/private/qquickitem_p.h>
+#include <algorithm>
QT_BEGIN_NAMESPACE
-class QQuickOverlayPrivate : public QQuickItemPrivate
-{
- Q_DECLARE_PUBLIC(QQuickOverlay)
-
-public:
- QQuickOverlayPrivate();
-
- void popupAboutToShow();
- void popupAboutToHide();
-
- void createOverlay(QQuickPopup *popup);
- void destroyOverlay(QQuickPopup *popup);
- void resizeOverlay(QQuickPopup *popup);
- void toggleOverlay();
-
- QVector<QQuickPopup *> stackingOrderPopups() const;
-
- QQmlComponent *modal;
- QQmlComponent *modeless;
- QVector<QQuickDrawer *> drawers;
- QVector<QQuickPopup *> popups;
- QPointer<QQuickPopup> mouseGrabberPopup;
- int modalPopups;
-};
-
void QQuickOverlayPrivate::popupAboutToShow()
{
Q_Q(QQuickOverlay);
@@ -97,27 +74,35 @@ void QQuickOverlayPrivate::popupAboutToHide()
static QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQuickItem *parent)
{
- if (!component)
- return nullptr;
+ QQuickItem *item = nullptr;
+ if (component) {
+ QQmlContext *creationContext = component->creationContext();
+ if (!creationContext)
+ creationContext = qmlContext(parent);
+ QQmlContext *context = new QQmlContext(creationContext);
+ context->setContextObject(popup);
+ item = qobject_cast<QQuickItem*>(component->beginCreate(context));
+ }
+
+ // when there is no overlay component available (with plain QQuickWindow),
+ // use a plain QQuickItem as a fallback to block hover events
+ if (!item && popup->isModal())
+ item = new QQuickItem;
- QQmlContext *creationContext = component->creationContext();
- if (!creationContext)
- creationContext = qmlContext(parent);
- QQmlContext *context = new QQmlContext(creationContext);
- context->setContextObject(popup);
- QQuickItem *item = qobject_cast<QQuickItem*>(component->beginCreate(context));
if (item) {
item->setOpacity(popup->isVisible() ? 1.0 : 0.0);
item->setParentItem(parent);
item->stackBefore(popup->popupItem());
item->setZ(popup->z());
- if (popup->isModal() && !qobject_cast<QQuickDrawer *>(popup)) {
+ if (popup->isModal()) {
+ item->setAcceptedMouseButtons(Qt::AllButtons);
// TODO: switch to QStyleHints::useHoverEffects in Qt 5.8
item->setAcceptHoverEvents(true);
// item->setAcceptHoverEvents(QGuiApplication::styleHints()->useHoverEffects());
// connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, item, &QQuickItem::setAcceptHoverEvents);
}
- component->completeCreate();
+ if (component)
+ component->completeCreate();
}
return item;
}
@@ -179,20 +164,65 @@ QVector<QQuickPopup *> QQuickOverlayPrivate::stackingOrderPopups() const
return popups;
}
+QVector<QQuickDrawer *> QQuickOverlayPrivate::stackingOrderDrawers() const
+{
+ QVector<QQuickDrawer *> sorted(allDrawers);
+ std::sort(sorted.begin(), sorted.end(), [](const QQuickDrawer *one, const QQuickDrawer *another) {
+ return one->z() > another->z();
+ });
+ return sorted;
+}
+
+void QQuickOverlayPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &)
+{
+ Q_Q(QQuickOverlay);
+ q->setSize(QSizeF(item->width(), item->height()));
+}
+
QQuickOverlayPrivate::QQuickOverlayPrivate() :
modal(nullptr),
- modeless(nullptr),
- modalPopups(0)
+ modeless(nullptr)
{
}
+void QQuickOverlayPrivate::addPopup(QQuickPopup *popup)
+{
+ Q_Q(QQuickOverlay);
+ allPopups += popup;
+ if (QQuickDrawer *drawer = qobject_cast<QQuickDrawer *>(popup)) {
+ allDrawers += drawer;
+ q->setVisible(!allDrawers.isEmpty() || !q->childItems().isEmpty());
+ }
+}
+
+void QQuickOverlayPrivate::removePopup(QQuickPopup *popup)
+{
+ Q_Q(QQuickOverlay);
+ allPopups.removeOne(popup);
+ if (allDrawers.removeOne(static_cast<QQuickDrawer *>(popup)))
+ q->setVisible(!allDrawers.isEmpty() || !q->childItems().isEmpty());
+}
+
QQuickOverlay::QQuickOverlay(QQuickItem *parent)
: QQuickItem(*(new QQuickOverlayPrivate), parent)
{
+ Q_D(QQuickOverlay);
setZ(1000001); // DefaultWindowDecoration+1
setAcceptedMouseButtons(Qt::AllButtons);
setFiltersChildMouseEvents(true);
setVisible(false);
+
+ if (parent) {
+ setSize(QSizeF(parent->width(), parent->height()));
+ QQuickItemPrivate::get(parent)->addItemChangeListener(d, QQuickItemPrivate::Geometry);
+ }
+}
+
+QQuickOverlay::~QQuickOverlay()
+{
+ Q_D(QQuickOverlay);
+ if (QQuickItem *parent = parentItem())
+ QQuickItemPrivate::get(parent)->removeItemChangeListener(d, QQuickItemPrivate::Geometry);
}
QQmlComponent *QQuickOverlay::modal() const
@@ -229,6 +259,29 @@ void QQuickOverlay::setModeless(QQmlComponent *modeless)
emit modelessChanged();
}
+QQuickOverlay *QQuickOverlay::overlay(QQuickWindow *window)
+{
+ if (!window)
+ return nullptr;
+
+ QQuickApplicationWindow *applicationWindow = qobject_cast<QQuickApplicationWindow *>(window);
+ if (applicationWindow)
+ return applicationWindow->overlay();
+
+ const char *name = "_q_QQuickOverlay";
+ QQuickOverlay *overlay = window->property(name).value<QQuickOverlay *>();
+ if (!overlay) {
+ QQuickItem *content = window->contentItem();
+ // Do not re-create the overlay if the window is being destroyed
+ // and thus, its content item no longer has a window associated.
+ if (content->window()) {
+ overlay = new QQuickOverlay(window->contentItem());
+ window->setProperty(name, QVariant::fromValue(overlay));
+ }
+ }
+ return overlay;
+}
+
void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
{
Q_D(QQuickOverlay);
@@ -237,41 +290,25 @@ void QQuickOverlay::itemChange(ItemChange change, const ItemChangeData &data)
QQuickPopup *popup = nullptr;
if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
popup = qobject_cast<QQuickPopup *>(data.item->parent());
- setVisible(!childItems().isEmpty());
+ setVisible(!d->allDrawers.isEmpty() || !childItems().isEmpty());
}
if (!popup)
return;
if (change == ItemChildAddedChange) {
- d->popups.append(popup);
if (popup->dim())
d->createOverlay(popup);
QObjectPrivate::connect(popup, &QQuickPopup::dimChanged, d, &QQuickOverlayPrivate::toggleOverlay);
QObjectPrivate::connect(popup, &QQuickPopup::modalChanged, d, &QQuickOverlayPrivate::toggleOverlay);
-
- QQuickDrawer *drawer = qobject_cast<QQuickDrawer *>(popup);
- if (drawer) {
- d->drawers.append(drawer);
- } else {
- if (popup->isModal())
- ++d->modalPopups;
-
+ if (!qobject_cast<QQuickDrawer *>(popup)) {
QObjectPrivate::connect(popup, &QQuickPopup::aboutToShow, d, &QQuickOverlayPrivate::popupAboutToShow);
QObjectPrivate::connect(popup, &QQuickPopup::aboutToHide, d, &QQuickOverlayPrivate::popupAboutToHide);
}
} else if (change == ItemChildRemovedChange) {
- d->popups.removeOne(popup);
d->destroyOverlay(popup);
QObjectPrivate::disconnect(popup, &QQuickPopup::dimChanged, d, &QQuickOverlayPrivate::toggleOverlay);
QObjectPrivate::disconnect(popup, &QQuickPopup::modalChanged, d, &QQuickOverlayPrivate::toggleOverlay);
-
- QQuickDrawer *drawer = qobject_cast<QQuickDrawer *>(popup);
- if (drawer) {
- d->drawers.removeOne(drawer);
- } else {
- if (popup->isModal())
- --d->modalPopups;
-
+ if (!qobject_cast<QQuickDrawer *>(popup)) {
QObjectPrivate::disconnect(popup, &QQuickPopup::aboutToShow, d, &QQuickOverlayPrivate::popupAboutToShow);
QObjectPrivate::disconnect(popup, &QQuickPopup::aboutToHide, d, &QQuickOverlayPrivate::popupAboutToHide);
}
@@ -282,79 +319,86 @@ void QQuickOverlay::geometryChanged(const QRectF &newGeometry, const QRectF &old
{
Q_D(QQuickOverlay);
QQuickItem::geometryChanged(newGeometry, oldGeometry);
- for (QQuickPopup *popup : d->popups)
+ for (QQuickPopup *popup : qAsConst(d->allPopups))
d->resizeOverlay(popup);
}
-bool QQuickOverlay::event(QEvent *event)
+void QQuickOverlay::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickOverlay);
- switch (event->type()) {
- case QEvent::MouseButtonPress: {
- emit pressed();
+ emit pressed();
+
+ if (!d->allDrawers.isEmpty()) {
+ // the overlay background was pressed, so there are no modal popups open.
+ // test if the press point lands on any drawer's drag margin
+
+ const QVector<QQuickDrawer *> drawers = d->stackingOrderDrawers();
+ for (QQuickDrawer *drawer : drawers) {
+ QQuickDrawerPrivate *p = QQuickDrawerPrivate::get(drawer);
+ if (p->startDrag(window(), event)) {
+ d->mouseGrabberPopup = drawer;
+ return;
+ }
+ }
+ }
+
+ if (!d->mouseGrabberPopup) {
const auto popups = d->stackingOrderPopups();
for (QQuickPopup *popup : popups) {
if (popup->overlayEvent(this, event)) {
d->mouseGrabberPopup = popup;
- return true;
+ return;
}
}
- break;
}
- case QEvent::MouseMove:
- if (d->mouseGrabberPopup) {
- if (d->mouseGrabberPopup->overlayEvent(this, event))
- return true;
- } else {
- const auto popups = d->stackingOrderPopups();
- for (QQuickPopup *popup : popups) {
- if (popup->overlayEvent(this, event))
- return true;
- }
- }
- break;
- case QEvent::MouseButtonRelease:
- emit released();
- if (d->mouseGrabberPopup) {
- QQuickPopup *grabber = d->mouseGrabberPopup;
- d->mouseGrabberPopup = nullptr;
- if (grabber->overlayEvent(this, event))
- return true;
- } else {
- const auto popups = d->stackingOrderPopups();
- for (QQuickPopup *popup : popups) {
- if (popup->overlayEvent(this, event))
- return true;
- }
+
+ event->ignore();
+}
+
+void QQuickOverlay::mouseMoveEvent(QMouseEvent *event)
+{
+ Q_D(QQuickOverlay);
+ if (d->mouseGrabberPopup)
+ d->mouseGrabberPopup->overlayEvent(this, event);
+}
+
+void QQuickOverlay::mouseReleaseEvent(QMouseEvent *event)
+{
+ Q_D(QQuickOverlay);
+ emit released();
+
+ if (d->mouseGrabberPopup) {
+ d->mouseGrabberPopup->overlayEvent(this, event);
+ d->mouseGrabberPopup = nullptr;
+ } else {
+ const auto popups = d->stackingOrderPopups();
+ for (QQuickPopup *popup : popups) {
+ if (popup->overlayEvent(this, event))
+ break;
}
- break;
- default:
- break;
}
-
- return QQuickItem::event(event);
}
bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event)
{
Q_D(QQuickOverlay);
- if (d->modalPopups == 0)
- return false;
- // TODO Filter touch events
- if (event->type() != QEvent::MouseButtonPress)
- return false;
- while (item->parentItem() != this)
- item = item->parentItem();
-
- const auto popups = d->stackingOrderPopups();
- for (QQuickPopup *popup : popups) {
- if (popup->popupItem() == item)
- break;
-
- if (popup->overlayEvent(item, event))
- return true;
+ for (QQuickPopup *popup : qAsConst(d->allPopups)) {
+ QQuickItem *dimmer = QQuickPopupPrivate::get(popup)->dimmer;
+ if (item == dimmer) {
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ emit pressed();
+ return popup->overlayEvent(item, event);
+ case QEvent::MouseMove:
+ return popup->overlayEvent(item, event);
+ case QEvent::MouseButtonRelease:
+ emit released();
+ return popup->overlayEvent(item, event);
+ default:
+ break;
+ }
+ }
}
-
return false;
}
diff --git a/src/quicktemplates2/qquickoverlay_p.h b/src/quicktemplates2/qquickoverlay_p.h
index 99d7ba75..07f7daec 100644
--- a/src/quicktemplates2/qquickoverlay_p.h
+++ b/src/quicktemplates2/qquickoverlay_p.h
@@ -64,6 +64,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickOverlay : public QQuickItem
public:
explicit QQuickOverlay(QQuickItem *parent = nullptr);
+ ~QQuickOverlay();
QQmlComponent *modal() const;
void setModal(QQmlComponent *modal);
@@ -71,6 +72,8 @@ public:
QQmlComponent *modeless() const;
void setModeless(QQmlComponent *modeless);
+ static QQuickOverlay *overlay(QQuickWindow *window);
+
Q_SIGNALS:
void modalChanged();
void modelessChanged();
@@ -81,7 +84,9 @@ protected:
void itemChange(ItemChange change, const ItemChangeData &data) override;
void geometryChanged(const QRectF &oldGeometry, const QRectF &newGeometry) override;
- bool event(QEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
bool childMouseEventFilter(QQuickItem *item, QEvent *event) override;
private:
diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h
new file mode 100644
index 00000000..db005555
--- /dev/null
+++ b/src/quicktemplates2/qquickoverlay_p_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** 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 QQUICKOVERLAY_P_P_H
+#define QQUICKOVERLAY_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 "qquickoverlay_p.h"
+
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qquickitemchangelistener_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickPopup;
+class QQuickDrawer;
+
+class QQuickOverlayPrivate : public QQuickItemPrivate, public QQuickItemChangeListener
+{
+ Q_DECLARE_PUBLIC(QQuickOverlay)
+
+public:
+ QQuickOverlayPrivate();
+
+ static QQuickOverlayPrivate *get(QQuickOverlay *overlay)
+ {
+ return overlay->d_func();
+ }
+
+ void addPopup(QQuickPopup *popup);
+ void removePopup(QQuickPopup *popup);
+
+ void popupAboutToShow();
+ void popupAboutToHide();
+
+ void createOverlay(QQuickPopup *popup);
+ void destroyOverlay(QQuickPopup *popup);
+ void resizeOverlay(QQuickPopup *popup);
+ void toggleOverlay();
+
+ QVector<QQuickPopup *> stackingOrderPopups() const;
+ QVector<QQuickDrawer *> stackingOrderDrawers() const;
+
+ void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
+
+ QQmlComponent *modal;
+ QQmlComponent *modeless;
+ QVector<QQuickPopup *> allPopups;
+ QVector<QQuickDrawer *> allDrawers;
+ QPointer<QQuickPopup> mouseGrabberPopup;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKOVERLAY_P_P_H
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 414ba782..4143ee3f 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -37,7 +37,7 @@
#include "qquickpopup_p.h"
#include "qquickpopup_p_p.h"
#include "qquickapplicationwindow_p.h"
-#include "qquickoverlay_p.h"
+#include "qquickoverlay_p_p.h"
#include "qquickcontrol_p_p.h"
#include <QtQml/qqmlinfo.h>
@@ -143,6 +143,7 @@ QQuickPopupPrivate::QQuickPopupPrivate()
, bottomMargin(0)
, contentWidth(0)
, contentHeight(0)
+ , transitionState(QQuickPopupPrivate::NoTransition)
, closePolicy(QQuickPopup::CloseOnEscape | QQuickPopup::CloseOnPressOutside)
, parentItem(nullptr)
, dimmer(nullptr)
@@ -180,43 +181,46 @@ bool QQuickPopupPrivate::tryClose(QQuickItem *item, QMouseEvent *event)
return false;
}
-void QQuickPopupPrivate::prepareEnterTransition(bool notify)
+bool QQuickPopupPrivate::prepareEnterTransition()
{
Q_Q(QQuickPopup);
if (!window) {
qmlInfo(q) << "cannot find any window to open popup in.";
- return;
+ return false;
}
- QQuickApplicationWindow *applicationWindow = qobject_cast<QQuickApplicationWindow*>(window);
- if (!applicationWindow) {
- window->installEventFilter(q);
- popupItem->setZ(1000001); // DefaultWindowDecoration+1
- popupItem->setParentItem(window->contentItem());
- } else {
- popupItem->setParentItem(applicationWindow->overlay());
- }
+ if (transitionState == EnterTransition && transitionManager.isRunning())
+ return false;
- if (notify)
+ if (transitionState != EnterTransition) {
+ popupItem->setParentItem(QQuickOverlay::overlay(window));
emit q->aboutToShow();
- visible = notify;
- popupItem->setVisible(true);
- positioner.setParentItem(parentItem);
- emit q->visibleChanged();
+ visible = true;
+ transitionState = EnterTransition;
+ popupItem->setVisible(true);
+ positioner.setParentItem(parentItem);
+ emit q->visibleChanged();
+ }
+ return true;
}
-void QQuickPopupPrivate::prepareExitTransition()
+bool QQuickPopupPrivate::prepareExitTransition()
{
Q_Q(QQuickPopup);
- if (window && !qobject_cast<QQuickApplicationWindow *>(window))
- window->removeEventFilter(q);
- if (focus) {
- // The setFocus(false) call below removes any active focus before we're
- // able to check it in finalizeExitTransition.
- hadActiveFocusBeforeExitTransition = popupItem->hasActiveFocus();
- popupItem->setFocus(false);
+ if (transitionState == ExitTransition && transitionManager.isRunning())
+ return false;
+
+ if (transitionState != ExitTransition) {
+ if (focus) {
+ // The setFocus(false) call below removes any active focus before we're
+ // able to check it in finalizeExitTransition.
+ hadActiveFocusBeforeExitTransition = popupItem->hasActiveFocus();
+ popupItem->setFocus(false);
+ }
+ transitionState = ExitTransition;
+ emit q->aboutToHide();
}
- emit q->aboutToHide();
+ return true;
}
void QQuickPopupPrivate::finalizeEnterTransition()
@@ -224,17 +228,16 @@ void QQuickPopupPrivate::finalizeEnterTransition()
Q_Q(QQuickPopup);
if (focus)
popupItem->setFocus(true);
+ transitionState = NoTransition;
emit q->opened();
}
-void QQuickPopupPrivate::finalizeExitTransition(bool hide)
+void QQuickPopupPrivate::finalizeExitTransition()
{
Q_Q(QQuickPopup);
- if (hide) {
- positioner.setParentItem(nullptr);
- popupItem->setParentItem(nullptr);
- popupItem->setVisible(false);
- }
+ positioner.setParentItem(nullptr);
+ popupItem->setParentItem(nullptr);
+ popupItem->setVisible(false);
if (hadActiveFocusBeforeExitTransition) {
QQuickApplicationWindow *applicationWindow = qobject_cast<QQuickApplicationWindow*>(window);
@@ -245,6 +248,7 @@ void QQuickPopupPrivate::finalizeExitTransition(bool hide)
}
visible = false;
+ transitionState = NoTransition;
hadActiveFocusBeforeExitTransition = false;
emit q->visibleChanged();
emit q->closed();
@@ -314,6 +318,18 @@ void QQuickPopupPrivate::setWindow(QQuickWindow *newWindow)
if (window == newWindow)
return;
+ if (window) {
+ QQuickOverlay *overlay = QQuickOverlay::overlay(window);
+ if (overlay)
+ QQuickOverlayPrivate::get(overlay)->removePopup(q);
+ }
+
+ if (newWindow) {
+ QQuickOverlay *overlay = QQuickOverlay::overlay(newWindow);
+ if (overlay)
+ QQuickOverlayPrivate::get(overlay)->addPopup(q);
+ }
+
window = newWindow;
emit q->windowChanged(newWindow);
}
@@ -711,19 +727,15 @@ bool QQuickPopupPositioner::isAncestor(QQuickItem *item) const
}
QQuickPopupTransitionManager::QQuickPopupTransitionManager(QQuickPopupPrivate *popup)
- : QQuickTransitionManager()
- , state(Off)
- , popup(popup)
+ : QQuickTransitionManager(), popup(popup)
{
}
void QQuickPopupTransitionManager::transitionEnter()
{
- if (state == Enter && isRunning())
+ if (!popup->prepareEnterTransition())
return;
- state = Enter;
- popup->prepareEnterTransition();
if (popup->window)
transition(popup->enterActions, popup->enter, popup->q_func());
else
@@ -732,11 +744,9 @@ void QQuickPopupTransitionManager::transitionEnter()
void QQuickPopupTransitionManager::transitionExit()
{
- if (state == Exit && isRunning())
+ if (!popup->prepareExitTransition())
return;
- state = Exit;
- popup->prepareExitTransition();
if (popup->window)
transition(popup->exitActions, popup->exit, popup->q_func());
else
@@ -745,12 +755,10 @@ void QQuickPopupTransitionManager::transitionExit()
void QQuickPopupTransitionManager::finished()
{
- if (state == Enter)
+ if (popup->transitionState == QQuickPopupPrivate::EnterTransition)
popup->finalizeEnterTransition();
- else if (state == Exit)
+ else if (popup->transitionState == QQuickPopupPrivate::ExitTransition)
popup->finalizeExitTransition();
-
- state = Off;
}
QQuickPopup::QQuickPopup(QObject *parent)
@@ -1895,13 +1903,6 @@ bool QQuickPopup::isComponentComplete() const
return d->complete;
}
-bool QQuickPopup::eventFilter(QObject *object, QEvent *event)
-{
- if (QQuickWindow *window = qobject_cast<QQuickWindow *>(object))
- return overlayEvent(window->contentItem(), event);
- return false;
-}
-
bool QQuickPopup::childMouseEventFilter(QQuickItem *child, QEvent *event)
{
Q_UNUSED(child);
@@ -1961,6 +1962,12 @@ void QQuickPopup::mouseDoubleClickEvent(QMouseEvent *event)
void QQuickPopup::mouseUngrabEvent()
{
+ QQuickOverlay *overlay = QQuickOverlay::overlay(window());
+ if (overlay) {
+ QQuickOverlayPrivate *p = QQuickOverlayPrivate::get(overlay);
+ if (p->mouseGrabberPopup == this)
+ p->mouseGrabberPopup = nullptr;
+ }
}
bool QQuickPopup::overlayEvent(QQuickItem *item, QEvent *event)
diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h
index 1f2cabcf..5f5fd6bd 100644
--- a/src/quicktemplates2/qquickpopup_p.h
+++ b/src/quicktemplates2/qquickpopup_p.h
@@ -344,7 +344,6 @@ protected:
void componentComplete() override;
bool isComponentComplete() const;
- bool eventFilter(QObject *object, QEvent *event) override;
virtual bool childMouseEventFilter(QQuickItem *child, QEvent *event);
virtual void focusInEvent(QFocusEvent *event);
virtual void focusOutEvent(QFocusEvent *event);
diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h
index 4478c555..93039287 100644
--- a/src/quicktemplates2/qquickpopup_p_p.h
+++ b/src/quicktemplates2/qquickpopup_p_p.h
@@ -76,11 +76,6 @@ protected:
void finished() override;
private:
- enum TransitionState {
- Off, Enter, Exit
- };
-
- TransitionState state;
QQuickPopupPrivate *popup;
};
@@ -163,10 +158,10 @@ public:
bool tryClose(QQuickItem *item, QMouseEvent *event);
virtual void reposition();
- virtual void prepareEnterTransition(bool notify = true);
- virtual void prepareExitTransition();
+ virtual bool prepareEnterTransition();
+ virtual bool prepareExitTransition();
virtual void finalizeEnterTransition();
- virtual void finalizeExitTransition(bool hide = true);
+ virtual void finalizeExitTransition();
QMarginsF getMargins() const;
@@ -178,6 +173,10 @@ public:
void setWindow(QQuickWindow *window);
void itemDestroyed(QQuickItem *item) override;
+ enum TransitionState {
+ NoTransition, EnterTransition, ExitTransition
+ };
+
bool focus;
bool modal;
bool dim;
@@ -202,6 +201,7 @@ public:
qreal bottomMargin;
qreal contentWidth;
qreal contentHeight;
+ TransitionState transitionState;
QQuickPopup::ClosePolicy closePolicy;
QQuickItem *parentItem;
QQuickItem *dimmer;
diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp
index cb966568..37ae53f0 100644
--- a/src/quicktemplates2/qquickswitch.cpp
+++ b/src/quicktemplates2/qquickswitch.cpp
@@ -126,6 +126,7 @@ bool QQuickSwitchPrivate::handleMousePressEvent(QQuickItem *child, QMouseEvent *
pressPoint = event->pos();
q->setPressed(true);
+ emit q->pressed();
event->accept();
return true;
}
@@ -155,11 +156,14 @@ bool QQuickSwitchPrivate::handleMouseReleaseEvent(QQuickItem *child, QMouseEvent
q->setChecked(position > 0.5);
q->setPosition(checked ? 1.0 : 0.0);
child->setKeepMouseGrab(false);
- if (wasChecked != checked)
+ if (wasChecked != checked) {
+ emit q->released();
emit q->clicked();
+ }
event->accept();
} else {
q->toggle();
+ emit q->released();
emit q->clicked();
event->accept();
}
diff --git a/src/quicktemplates2/quicktemplates2.pri b/src/quicktemplates2/quicktemplates2.pri
index 686cbd52..0d6a0e5a 100644
--- a/src/quicktemplates2/quicktemplates2.pri
+++ b/src/quicktemplates2/quicktemplates2.pri
@@ -21,6 +21,7 @@ HEADERS += \
$$PWD/qquickdialogbuttonbox_p.h \
$$PWD/qquickdialogbuttonbox_p_p.h \
$$PWD/qquickdrawer_p.h \
+ $$PWD/qquickdrawer_p_p.h \
$$PWD/qquickframe_p.h \
$$PWD/qquickframe_p_p.h \
$$PWD/qquickgroupbox_p.h \
@@ -33,6 +34,7 @@ HEADERS += \
$$PWD/qquickmenuitem_p.h \
$$PWD/qquickmenuseparator_p.h \
$$PWD/qquickoverlay_p.h \
+ $$PWD/qquickoverlay_p_p.h \
$$PWD/qquickpage_p.h \
$$PWD/qquickpageindicator_p.h \
$$PWD/qquickpagelayout_p_p.h \