vcl/qt5/QtBuilder.cxx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
New commits: commit 592665ce867d51ed3dcf95fd0f06fd22dc2804e8 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Sep 27 21:56:34 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Sep 28 09:35:13 2024 +0200 tdf#130857 qt weld: Avoid unnecessary OUString copy Change-Id: I36802f84070e579b714b696144536a2f130e2f7a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174074 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index b93e59c15a63..5d434dc58d71 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -183,10 +183,8 @@ void QtBuilder::setProperties(QObject* pObject, stringmap& rProps) { if (QMessageBox* pMessageBox = qobject_cast<QMessageBox*>(pObject)) { - for (auto const & [ Key, rValue ] : rProps) + for (auto const & [ rKey, rValue ] : rProps) { - OUString rKey = Key; - if (rKey == u"text") { pMessageBox->setText(toQString(rValue)); commit a9c637da431485f2e0e27045ccae10866c587538 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Sep 27 21:52:18 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Sep 28 09:35:05 2024 +0200 tdf#130857 qt weld: Use "p" prefix for pointer param name Change-Id: I732b67ef6f864fcbb1724b6d6bc3290417660dcb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174073 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 23f5e59c4f84..b93e59c15a63 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -179,9 +179,9 @@ void QtBuilder::set_response(std::u16string_view sID, short nResponse) pPushButton->setProperty(QtInstanceMessageDialog::PROPERTY_VCL_RESPONSE_CODE, int(nResponse)); } -void QtBuilder::setProperties(QObject* obj, stringmap& rProps) +void QtBuilder::setProperties(QObject* pObject, stringmap& rProps) { - if (QMessageBox* pMessageBox = qobject_cast<QMessageBox*>(obj)) + if (QMessageBox* pMessageBox = qobject_cast<QMessageBox*>(pObject)) { for (auto const & [ Key, rValue ] : rProps) { @@ -214,7 +214,7 @@ void QtBuilder::setProperties(QObject* obj, stringmap& rProps) } } } - else if (QPushButton* pButton = qobject_cast<QPushButton*>(obj)) + else if (QPushButton* pButton = qobject_cast<QPushButton*>(pObject)) { for (auto const & [ rKey, rValue ] : rProps) { commit 0aa5380c22e19ae43a251a2d2fae12a31069b8d9 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Sep 27 21:41:43 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Sep 28 09:34:58 2024 +0200 tdf#130857 qt weld: Set widget layout and add to parent layout When creating a QLayout, pass the parent widget to the ctor as well, which makes the layout be set for the widget. Quoting from the QVBoxLayout ctor doc [1] > Constructs a new top-level vertical box with parent parent. > > The layout is set directly as the top-level layout for parent. > There can be only one top-level layout for a widget. It is returned > by QWidget::layout(). Also add widgets to their parent layout if the parent is a QLayout, and not a QWidget. This makes the items of the "Help" -> "License" dialog actually be part of the dialog in a WIP branch that has "QtInstanceBuilder::IsUIFileSupported" in the set of supported files in QtInstanceBuilder::IsUIFileSupported. [1] https://doc.qt.io/qt-6/qvboxlayout.html#QVBoxLayout-1 Change-Id: Ib823896a28520b6f7e1e89244239d3204d1d10e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174072 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx index 58263b981cf8..23f5e59c4f84 100644 --- a/vcl/qt5/QtBuilder.cxx +++ b/vcl/qt5/QtBuilder.cxx @@ -75,6 +75,7 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons return nullptr; QWidget* pParentWidget = qobject_cast<QWidget*>(pParent); + QLayout* pParentLayout = qobject_cast<QLayout*>(pParent); QObject* pObject = nullptr; @@ -94,9 +95,9 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons { const bool bVertical = hasOrientationVertical(rMap); if (bVertical) - pObject = new QVBoxLayout(); + pObject = new QVBoxLayout(pParentWidget); else - pObject = new QHBoxLayout(); + pObject = new QHBoxLayout(pParentWidget); } } else if (sName == u"GtkButtonBox") @@ -108,6 +109,9 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons QDialogButtonBox* pButtonBox = findButtonBox(pMessageBox); assert(pButtonBox && "Could not find QMessageBox's button box"); pObject = pButtonBox; + + // skip adding to layout below, button box is already contained in dialog + pParentLayout = nullptr; } else { @@ -136,6 +140,14 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, cons assert(false && "Widget type not supported yet"); } + // add widgets to parent layout + if (pParentLayout) + { + QWidget* pWidget = qobject_cast<QWidget*>(pObject); + if (pWidget) + pParentLayout->addWidget(pWidget); + } + m_aChildren.emplace_back(sID, pObject); return pObject;