aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickpopup.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-11-15 15:43:09 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2016-11-15 15:43:09 +0100
commitab027c7d786966ab87500ca609fd45b0551902c9 (patch)
tree55d496a604ae36f7ce9d8adae8160d3efab148a4 /src/quicktemplates2/qquickpopup.cpp
parent7b33addb8d8d1c07dda9a9f39d86f7bda812da82 (diff)
parent0edce6c41e9b193c7482334e313c4886c94702f1 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: src/quicktemplates2/qquickpopup.cpp Change-Id: I227b071476e569d13eebd7d11ed041fe30daa389
Diffstat (limited to 'src/quicktemplates2/qquickpopup.cpp')
-rw-r--r--src/quicktemplates2/qquickpopup.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 5155b339..7ff99c49 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -41,6 +41,7 @@
#include "qquickapplicationwindow_p.h"
#include "qquickoverlay_p_p.h"
#include "qquickcontrol_p_p.h"
+#include "qquickdialog_p.h"
#include <QtQml/qqmlinfo.h>
#include <QtQuick/qquickitem.h>
@@ -245,16 +246,24 @@ void QQuickPopupPrivate::init()
positioner = new QQuickPopupPositioner(q);
}
-bool QQuickPopupPrivate::tryClose(QQuickItem *item, QMouseEvent *event)
+void QQuickPopupPrivate::closeOrReject()
{
Q_Q(QQuickPopup);
+ if (QQuickDialog *dialog = qobject_cast<QQuickDialog*>(q))
+ dialog->reject();
+ else
+ q->close();
+}
+
+bool QQuickPopupPrivate::tryClose(QQuickItem *item, QMouseEvent *event)
+{
const bool isPress = event->type() == QEvent::MouseButtonPress;
const bool onOutside = closePolicy.testFlag(isPress ? QQuickPopup::CloseOnPressOutside : QQuickPopup::CloseOnReleaseOutside);
const bool onOutsideParent = closePolicy.testFlag(isPress ? QQuickPopup::CloseOnPressOutsideParent : QQuickPopup::CloseOnReleaseOutsideParent);
if (onOutside || onOutsideParent) {
if (!popupItem->contains(item->mapToItem(popupItem, event->pos()))) {
if (!onOutsideParent || !parentItem || !parentItem->contains(item->mapToItem(parentItem, event->pos()))) {
- q->close();
+ closeOrReject();
return true;
}
}
@@ -1563,6 +1572,10 @@ void QQuickPopup::setScale(qreal scale)
has active focus.
The default value is \c {Popup.CloseOnEscape | Popup.CloseOnPressOutside}.
+
+ \note There is a known limitation that the \c Popup.CloseOnReleaseOutside
+ and \c Popup.CloseOnReleaseOutsideParent policies only work with
+ \l modal popups.
*/
QQuickPopup::ClosePolicy QQuickPopup::closePolicy() const
{