vcl/inc/qt5/QtBuilder.hxx | 2 +- vcl/qt5/QtBuilder.cxx | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-)
New commits: commit 37cc6b8e46288c132ef3b7c5cf44560517a7a00e Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Oct 25 21:32:56 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Oct 26 13:12:27 2024 +0200 tdf#130857 qt weld: Set actual positions for layouts inside grid Extend QtBuilder::applyGridPackingProperties to not only handle widgets (QWidget), but also layouts (QLayout), so that the proper position inside the grid is also set for these. This will be used e.g. by the "Help" -> "About LibreOfficeDev" dialog. (When adding "cui/ui/aboutdialog.ui" to the list of .ui files in QtInstanceBuilder::IsUIFileSupported, those UI elements that show up are now in the correct positions, but other things unrelated to this particular commit are still missing.) Change-Id: Ic7c342e0307526f29e1fa149acd25a27373069ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175662 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtBuilder.hxx b/vcl/inc/qt5/QtBuilder.hxx index 51a59d47a712..ad7569b77a11 100644 --- a/vcl/inc/qt5/QtBuilder.hxx +++ b/vcl/inc/qt5/QtBuilder.hxx @@ -75,7 +75,7 @@ private: static QWidget* windowForObject(QObject* pObject); static QDialogButtonBox* findButtonBox(QDialog* pDialog); - static void applyGridPackingProperties(QObject& rCurrentChild, QGridLayout& rGrid, + static void applyGridPackingProperties(QObject* pCurrentChild, QGridLayout& rGrid, const stringmap& rPackingProperties); }; diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 9bb32a642288..edb58b16700a 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -344,12 +344,10 @@ void QtBuilder::applyAtkProperties(QObject* pObject, const stringmap& rPropertie } } -void QtBuilder::applyGridPackingProperties(QObject& rCurrentChild, QGridLayout& rGrid, +void QtBuilder::applyGridPackingProperties(QObject* pCurrentChild, QGridLayout& rGrid, const stringmap& rPackingProperties) { - if (!rCurrentChild.isWidgetType()) - return; - + assert(pCurrentChild); assert(rPackingProperties.contains(u"left-attach"_ustr) && "left-attach property missing for grid item"); assert(rPackingProperties.contains(u"top-attach"_ustr) @@ -358,9 +356,18 @@ void QtBuilder::applyGridPackingProperties(QObject& rCurrentChild, QGridLayout& const sal_Int32 nColumn = rPackingProperties.at(u"left-attach"_ustr).toInt32(); const sal_Int32 nRow = rPackingProperties.at(u"top-attach"_ustr).toInt32(); - QWidget& rCurrentWidget = static_cast<QWidget&>(rCurrentChild); - rGrid.removeWidget(&rCurrentWidget); - rGrid.addWidget(&rCurrentWidget, nRow, nColumn); + if (pCurrentChild->isWidgetType()) + { + QWidget* pWidget = static_cast<QWidget*>(pCurrentChild); + rGrid.removeWidget(pWidget); + rGrid.addWidget(pWidget, nRow, nColumn); + return; + } + + // if it's not a QWidget, it must be a QLayout + QLayout* pLayout = static_cast<QLayout*>(pCurrentChild); + rGrid.removeItem(pLayout); + rGrid.addLayout(pLayout, nRow, nColumn); } void QtBuilder::applyPackingProperties(QObject* pCurrentChild, QObject* pParent, @@ -370,7 +377,7 @@ void QtBuilder::applyPackingProperties(QObject* pCurrentChild, QObject* pParent, return; if (QGridLayout* pGrid = qobject_cast<QGridLayout*>(pParent)) - applyGridPackingProperties(*pCurrentChild, *pGrid, rPackingProperties); + applyGridPackingProperties(pCurrentChild, *pGrid, rPackingProperties); else SAL_WARN("vcl.qt", "QtBuilder::applyPackingProperties not yet implemented for this case"); }