aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickpopupitem.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-12-15 12:34:03 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-12-19 09:35:21 +0000
commitf5c13e141c9c9bf7b131da6948ebcfc01d82f160 (patch)
tree3f5e6d409612f36f230a7bb4e3eefc08940cca7e /src/quicktemplates2/qquickpopupitem.cpp
parent6b89293b99e763589181fd1f75470712f52cee3c (diff)
Popups: use deferred execution
QQuickPopup is backed by a QQuickControl subclass aka QQuickPopupItem. However, since the QML engine sees "background" and "contentItem" as properties of QQuickPopup, we must ensure that the deferred properties are executed for the QQuickPopup wrapper object. Task-number: QTBUG-50992 Change-Id: I2ec055b382e41530a6f4a740cb80853c0181c21a Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickpopupitem.cpp')
-rw-r--r--src/quicktemplates2/qquickpopupitem.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp
index bd667835..db335a06 100644
--- a/src/quicktemplates2/qquickpopupitem.cpp
+++ b/src/quicktemplates2/qquickpopupitem.cpp
@@ -39,6 +39,7 @@
#include "qquickshortcutcontext_p_p.h"
#include "qquickcontrol_p_p.h"
#include "qquickpopup_p_p.h"
+#include "qquickdeferredexecute_p_p.h"
#include <QtGui/private/qshortcutmap_p.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -59,6 +60,9 @@ public:
QQuickItem *getContentItem() override;
+ void executeContentItem(bool complete = false) override;
+ void executeBackground(bool complete = false) override;
+
int backId;
int escapeId;
QQuickPopup *popup;
@@ -100,6 +104,32 @@ QQuickItem *QQuickPopupItemPrivate::getContentItem()
return new QQuickItem(q);
}
+static inline QString contentItemName() { return QStringLiteral("contentItem"); }
+
+void QQuickPopupItemPrivate::executeContentItem(bool complete)
+{
+ if (contentItem.wasExecuted())
+ return;
+
+ if (!contentItem)
+ quickBeginDeferred(popup, contentItemName(), contentItem);
+ if (complete)
+ quickCompleteDeferred(popup, contentItemName(), contentItem);
+}
+
+static inline QString backgroundName() { return QStringLiteral("background"); }
+
+void QQuickPopupItemPrivate::executeBackground(bool complete)
+{
+ if (background.wasExecuted())
+ return;
+
+ if (!background)
+ quickBeginDeferred(popup, backgroundName(), background);
+ if (complete)
+ quickCompleteDeferred(popup, backgroundName(), background);
+}
+
QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup)
: QQuickControl(*(new QQuickPopupItemPrivate(popup)), nullptr)
{