From f74cff42a76a363d98055b2d10ea4d5b96532f2d Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Mon, 12 Aug 2019 16:05:44 +0200 Subject: Doc: Replace the "Qt Quick Controls 2" instances Now that Controls 1 is deprecated, it's ideal to use "Qt Quick Controls" instead of "Qt Quick Controls 2". Task-number: QTBUG-70333 Change-Id: Ie745db4b61071ddb5e06150d4e739cda74c59f41 Reviewed-by: Paul Wicking --- src/quicktemplates2/qquickabstractbutton.cpp | 2 +- src/quicktemplates2/qquickapplicationwindow.cpp | 2 +- src/quicktemplates2/qquickbutton.cpp | 2 +- src/quicktemplates2/qquickcombobox.cpp | 2 +- src/quicktemplates2/qquickcontrol.cpp | 4 ++-- src/quicktemplates2/qquickitemdelegate.cpp | 2 +- src/quicktemplates2/qquickmenubar.cpp | 2 +- src/quicktemplates2/qquickmenuitem.cpp | 2 +- src/quicktemplates2/qquickpage.cpp | 2 +- src/quicktemplates2/qquickpane.cpp | 2 +- src/quicktemplates2/qquickrangeslider.cpp | 2 +- src/quicktemplates2/qquickscrollview.cpp | 2 +- src/quicktemplates2/qquickspinbox.cpp | 2 +- src/quicktemplates2/qquickstackview.cpp | 2 +- src/quicktemplates2/qquickswipeview.cpp | 2 +- src/quicktemplates2/qquicktabbar.cpp | 2 +- src/quicktemplates2/qquicktoolbutton.cpp | 2 +- 17 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 0aa8ec28..983f2651 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -736,7 +736,7 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator) \include qquickicon.qdocinc grouped-properties - \sa text, display, {Icons in Qt Quick Controls 2} + \sa text, display, {Icons in Qt Quick Controls} */ QQuickIcon QQuickAbstractButton::icon() const diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index acd98470..0d05bee7 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -113,7 +113,7 @@ QT_BEGIN_NAMESPACE attached properties works in any window regardless of its \c id. \sa {Customizing ApplicationWindow}, Overlay, Page, {Container Controls}, - {Focus Management in Qt Quick Controls 2} + {Focus Management in Qt Quick Controls} */ static const QQuickItemPrivate::ChangeTypes ItemChanges = QQuickItemPrivate::Visibility diff --git a/src/quicktemplates2/qquickbutton.cpp b/src/quicktemplates2/qquickbutton.cpp index fbce5225..b4188a95 100644 --- a/src/quicktemplates2/qquickbutton.cpp +++ b/src/quicktemplates2/qquickbutton.cpp @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE \e Yes, \e No, and \e Help. Button inherits its API from AbstractButton. For instance, you can set - \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls 2}{icon}, + \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls}{icon}, and react to \l {AbstractButton::clicked}{clicks} using the AbstractButton API. A button emits the signal \l {AbstractButton::}{clicked()} when it is activated by the user. diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 0fa6298f..dd0bb905 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -134,7 +134,7 @@ QT_BEGIN_NAMESPACE \l textRole is not defined, ComboBox is unable to visualize it and throws a \c {ReferenceError: modelData is not defined}. - \sa {Customizing ComboBox}, {Input Controls}, {Focus Management in Qt Quick Controls 2} + \sa {Customizing ComboBox}, {Input Controls}, {Focus Management in Qt Quick Controls} */ /*! diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index dd954b2b..e156fb57 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -1470,9 +1470,9 @@ void QQuickControl::setHovered(bool hovered) Setting this property propagates the value to all child controls that do not have \c hoverEnabled explicitly set. - You can also enable or disable hover effects for all Qt Quick Controls 2 applications + You can also enable or disable hover effects for all Qt Quick Controls applications by setting the \c QT_QUICK_CONTROLS_HOVER_ENABLED \l {Supported Environment Variables - in Qt Quick Controls 2}{environment variable}. + in Qt Quick Controls}{environment variable}. \sa hovered */ diff --git a/src/quicktemplates2/qquickitemdelegate.cpp b/src/quicktemplates2/qquickitemdelegate.cpp index ac409118..8156ab65 100644 --- a/src/quicktemplates2/qquickitemdelegate.cpp +++ b/src/quicktemplates2/qquickitemdelegate.cpp @@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE in various views and controls, such as \l ListView and \l ComboBox. ItemDelegate inherits its API from AbstractButton. For instance, you can set - \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls 2}{icon}, + \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls}{icon}, and react to \l {AbstractButton::clicked}{clicks} using the AbstractButton API. \snippet qtquickcontrols2-itemdelegate.qml 1 diff --git a/src/quicktemplates2/qquickmenubar.cpp b/src/quicktemplates2/qquickmenubar.cpp index 6016e70d..1761d999 100644 --- a/src/quicktemplates2/qquickmenubar.cpp +++ b/src/quicktemplates2/qquickmenubar.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE menus in a menu bar can be accessed using \l menuAt(). \sa {Customizing MenuBar}, Menu, MenuBarItem, {Menu Controls}, - {Focus Management in Qt Quick Controls 2} + {Focus Management in Qt Quick Controls} */ QQuickItem *QQuickMenuBarPrivate::beginCreateItem() diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp index 22fe664a..a7fc63e8 100644 --- a/src/quicktemplates2/qquickmenuitem.cpp +++ b/src/quicktemplates2/qquickmenuitem.cpp @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE example. MenuItem inherits its API from AbstractButton. For instance, you can set - \l {AbstractButton::text}{text} and \l {Icons in Qt Quick Controls 2}{icon} + \l {AbstractButton::text}{text} and \l {Icons in Qt Quick Controls}{icon} using the AbstractButton API. \code diff --git a/src/quicktemplates2/qquickpage.cpp b/src/quicktemplates2/qquickpage.cpp index cb90ac48..78bae921 100644 --- a/src/quicktemplates2/qquickpage.cpp +++ b/src/quicktemplates2/qquickpage.cpp @@ -83,7 +83,7 @@ QT_BEGIN_NAMESPACE \endqml \sa ApplicationWindow, {Container Controls}, - {Focus Management in Qt Quick Controls 2} + {Focus Management in Qt Quick Controls} */ static const QQuickItemPrivate::ChangeTypes LayoutChanges = QQuickItemPrivate::Geometry | QQuickItemPrivate::Visibility | QQuickItemPrivate::Destroyed diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp index fd9d2cf0..18c8bd51 100644 --- a/src/quicktemplates2/qquickpane.cpp +++ b/src/quicktemplates2/qquickpane.cpp @@ -120,7 +120,7 @@ QT_BEGIN_NAMESPACE \endcode \sa {Customizing Pane}, {Container Controls}, - {Focus Management in Qt Quick Controls 2}, {Event Handling} + {Focus Management in Qt Quick Controls}, {Event Handling} */ void QQuickPanePrivate::init() diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index acf4dca3..378ece50 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE For a slider that allows the user to select a single value, see \l Slider. \sa {Customizing RangeSlider}, {Input Controls}, - {Focus Management in Qt Quick Controls 2} + {Focus Management in Qt Quick Controls} */ class QQuickRangeSliderNodePrivate : public QObjectPrivate diff --git a/src/quicktemplates2/qquickscrollview.cpp b/src/quicktemplates2/qquickscrollview.cpp index 98bd174e..70390351 100644 --- a/src/quicktemplates2/qquickscrollview.cpp +++ b/src/quicktemplates2/qquickscrollview.cpp @@ -113,7 +113,7 @@ QT_BEGIN_NAMESPACE \snippet qtquickcontrols2-scrollview-interactive.qml file \sa ScrollBar, ScrollIndicator, {Customizing ScrollView}, {Container Controls}, - {Focus Management in Qt Quick Controls 2} + {Focus Management in Qt Quick Controls} */ class QQuickScrollViewPrivate : public QQuickPanePrivate diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 274929b0..389e5c54 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -92,7 +92,7 @@ static const int AUTO_REPEAT_INTERVAL = 100; \snippet qtquickcontrols2-spinbox-double.qml 1 - \sa Tumbler, {Customizing SpinBox}, {Focus Management in Qt Quick Controls 2} + \sa Tumbler, {Customizing SpinBox}, {Focus Management in Qt Quick Controls} */ /*! diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp index 18f65127..b2a95731 100644 --- a/src/quicktemplates2/qquickstackview.cpp +++ b/src/quicktemplates2/qquickstackview.cpp @@ -373,7 +373,7 @@ QT_BEGIN_NAMESPACE \endlist \sa {Customizing StackView}, {Navigation Controls}, {Container Controls}, - {Focus Management in Qt Quick Controls 2} + {Focus Management in Qt Quick Controls} */ QQuickStackView::QQuickStackView(QQuickItem *parent) diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp index e6a88b47..3ba4f4d3 100644 --- a/src/quicktemplates2/qquickswipeview.cpp +++ b/src/quicktemplates2/qquickswipeview.cpp @@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE or using anchors for its children works as expected. \sa TabBar, PageIndicator, {Customizing SwipeView}, {Navigation Controls}, {Container Controls}, - {Focus Management in Qt Quick Controls 2} + {Focus Management in Qt Quick Controls} */ class QQuickSwipeViewPrivate : public QQuickContainerPrivate diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp index 745023c3..5a439b4b 100644 --- a/src/quicktemplates2/qquicktabbar.cpp +++ b/src/quicktemplates2/qquicktabbar.cpp @@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE \snippet qtquickcontrols2-tabbar-flickable.qml 1 \sa TabButton, {Customizing TabBar}, {Navigation Controls}, {Container Controls}, - {Focus Management in Qt Quick Controls 2} + {Focus Management in Qt Quick Controls} */ class QQuickTabBarPrivate : public QQuickContainerPrivate diff --git a/src/quicktemplates2/qquicktoolbutton.cpp b/src/quicktemplates2/qquicktoolbutton.cpp index eb70fbc4..b613e69b 100644 --- a/src/quicktemplates2/qquicktoolbutton.cpp +++ b/src/quicktemplates2/qquicktoolbutton.cpp @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE \snippet qtquickcontrols2-toolbar.qml 1 ToolButton inherits its API from AbstractButton. For instance, you can set - \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls 2}{icon}, + \l {AbstractButton::text}{text}, display an \l {Icons in Qt Quick Controls}{icon}, and react to \l {AbstractButton::clicked}{clicks} using the AbstractButton API. \sa ToolBar, {Customizing ToolButton}, {Button Controls} -- cgit v1.2.3 From 315fabdb574d9952a072ec7122266f59011c0257 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 26 Aug 2019 15:01:11 +0300 Subject: Minor typo fix Change-Id: I335e59f09c48a8b52c7f690cedba95952c5adfa3 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickoverlay_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickoverlay_p.h b/src/quicktemplates2/qquickoverlay_p.h index 0d8bccf5..1d238163 100644 --- a/src/quicktemplates2/qquickoverlay_p.h +++ b/src/quicktemplates2/qquickoverlay_p.h @@ -86,7 +86,7 @@ Q_SIGNALS: protected: void itemChange(ItemChange change, const ItemChangeData &data) override; - void geometryChanged(const QRectF &oldGeometry, const QRectF &newGeometry) override; + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; void mousePressEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; -- cgit v1.2.3 From 7ce1bdfe79d5c9aeb7202fb38b4174028ea2bf9c Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 26 Aug 2019 18:14:27 +0300 Subject: QQuickPopup: fix compiler warning > warning: unannotated fall-through between switch labels > note: insert 'break;' to avoid fall-through Change-Id: Ia70fb6b666f874a245a113d61a6cb3e8e7aa2712 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickpopup.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index dd7dede6..f0cf1869 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -2582,6 +2582,7 @@ void QQuickPopup::itemChange(QQuickItem::ItemChange change, const QQuickItem::It else d->popupItem->ungrabShortcut(); } + break; default: break; } -- cgit v1.2.3 From 616c430d2b7f36e70987df7b2dc97e71f0e8b589 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 2 May 2019 16:50:31 +0200 Subject: ComboBox: document the behavior surrounding the accepted() signal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I65be8e54ded284d2f80b5a1f301b75223bd81bb3 Fixes: QTBUG-75338 Reviewed-by: Henning Gründl Reviewed-by: Mitch Curtis Reviewed-by: Paul Wicking --- src/quicktemplates2/qquickcombobox.cpp | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 78ec7ef8..372b7905 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -90,21 +90,7 @@ QT_BEGIN_NAMESPACE The following example demonstrates appending content to an editable combo box by reacting to the \l accepted signal. - \code - ComboBox { - editable: true - model: ListModel { - id: model - ListElement { text: "Banana" } - ListElement { text: "Apple" } - ListElement { text: "Coconut" } - } - onAccepted: { - if (find(editText) === -1) - model.append({text: editText}) - } - } - \endcode + \snippet qtquickcontrols2-combobox-accepted.qml combobox \section1 ComboBox Model Roles @@ -167,9 +153,22 @@ QT_BEGIN_NAMESPACE \qmlsignal void QtQuick.Controls::ComboBox::accepted() This signal is emitted when the \uicontrol Return or \uicontrol Enter key is pressed - on an \l editable combo box. If the confirmed string is not currently in the model, - the \l currentIndex will be set to \c -1 and the \l currentText will be updated - accordingly. + on an \l editable combo box. + + You can handle this signal in order to add the newly entered + item to the model, for example: + + \snippet qtquickcontrols2-combobox-accepted.qml combobox + + Before the signal is emitted, a check is done to see if the string + exists in the model. If it does, \l currentIndex will be set to its index, + and \l currentText to the string itself. + + After the signal has been emitted, and if the first check failed (that is, + the item did not exist), another check will be done to see if the item was + added by the signal handler. If it was, the \l currentIndex and + \l currentText are updated accordingly. Otherwise, they will be set to + \c -1 and \c "", respectively. \note If there is a \l validator set on the combo box, the signal will only be emitted if the input is in an acceptable state. -- cgit v1.2.3 From 382531ab5e2270833d3805c57c00ebcf6b24d635 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 25 Apr 2019 18:23:32 +0300 Subject: QQuickIcon: properly resolve implicit values when the property has not been set explicitly, the resolved mask must not contain a respective bit set either Change-Id: Iab0bd600b5bf458e26ed4601d4d2f608021f1518 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickicon.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp index 1b8f4797..bfa2f8c1 100644 --- a/src/quicktemplates2/qquickicon.cpp +++ b/src/quicktemplates2/qquickicon.cpp @@ -204,19 +204,19 @@ QQuickIcon QQuickIcon::resolve(const QQuickIcon &other) const QQuickIcon resolved = *this; if (!(d->resolveMask & QQuickIconPrivate::NameResolved)) - resolved.setName(other.name()); + resolved.d->name = other.name(); if (!(d->resolveMask & QQuickIconPrivate::SourceResolved)) - resolved.setSource(other.source()); + resolved.d->source = other.source(); if (!(d->resolveMask & QQuickIconPrivate::WidthResolved)) - resolved.setWidth(other.width()); + resolved.d->width = other.width(); if (!(d->resolveMask & QQuickIconPrivate::HeightResolved)) - resolved.setHeight(other.height()); + resolved.d->height = other.height(); if (!(d->resolveMask & QQuickIconPrivate::ColorResolved)) - resolved.setColor(other.color()); + resolved.d->color = other.color(); return resolved; } -- cgit v1.2.3 From 0bcd8ed5c38a451e7458b820a25449c9cb408704 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 9 Sep 2019 16:10:37 +0300 Subject: QQuickIcon: properly resolve implicit values - take 2 This is a follow up of 382531ab5e2270833d3805c57c00ebcf6b24d635, and amends 1241c80eca725c9ac46a0b94d6bdec11a5d00302 . when the property has not been set explicitly, the resolved mask must not contain a respective bit set either Change-Id: I45a334b51fce09ead8e30fe3326a94f35b0f4f56 Reviewed-by: Liang Qi --- src/quicktemplates2/qquickicon.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp index 63ca96d5..61803e30 100644 --- a/src/quicktemplates2/qquickicon.cpp +++ b/src/quicktemplates2/qquickicon.cpp @@ -227,22 +227,22 @@ QQuickIcon QQuickIcon::resolve(const QQuickIcon &other) const QQuickIcon resolved = *this; if (!(d->resolveMask & QQuickIconPrivate::NameResolved)) - resolved.d->name = other.name(); + resolved.d->name = other.d->name; if (!(d->resolveMask & QQuickIconPrivate::SourceResolved)) - resolved.d->source = other.source(); + resolved.d->source = other.d->source; if (!(d->resolveMask & QQuickIconPrivate::WidthResolved)) - resolved.d->width = other.width(); + resolved.d->width = other.d->width; if (!(d->resolveMask & QQuickIconPrivate::HeightResolved)) - resolved.d->height = other.height(); + resolved.d->height = other.d->height; if (!(d->resolveMask & QQuickIconPrivate::ColorResolved)) - resolved.d->color = other.color(); + resolved.d->color = other.d->color; if (!(d->resolveMask & QQuickIconPrivate::CacheResolved)) - resolved.setCache(other.cache()); + resolved.d->cache = other.d->cache; return resolved; } -- cgit v1.2.3 From 1fec97053884d998442710a5d4258ffb6bed8955 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 25 Apr 2019 18:23:43 +0300 Subject: QQuickIcon: prevent detach-ing when there is nothing to change saves a bunch of pointless detach attempts on each deep-copy Change-Id: Ibb1ae99bd54b2d35f9c9aa9e541fb03891ad94ec Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickicon.cpp | 13 +++++++++++++ src/quicktemplates2/qquickicon_p.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickicon.cpp b/src/quicktemplates2/qquickicon.cpp index 61803e30..bf0a4658 100644 --- a/src/quicktemplates2/qquickicon.cpp +++ b/src/quicktemplates2/qquickicon.cpp @@ -112,12 +112,14 @@ void QQuickIcon::setName(const QString &name) if ((d->resolveMask & QQuickIconPrivate::NameResolved) && d->name == name) return; + d.detach(); d->name = name; d->resolveMask |= QQuickIconPrivate::NameResolved; } void QQuickIcon::resetName() { + d.detach(); d->name = QString(); d->resolveMask &= ~QQuickIconPrivate::NameResolved; } @@ -132,12 +134,14 @@ void QQuickIcon::setSource(const QUrl &source) if ((d->resolveMask & QQuickIconPrivate::SourceResolved) && d->source == source) return; + d.detach(); d->source = source; d->resolveMask |= QQuickIconPrivate::SourceResolved; } void QQuickIcon::resetSource() { + d.detach(); d->source = QString(); d->resolveMask &= ~QQuickIconPrivate::SourceResolved; } @@ -152,12 +156,14 @@ void QQuickIcon::setWidth(int width) if ((d->resolveMask & QQuickIconPrivate::WidthResolved) && d->width == width) return; + d.detach(); d->width = width; d->resolveMask |= QQuickIconPrivate::WidthResolved; } void QQuickIcon::resetWidth() { + d.detach(); d->width = 0; d->resolveMask &= ~QQuickIconPrivate::WidthResolved; } @@ -172,12 +178,14 @@ void QQuickIcon::setHeight(int height) if ((d->resolveMask & QQuickIconPrivate::HeightResolved) && d->height == height) return; + d.detach(); d->height = height; d->resolveMask |= QQuickIconPrivate::HeightResolved; } void QQuickIcon::resetHeight() { + d.detach(); d->height = 0; d->resolveMask &= ~QQuickIconPrivate::HeightResolved; } @@ -192,12 +200,14 @@ void QQuickIcon::setColor(const QColor &color) if ((d->resolveMask & QQuickIconPrivate::ColorResolved) && d->color == color) return; + d.detach(); d->color = color; d->resolveMask |= QQuickIconPrivate::ColorResolved; } void QQuickIcon::resetColor() { + d.detach(); d->color = Qt::transparent; d->resolveMask &= ~QQuickIconPrivate::ColorResolved; } @@ -212,12 +222,14 @@ void QQuickIcon::setCache(bool cache) if ((d->resolveMask & QQuickIconPrivate::CacheResolved) && d->cache == cache) return; + d.detach(); d->cache = cache; d->resolveMask |= QQuickIconPrivate::CacheResolved; } void QQuickIcon::resetCache() { + d.detach(); d->cache = true; d->resolveMask &= ~QQuickIconPrivate::CacheResolved; } @@ -225,6 +237,7 @@ void QQuickIcon::resetCache() QQuickIcon QQuickIcon::resolve(const QQuickIcon &other) const { QQuickIcon resolved = *this; + resolved.d.detach(); if (!(d->resolveMask & QQuickIconPrivate::NameResolved)) resolved.d->name = other.d->name; diff --git a/src/quicktemplates2/qquickicon_p.h b/src/quicktemplates2/qquickicon_p.h index 57cab720..1835585d 100644 --- a/src/quicktemplates2/qquickicon_p.h +++ b/src/quicktemplates2/qquickicon_p.h @@ -107,7 +107,7 @@ public: QQuickIcon resolve(const QQuickIcon &other) const; private: - QSharedDataPointer d; + QExplicitlySharedDataPointer d; }; QT_END_NAMESPACE -- cgit v1.2.3 From c18c7bd7f9596e5ad3d13876a91203e1ceba2544 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 9 Sep 2019 15:59:49 +0200 Subject: DialogButtonBox: fix standard buttons not being translated When calling QQmlEngine::retranslate() after component completion, buttons in a DialogButtonBox were not being retranslated. For now the only way to be notified of language change events is by installing an event filter on the application, but in the future we can use the solution to QTBUG-78141 instead. Change-Id: Ibc435c3829945489adcbaa8a813013fe735a9c38 Fixes: QTBUG-75085 Reviewed-by: Andy Shaw --- src/quicktemplates2/qquickdialogbuttonbox.cpp | 44 ++++++++++++++++++++++++- src/quicktemplates2/qquickdialogbuttonbox_p_p.h | 2 ++ 2 files changed, 45 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index 91fb41f2..10d80778 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -430,7 +430,8 @@ void QQuickDialogButtonBoxPrivate::removeStandardButtons() while (i >= 0) { QQuickAbstractButton *button = qobject_cast(q->itemAt(i)); if (button) { - QQuickDialogButtonBoxAttached *attached = qobject_cast(qmlAttachedPropertiesObject(button, false)); + QQuickDialogButtonBoxAttached *attached = qobject_cast( + qmlAttachedPropertiesObject(button, false)); if (attached) { QQuickDialogButtonBoxAttachedPrivate *p = QQuickDialogButtonBoxAttachedPrivate::get(attached); if (p->standardButton != QPlatformDialogHelper::NoButton) { @@ -443,6 +444,24 @@ void QQuickDialogButtonBoxPrivate::removeStandardButtons() } } +void QQuickDialogButtonBoxPrivate::updateLanguage() +{ + Q_Q(QQuickDialogButtonBox); + int i = q->count() - 1; + while (i >= 0) { + QQuickAbstractButton *button = qobject_cast(itemAt(i)); + if (button) { + QQuickDialogButtonBoxAttached *attached = qobject_cast( + qmlAttachedPropertiesObject(button, true)); + const auto boxAttachedPrivate = QQuickDialogButtonBoxAttachedPrivate::get(attached); + const QPlatformDialogHelper::StandardButton standardButton = boxAttachedPrivate->standardButton; + const QString buttonText = QGuiApplicationPrivate::platformTheme()->standardButtonText(standardButton); + button->setText(QPlatformTheme::removeMnemonics(buttonText)); + } + --i; + } +} + QQuickDialogButtonBox::QQuickDialogButtonBox(QQuickItem *parent) : QQuickContainer(*(new QQuickDialogButtonBoxPrivate), parent) { @@ -684,11 +703,34 @@ void QQuickDialogButtonBox::updatePolish() d->updateLayout(); } +class LanguageEventFilter : public QObject +{ +public: + LanguageEventFilter(QQuickDialogButtonBoxPrivate *box) + : QObject(box->q_ptr) + , boxPrivate(box) + { + } + +protected: + bool eventFilter(QObject *, QEvent *event) + { + if (event->type() == QEvent::LanguageChange) + boxPrivate->updateLanguage(); + return false; + } + +private: + QQuickDialogButtonBoxPrivate *boxPrivate; +}; + void QQuickDialogButtonBox::componentComplete() { Q_D(QQuickDialogButtonBox); QQuickContainer::componentComplete(); d->updateLayout(); + // TODO: use the solution in QTBUG-78141 instead, when it's implemented. + qApp->installEventFilter(new LanguageEventFilter(d)); } void QQuickDialogButtonBox::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) diff --git a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h index 66386911..6f9c9033 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox_p_p.h +++ b/src/quicktemplates2/qquickdialogbuttonbox_p_p.h @@ -78,6 +78,8 @@ public: QQuickAbstractButton *createStandardButton(QPlatformDialogHelper::StandardButton button); void removeStandardButtons(); + void updateLanguage(); + Qt::Alignment alignment = 0; QQuickDialogButtonBox::Position position = QQuickDialogButtonBox::Footer; QPlatformDialogHelper::StandardButtons standardButtons = QPlatformDialogHelper::NoButton; -- cgit v1.2.3 From 77e577592e64ab9b099de09c281140c60c898df7 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 12 Sep 2019 12:05:09 +0200 Subject: QQuickStackElemnt: fix compilation While QQuickStack should ideally completely support required properties, by setting them accordingly if provided in StackView.push, for now it compiles at least again. Fixes: QTBUG-78252 Change-Id: Ib8efc7a1c9f0779ca972307ca95e632f51c6ca46 Reviewed-by: Liang Qi --- src/quicktemplates2/qquickstackelement.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickstackelement.cpp b/src/quicktemplates2/qquickstackelement.cpp index 7ae5c495..4c14022a 100644 --- a/src/quicktemplates2/qquickstackelement.cpp +++ b/src/quicktemplates2/qquickstackelement.cpp @@ -44,6 +44,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -210,7 +211,12 @@ void QQuickStackElement::initialize() QV4::ScopedValue ipv(scope, properties.value()); QV4::Scoped qmlContext(scope, qmlCallingContext.value()); QV4::ScopedValue qmlObject(scope, QV4::QObjectWrapper::wrap(v4, item)); +#if Q_QML_PRIVATE_API_VERSION >= 6 + RequiredProperties requiredPropertiesCurrentlyNotSupported; + QQmlComponentPrivate::setInitialProperties(v4, qmlContext, qmlObject, ipv, requiredPropertiesCurrentlyNotSupported, item); +#else QQmlComponentPrivate::setInitialProperties(v4, qmlContext, qmlObject, ipv); +#endif properties.clear(); } -- cgit v1.2.3 From a5be4ae50c40f938ca8660296362fc06cc8273b1 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 26 Aug 2019 17:59:22 +0300 Subject: Fix timer events handling if the timer event's timerId isn't recognized, make sure control passes to the base class Change-Id: If5988dbf4ccda6a9887805961b439f93640f71ea Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickmenu.cpp | 2 ++ src/quicktemplates2/qquicktooltip.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index 82cc063f..67e2d806 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -1487,7 +1487,9 @@ void QQuickMenu::timerEvent(QTimerEvent *event) if (QQuickMenu *subMenu = d->currentSubMenu()) subMenu->open(); d->stopHoverTimer(); + return; } + QQuickPopup::timerEvent(event); } QFont QQuickMenu::defaultFont() const diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp index ddf434a2..c1271dab 100644 --- a/src/quicktemplates2/qquicktooltip.cpp +++ b/src/quicktemplates2/qquicktooltip.cpp @@ -327,10 +327,14 @@ void QQuickToolTip::timerEvent(QTimerEvent *event) if (event->timerId() == d->timeoutTimer.timerId()) { d->stopTimeout(); QQuickPopup::setVisible(false); - } else if (event->timerId() == d->delayTimer.timerId()) { + return; + } + if (event->timerId() == d->delayTimer.timerId()) { d->stopDelay(); QQuickPopup::setVisible(true); + return; } + QQuickPopup::timerEvent(event); } #if QT_CONFIG(accessibility) -- cgit v1.2.3 From 44a522445c94583e8d8502b9da3de217b6f075d5 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 26 Aug 2019 18:17:20 +0300 Subject: QQuickOverlay: micro optimization for disabled multitouch support avoid checking every press event to be one of touch events type when touch events are not delivered at all Change-Id: I1ed91fa124608d8a006cf2f5256ad68294dd465f Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickoverlay.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index cf72c8a6..3f358706 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -126,11 +126,6 @@ bool QQuickOverlayPrivate::startDrag(QEvent *event, const QPointF &pos) return false; } -static bool isTouchEvent(QEvent *event) -{ - return event->type() == QEvent::TouchBegin || event->type() == QEvent::TouchUpdate || event->type() == QEvent::TouchEnd; -} - bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuickPopup *target) { if (target) { @@ -139,7 +134,18 @@ bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuick return true; } return false; - } else if (!mouseGrabberPopup || isTouchEvent(event)) { + } + + switch (event->type()) { + default: { + if (mouseGrabberPopup) + break; +#if QT_CONFIG(quicktemplates2_multitouch) + Q_FALLTHROUGH(); + case QEvent::TouchBegin: + case QEvent::TouchUpdate: + case QEvent::TouchEnd: +#endif // allow non-modal popups to close themselves, // and non-dimming modal popups to block the event const auto popups = stackingOrderPopups(); @@ -149,6 +155,8 @@ bool QQuickOverlayPrivate::handlePress(QQuickItem *source, QEvent *event, QQuick return true; } } + break; + } } event->ignore(); -- cgit v1.2.3 From d41362ed752031fdd798e4838b3a56fbb2717f3f Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 11 Sep 2019 20:54:25 +0300 Subject: TextArea: correctly resize background when there is no flickable Change-Id: Idaf385d12ca9388c0bb0b3f8a47c8e75c620b7eb Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktextarea.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 95bf5bb1..e24844d8 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -369,6 +369,8 @@ void QQuickTextAreaPrivate::detachFlickable() QObjectPrivate::disconnect(flickable, &QQuickFlickable::contentHeightChanged, this, &QQuickTextAreaPrivate::resizeFlickableControl); flickable = nullptr; + + resizeBackground(); } void QQuickTextAreaPrivate::ensureCursorVisible() @@ -437,7 +439,10 @@ void QQuickTextAreaPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometry Q_UNUSED(change); Q_UNUSED(diff); - resizeFlickableControl(); + if (flickable) + resizeFlickableControl(); + else + resizeBackground(); } qreal QQuickTextAreaPrivate::getImplicitWidth() const -- cgit v1.2.3 From a89c3bc67ea6c76bfc89d64f235ebf5cb4b0fca4 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 11 Sep 2019 16:39:47 +0000 Subject: Revert "QQuickTextArea: prevent changing size of background recursively" This reverts commit da06da57002b64cf4bcde0ca708b3275a5f919ae. Reason for revert: the change removes symptoms leaving a cause unfixed Change-Id: I0a91409230c521da73ed53e2a00a4ccd8dca7335 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktextarea.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index e24844d8..7fdc8f0a 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -517,11 +517,8 @@ void QQuickTextAreaPrivate::executeBackground(bool complete) if (!background || complete) quickBeginDeferred(q, backgroundName(), background); - if (complete) { + if (complete) quickCompleteDeferred(q, backgroundName(), background); - if (background) - QQuickControlPrivate::addImplicitSizeListener(background, this, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); - } } void QQuickTextAreaPrivate::itemImplicitWidthChanged(QQuickItem *item) @@ -641,10 +638,9 @@ void QQuickTextArea::setBackground(QQuickItem *background) d->extra.value().hasBackgroundWidth = p->widthValid; d->extra.value().hasBackgroundHeight = p->heightValid; } - if (isComponentComplete()) { + if (isComponentComplete()) d->resizeBackground(); - QQuickControlPrivate::addImplicitSizeListener(background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); - } + QQuickControlPrivate::addImplicitSizeListener(background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); } if (!qFuzzyCompare(oldImplicitBackgroundWidth, implicitBackgroundWidth())) -- cgit v1.2.3 From 6815f353e5a73c0dcf39fbfc91c6a2c1b0784324 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 11 Sep 2019 21:54:53 +0300 Subject: TextArea: prevent changing size of background recursively When the x/y position of background depends on the height/width of background and these values are not constant, the if statement in the method resizeBackground() will always pass. And since `resizingBackground` guard wasn't checked, any geometry change will always call resizeBackground() and then call themself recursively (via the change listener), that means the height/width of background will always be reset, no matter what value you set. Another part of the issue was in determining the extra bits too late: in case the background gets parented by the flickable, the new child caused the flickable to re-calculate its metrics and thus resize the background *prior* to remembering if it has w/h set. As a side effect, this fix also brings the possibility to reset previously set w/h to get the default background sizing behavior. Inspired by da06da57002b64cf4bcde0ca708b3275a5f919ae [ChangeLog][QtQuick][QQuickTextArea] prevent changing size of background recursively in construction Fixes: QTBUG-76369 Change-Id: Ide51ec1ebab63605ae3bfcc10a76a28be960ef36 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktextarea.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 7fdc8f0a..f7b8969c 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -435,9 +435,16 @@ void QQuickTextAreaPrivate::resizeFlickableContent() void QQuickTextAreaPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) { - Q_UNUSED(item); - Q_UNUSED(change); Q_UNUSED(diff); + if (!resizingBackground && item == background) { + QQuickItemPrivate *p = QQuickItemPrivate::get(item); + // Only set hasBackgroundWidth/Height if it was a width/height change, + // otherwise we're prevented from setting a width/height in the future. + if (change.widthChange()) + extra.value().hasBackgroundWidth = p->widthValid; + if (change.heightChange()) + extra.value().hasBackgroundHeight = p->heightValid; + } if (flickable) resizeFlickableControl(); @@ -627,17 +634,17 @@ void QQuickTextArea::setBackground(QQuickItem *background) d->background = background; if (background) { + QQuickItemPrivate *p = QQuickItemPrivate::get(background); + if (p->widthValid || p->heightValid) { + d->extra.value().hasBackgroundWidth = p->widthValid; + d->extra.value().hasBackgroundHeight = p->heightValid; + } if (d->flickable) background->setParentItem(d->flickable); else background->setParentItem(this); if (qFuzzyIsNull(background->z())) background->setZ(-1); - QQuickItemPrivate *p = QQuickItemPrivate::get(background); - if (p->widthValid || p->heightValid) { - d->extra.value().hasBackgroundWidth = p->widthValid; - d->extra.value().hasBackgroundHeight = p->heightValid; - } if (isComponentComplete()) d->resizeBackground(); QQuickControlPrivate::addImplicitSizeListener(background, d, QQuickControlPrivate::ImplicitSizeChanges | QQuickItemPrivate::Geometry); -- cgit v1.2.3 From 2275541b52a8879cd8c7bf281b385738e5a664fe Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 9 Sep 2019 11:02:59 +0200 Subject: Doc: clarify autoRepeat/pressAndHold() behavior Change-Id: Ia0dea6060be7ffd1c4a16348f166e7cde7ef2df2 Reviewed-by: Paul Wicking --- src/quicktemplates2/qquickabstractbutton.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 983f2651..2099f2db 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -105,6 +105,7 @@ QT_BEGIN_NAMESPACE \qmlsignal QtQuick.Controls::AbstractButton::pressAndHold() This signal is emitted when the button is interactively pressed and held down by the user via touch or mouse. + It is not emitted when \l autoRepeat is enabled. */ /*! @@ -658,6 +659,9 @@ void QQuickAbstractButton::setAutoExclusive(bool exclusive) This property holds whether the button repeats \l pressed(), \l released() and \l clicked() signals while the button is pressed and held down. + If this property is set to \c true, the \l pressAndHold() signal will not + be emitted. + The default value is \c false. The initial delay and the repetition interval are defined in milliseconds -- cgit v1.2.3 From d39a6d80f63414a4e933ac2f859805635850942a Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 24 Sep 2019 10:09:12 +0200 Subject: Tumbler: fix displacement calculation when wrap is false Use the position of the item and the currentItem in the calculation in order to get reliable results. This fixes the displacement being off by a small margin, which increased as the delegate height became smaller. Fixes: QTBUG-66799 Change-Id: Ieca5033fb4c0ed62f5965a21fcab7aa558bd40e6 Reviewed-by: Andy Shaw Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktumbler.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp index 8b702c60..85c70b1b 100644 --- a/src/quicktemplates2/qquicktumbler.cpp +++ b/src/quicktemplates2/qquicktumbler.cpp @@ -949,9 +949,20 @@ void QQuickTumblerAttachedPrivate::calculateDisplacement() const qreal contentY = tumblerPrivate->viewContentY; const qreal delegateH = delegateHeight(tumbler); const qreal preferredHighlightBegin = tumblerPrivate->view->property("preferredHighlightBegin").toReal(); - // Tumbler's displacement goes from negative at the top to positive towards the bottom, so we must switch this around. - const qreal reverseDisplacement = (contentY + preferredHighlightBegin) / delegateH; - displacement = reverseDisplacement - index; + const qreal itemY = qobject_cast(parent)->y(); + qreal currentItemY = 0; + auto currentItem = tumblerPrivate->view->property("currentItem").value(); + if (currentItem) + currentItemY = currentItem->y(); + // Start from the y position of the current item. + const qreal topOfCurrentItemInViewport = currentItemY - contentY; + // Then, calculate the distance between it and the preferredHighlightBegin. + const qreal relativePositionToPreferredHighlightBegin = topOfCurrentItemInViewport - preferredHighlightBegin; + // Next, calculate the distance between us and the current item. + const qreal distanceFromCurrentItem = currentItemY - itemY; + const qreal displacementInPixels = distanceFromCurrentItem - relativePositionToPreferredHighlightBegin; + // Convert it from pixels to a floating point index. + displacement = displacementInPixels / delegateH; } emitIfDisplacementChanged(previousDisplacement, displacement); -- cgit v1.2.3 From 100550dd22dc8eaa47405cdb3e7e461edb01a7a3 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 26 Aug 2019 17:56:43 +0300 Subject: QQuickToolTip: fix setTimeout() behavior when tool tip is visible by applying the passed timeout value prior to re-starting the timer Change-Id: I27953dbb4781b5cb0c2039d56faa56f3c000206f Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquicktooltip.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquicktooltip.cpp b/src/quicktemplates2/qquicktooltip.cpp index c1271dab..0a36e0c7 100644 --- a/src/quicktemplates2/qquicktooltip.cpp +++ b/src/quicktemplates2/qquicktooltip.cpp @@ -238,12 +238,13 @@ void QQuickToolTip::setTimeout(int timeout) if (d->timeout == timeout) return; + d->timeout = timeout; + if (timeout <= 0) d->stopTimeout(); else if (isVisible()) d->startTimeout(); - d->timeout = timeout; emit timeoutChanged(); } -- cgit v1.2.3 From 83fbf44b980c4a072ede122f2f16921bfff8c08d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 23 Sep 2019 13:42:03 +0200 Subject: Fix a crash on exit when using ToolTip in a specific item hierarchy QQuickPopup connects its parent item's (MouseArea, in this case) windowChanged() signal to QQuickPopupPrivate::setWindow(). It does this so that: 1) QQuickOverlay can keep track of all of the popups that it manages. 2) Fonts, palettes and locales can be resolved. 3) If the QQuickPopup component has completed loading and the popup is visible with a valid window, start the enter transition. The problem arises only when using a very specific item hierarchy: Window { width: 640 height: 480 visible: true Item { anchors.fill: parent Item { anchors.fill: parent ColorOverlay { source: parent anchors.fill: parent } MouseArea { anchors.fill: parent hoverEnabled: true ToolTip.visible: containsMouse ToolTip.text: "ToolTip text" } } } } When the window is closed and hence begins to be destroyed, the following events occur: - QQuickWindow's destructor is called. - The window's root item (QQuickRootItem) begins destruction. - QQuickOverlay is destroyed. - QQuickWindow's destructor is done, so the QWindow and then QObject destructors are called. - The QQuickItem destructor for the outer Item is called. - The child items of the outer Item have setParentItem(nullptr) called on them, one of which being the inner Item. - The inner Item's setParentItem() function calls derefWindow(), which in turn calls derefWindow() on its children. One of those children is MouseArea. - Since the MouseArea's window is deref'd, it emits the windowChanged() signal. MouseArea is the parentItem of the popup, so its windowChanged() signal causes QQuickPopupPrivate::setWindow() to be called. - setWindow() tries to remove the popup from the old overlay, which has already been destroyed. One approach I tried involved using QQuickOverlay::itemChange() to remove all of the popups (via setWindow(nullptr), to ensure that their window pointer is nullified), since that was called much earlier than the windowChanged() signal is emitted. However, this still resulted in a heap-use-after-free in the same place when running the newly added setOverlayParentToNull() test. I also tried removing the popups in QQuickOverlay's destructor, but this resulted in another heap-use-after-free (when accessing a popup in the destructor) in tst_QQuickPopup::Universal::visible(). The remaining options were: store the window in a QPointer or return early in overlay() if the wasDeleted member of the window was true. Using QPointer seems like it would catch more issues than a single check in overlay(), so I went with that. Fixes: QTBUG-73243 Change-Id: Ieb5ce26dd76d45771d28297031ec43e27d958b5b Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickpopup_p_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickpopup_p_p.h b/src/quicktemplates2/qquickpopup_p_p.h index e32fdb28..8a85f914 100644 --- a/src/quicktemplates2/qquickpopup_p_p.h +++ b/src/quicktemplates2/qquickpopup_p_p.h @@ -187,7 +187,7 @@ public: QQuickPopup::ClosePolicy closePolicy = DefaultClosePolicy; QQuickItem *parentItem = nullptr; QQuickItem *dimmer = nullptr; - QQuickWindow *window = nullptr; + QPointer window; QQuickTransition *enter = nullptr; QQuickTransition *exit = nullptr; QQuickPopupItem *popupItem = nullptr; -- cgit v1.2.3 From b321adcf7591d2c011a8ddc34758543b44f6afbf Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 30 Sep 2019 09:50:15 +0200 Subject: ComboBox: add missing revisions These were forgotten in f462312365d4955fc82b247b72f84e1c77d8104d. Change-Id: If0415c9aab9555e14ee222aaa667ca1233ab4405 Reviewed-by: Ulf Hermann --- src/quicktemplates2/qquickcombobox_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickcombobox_p.h b/src/quicktemplates2/qquickcombobox_p.h index a55541d4..c9063d6a 100644 --- a/src/quicktemplates2/qquickcombobox_p.h +++ b/src/quicktemplates2/qquickcombobox_p.h @@ -163,8 +163,8 @@ public: // 2.14 (Qt 5.14) QVariant currentValue() const; - Q_INVOKABLE QVariant valueAt(int index) const; - Q_INVOKABLE int indexOfValue(const QVariant &value) const; + Q_REVISION(14) Q_INVOKABLE QVariant valueAt(int index) const; + Q_REVISION(14) Q_INVOKABLE int indexOfValue(const QVariant &value) const; public Q_SLOTS: void incrementCurrentIndex(); -- cgit v1.2.3 From a392194a575653dff3cd21227e6a1a2902b8399f Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 4 Sep 2019 14:19:48 +0200 Subject: ComboBox: fix performance regression f4623123 introduced a performance regression by calling delegateModel->object() twice: if (componentComplete) { updateCurrentText(); updateCurrentValue(); } We can avoid this by introducing versions of these functions that take the delegate model object as a parameter in order to cache it between calls. Change-Id: I5f9041a8ff00b53e04d759f38677bd87c748f8d1 Fixes: QTBUG-76029 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickcombobox.cpp | 119 ++++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 24 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 60526a0a..21eecfe1 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -43,6 +43,7 @@ #include #include +#include #include #include #include @@ -231,6 +232,13 @@ public: void updateEditText(); void updateCurrentText(); void updateCurrentValue(); + void updateCurrentText(bool hasDelegateModelObject); + void updateCurrentValue(bool hasDelegateModelObject); + void updateCurrentTextAndValue(); + + bool isValidIndex(int index) const; + QString fastTextAt(int index) const; + QVariant fastValueAt(int index) const; void acceptInput(); QString tryComplete(const QString &inputText); @@ -433,10 +441,34 @@ void QQuickComboBoxPrivate::updateEditText() q->setEditText(text); } +// We have these two rather than just using default arguments +// because QObjectPrivate::connect() doesn't accept lambdas. void QQuickComboBoxPrivate::updateCurrentText() +{ + updateCurrentText(false); +} + +void QQuickComboBoxPrivate::updateCurrentValue() +{ + updateCurrentValue(false); +} + +void QQuickComboBoxPrivate::updateCurrentText(bool hasDelegateModelObject) { Q_Q(QQuickComboBox); - QString text = q->textAt(currentIndex); + QString text; + // If a delegate model object was passed in, it means the calling code + // has decided to reuse it for several function calls to speed things up. + // So, use the faster (private) version in that case. + // For other cases, we use the version that creates the delegate model object + // itself in order to have neater, more convenient calling code. + if (isValidIndex(currentIndex)) { + if (hasDelegateModelObject) + text = fastTextAt(currentIndex); + else + text = q->textAt(currentIndex); + } + if (currentText != text) { currentText = text; if (!hasDisplayText) @@ -451,10 +483,19 @@ void QQuickComboBoxPrivate::updateCurrentText() q->setEditText(currentText); } -void QQuickComboBoxPrivate::updateCurrentValue() +void QQuickComboBoxPrivate::updateCurrentValue(bool hasDelegateModelObject) { Q_Q(QQuickComboBox); - const QVariant value = q->valueAt(currentIndex); + QVariant value; + // If a delegate model object was passed in, it means the calling code + // has decided to reuse it for several function calls to speed things up. + // So, use the faster (private) version in that case. + if (isValidIndex(currentIndex)) { + if (hasDelegateModelObject) + value = fastValueAt(currentIndex); + else + value = q->valueAt(currentIndex); + } if (currentValue == value) return; @@ -462,6 +503,38 @@ void QQuickComboBoxPrivate::updateCurrentValue() emit q->currentValueChanged(); } +void QQuickComboBoxPrivate::updateCurrentTextAndValue() +{ + QObject *object = nullptr; + // For performance reasons, we reuse the same delegate model object: QTBUG-76029. + if (isValidIndex(currentIndex)) + object = delegateModel->object(currentIndex); + const bool hasDelegateModelObject = object != nullptr; + updateCurrentText(hasDelegateModelObject); + updateCurrentValue(hasDelegateModelObject); + if (object) + delegateModel->release(object); +} + +bool QQuickComboBoxPrivate::isValidIndex(int index) const +{ + return delegateModel && index >= 0 && index < delegateModel->count(); +} + +// For performance reasons (QTBUG-76029), both this and valueAt assume that +// the index is valid and delegateModel->object(index) has been called. +QString QQuickComboBoxPrivate::fastTextAt(int index) const +{ + const QString effectiveTextRole = textRole.isEmpty() ? QStringLiteral("modelData") : textRole; + return delegateModel->stringValue(index, effectiveTextRole); +} + +QVariant QQuickComboBoxPrivate::fastValueAt(int index) const +{ + const QString effectiveValueRole = valueRole.isEmpty() ? QStringLiteral("modelData") : valueRole; + return delegateModel->variantValue(index, effectiveValueRole); +} + void QQuickComboBoxPrivate::acceptInput() { Q_Q(QQuickComboBox); @@ -508,10 +581,8 @@ void QQuickComboBoxPrivate::setCurrentIndex(int index, Activation activate) currentIndex = index; emit q->currentIndexChanged(); - if (componentComplete) { - updateCurrentText(); - updateCurrentValue(); - } + if (componentComplete) + updateCurrentTextAndValue(); if (activate) emit q->activated(index); @@ -832,10 +903,14 @@ void QQuickComboBox::setModel(const QVariant& m) if (d->model == model) return; - if (QAbstractItemModel* aim = qvariant_cast(d->model)) - QObjectPrivate::disconnect(aim, &QAbstractItemModel::dataChanged, d, &QQuickComboBoxPrivate::updateCurrentText); - if (QAbstractItemModel* aim = qvariant_cast(model)) - QObjectPrivate::connect(aim, &QAbstractItemModel::dataChanged, d, &QQuickComboBoxPrivate::updateCurrentText); + if (QAbstractItemModel* aim = qvariant_cast(d->model)) { + QObjectPrivate::disconnect(aim, &QAbstractItemModel::dataChanged, + d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentText)); + } + if (QAbstractItemModel* aim = qvariant_cast(model)) { + QObjectPrivate::connect(aim, &QAbstractItemModel::dataChanged, + d, QOverload<>::of(&QQuickComboBoxPrivate::updateCurrentText)); + } d->model = model; d->createDelegateModel(); @@ -1505,15 +1580,13 @@ QVariant QQuickComboBox::currentValue() const QVariant QQuickComboBox::valueAt(int index) const { Q_D(const QQuickComboBox); - if (!d->delegateModel || index < 0 || index >= d->delegateModel->count()) + if (!d->isValidIndex(index)) return QVariant(); - // We use QVariant because the model API uses QVariant. - QVariant value; QObject *object = d->delegateModel->object(index); + QVariant value; if (object) { - const QString role = d->valueRole.isEmpty() ? QStringLiteral("modelData") : d->valueRole; - value = d->delegateModel->variantValue(index, role); + value = d->fastValueAt(index); d->delegateModel->release(object); } return value; @@ -1550,13 +1623,13 @@ int QQuickComboBox::indexOfValue(const QVariant &value) const QString QQuickComboBox::textAt(int index) const { Q_D(const QQuickComboBox); - if (!d->delegateModel || index < 0 || index >= d->delegateModel->count()) + if (!d->isValidIndex(index)) return QString(); - QString text; QObject *object = d->delegateModel->object(index); + QString text; if (object) { - text = d->delegateModel->stringValue(index, d->textRole.isEmpty() ? QStringLiteral("modelData") : d->textRole); + text = d->fastTextAt(index); d->delegateModel->release(object); } return text; @@ -1823,12 +1896,10 @@ void QQuickComboBox::componentComplete() static_cast(d->delegateModel)->componentComplete(); if (count() > 0) { - if (!d->hasCurrentIndex && d->currentIndex == -1) { + if (!d->hasCurrentIndex && d->currentIndex == -1) setCurrentIndex(0); - } else { - d->updateCurrentText(); - d->updateCurrentValue(); - } + else + d->updateCurrentTextAndValue(); } } -- cgit v1.2.3