diff options
| author | Matthias Rauter <matthias.rauter@qt.io> | 2023-03-16 14:15:44 +0100 |
|---|---|---|
| committer | Matthias Rauter <matthias.rauter@qt.io> | 2023-06-01 14:10:53 +0200 |
| commit | 9982f16eadac1a252353a31972b03e3d3449f815 (patch) | |
| tree | 9025bf21ef7de97489e5e302489b0b45d380b897 /src/quicklayouts/qquicklinearlayout.cpp | |
| parent | bf712068978ff93f992d5fc8b2c779487828e1b8 (diff) | |
Add uniformCellWidths and uniformCellHeights to QuickLayout
Some users wish to make layouts with uniform column widths or
uniform row heights, ignoring the sizeHints of individual items.
This patch enables this mode in the QuickLayout.
[ChangeLog][Layouts] Added uniformCellSizes properties to QuickLayout
Change-Id: I25777d4d47d8d943f69e8f829a6d9602abccad92
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quicklayouts/qquicklinearlayout.cpp')
| -rw-r--r-- | src/quicklayouts/qquicklinearlayout.cpp | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/src/quicklayouts/qquicklinearlayout.cpp b/src/quicklayouts/qquicklinearlayout.cpp index b34815e449..31c1857d9f 100644 --- a/src/quicklayouts/qquicklinearlayout.cpp +++ b/src/quicklayouts/qquicklinearlayout.cpp @@ -622,6 +622,75 @@ 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. + + \note This API is considered tech preview and may change or be removed in future versions of + Qt. + + \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. + + \note This API is considered tech preview and may change or be removed in future versions of + Qt. + + \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); @@ -796,6 +865,49 @@ QQuickLinearLayout::QQuickLinearLayout(Qt::Orientation orientation, \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. + + \note This API is considered tech preview and may change or be removed in future versions of + Qt. + + \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. + + \note This API is considered tech preview and may change or be removed in future versions of + Qt. + + \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 |
