aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicklayouts/qquicklinearlayout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicklayouts/qquicklinearlayout.cpp')
-rw-r--r--src/quicklayouts/qquicklinearlayout.cpp159
1 files changed, 127 insertions, 32 deletions
diff --git a/src/quicklayouts/qquicklinearlayout.cpp b/src/quicklayouts/qquicklinearlayout.cpp
index c7beb6045e..41f45259ea 100644
--- a/src/quicklayouts/qquicklinearlayout.cpp
+++ b/src/quicklayouts/qquicklinearlayout.cpp
@@ -247,10 +247,8 @@ QSizeF QQuickGridLayoutBase::sizeHint(Qt::SizeHint whichSizeHint) const
Possible values:
- \list
- \li Qt.LeftToRight (default) - Items are laid out from left to right.
- \li Qt.RightToLeft - Items are laid out from right to left.
- \endlist
+ \value Qt.LeftToRight (default) Items are laid out from left to right.
+ \value Qt.RightToLeft Items are laid out from right to left.
\sa RowLayout::layoutDirection, ColumnLayout::layoutDirection
*/
@@ -363,26 +361,24 @@ void QQuickGridLayoutBase::invalidate(QQuickItem *childItem)
if (!isReady())
return;
qCDebug(lcQuickLayouts) << "QQuickGridLayoutBase::invalidate()" << this << ", invalidated:" << invalidated();
- if (invalidated()) {
- return;
- }
- qCDebug(lcQuickLayouts) << "d->m_rearranging:" << d->m_rearranging;
- if (d->m_rearranging) {
- d->m_invalidateAfterRearrange << childItem;
- return;
- }
-
if (childItem) {
- if (QQuickGridLayoutItem *layoutItem = d->engine.findLayoutItem(childItem))
+ if (d->m_rearranging) {
+ if (!d->m_invalidateAfterRearrange.contains(childItem))
+ d->m_invalidateAfterRearrange << childItem;
+ return;
+ }
+ if (QQuickGridLayoutItem *layoutItem = d->engine.findLayoutItem(childItem)) {
layoutItem->invalidate();
+ }
}
+
// invalidate engine
d->engine.invalidate();
qCDebug(lcQuickLayouts) << "calling QQuickLayout::invalidate();";
QQuickLayout::invalidate();
- if (QQuickLayout *parentLayout = qobject_cast<QQuickLayout *>(parentItem()))
+ if (auto *parentLayout = qobject_cast<QQuickLayout *>(parentItem()))
parentLayout->invalidate(this);
qCDebug(lcQuickLayouts) << "QQuickGridLayoutBase::invalidate() LEAVING" << this;
}
@@ -445,7 +441,7 @@ void QQuickGridLayoutBase::itemVisibilityChanged(QQuickItem *item)
void QQuickGridLayoutBase::rearrange(const QSizeF &size)
{
Q_D(QQuickGridLayoutBase);
- if (!isReady())
+ if (!isReady() || !size.isValid())
return;
qCDebug(lcQuickLayouts) << "QQuickGridLayoutBase::rearrange" << d->m_recurRearrangeCounter << this;
@@ -459,6 +455,10 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size)
return;
}
+ // Should normally not be needed, but there might be an incoming window resize event that we
+ // will process before we process updatePolish()
+ ensureLayoutItemsUpdated(QQuickLayout::ApplySizeHints | QQuickLayout::Recursive);
+
d->m_rearranging = true;
qCDebug(lcQuickLayouts) << objectName() << "QQuickGridLayoutBase::rearrange()" << size;
Qt::LayoutDirection visualDir = effectiveLayoutDirection();
@@ -477,8 +477,8 @@ void QQuickGridLayoutBase::rearrange(const QSizeF &size)
d->engine.setGeometries(QRectF(QPointF(0,0), size), d->styleInfo);
d->m_rearranging = false;
- for (QQuickItem *invalid : std::as_const(d->m_invalidateAfterRearrange))
- invalidate(invalid);
+ for (auto childItem : std::as_const(d->m_invalidateAfterRearrange))
+ invalidate(childItem);
d->m_invalidateAfterRearrange.clear();
}
@@ -595,12 +595,10 @@ void QQuickGridLayout::setRows(int rows)
Possible values are:
- \list
- \li GridLayout.LeftToRight (default) - Items are positioned next to
- each other, then wrapped to the next line.
- \li GridLayout.TopToBottom - Items are positioned next to each
- other from top to bottom, then wrapped to the next column.
- \endlist
+ \value GridLayout.LeftToRight
+ (default) Items are positioned next to each other, then wrapped to the next line.
+ \value GridLayout.TopToBottom
+ Items are positioned next to each other from top to bottom, then wrapped to the next column.
\sa rows
\sa columns
@@ -622,6 +620,69 @@ void QQuickGridLayout::setFlow(QQuickGridLayout::Flow flow)
emit flowChanged();
}
+/*!
+ \qmlproperty bool GridLayout::uniformCellWidths
+ \since QtQuick.Layouts 6.6
+
+ If this property is set to \c true, the layout will force all cells to have
+ a uniform width. The layout aims to respect
+ \l{Layout::minimumWidth}{Layout.minimumWidth},
+ \l{Layout::preferredWidth}{Layout.preferredWidth} and
+ \l{Layout::maximumWidth}{Layout.maximumWidth} in this mode but might make
+ compromisses to fullfill the requirements of all items.
+
+ Default value is \c false.
+
+ \sa GridLayout::uniformCellHeights, RowLayout::uniformCellSizes, ColumnLayout::uniformCellSizes
+*/
+bool QQuickGridLayout::uniformCellWidths() const
+{
+ Q_D(const QQuickGridLayout);
+ return d->engine.uniformCellWidths();
+}
+
+void QQuickGridLayout::setUniformCellWidths(bool uniformCellWidths)
+{
+ Q_D(QQuickGridLayout);
+ if (d->engine.uniformCellWidths() == uniformCellWidths)
+ return;
+ d->engine.setUniformCellWidths(uniformCellWidths);
+ invalidate();
+ emit uniformCellWidthsChanged();
+}
+
+/*!
+ \qmlproperty bool GridLayout::uniformCellHeights
+ \since QtQuick.Layouts 6.6
+
+ If this property is set to \c true, the layout will force all cells to have an
+ uniform Height. The layout aims to respect
+ \l{Layout::minimumHeight}{Layout.minimumHeight},
+ \l{Layout::preferredHeight}{Layout.preferredHeight} and
+ \l{Layout::maximumHeight}{Layout.maximumHeight} in this mode but might make
+ compromisses to fullfill the requirements of all items.
+
+ Default value is \c false.
+
+ \sa GridLayout::uniformCellWidths, RowLayout::uniformCellSizes, ColumnLayout::uniformCellSizes
+*/
+bool QQuickGridLayout::uniformCellHeights() const
+{
+ Q_D(const QQuickGridLayout);
+ return d->engine.uniformCellHeights();
+}
+
+void QQuickGridLayout::setUniformCellHeights(bool uniformCellHeights)
+{
+ Q_D(QQuickGridLayout);
+ if (d->engine.uniformCellHeights() == uniformCellHeights)
+ return;
+ d->engine.setUniformCellHeights(uniformCellHeights);
+ invalidate();
+ emit uniformCellHeightsChanged();
+}
+
+
void QQuickGridLayout::insertLayoutItems()
{
Q_D(QQuickGridLayout);
@@ -750,6 +811,7 @@ void QQuickGridLayout::insertLayoutItems()
layoutItem->setStretchFactor(hStretch, Qt::Horizontal);
if (vStretch >= 0)
layoutItem->setStretchFactor(vStretch, Qt::Vertical);
+
d->engine.insertItem(layoutItem, -1);
}
}
@@ -775,10 +837,8 @@ QQuickLinearLayout::QQuickLinearLayout(Qt::Orientation orientation,
Possible values:
- \list
- \li Qt.LeftToRight (default) - Items are laid out from left to right.
- \li Qt.RightToLeft - Items are laid out from right to left
- \endlist
+ \value Qt.LeftToRight (default) Items are laid out from left to right.
+ \value Qt.RightToLeft Items are laid out from right to left
\sa GridLayout::layoutDirection, ColumnLayout::layoutDirection
*/
@@ -792,14 +852,49 @@ QQuickLinearLayout::QQuickLinearLayout(Qt::Orientation orientation,
Possible values:
- \list
- \li Qt.LeftToRight (default) - Items are laid out from left to right.
- \li Qt.RightToLeft - Items are laid out from right to left
- \endlist
+ \value Qt.LeftToRight (default) Items are laid out from left to right.
+ \value Qt.RightToLeft Items are laid out from right to left
\sa GridLayout::layoutDirection, RowLayout::layoutDirection
*/
+/*!
+ \qmlproperty bool RowLayout::uniformCellSizes
+ \since QtQuick.Layouts 6.6
+
+ If this property is set to \c true, the layout will force all cells to have
+ a uniform size.
+
+ \sa GridLayout::uniformCellWidths, GridLayout::uniformCellHeights, ColumnLayout::uniformCellSizes
+*/
+/*!
+ \qmlproperty bool ColumnLayout::uniformCellSizes
+ \since QtQuick.Layouts 6.6
+
+ If this property is set to \c true, the layout will force all cells to have
+ a uniform size.
+
+ \sa GridLayout::uniformCellWidths, GridLayout::uniformCellHeights, RowLayout::uniformCellSizes
+*/
+bool QQuickLinearLayout::uniformCellSizes() const
+{
+ Q_D(const QQuickLinearLayout);
+ Q_ASSERT(d->engine.uniformCellWidths() == d->engine.uniformCellHeights());
+ return d->engine.uniformCellWidths();
+}
+
+void QQuickLinearLayout::setUniformCellSizes(bool uniformCellSizes)
+{
+ Q_D(QQuickLinearLayout);
+ Q_ASSERT(d->engine.uniformCellWidths() == d->engine.uniformCellHeights());
+ if (d->engine.uniformCellHeights() == uniformCellSizes)
+ return;
+ d->engine.setUniformCellWidths(uniformCellSizes);
+ d->engine.setUniformCellHeights(uniformCellSizes);
+ invalidate();
+ emit uniformCellSizesChanged();
+}
+
/*!
\qmlproperty real RowLayout::spacing