aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-01-08 11:41:56 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-01-10 13:43:39 +0100
commit5d9736653e49f697be3ea514af5b3ec69e747e2d (patch)
tree79aaa11e92d9fe2e7476e37f187e4ff6707454e5 /src/quicktemplates2
parent10b8f6af42a1cd80273d0a2d36e75b79078b5994 (diff)
parent55522df46edd295a65edd32e0ca7d32408ab6de4 (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: src/imports/controls/BusyIndicator.qml src/imports/controls/CheckBox.qml src/imports/controls/CheckDelegate.qml src/imports/controls/ComboBox.qml src/imports/controls/DelayButton.qml src/imports/controls/Dial.qml src/imports/controls/ItemDelegate.qml src/imports/controls/MenuItem.qml src/imports/controls/RadioButton.qml src/imports/controls/RadioDelegate.qml src/imports/controls/SwipeDelegate.qml src/imports/controls/Switch.qml src/imports/controls/SwitchDelegate.qml src/imports/controls/doc/src/qtquickcontrols2-configuration.qdoc src/imports/controls/material/CheckDelegate.qml src/imports/controls/material/ItemDelegate.qml src/imports/controls/material/MenuItem.qml src/imports/controls/material/RadioDelegate.qml src/imports/controls/material/SwipeDelegate.qml src/imports/controls/material/SwitchDelegate.qml src/imports/controls/qquickdefaultbusyindicator.cpp src/imports/controls/qquickdefaultbusyindicator_p.h src/imports/controls/qtquickcontrols2plugin.cpp src/imports/controls/universal/CheckDelegate.qml src/imports/controls/universal/ItemDelegate.qml src/imports/controls/universal/MenuItem.qml src/imports/controls/universal/RadioDelegate.qml src/imports/controls/universal/SwipeDelegate.qml src/imports/controls/universal/SwitchDelegate.qml src/quickcontrols2/quickcontrols2.pri src/quicktemplates2/qquickcontrol.cpp src/quicktemplates2/qquickmenu.cpp src/quicktemplates2/qquickpopup_p.h Change-Id: Ib25c8b4a7fe018b7c0ade9b02bfaaa6980118c15
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp13
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p_p.h1
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp12
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp25
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp22
-rw-r--r--src/quicktemplates2/qquickcontrol_p_p.h7
-rw-r--r--src/quicktemplates2/qquickdeferredexecute.cpp32
-rw-r--r--src/quicktemplates2/qquickdeferredexecute_p_p.h9
-rw-r--r--src/quicktemplates2/qquickdial.cpp12
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp5
-rw-r--r--src/quicktemplates2/qquickgroupbox.cpp12
-rw-r--r--src/quicktemplates2/qquicklabel.cpp11
-rw-r--r--src/quicktemplates2/qquicklabel_p_p.h1
-rw-r--r--src/quicktemplates2/qquickmenu.cpp3
-rw-r--r--src/quicktemplates2/qquickpagelayout.cpp13
-rw-r--r--src/quicktemplates2/qquickpopup.cpp11
-rw-r--r--src/quicktemplates2/qquickpopup_p.h1
-rw-r--r--src/quicktemplates2/qquickpopupitem.cpp43
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp16
-rw-r--r--src/quicktemplates2/qquickslider.cpp12
-rw-r--r--src/quicktemplates2/qquickspinbox.cpp12
-rw-r--r--src/quicktemplates2/qquickstackview.cpp7
-rw-r--r--src/quicktemplates2/qquickstackview_p.h4
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp11
-rw-r--r--src/quicktemplates2/qquicktextarea_p_p.h1
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp11
-rw-r--r--src/quicktemplates2/qquicktextfield_p_p.h1
27 files changed, 269 insertions, 39 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index be7d35a2..b1522995 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -333,13 +333,19 @@ void QQuickAbstractButtonPrivate::toggle(bool value)
static inline QString indicatorName() { return QStringLiteral("indicator"); }
+void QQuickAbstractButtonPrivate::cancelIndicator()
+{
+ Q_Q(QQuickAbstractButton);
+ quickCancelDeferred(q, indicatorName());
+}
+
void QQuickAbstractButtonPrivate::executeIndicator(bool complete)
{
- Q_Q(QQuickControl);
+ Q_Q(QQuickAbstractButton);
if (indicator.wasExecuted())
return;
- if (!indicator)
+ if (!indicator || complete)
quickBeginDeferred(q, indicatorName(), indicator);
if (complete)
quickCompleteDeferred(q, indicatorName(), indicator);
@@ -649,6 +655,9 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator)
if (d->indicator == indicator)
return;
+ if (!d->indicator.isExecuting())
+ d->cancelIndicator();
+
delete d->indicator;
d->indicator = indicator;
if (indicator) {
diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h
index cdf7419e..3b2a87f2 100644
--- a/src/quicktemplates2/qquickabstractbutton_p_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p_p.h
@@ -97,6 +97,7 @@ public:
void trigger();
void toggle(bool value);
+ void cancelIndicator();
void executeIndicator(bool complete = false);
QString text;
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index 94b0de98..687b4233 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -166,6 +166,7 @@ public:
static void contentData_append(QQmlListProperty<QObject> *prop, QObject *obj);
+ void cancelBackground();
void executeBackground(bool complete = false);
bool complete;
@@ -334,13 +335,19 @@ void QQuickApplicationWindowPrivate::contentData_append(QQmlListProperty<QObject
static inline QString backgroundName() { return QStringLiteral("background"); }
+void QQuickApplicationWindowPrivate::cancelBackground()
+{
+ Q_Q(QQuickApplicationWindow);
+ quickCancelDeferred(q, backgroundName());
+}
+
void QQuickApplicationWindowPrivate::executeBackground(bool complete)
{
Q_Q(QQuickApplicationWindow);
if (background.wasExecuted())
return;
- if (!background)
+ if (!background || complete)
quickBeginDeferred(q, backgroundName(), background);
if (complete)
quickCompleteDeferred(q, backgroundName(), background);
@@ -404,6 +411,9 @@ void QQuickApplicationWindow::setBackground(QQuickItem *background)
if (d->background == background)
return;
+ if (!d->background.isExecuting())
+ d->cancelBackground();
+
delete d->background;
d->background = background;
if (background) {
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 3b37900d..f1e05b7e 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -256,7 +256,10 @@ public:
void handleRelease(const QPointF &point) override;
void handleUngrab() override;
+ void cancelIndicator();
void executeIndicator(bool complete = false);
+
+ void cancelPopup();
void executePopup(bool complete = false);
bool flat;
@@ -704,13 +707,19 @@ void QQuickComboBoxPrivate::handleUngrab()
static inline QString indicatorName() { return QStringLiteral("indicator"); }
+void QQuickComboBoxPrivate::cancelIndicator()
+{
+ Q_Q(QQuickComboBox);
+ quickCancelDeferred(q, indicatorName());
+}
+
void QQuickComboBoxPrivate::executeIndicator(bool complete)
{
Q_Q(QQuickComboBox);
if (indicator.wasExecuted())
return;
- if (!indicator)
+ if (!indicator || complete)
quickBeginDeferred(q, indicatorName(), indicator);
if (complete)
quickCompleteDeferred(q, indicatorName(), indicator);
@@ -718,13 +727,19 @@ void QQuickComboBoxPrivate::executeIndicator(bool complete)
static inline QString popupName() { return QStringLiteral("popup"); }
+void QQuickComboBoxPrivate::cancelPopup()
+{
+ Q_Q(QQuickComboBox);
+ quickCancelDeferred(q, popupName());
+}
+
void QQuickComboBoxPrivate::executePopup(bool complete)
{
Q_Q(QQuickComboBox);
if (popup.wasExecuted())
return;
- if (!popup)
+ if (!popup || complete)
quickBeginDeferred(q, popupName(), popup);
if (complete)
quickCompleteDeferred(q, popupName(), popup);
@@ -1048,6 +1063,9 @@ void QQuickComboBox::setIndicator(QQuickItem *indicator)
if (d->indicator == indicator)
return;
+ if (!d->indicator.isExecuting())
+ d->cancelIndicator();
+
delete d->indicator;
d->indicator = indicator;
if (indicator) {
@@ -1085,6 +1103,9 @@ void QQuickComboBox::setPopup(QQuickPopup *popup)
if (d->popup == popup)
return;
+ if (!d->popup.isExecuting())
+ d->cancelPopup();
+
if (d->popup) {
QObjectPrivate::disconnect(d->popup.data(), &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged);
delete d->popup;
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index 76d6a688..f860bcad 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -291,6 +291,9 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify)
if (contentItem == item)
return;
+ if (!contentItem.isExecuting())
+ cancelContentItem();
+
q->contentItemChange(item, contentItem);
delete contentItem;
contentItem = item;
@@ -649,13 +652,19 @@ bool QQuickControlPrivate::calcHoverEnabled(const QQuickItem *item)
static inline QString contentItemName() { return QStringLiteral("contentItem"); }
+void QQuickControlPrivate::cancelContentItem()
+{
+ Q_Q(QQuickControl);
+ quickCancelDeferred(q, contentItemName());
+}
+
void QQuickControlPrivate::executeContentItem(bool complete)
{
Q_Q(QQuickControl);
if (contentItem.wasExecuted())
return;
- if (!contentItem)
+ if (!contentItem || complete)
quickBeginDeferred(q, contentItemName(), contentItem);
if (complete)
quickCompleteDeferred(q, contentItemName(), contentItem);
@@ -663,13 +672,19 @@ void QQuickControlPrivate::executeContentItem(bool complete)
static inline QString backgroundName() { return QStringLiteral("background"); }
+void QQuickControlPrivate::cancelBackground()
+{
+ Q_Q(QQuickControl);
+ quickCancelDeferred(q, backgroundName());
+}
+
void QQuickControlPrivate::executeBackground(bool complete)
{
Q_Q(QQuickControl);
if (background.wasExecuted())
return;
- if (!background)
+ if (!background || complete)
quickBeginDeferred(q, backgroundName(), background);
if (complete)
quickCompleteDeferred(q, backgroundName(), background);
@@ -1313,6 +1328,9 @@ void QQuickControl::setBackground(QQuickItem *background)
if (d->background == background)
return;
+ if (!d->background.isExecuting())
+ d->cancelBackground();
+
delete d->background;
d->background = background;
if (background) {
diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h
index f159c96d..3fe0a65b 100644
--- a/src/quicktemplates2/qquickcontrol_p_p.h
+++ b/src/quicktemplates2/qquickcontrol_p_p.h
@@ -140,8 +140,11 @@ public:
static bool calcHoverEnabled(const QQuickItem *item);
#endif
- void executeContentItem(bool complete = false);
- void executeBackground(bool complete = false);
+ virtual void cancelContentItem();
+ virtual void executeContentItem(bool complete = false);
+
+ virtual void cancelBackground();
+ virtual void executeBackground(bool complete = false);
static void destroyDelegate(QObject *object, QObject *parent);
diff --git a/src/quicktemplates2/qquickdeferredexecute.cpp b/src/quicktemplates2/qquickdeferredexecute.cpp
index 802ed3d0..ca6953bc 100644
--- a/src/quicktemplates2/qquickdeferredexecute.cpp
+++ b/src/quicktemplates2/qquickdeferredexecute.cpp
@@ -55,13 +55,24 @@ static inline uint qHash(QObject *object, const QString &propertyName)
Q_GLOBAL_STATIC(DeferredStates, deferredStates)
-static void beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &property, QQmlComponentPrivate::DeferredState *deferredState)
+static void cancelDeferred(QObject *object, int propertyIndex)
+{
+ QQmlData *ddata = QQmlData::get(object);
+ auto dit = ddata->deferredData.rbegin();
+ while (dit != ddata->deferredData.rend()) {
+ (*dit)->bindings.remove(propertyIndex);
+ ++dit;
+ }
+}
+
+static bool beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &property, QQmlComponentPrivate::DeferredState *deferredState)
{
QObject *object = property.object();
QQmlData *ddata = QQmlData::get(object);
Q_ASSERT(!ddata->deferredData.isEmpty());
int propertyIndex = property.index();
+ int wasInProgress = enginePriv->inProgressCreations;
for (auto dit = ddata->deferredData.rbegin(); dit != ddata->deferredData.rend(); ++dit) {
QQmlData::DeferredData *deferData = *dit;
@@ -91,12 +102,11 @@ static void beginDeferred(QQmlEnginePrivate *enginePriv, const QQmlProperty &pro
// Cleanup any remaining deferred bindings for this property, also in inner contexts,
// to avoid executing them later and overriding the property that was just populated.
- while (dit != ddata->deferredData.rend()) {
- (*dit)->bindings.remove(propertyIndex);
- ++dit;
- }
+ cancelDeferred(object, propertyIndex);
break;
}
+
+ return enginePriv->inProgressCreations > wasInProgress;
}
void beginDeferred(QObject *object, const QString &property)
@@ -106,15 +116,21 @@ void beginDeferred(QObject *object, const QString &property)
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine);
QQmlComponentPrivate::DeferredState *state = new QQmlComponentPrivate::DeferredState;
- beginDeferred(ep, QQmlProperty(object, property), state);
+ if (beginDeferred(ep, QQmlProperty(object, property), state))
+ deferredStates()->insert(qHash(object, property), state);
+ else
+ delete state;
// Release deferred data for those compilation units that no longer have deferred bindings
data->releaseDeferredData();
-
- deferredStates()->insert(qHash(object, property), state);
}
}
+void cancelDeferred(QObject *object, const QString &property)
+{
+ cancelDeferred(object, QQmlProperty(object, property).index());
+}
+
void completeDeferred(QObject *object, const QString &property)
{
QQmlData *data = QQmlData::get(object);
diff --git a/src/quicktemplates2/qquickdeferredexecute_p_p.h b/src/quicktemplates2/qquickdeferredexecute_p_p.h
index 87124e48..400c5734 100644
--- a/src/quicktemplates2/qquickdeferredexecute_p_p.h
+++ b/src/quicktemplates2/qquickdeferredexecute_p_p.h
@@ -58,25 +58,28 @@ class QObject;
namespace QtQuickPrivate {
void beginDeferred(QObject *object, const QString &property);
+ void cancelDeferred(QObject *object, const QString &property);
void completeDeferred(QObject *object, const QString &property);
}
template<typename T>
void quickBeginDeferred(QObject *object, const QString &property, QQuickDeferredPointer<T> &delegate)
{
- Q_ASSERT(delegate.isNull());
delegate.setExecuting(true);
QtQuickPrivate::beginDeferred(object, property);
delegate.setExecuting(false);
}
+inline void quickCancelDeferred(QObject *object, const QString &property)
+{
+ QtQuickPrivate::cancelDeferred(object, property);
+}
+
template<typename T>
void quickCompleteDeferred(QObject *object, const QString &property, QQuickDeferredPointer<T> &delegate)
{
Q_ASSERT(!delegate.wasExecuted());
- delegate.setExecuting(true);
QtQuickPrivate::completeDeferred(object, property);
- delegate.setExecuting(false);
delegate.setExecuted();
}
diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp
index 964cefe1..b5957069 100644
--- a/src/quicktemplates2/qquickdial.cpp
+++ b/src/quicktemplates2/qquickdial.cpp
@@ -123,6 +123,7 @@ public:
void handleRelease(const QPointF &point) override;
void handleUngrab() override;
+ void cancelHandle();
void executeHandle(bool complete = false);
qreal from;
@@ -258,13 +259,19 @@ void QQuickDialPrivate::handleUngrab()
static inline QString handleName() { return QStringLiteral("handle"); }
+void QQuickDialPrivate::cancelHandle()
+{
+ Q_Q(QQuickDial);
+ quickCancelDeferred(q, handleName());
+}
+
void QQuickDialPrivate::executeHandle(bool complete)
{
Q_Q(QQuickDial);
if (handle.wasExecuted())
return;
- if (!handle)
+ if (!handle || complete)
quickBeginDeferred(q, handleName(), handle);
if (complete)
quickCompleteDeferred(q, handleName(), handle);
@@ -553,6 +560,9 @@ void QQuickDial::setHandle(QQuickItem *handle)
if (handle == d->handle)
return;
+ if (!d->handle.isExecuting())
+ d->cancelHandle();
+
delete d->handle;
d->handle = handle;
if (d->handle && !d->handle->parentItem())
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index 022c9dbf..202d02d1 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -79,6 +79,11 @@ QT_BEGIN_NAMESPACE
id: drawer
width: 0.66 * window.width
height: window.height
+
+ Label {
+ text: "Content goes here!"
+ anchors.centerIn: parent
+ }
}
}
\endcode
diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp
index c127192c..4f4c5eed 100644
--- a/src/quicktemplates2/qquickgroupbox.cpp
+++ b/src/quicktemplates2/qquickgroupbox.cpp
@@ -91,6 +91,7 @@ class QQuickGroupBoxPrivate : public QQuickFramePrivate
public:
QQuickGroupBoxPrivate() : label(nullptr) { }
+ void cancelLabel();
void executeLabel(bool complete = false);
QString title;
@@ -99,13 +100,19 @@ public:
static inline QString labelName() { return QStringLiteral("label"); }
+void QQuickGroupBoxPrivate::cancelLabel()
+{
+ Q_Q(QQuickGroupBox);
+ quickCancelDeferred(q, labelName());
+}
+
void QQuickGroupBoxPrivate::executeLabel(bool complete)
{
Q_Q(QQuickGroupBox);
if (label.wasExecuted())
return;
- if (!label)
+ if (!label || complete)
quickBeginDeferred(q, labelName(), label);
if (complete)
quickCompleteDeferred(q, labelName(), label);
@@ -162,6 +169,9 @@ void QQuickGroupBox::setLabel(QQuickItem *label)
if (d->label == label)
return;
+ if (!d->label.isExecuting())
+ d->cancelLabel();
+
delete d->label;
d->label = label;
if (label && !label->parentItem())
diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp
index d27393ae..41b2d93a 100644
--- a/src/quicktemplates2/qquicklabel.cpp
+++ b/src/quicktemplates2/qquicklabel.cpp
@@ -205,13 +205,19 @@ QAccessible::Role QQuickLabelPrivate::accessibleRole() const
static inline QString backgroundName() { return QStringLiteral("background"); }
+void QQuickLabelPrivate::cancelBackground()
+{
+ Q_Q(QQuickLabel);
+ quickCancelDeferred(q, backgroundName());
+}
+
void QQuickLabelPrivate::executeBackground(bool complete)
{
Q_Q(QQuickLabel);
if (background.wasExecuted())
return;
- if (!background)
+ if (!background || complete)
quickBeginDeferred(q, backgroundName(), background);
if (complete)
quickCompleteDeferred(q, backgroundName(), background);
@@ -264,6 +270,9 @@ void QQuickLabel::setBackground(QQuickItem *background)
if (d->background == background)
return;
+ if (!d->background.isExecuting())
+ d->cancelBackground();
+
delete d->background;
d->background = background;
if (background) {
diff --git a/src/quicktemplates2/qquicklabel_p_p.h b/src/quicktemplates2/qquicklabel_p_p.h
index 5f432a22..bcd1aca6 100644
--- a/src/quicktemplates2/qquicklabel_p_p.h
+++ b/src/quicktemplates2/qquicklabel_p_p.h
@@ -99,6 +99,7 @@ public:
QAccessible::Role accessibleRole() const override;
#endif
+ void cancelBackground();
void executeBackground(bool complete = false);
struct ExtraData {
diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp
index 7ebeb344..5dbfe3d9 100644
--- a/src/quicktemplates2/qquickmenu.cpp
+++ b/src/quicktemplates2/qquickmenu.cpp
@@ -1013,6 +1013,9 @@ QVariant QQuickMenu::contentModel() const
*/
QQmlListProperty<QObject> QQuickMenu::contentData()
{
+ Q_D(QQuickMenu);
+ if (!d->contentItem)
+ QQuickControlPrivate::get(d->popupItem)->executeContentItem();
return QQmlListProperty<QObject>(this, nullptr,
QQuickMenuPrivate::contentData_append,
QQuickMenuPrivate::contentData_count,
diff --git a/src/quicktemplates2/qquickpagelayout.cpp b/src/quicktemplates2/qquickpagelayout.cpp
index 99d4fe23..595db560 100644
--- a/src/quicktemplates2/qquickpagelayout.cpp
+++ b/src/quicktemplates2/qquickpagelayout.cpp
@@ -36,6 +36,7 @@
#include "qquickpagelayout_p_p.h"
#include "qquickcontrol_p.h"
+#include "qquickcontrol_p_p.h"
#include "qquicktoolbar_p.h"
#include "qquicktabbar_p.h"
#include "qquickdialogbuttonbox_p.h"
@@ -140,17 +141,19 @@ bool QQuickPageLayout::setFooter(QQuickItem *footer)
void QQuickPageLayout::update()
{
- QQuickItem *content = m_control->contentItem();
+ QQuickItem *content = QQuickControlPrivate::get(m_control)->contentItem;
const qreal hh = m_header && m_header->isVisible() ? m_header->height() : 0;
const qreal fh = m_footer && m_footer->isVisible() ? m_footer->height() : 0;
const qreal hsp = hh > 0 ? m_control->spacing() : 0;
const qreal fsp = fh > 0 ? m_control->spacing() : 0;
- content->setY(m_control->topPadding() + hh + hsp);
- content->setX(m_control->leftPadding());
- content->setWidth(m_control->availableWidth());
- content->setHeight(m_control->availableHeight() - hh - fh - hsp - fsp);
+ if (content) {
+ content->setY(m_control->topPadding() + hh + hsp);
+ content->setX(m_control->leftPadding());
+ content->setWidth(m_control->availableWidth());
+ content->setHeight(m_control->availableHeight() - hh - fh - hsp - fsp);
+ }
if (m_header)
m_header->setWidth(m_control->width());
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 472d2124..1a4c90a4 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -265,6 +265,7 @@ void QQuickPopupPrivate::init()
q->setParentItem(qobject_cast<QQuickItem *>(parent));
QObject::connect(popupItem, &QQuickItem::enabledChanged, q, &QQuickPopup::enabledChanged);
QObject::connect(popupItem, &QQuickControl::paddingChanged, q, &QQuickPopup::paddingChanged);
+ QObject::connect(popupItem, &QQuickControl::backgroundChanged, q, &QQuickPopup::backgroundChanged);
QObject::connect(popupItem, &QQuickControl::contentItemChanged, q, &QQuickPopup::contentItemChanged);
positioner = new QQuickPopupPositioner(q);
}
@@ -1605,11 +1606,7 @@ QQuickItem *QQuickPopup::background() const
void QQuickPopup::setBackground(QQuickItem *background)
{
Q_D(QQuickPopup);
- if (d->popupItem->background() == background)
- return;
-
d->popupItem->setBackground(background);
- emit backgroundChanged();
}
/*!
@@ -1662,6 +1659,9 @@ void QQuickPopup::setContentItem(QQuickItem *item)
QQmlListProperty<QObject> QQuickPopup::contentData()
{
Q_D(QQuickPopup);
+ QQuickControlPrivate *p = QQuickControlPrivate::get(d->popupItem);
+ if (!p->contentItem)
+ p->executeContentItem();
return QQmlListProperty<QObject>(d->popupItem->contentItem(), nullptr,
QQuickItemPrivate::data_append,
QQuickItemPrivate::data_count,
@@ -2110,6 +2110,9 @@ void QQuickPopup::classBegin()
{
Q_D(QQuickPopup);
d->complete = false;
+ QQmlContext *context = qmlContext(this);
+ if (context)
+ QQmlEngine::setContextForObject(d->popupItem, context);
d->popupItem->classBegin();
}
diff --git a/src/quicktemplates2/qquickpopup_p.h b/src/quicktemplates2/qquickpopup_p.h
index ada4b649..2a42ff27 100644
--- a/src/quicktemplates2/qquickpopup_p.h
+++ b/src/quicktemplates2/qquickpopup_p.h
@@ -121,6 +121,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopup : public QObject, public QQml
Q_PROPERTY(bool mirrored READ isMirrored NOTIFY mirroredChanged FINAL REVISION 3)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL REVISION 3)
Q_PROPERTY(QPalette palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL REVISION 3)
+ Q_CLASSINFO("DeferredPropertyNames", "background,contentItem")
Q_CLASSINFO("DefaultProperty", "contentData")
public:
diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp
index af4d03a4..566a5245 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>
@@ -60,6 +61,12 @@ public:
QQuickItem *getContentItem() override;
+ void cancelContentItem() override;
+ void executeContentItem(bool complete = false) override;
+
+ void cancelBackground() override;
+ void executeBackground(bool complete = false) override;
+
int backId;
int escapeId;
QQuickPopup *popup;
@@ -109,6 +116,42 @@ QQuickItem *QQuickPopupItemPrivate::getContentItem()
return new QQuickItem(q);
}
+static inline QString contentItemName() { return QStringLiteral("contentItem"); }
+
+void QQuickPopupItemPrivate::cancelContentItem()
+{
+ quickCancelDeferred(popup, contentItemName());
+}
+
+void QQuickPopupItemPrivate::executeContentItem(bool complete)
+{
+ if (contentItem.wasExecuted())
+ return;
+
+ if (!contentItem || complete)
+ quickBeginDeferred(popup, contentItemName(), contentItem);
+ if (complete)
+ quickCompleteDeferred(popup, contentItemName(), contentItem);
+}
+
+static inline QString backgroundName() { return QStringLiteral("background"); }
+
+void QQuickPopupItemPrivate::cancelBackground()
+{
+ quickCancelDeferred(popup, backgroundName());
+}
+
+void QQuickPopupItemPrivate::executeBackground(bool complete)
+{
+ if (background.wasExecuted())
+ return;
+
+ if (!background || complete)
+ quickBeginDeferred(popup, backgroundName(), background);
+ if (complete)
+ quickCompleteDeferred(popup, backgroundName(), background);
+}
+
QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup)
: QQuickControl(*(new QQuickPopupItemPrivate(popup)), nullptr)
{
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index 937de9c9..075306cf 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -110,6 +110,7 @@ public:
void setPosition(qreal position, bool ignoreOtherPosition = false);
void updatePosition(bool ignoreOtherPosition = false);
+ void cancelHandle();
void executeHandle(bool complete = false);
static QQuickRangeSliderNodePrivate *get(QQuickRangeSliderNode *node);
@@ -154,13 +155,19 @@ void QQuickRangeSliderNodePrivate::updatePosition(bool ignoreOtherPosition)
static inline QString handleName() { return QStringLiteral("handle"); }
+void QQuickRangeSliderNodePrivate::cancelHandle()
+{
+ Q_Q(QQuickRangeSliderNode);
+ quickCancelDeferred(q, handleName());
+}
+
void QQuickRangeSliderNodePrivate::executeHandle(bool complete)
{
Q_Q(QQuickRangeSliderNode);
if (handle.wasExecuted())
return;
- if (!handle)
+ if (!handle || complete)
quickBeginDeferred(q, handleName(), handle);
if (complete)
quickCompleteDeferred(q, handleName(), handle);
@@ -256,14 +263,17 @@ void QQuickRangeSliderNode::setHandle(QQuickItem *handle)
if (d->handle == handle)
return;
+ if (!d->handle.isExecuting())
+ d->cancelHandle();
+
delete d->handle;
d->handle = handle;
if (handle) {
if (!handle->parentItem())
handle->setParentItem(d->slider);
- QQuickItem *firstHandle = d->slider->first()->handle();
- QQuickItem *secondHandle = d->slider->second()->handle();
+ QQuickItem *firstHandle = QQuickRangeSliderNodePrivate::get(d->slider->first())->handle;
+ QQuickItem *secondHandle = QQuickRangeSliderNodePrivate::get(d->slider->second())->handle;
if (firstHandle && secondHandle) {
// The order of property assignments in QML is undefined,
// but we need the first handle to be before the second due
diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp
index 21aeda39..ef2077af 100644
--- a/src/quicktemplates2/qquickslider.cpp
+++ b/src/quicktemplates2/qquickslider.cpp
@@ -113,6 +113,7 @@ public:
void handleRelease(const QPointF &point) override;
void handleUngrab() override;
+ void cancelHandle();
void executeHandle(bool complete = false);
qreal from;
@@ -240,13 +241,19 @@ void QQuickSliderPrivate::handleUngrab()
static inline QString handleName() { return QStringLiteral("handle"); }
+void QQuickSliderPrivate::cancelHandle()
+{
+ Q_Q(QQuickSlider);
+ quickCancelDeferred(q, handleName());
+}
+
void QQuickSliderPrivate::executeHandle(bool complete)
{
Q_Q(QQuickSlider);
if (handle.wasExecuted())
return;
- if (!handle)
+ if (!handle || complete)
quickBeginDeferred(q, handleName(), handle);
if (complete)
quickCompleteDeferred(q, handleName(), handle);
@@ -546,6 +553,9 @@ void QQuickSlider::setHandle(QQuickItem *handle)
if (d->handle == handle)
return;
+ if (!d->handle.isExecuting())
+ d->cancelHandle();
+
delete d->handle;
d->handle = handle;
if (handle && !handle->parentItem())
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp
index 27dd0d5e..4b998325 100644
--- a/src/quicktemplates2/qquickspinbox.cpp
+++ b/src/quicktemplates2/qquickspinbox.cpp
@@ -180,6 +180,7 @@ public:
return button->d_func();
}
+ void cancelIndicator();
void executeIndicator(bool complete = false);
bool pressed;
@@ -986,13 +987,19 @@ void QQuickSpinBox::accessibilityActiveChanged(bool active)
static inline QString indicatorName() { return QStringLiteral("indicator"); }
+void QQuickSpinButtonPrivate::cancelIndicator()
+{
+ Q_Q(QQuickSpinButton);
+ quickCancelDeferred(q, indicatorName());
+}
+
void QQuickSpinButtonPrivate::executeIndicator(bool complete)
{
Q_Q(QQuickSpinButton);
if (indicator.wasExecuted())
return;
- if (!indicator)
+ if (!indicator || complete)
quickBeginDeferred(q, indicatorName(), indicator);
if (complete)
quickCompleteDeferred(q, indicatorName(), indicator);
@@ -1033,6 +1040,9 @@ void QQuickSpinButton::setIndicator(QQuickItem *indicator)
if (d->indicator == indicator)
return;
+ if (!d->indicator.isExecuting())
+ d->cancelIndicator();
+
delete d->indicator;
d->indicator = indicator;
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index 2f13b1a1..2aa41c0d 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -1068,6 +1068,13 @@ bool QQuickStackView::childMouseEventFilter(QQuickItem *item, QEvent *event)
return window && !window->mouseGrabberItem();
}
+#if QT_CONFIG(quicktemplates2_multitouch)
+void QQuickStackView::touchEvent(QTouchEvent *event)
+{
+ event->ignore(); // QTBUG-65084
+}
+#endif
+
#if QT_CONFIG(accessibility)
QAccessible::Role QQuickStackView::accessibleRole() const
{
diff --git a/src/quicktemplates2/qquickstackview_p.h b/src/quicktemplates2/qquickstackview_p.h
index 2cddb800..e347ba9d 100644
--- a/src/quicktemplates2/qquickstackview_p.h
+++ b/src/quicktemplates2/qquickstackview_p.h
@@ -160,6 +160,10 @@ protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
bool childMouseEventFilter(QQuickItem *, QEvent *) override;
+#if QT_CONFIG(quicktemplates2_multitouch)
+ void touchEvent(QTouchEvent *event) override;
+#endif
+
#if QT_CONFIG(accessibility)
QAccessible::Role accessibleRole() const override;
#endif
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index d2458c24..319f7bbe 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -440,13 +440,19 @@ QAccessible::Role QQuickTextAreaPrivate::accessibleRole() const
static inline QString backgroundName() { return QStringLiteral("background"); }
+void QQuickTextAreaPrivate::cancelBackground()
+{
+ Q_Q(QQuickTextArea);
+ quickCancelDeferred(q, backgroundName());
+}
+
void QQuickTextAreaPrivate::executeBackground(bool complete)
{
Q_Q(QQuickTextArea);
if (background.wasExecuted())
return;
- if (!background)
+ if (!background || complete)
quickBeginDeferred(q, backgroundName(), background);
if (complete)
quickCompleteDeferred(q, backgroundName(), background);
@@ -517,6 +523,9 @@ void QQuickTextArea::setBackground(QQuickItem *background)
if (d->background == background)
return;
+ if (!d->background.isExecuting())
+ d->cancelBackground();
+
delete d->background;
d->background = background;
if (background) {
diff --git a/src/quicktemplates2/qquicktextarea_p_p.h b/src/quicktemplates2/qquicktextarea_p_p.h
index d27af8f6..8621c61c 100644
--- a/src/quicktemplates2/qquicktextarea_p_p.h
+++ b/src/quicktemplates2/qquicktextarea_p_p.h
@@ -125,6 +125,7 @@ public:
QAccessible::Role accessibleRole() const override;
#endif
+ void cancelBackground();
void executeBackground(bool complete = false);
#if QT_CONFIG(quicktemplates2_hover)
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index 03da9323..49f9b4c8 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -314,13 +314,19 @@ QAccessible::Role QQuickTextFieldPrivate::accessibleRole() const
static inline QString backgroundName() { return QStringLiteral("background"); }
+void QQuickTextFieldPrivate::cancelBackground()
+{
+ Q_Q(QQuickTextField);
+ quickCancelDeferred(q, backgroundName());
+}
+
void QQuickTextFieldPrivate::executeBackground(bool complete)
{
Q_Q(QQuickTextField);
if (background.wasExecuted())
return;
- if (!background)
+ if (!background || complete)
quickBeginDeferred(q, backgroundName(), background);
if (complete)
quickCompleteDeferred(q, backgroundName(), background);
@@ -379,6 +385,9 @@ void QQuickTextField::setBackground(QQuickItem *background)
if (d->background == background)
return;
+ if (!d->background.isExecuting())
+ d->cancelBackground();
+
delete d->background;
d->background = background;
if (background) {
diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h
index 5ae79b7f..41843370 100644
--- a/src/quicktemplates2/qquicktextfield_p_p.h
+++ b/src/quicktemplates2/qquicktextfield_p_p.h
@@ -113,6 +113,7 @@ public:
QAccessible::Role accessibleRole() const override;
#endif
+ void cancelBackground();
void executeBackground(bool complete = false);
#if QT_CONFIG(quicktemplates2_hover)