diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-09-14 12:09:39 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-09-14 12:09:39 +0200 |
commit | a6ca9472de6d4cbdb85dfceaa4f8c10b243cea07 (patch) | |
tree | 719e2c3a1732ab0cc82c32d560484b5740f40a05 | |
parent | 658b0f610a71fab8c103b913d2cfd11c3c7c6bef (diff) | |
parent | b3619f32c20b5851ada0826ec2e7ddc2ec8a210b (diff) |
Merge remote-tracking branch 'origin/5.7' into 5.8
Conflicts:
src/quicktemplates2/qquicktextarea_p_p.h
src/quicktemplates2/qquicktextfield_p_p.h
Change-Id: Ie7b4a114ad27a4cad337c91e8ebcf696b0e845d7
30 files changed, 625 insertions, 49 deletions
@@ -4,6 +4,7 @@ /include /lib /mkspecs +/doc /examples/quickcontrols2/chattutorial/chapter1-settingup/chapter1-settingup /examples/quickcontrols2/chattutorial/chapter2-lists/chapter2-lists diff --git a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc index bbdf7f89..5cb7a9a5 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc @@ -300,6 +300,9 @@ \li \l [QML QtQuickControls] {Slider} \li \l [QML QtQuickControls2] {Slider} \row + \li \l [QML QtQuickControls] {SplitView} + \li \mdash + \row \li \l [QML QtQuickControls] {SpinBox} \li \l [QML QtQuickControls2] {SpinBox} \row diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index 1155032b..1fadfd75 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -82,7 +82,9 @@ \section1 Examples \list - \li \l{Qt Quick Controls 2 Examples} + \li \l{Qt Quick Controls 2 - Gallery}{Gallery} + \li \l{Qt Quick Controls 2 - Chat Tutorial}{Chat Tutorial} + \li \l{Qt Quick Controls 2 Examples}{All Examples} \endlist \section1 Related Modules diff --git a/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc index 5685a852..eed4efe8 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-material.qdoc @@ -151,22 +151,19 @@ \row \li \c QT_QUICK_CONTROLS_MATERIAL_ACCENT \li The value can be any \l {colorbasictypedocs}{color}, but it is recommended - to use one of the \l {Pre-defined Colors}{pre-defined colors}, for example - for example \c "Teal". + to use one of the \l {pre-defined Material colors}, for example \c "Teal". \row \li \c QT_QUICK_CONTROLS_MATERIAL_PRIMARY \li The value can be any \l {colorbasictypedocs}{color}, but it is recommended - to use one of the \l {Pre-defined Colors}{pre-defined colors}, for example - for example \c "BlueGrey". + to use one of the \l {pre-defined Material colors}, for example \c "BlueGrey". \row \li \c QT_QUICK_CONTROLS_MATERIAL_FOREGROUND \li The value can be any \l {colorbasictypedocs}{color}, or one of the - \l {Pre-defined Colors}{pre-defined colors}. - + \l {pre-defined Material colors}. \row \li \c QT_QUICK_CONTROLS_MATERIAL_BACKGROUND \li The value can be any \l {colorbasictypedocs}{color}, or one of the - \l {Pre-defined Colors}{pre-defined colors}. + \l {pre-defined Material colors}. \endtable \section2 Dependency @@ -184,7 +181,7 @@ style-specific tweaks can be applied without creating a hard dependency to a style. - \section2 Pre-defined Colors + \section2 Pre-defined Material Colors Even though primary and accent can be any \l {colorbasictypedocs}{color}, it is recommended to use one of the pre-defined colors that have been designed @@ -238,8 +235,8 @@ There are several different \l {https://material.google.com/style/color.html#color-color-palette}{shades} - of each \l {Pre-defined Colors}{pre-defined color} that can be passed to the - \l {material-color-attached-method}{Material.color()} function: + of each \l {Pre-defined Material Colors}{pre-defined color} that can be passed + to the \l {material-color-attached-method}{Material.color()} function: \value Material.Shade50 \value Material.Shade100 \value Material.Shade200 @@ -267,8 +264,8 @@ The default value is \c Material.Pink. \note Even though the accent can be any \l {colorbasictypedocs}{color}, it is - recommended to use one of the \l {pre-defined colors} that have been designed - to work well with the rest of the Material style palette. + recommended to use one of the \l {pre-defined Material colors} that have been + designed to work well with the rest of the Material style palette. \endstyleproperty @@ -308,8 +305,8 @@ The default value is \c Material.Indigo. \note Even though the primary can be any \l {colorbasictypedocs}{color}, it is - recommended to use one of the \l {pre-defined colors} that have been designed - to work well with the rest of the Material style palette. + recommended to use one of the \l {pre-defined Material colors} that have been + designed to work well with the rest of the Material style palette. \endstyleproperty @@ -333,9 +330,10 @@ \stylemethod2 {color} {color} {enumeration} {predefined} {enumeration} {shade} {material-color-attached-method} \target material-color-attached-method - This attached method returns the color value of the specified \l {pre-defined colors} - {pre-defined color} combined with the given \l {pre-defined colors}{shade}. - If omitted, the shade argument defaults to \c Material.Shade500. + This attached method returns the effective color value of the specified + \l {pre-defined Material colors}{pre-defined Material color} combined with + the given \l {pre-defined shades}{shade}. If omitted, the shade argument + defaults to \c Material.Shade500. \qml import QtQuick 2.0 diff --git a/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc index cb6ac17e..c3e75185 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-universal.qdoc @@ -150,8 +150,15 @@ \row \li \c QT_QUICK_CONTROLS_UNIVERSAL_ACCENT \li The value can be any \l {colorbasictypedocs}{color}, but it is recommended - to use one of the pre-defined \l {universal-accent-attached-prop} {accents}, for - example \c "Violet". + to use one of the \l {pre-defined Universal colors}, for example \c "Violet". + \row + \li \c QT_QUICK_CONTROLS_UNIVERSAL_FOREGROUND + \li The value can be any \l {colorbasictypedocs}{color}, or one of the + \l {pre-defined Universal colors}. + \row + \li \c QT_QUICK_CONTROLS_UNIVERSAL_BACKGROUND + \li The value can be any \l {colorbasictypedocs}{color}, or one of the + \l {pre-defined Universal colors}. \endtable \section2 Dependency @@ -169,19 +176,9 @@ style-specific tweaks can be applied without creating a hard dependency to a style. - \b {See also} \l {Default Style}, \l {Material Style} - - \section1 Attached Property Documentation - - \styleproperty {Universal.accent} {color} {universal-accent-attached-prop} - \target universal-accent-attached-prop - This attached property holds the accent color of the theme. The property - can be attached to any window or item. The value is propagated to children. - - Even though the accent can be any \l {colorbasictypedocs}{color}, it is - recommended to use one of the pre-defined accents that have been designed - to work well with the rest of the Universal style palette: + \section2 Pre-defined Universal Colors + Available pre-defined colors: \value Universal.Lime \stylecolor {#A4C400} {} \value Universal.Green \stylecolor {#60A917} {} \value Universal.Emerald \stylecolor {#008A00} {} @@ -203,6 +200,19 @@ \value Universal.Mauve \stylecolor {#76608A} {} \value Universal.Taupe \stylecolor {#87794E} {} + \b {See also} \l {Default Style}, \l {Material Style} + + \section1 Attached Property Documentation + + \styleproperty {Universal.accent} {color} {universal-accent-attached-prop} + \target universal-accent-attached-prop + This attached property holds the accent color of the theme. The property + can be attached to any window or item. The value is propagated to children. + + \note Even though the accent can be any \l {colorbasictypedocs}{color}, it is + recommended to use one of the \l {pre-defined Universal colors} that have been + designed to work well with the rest of the Universal style palette. + \endstyleproperty \styleproperty {Universal.background} {color} {universal-background-attached-prop} @@ -241,8 +251,8 @@ \stylemethod {color} {color} {enumeration} {predefined} {color-attached-method} \target color-attached-method - This attached method returns the color value of the specified \l {pre-defined colors} - {pre-defined color}. + This attached method returns the effective color value of the specified + \l {pre-defined Universal colors}{pre-defined Universal color}. \qml import QtQuick 2.0 diff --git a/src/imports/controls/material/qquickmaterialstyle_p.h b/src/imports/controls/material/qquickmaterialstyle_p.h index e6e4fe05..6ff779a5 100644 --- a/src/imports/controls/material/qquickmaterialstyle_p.h +++ b/src/imports/controls/material/qquickmaterialstyle_p.h @@ -53,8 +53,6 @@ QT_BEGIN_NAMESPACE -class QQuickMaterialStylePrivate; - class QQuickMaterialStyle : public QQuickStyleAttached { Q_OBJECT diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index ac5fbf55..9c840493 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -438,7 +438,7 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; - delete d->indicator; + d->deleteDelegate(d->indicator); d->indicator = indicator; if (indicator) { if (!indicator->parentItem()) diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 59c108c2..07d7d126 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -658,7 +658,7 @@ void QQuickComboBox::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; - delete d->indicator; + d->deleteDelegate(d->indicator); d->indicator = indicator; if (indicator) { if (!indicator->parentItem()) @@ -686,7 +686,7 @@ void QQuickComboBox::setPopup(QQuickPopup *popup) if (d->popup == popup) return; - delete d->popup; + d->deleteDelegate(d->popup); if (popup) { popup->setAllowVerticalFlip(true); popup->setClosePolicy(QQuickPopup::CloseOnEscape | QQuickPopup::CloseOnPressOutsideParent); diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 0e2154e7..642e2e72 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -717,6 +717,18 @@ QLocale QQuickControlPrivate::calcLocale(const QQuickItem *item) return QLocale(); } +/* + Deletes "delegate" if Component.completed() has been emitted, + otherwise stores it in pendingDeletions. +*/ +void QQuickControlPrivate::deleteDelegate(QObject *delegate) +{ + if (componentComplete) + delete delegate; + else + extra.value().pendingDeletions.append(delegate); +} + void QQuickControlPrivate::updateLocale(const QLocale &l, bool e) { Q_Q(QQuickControl); @@ -943,7 +955,7 @@ void QQuickControl::setBackground(QQuickItem *background) if (d->background == background) return; - delete d->background; + d->deleteDelegate(d->background); d->background = background; if (background) { background->setParentItem(this); @@ -975,7 +987,7 @@ void QQuickControl::setContentItem(QQuickItem *item) return; contentItemChange(item, d->contentItem); - delete d->contentItem; + d->deleteDelegate(d->contentItem); d->contentItem = item; if (item) { if (!item->parentItem()) @@ -1003,6 +1015,11 @@ void QQuickControl::componentComplete() if (!d->accessibleAttached && QAccessible::isActive()) accessibilityActiveChanged(true); #endif + + if (d->extra.isAllocated()) { + qDeleteAll(d->extra.value().pendingDeletions); + d->extra.value().pendingDeletions.clear(); + } } QFont QQuickControl::defaultFont() const diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h index d36b8f9e..64f29986 100644 --- a/src/quicktemplates2/qquickcontrol_p_p.h +++ b/src/quicktemplates2/qquickcontrol_p_p.h @@ -109,9 +109,15 @@ public: static void updateLocaleRecur(QQuickItem *item, const QLocale &l); static QLocale calcLocale(const QQuickItem *item); + void deleteDelegate(QObject *object); + struct ExtraData { ExtraData(); QFont font; + // This list contains the default delegates which were + // replaced with custom ones via declarative assignments + // before Component.completed() was emitted. See QTBUG-50992. + QVector<QObject*> pendingDeletions; }; QLazilyAllocated<ExtraData> extra; diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index de220853..3b096255 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -480,6 +480,7 @@ void QQuickDial::setHandle(QQuickItem *handle) if (handle == d->handle) return; + d->deleteDelegate(d->handle); d->handle = handle; if (d->handle && !d->handle->parentItem()) d->handle->setParentItem(this); diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index a64b5f4e..4c9fbb62 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -527,7 +527,7 @@ bool QQuickDrawer::overlayEvent(QQuickItem *item, QEvent *event) d->tryClose(item, static_cast<QMouseEvent *>(event)); return d->handleMouseReleaseEvent(item, static_cast<QMouseEvent *>(event)); default: - return false; + return QQuickPopup::overlayEvent(item, event); } } diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp index 43c75665..45fe406f 100644 --- a/src/quicktemplates2/qquickgroupbox.cpp +++ b/src/quicktemplates2/qquickgroupbox.cpp @@ -137,7 +137,7 @@ void QQuickGroupBox::setLabel(QQuickItem *label) if (d->label == label) return; - delete d->label; + d->deleteDelegate(d->label); d->label = label; if (label && !label->parentItem()) label->setParentItem(this); diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp index 6a0c6a0b..03bed16f 100644 --- a/src/quicktemplates2/qquicklabel.cpp +++ b/src/quicktemplates2/qquicklabel.cpp @@ -167,6 +167,18 @@ QAccessible::Role QQuickLabelPrivate::accessibleRole() const } #endif +/* + Deletes "delegate" if Component.completed() has been emitted, + otherwise stores it in pendingDeletions. +*/ +void QQuickLabelPrivate::deleteDelegate(QObject *delegate) +{ + if (componentComplete) + delete delegate; + else + pendingDeletions.append(delegate); +} + QFont QQuickLabel::font() const { return QQuickText::font(); @@ -205,7 +217,7 @@ void QQuickLabel::setBackground(QQuickItem *background) if (d->background == background) return; - delete d->background; + d->deleteDelegate(d->background); d->background = background; if (background) { background->setParentItem(this); @@ -230,6 +242,9 @@ void QQuickLabel::componentComplete() if (!d->accessibleAttached && QAccessible::isActive()) d->accessibilityActiveChanged(true); #endif + + qDeleteAll(d->pendingDeletions); + d->pendingDeletions.clear(); } void QQuickLabel::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) diff --git a/src/quicktemplates2/qquicklabel_p_p.h b/src/quicktemplates2/qquicklabel_p_p.h index 2c8a3362..f5185768 100644 --- a/src/quicktemplates2/qquicklabel_p_p.h +++ b/src/quicktemplates2/qquicklabel_p_p.h @@ -83,9 +83,15 @@ public: QAccessible::Role accessibleRole() const override; #endif + void deleteDelegate(QObject *object); + QFont font; QQuickItem *background; QQuickAccessibleAttached *accessibleAttached; + // This list contains the default delegates which were + // replaced with custom ones via declarative assignments + // before Component.completed() was emitted. See QTBUG-50992. + QVector<QObject *> pendingDeletions; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index 172307e1..ccae4da6 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -379,6 +379,22 @@ void QQuickOverlay::mouseReleaseEvent(QMouseEvent *event) } } +void QQuickOverlay::wheelEvent(QWheelEvent *event) +{ + Q_D(QQuickOverlay); + if (d->mouseGrabberPopup) { + d->mouseGrabberPopup->overlayEvent(this, event); + return; + } else { + const auto popups = d->stackingOrderPopups(); + for (QQuickPopup *popup : popups) { + if (popup->overlayEvent(this, event)) + return; + } + } + event->ignore(); +} + bool QQuickOverlay::childMouseEventFilter(QQuickItem *item, QEvent *event) { Q_D(QQuickOverlay); diff --git a/src/quicktemplates2/qquickoverlay_p.h b/src/quicktemplates2/qquickoverlay_p.h index 07f7daec..af16900f 100644 --- a/src/quicktemplates2/qquickoverlay_p.h +++ b/src/quicktemplates2/qquickoverlay_p.h @@ -87,6 +87,7 @@ protected: void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; + void wheelEvent(QWheelEvent *event) override; bool childMouseEventFilter(QQuickItem *item, QEvent *event) override; private: diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index b4c3838f..34654fe1 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -228,7 +228,7 @@ void QQuickRangeSliderNode::setHandle(QQuickItem *handle) if (d->handle == handle) return; - delete d->handle; + QQuickControlPrivate::get(d->slider)->deleteDelegate(d->handle); d->handle = handle; if (handle) { if (!handle->parentItem()) diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 2a89ab4f..43754260 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -406,7 +406,7 @@ void QQuickSlider::setHandle(QQuickItem *handle) if (d->handle == handle) return; - delete d->handle; + d->deleteDelegate(d->handle); d->handle = handle; if (handle && !handle->parentItem()) handle->setParentItem(this); diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 634e3732..fcce8374 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -821,8 +821,14 @@ void QQuickSpinButton::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; - delete d->indicator; + QQuickControl *control = qobject_cast<QQuickControl*>(d->parent); + if (control) + QQuickControlPrivate::get(control)->deleteDelegate(d->indicator); + else + delete d->indicator; + d->indicator = indicator; + if (indicator) { if (!indicator->parentItem()) indicator->setParentItem(static_cast<QQuickItem *>(parent())); diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 7c2e0f11..92c85941 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -388,6 +388,14 @@ QAccessible::Role QQuickTextAreaPrivate::accessibleRole() const } #endif +void QQuickTextAreaPrivate::deleteDelegate(QObject *delegate) +{ + if (componentComplete) + delete delegate; + else + pendingDeletions.append(delegate); +} + QFont QQuickTextArea::font() const { return QQuickTextEdit::font(); @@ -426,7 +434,7 @@ void QQuickTextArea::setBackground(QQuickItem *background) if (d->background == background) return; - delete d->background; + d->deleteDelegate(d->background); d->background = background; if (background) { background->setParentItem(this); @@ -571,6 +579,9 @@ void QQuickTextArea::componentComplete() if (!d->accessibleAttached && QAccessible::isActive()) d->accessibilityActiveChanged(true); #endif + + qDeleteAll(d->pendingDeletions); + d->pendingDeletions.clear(); } void QQuickTextArea::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) diff --git a/src/quicktemplates2/qquicktextarea_p_p.h b/src/quicktemplates2/qquicktextarea_p_p.h index a9114054..3ffa29bc 100644 --- a/src/quicktemplates2/qquicktextarea_p_p.h +++ b/src/quicktemplates2/qquicktextarea_p_p.h @@ -102,6 +102,8 @@ public: QAccessible::Role accessibleRole() const override; #endif + void deleteDelegate(QObject *object); + bool hovered; QFont font; QQuickItem *background; @@ -110,6 +112,10 @@ public: QQuickPressHandler pressHandler; QQuickAccessibleAttached *accessibleAttached; QQuickFlickable *flickable; + // This list contains the default delegates which were + // replaced with custom ones via declarative assignments + // before Component.completed() was emitted. See QTBUG-50992. + QVector<QObject *> pendingDeletions; }; QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp index 88450e78..0ca0c6ce 100644 --- a/src/quicktemplates2/qquicktextfield.cpp +++ b/src/quicktemplates2/qquicktextfield.cpp @@ -265,6 +265,18 @@ QAccessible::Role QQuickTextFieldPrivate::accessibleRole() const } #endif +/* + Deletes "delegate" if Component.completed() has been emitted, + otherwise stores it in pendingDeletions. +*/ +void QQuickTextFieldPrivate::deleteDelegate(QObject *delegate) +{ + if (componentComplete) + delete delegate; + else + pendingDeletions.append(delegate); +} + QFont QQuickTextField::font() const { return QQuickTextInput::font(); @@ -303,7 +315,7 @@ void QQuickTextField::setBackground(QQuickItem *background) if (d->background == background) return; - delete d->background; + d->deleteDelegate(d->background); d->background = background; if (background) { background->setParentItem(this); @@ -440,6 +452,9 @@ void QQuickTextField::componentComplete() if (!d->accessibleAttached && QAccessible::isActive()) d->accessibilityActiveChanged(true); #endif + + qDeleteAll(d->pendingDeletions); + d->pendingDeletions.clear(); } void QQuickTextField::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h index dd355145..99e1c48c 100644 --- a/src/quicktemplates2/qquicktextfield_p_p.h +++ b/src/quicktemplates2/qquicktextfield_p_p.h @@ -93,6 +93,8 @@ public: QAccessible::Role accessibleRole() const override; #endif + void deleteDelegate(QObject *object); + bool hovered; QFont font; QQuickItem *background; @@ -100,6 +102,10 @@ public: Qt::FocusReason focusReason; QQuickPressHandler pressHandler; QQuickAccessibleAttached *accessibleAttached; + // This list contains the default delegates which were + // replaced with custom ones via declarative assignments + // before Component.completed() was emitted. See QTBUG-50992. + QVector<QObject *> pendingDeletions; }; QT_END_NAMESPACE diff --git a/tests/auto/drawer/data/applicationwindow-wheel.qml b/tests/auto/drawer/data/applicationwindow-wheel.qml new file mode 100644 index 00000000..9c8b4a83 --- /dev/null +++ b/tests/auto/drawer/data/applicationwindow-wheel.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.0 + +ApplicationWindow { + id: window + width: 400 + height: 400 + + property alias drawer: drawer + property alias drawerSlider: drawerSlider + property alias contentSlider: contentSlider + + Slider { + id: contentSlider + anchors.fill: parent + wheelEnabled: true + } + + Drawer { + id: drawer + edge: Qt.RightEdge + width: window.width * 0.8 + height: window.height + clip: true + contentItem: Slider { + id: drawerSlider + wheelEnabled: true + } + } +} diff --git a/tests/auto/drawer/data/window-wheel.qml b/tests/auto/drawer/data/window-wheel.qml new file mode 100644 index 00000000..18ca2ace --- /dev/null +++ b/tests/auto/drawer/data/window-wheel.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Controls 2.0 + +Window { + id: window + width: 400 + height: 400 + + property alias drawer: drawer + property alias drawerSlider: drawerSlider + property alias contentSlider: contentSlider + + Slider { + id: contentSlider + anchors.fill: parent + wheelEnabled: true + } + + Drawer { + id: drawer + edge: Qt.RightEdge + width: window.width * 0.8 + height: window.height + clip: true + contentItem: Slider { + id: drawerSlider + wheelEnabled: true + } + } +} diff --git a/tests/auto/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp index 8f023c29..8b02e95c 100644 --- a/tests/auto/drawer/tst_drawer.cpp +++ b/tests/auto/drawer/tst_drawer.cpp @@ -45,6 +45,7 @@ #include <QtQuickTemplates2/private/qquickoverlay_p.h> #include <QtQuickTemplates2/private/qquickdrawer_p.h> #include <QtQuickTemplates2/private/qquickbutton_p.h> +#include <QtQuickTemplates2/private/qquickslider_p.h> using namespace QQuickVisualTestUtil; @@ -69,6 +70,9 @@ private slots: void hover_data(); void hover(); + void wheel_data(); + void wheel(); + void multiple(); }; @@ -406,6 +410,90 @@ void tst_Drawer::hover() QVERIFY(backgroundButton->isHovered()); } +void tst_Drawer::wheel_data() +{ + QTest::addColumn<QString>("source"); + QTest::addColumn<bool>("modal"); + + QTest::newRow("Window:modal") << "window-wheel.qml" << true; + QTest::newRow("Window:modeless") << "window-wheel.qml" << false; + QTest::newRow("ApplicationWindow:modal") << "applicationwindow-wheel.qml" << true; + QTest::newRow("ApplicationWindow:modeless") << "applicationwindow-wheel.qml" << false; +} + +static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees) +{ + QQuickWindow *window = item->window(); + QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), QPoint(0, 8 * degrees), 0, Qt::Vertical, Qt::NoButton, 0); + QSpontaneKeyEvent::setSpontaneous(&wheelEvent); + return qGuiApp->notify(window, &wheelEvent); +} + +void tst_Drawer::wheel() +{ + QFETCH(QString, source); + QFETCH(bool, modal); + + QQuickApplicationHelper helper(this, source); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickSlider *contentSlider = window->property("contentSlider").value<QQuickSlider*>(); + QVERIFY(contentSlider); + + QQuickDrawer *drawer = window->property("drawer").value<QQuickDrawer*>(); + QVERIFY(drawer && drawer->contentItem()); + drawer->setModal(modal); + + QQuickSlider *drawerSlider = window->property("drawerSlider").value<QQuickSlider*>(); + QVERIFY(drawerSlider); + + { + // wheel over the content + qreal oldContentValue = contentSlider->value(); + qreal oldDrawerValue = drawerSlider->value(); + + QVERIFY(sendWheelEvent(contentSlider, QPoint(contentSlider->width() / 2, contentSlider->height() / 2), 15)); + + QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); // must have moved + QVERIFY(qFuzzyCompare(drawerSlider->value(), oldDrawerValue)); // must not have moved + } + + QSignalSpy openedSpy(drawer, SIGNAL(opened())); + QVERIFY(openedSpy.isValid()); + drawer->open(); + QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); + + { + // wheel over the drawer content + qreal oldContentValue = contentSlider->value(); + qreal oldDrawerValue = drawerSlider->value(); + + QVERIFY(sendWheelEvent(drawerSlider, QPoint(drawerSlider->width() / 2, drawerSlider->height() / 2), 15)); + + QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved + QVERIFY(!qFuzzyCompare(drawerSlider->value(), oldDrawerValue)); // must have moved + } + + { + // wheel over the overlay + qreal oldContentValue = contentSlider->value(); + qreal oldDrawerValue = drawerSlider->value(); + + QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPoint(0, 0), 15)); + + if (modal) { + // the content below a modal overlay must not move + QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); + } else { + // the content below a modeless overlay must move + QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); + } + QVERIFY(qFuzzyCompare(drawerSlider->value(), oldDrawerValue)); // must not have moved + } +} + void tst_Drawer::multiple() { QQuickApplicationHelper helper(this, QStringLiteral("multiple.qml")); diff --git a/tests/auto/popup/data/applicationwindow-wheel.qml b/tests/auto/popup/data/applicationwindow-wheel.qml new file mode 100644 index 00000000..a655713e --- /dev/null +++ b/tests/auto/popup/data/applicationwindow-wheel.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Controls 2.0 + +ApplicationWindow { + id: window + width: 400 + height: 400 + + property alias popup: popup + property alias popupSlider: popupSlider + property alias contentSlider: contentSlider + + Slider { + id: contentSlider + anchors.fill: parent + wheelEnabled: true + } + + Popup { + id: popup + x: 50; y: 50 + implicitWidth: parent.width - 100 + implicitHeight: parent.height - 100 + clip: true + contentItem: Slider { + id: popupSlider + wheelEnabled: true + } + } +} diff --git a/tests/auto/popup/data/window-wheel.qml b/tests/auto/popup/data/window-wheel.qml new file mode 100644 index 00000000..2ffe4bf6 --- /dev/null +++ b/tests/auto/popup/data/window-wheel.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Controls 2.0 + +Window { + id: window + width: 400 + height: 400 + + property alias popup: popup + property alias popupSlider: popupSlider + property alias contentSlider: contentSlider + + Slider { + id: contentSlider + anchors.fill: parent + wheelEnabled: true + } + + Popup { + id: popup + x: 50; y: 50 + implicitWidth: parent.width - 100 + implicitHeight: parent.height - 100 + clip: true + contentItem: Slider { + id: popupSlider + wheelEnabled: true + } + } +} diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp index a6848fc8..298328de 100644 --- a/tests/auto/popup/tst_popup.cpp +++ b/tests/auto/popup/tst_popup.cpp @@ -43,6 +43,7 @@ #include <QtQuickTemplates2/private/qquickoverlay_p.h> #include <QtQuickTemplates2/private/qquickpopup_p.h> #include <QtQuickTemplates2/private/qquickbutton_p.h> +#include <QtQuickTemplates2/private/qquickslider_p.h> using namespace QQuickVisualTestUtil; @@ -65,6 +66,8 @@ private slots: void activeFocusOnClose2(); void hover_data(); void hover(); + void wheel_data(); + void wheel(); void parentDestroyed(); }; @@ -514,6 +517,90 @@ void tst_popup::hover() QVERIFY(parentButton->isHovered()); } +void tst_popup::wheel_data() +{ + QTest::addColumn<QString>("source"); + QTest::addColumn<bool>("modal"); + + QTest::newRow("Window:modal") << "window-wheel.qml" << true; + QTest::newRow("Window:modeless") << "window-wheel.qml" << false; + QTest::newRow("ApplicationWindow:modal") << "applicationwindow-wheel.qml" << true; + QTest::newRow("ApplicationWindow:modeless") << "applicationwindow-wheel.qml" << false; +} + +static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees) +{ + QQuickWindow *window = item->window(); + QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), QPoint(0, 8 * degrees), 0, Qt::Vertical, Qt::NoButton, 0); + QSpontaneKeyEvent::setSpontaneous(&wheelEvent); + return qGuiApp->notify(window, &wheelEvent); +} + +void tst_popup::wheel() +{ + QFETCH(QString, source); + QFETCH(bool, modal); + + QQuickApplicationHelper helper(this, source); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickSlider *contentSlider = window->property("contentSlider").value<QQuickSlider*>(); + QVERIFY(contentSlider); + + QQuickPopup *popup = window->property("popup").value<QQuickPopup*>(); + QVERIFY(popup && popup->contentItem()); + popup->setModal(modal); + + QQuickSlider *popupSlider = window->property("popupSlider").value<QQuickSlider*>(); + QVERIFY(popupSlider); + + { + // wheel over the content + qreal oldContentValue = contentSlider->value(); + qreal oldPopupValue = popupSlider->value(); + + QVERIFY(sendWheelEvent(contentSlider, QPoint(contentSlider->width() / 2, contentSlider->height() / 2), 15)); + + QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); // must have moved + QVERIFY(qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must not have moved + } + + QSignalSpy openedSpy(popup, SIGNAL(opened())); + QVERIFY(openedSpy.isValid()); + popup->open(); + QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); + + { + // wheel over the popup content + qreal oldContentValue = contentSlider->value(); + qreal oldPopupValue = popupSlider->value(); + + QVERIFY(sendWheelEvent(popupSlider, QPoint(popupSlider->width() / 2, popupSlider->height() / 2), 15)); + + QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved + QVERIFY(!qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must have moved + } + + { + // wheel over the overlay + qreal oldContentValue = contentSlider->value(); + qreal oldPopupValue = popupSlider->value(); + + QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPoint(0, 0), 15)); + + if (modal) { + // the content below a modal overlay must not move + QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); + } else { + // the content below a modeless overlay must move + QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); + } + QVERIFY(qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must not have moved + } +} + void tst_popup::parentDestroyed() { QQuickPopup popup; |