From 2da5559cc43a3d8bdf49f634ed8add4e929aaa03 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 2 May 2019 15:49:19 +0200 Subject: Doc: fix currentText link, add more \sa links Change-Id: Ibde952a165c9e0fb40133ce554e90ba35c93feee Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickcombobox.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 328797b8..78ec7ef8 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -168,7 +168,7 @@ QT_BEGIN_NAMESPACE 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 \c currentText will be updated + the \l currentIndex will be set to \c -1 and the \l currentText will be updated accordingly. \note If there is a \l validator set on the combo box, the signal will only be @@ -923,7 +923,7 @@ void QQuickComboBox::setCurrentIndex(int index) This property holds the text of the current item in the combo box. - \sa currentIndex, displayText, textRole + \sa currentIndex, displayText, textRole, editText */ QString QQuickComboBox::currentText() const { @@ -1266,7 +1266,7 @@ void QQuickComboBox::setEditable(bool editable) This property holds the text in the text field of an editable combo box. - \sa editable + \sa editable, currentText, displayText */ QString QQuickComboBox::editText() const { -- cgit v1.2.3 From 51f6c17ff2b5b6ce23d115e1871fea7d8350a049 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 25 Mar 2019 11:02:16 +0100 Subject: Doc: bindings to x/y/width/height of contentItem aren't respected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idecee26bcae178ed294c062819f55e12a65af37d Reviewed-by: Henning Gründl Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickcontrol.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index a61df3ca..dd954b2b 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -1626,8 +1626,9 @@ void QQuickControl::setBackground(QQuickItem *background) } \endcode - \note The content item is automatically resized to fit within the - \l padding of the control. + \note The content item is automatically positioned and resized to fit + within the \l padding of the control. Bindings to the \l x, \l y, \l width, + and \l height properties of the contentItem are not respected. \note Most controls use the implicit size of the content item to calculate the implicit size of the control itself. If you replace the content item -- cgit v1.2.3 From 0525d640cd11ddced2ec418be182c585204fc45f Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 12 Apr 2019 15:21:42 +0200 Subject: Fix MenuItem width not matching Menu's available width Short version: There are currently two problems with MenuItems: - Mirrored MenuItems don't fill the Menu's available width. - MenuItem does not fill the Menu's available width when changed after Component completion. This patch fixes both of them by listening to geometry changes in both the contentItem and individual menu items, and setting the explicit width of those menu items when either changes. Longer version: The first problem can be seen whenever the MenuItem's implicitWidth changes: - QQmlEngine::retranslate() is called, causing all bindings to be re-evaluated - The MenuItem's font size changes - The MenuItem's icon size changes - etc. We fix this by making Menu listen to the width of each of its MenuItems and call resizeItem() if it doesn't have an explicit width. The second problem can be seen when e.g. resizing a Menu to account for new items that are wider and hence require more space. This can be fixed by listening to width changes in Menu's contentItem, which was actually done in earlier versions but (probably accidentally) removed in 482ecb0f. I had tried to solve both issues by setting the explicit width of MenuItem to the width of its Menu, or undefined if it has none (which means it reverts to its implicit width). However, this does not account for e.g. MenuSeparator and custom items that can be added to Menu - they should also have their width fill the Menu automatically if they don't have an explicit width set. Change-Id: I95dd0da0919a1e297f2e2030da746ff1f1a17644 Fixes: QTBUG-75051 Fixes: QTBUG-75142 Reviewed-by: Richard Moe Gustavsen --- src/quicktemplates2/qquickmenu.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp index f91d15a5..aa44e845 100644 --- a/src/quicktemplates2/qquickmenu.cpp +++ b/src/quicktemplates2/qquickmenu.cpp @@ -213,6 +213,7 @@ void QQuickMenuPrivate::insertItem(int index, QQuickItem *item) if (complete) resizeItem(item); QQuickItemPrivate::get(item)->addItemChangeListener(this, QQuickItemPrivate::Destroyed | QQuickItemPrivate::Parent); + QQuickItemPrivate::get(item)->updateOrAddGeometryChangeListener(this, QQuickGeometryChange::Width); contentModel->insert(index, item); QQuickMenuItem *menuItem = qobject_cast(item); @@ -237,6 +238,7 @@ void QQuickMenuPrivate::removeItem(int index, QQuickItem *item) contentData.removeOne(item); QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Destroyed | QQuickItemPrivate::Parent); + QQuickItemPrivate::get(item)->removeItemChangeListener(this, QQuickItemPrivate::Geometry); item->setParentItem(nullptr); contentModel->remove(index); @@ -358,10 +360,20 @@ void QQuickMenuPrivate::itemDestroyed(QQuickItem *item) removeItem(index, item); } -void QQuickMenuPrivate::itemGeometryChanged(QQuickItem *, QQuickGeometryChange, const QRectF &) +void QQuickMenuPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange, const QRectF &) { - if (complete) + if (!complete) + return; + + if (item == contentItem) { + // The contentItem's geometry changed, so resize any items + // that don't have explicit widths set so that they fill the width of the menu. resizeItems(); + } else { + // The geometry of an item in the menu changed. If the item + // doesn't have an explicit width set, make it fill the width of the menu. + resizeItem(item); + } } QQuickPopupPositioner *QQuickMenuPrivate::getPositioner() @@ -1382,10 +1394,14 @@ void QQuickMenu::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) Q_D(QQuickMenu); QQuickPopup::contentItemChange(newItem, oldItem); - if (oldItem) + if (oldItem) { QQuickItemPrivate::get(oldItem)->removeItemChangeListener(d, QQuickItemPrivate::Children); - if (newItem) + QQuickItemPrivate::get(oldItem)->removeItemChangeListener(d, QQuickItemPrivate::Geometry); + } + if (newItem) { QQuickItemPrivate::get(newItem)->addItemChangeListener(d, QQuickItemPrivate::Children); + QQuickItemPrivate::get(newItem)->updateOrAddGeometryChangeListener(d, QQuickGeometryChange::Width); + } d->contentItem = newItem; } -- cgit v1.2.3