vcl/inc/qt5/QtInstanceBuilder.hxx |    2 +-
 vcl/qt5/QtInstanceBuilder.cxx     |   14 +++++++++++---
 vcl/qt5/QtInstanceContainer.cxx   |   14 +++++++++++---
 vcl/qt5/QtInstanceWidget.cxx      |   10 +++++++++-
 4 files changed, 32 insertions(+), 8 deletions(-)

New commits:
commit 225b902ad3f61a7456dd88ed116ffc4488f231f1
Author:     Michael Weghorn <[email protected]>
AuthorDate: Tue Nov 5 15:32:20 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Nov 6 18:59:21 2024 +0100

    tdf#130857 qt weld: Implement QtInstanceWidget::weld_parent
    
    Change-Id: Ie26a40badb891f17b26b9e9202709a3edb909a05
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176089
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx
index 5f3590bd88d9..6764c83422d2 100644
--- a/vcl/qt5/QtInstanceWidget.cxx
+++ b/vcl/qt5/QtInstanceWidget.cxx
@@ -8,6 +8,7 @@
  */
 
 #include <QtInstanceWidget.hxx>
+#include <QtInstanceContainer.hxx>
 
 #include <vcl/transfer.hxx>
 #include <vcl/qt/QtUtils.hxx>
@@ -402,7 +403,14 @@ void QtInstanceWidget::thaw() {}
 
 void QtInstanceWidget::set_busy_cursor(bool) {}
 
-std::unique_ptr<weld::Container> QtInstanceWidget::weld_parent() const { 
return nullptr; }
+std::unique_ptr<weld::Container> QtInstanceWidget::weld_parent() const
+{
+    QWidget* pParentWidget = m_pWidget->parentWidget();
+    if (!pParentWidget)
+        return nullptr;
+
+    return std::make_unique<QtInstanceContainer>(pParentWidget);
+}
 
 void QtInstanceWidget::queue_resize() {}
 
commit 790749fde3a008047d1aa20eb6db0d00d2c355de
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Oct 31 22:34:01 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Nov 6 18:59:14 2024 +0100

    tdf#130857 qt weld: Assert in unimplemented QtInstanceContainer methods
    
    This way, implementations needed by any dialog that will
    be declared as supported in the future will become clear,
    rather than going unnoticed, with the functionality not
    working as expected.
    
    Change-Id: I27eba58c829586fff5566cc88983013429ca0b68
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176088
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/qt5/QtInstanceContainer.cxx b/vcl/qt5/QtInstanceContainer.cxx
index f86a8a1c06d4..53f79eca9999 100644
--- a/vcl/qt5/QtInstanceContainer.cxx
+++ b/vcl/qt5/QtInstanceContainer.cxx
@@ -15,15 +15,22 @@ QtInstanceContainer::QtInstanceContainer(QWidget* pWidget)
     assert(pWidget->layout() && "no layout to use for container");
 }
 
-void QtInstanceContainer::move(weld::Widget*, weld::Container*) {}
+void QtInstanceContainer::move(weld::Widget*, weld::Container*)
+{
+    assert(false && "Not implemented yet");
+}
 
 css::uno::Reference<css::awt::XWindow> QtInstanceContainer::CreateChildFrame()
 {
+    assert(false && "Not implemented yet");
     return css::uno::Reference<css::awt::XWindow>();
 }
 
-void QtInstanceContainer::child_grab_focus() {}
+void QtInstanceContainer::child_grab_focus() { assert(false && "Not 
implemented yet"); }
 
-void QtInstanceContainer::connect_container_focus_changed(const 
Link<Container&, void>&) {}
+void QtInstanceContainer::connect_container_focus_changed(const 
Link<Container&, void>&)
+{
+    assert(false && "Not implemented yet");
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 10b28684f6aee277c42457f2e663d8e86acc6492
Author:     Michael Weghorn <[email protected]>
AuthorDate: Tue Nov 5 15:23:09 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Wed Nov 6 18:59:06 2024 +0100

    tdf#130857 qt weld: Implement QtInstanceBuilder::weld_container
    
    Create a QtInstanceContainer, passing the layout's
    parent widget in the ctor.
    
    See also preparatory commit
    
        commit bf42162fc50d0c6f8e567d8765f8b14b96d7cc50
        Author: Michael Weghorn <[email protected]>
        Date:   Mon Nov 4 19:06:15 2024 +0100
    
            tdf#130857 qt weld: Add extra QWidget parents for layouts
    
    to ensure that layouts actually have an associated
    QWidget parent.
    
    Change-Id: Id95e1649d6a8b38eb2b685dc85b486920537d8ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176087
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtInstanceBuilder.hxx 
b/vcl/inc/qt5/QtInstanceBuilder.hxx
index 704d47a01cd8..120c6f9abbb8 100644
--- a/vcl/inc/qt5/QtInstanceBuilder.hxx
+++ b/vcl/inc/qt5/QtInstanceBuilder.hxx
@@ -34,7 +34,7 @@ public:
     virtual std::unique_ptr<weld::Assistant> weld_assistant(const OUString&) 
override;
     virtual std::unique_ptr<weld::Window> create_screenshot_window() override;
     virtual std::unique_ptr<weld::Widget> weld_widget(const OUString& rId) 
override;
-    virtual std::unique_ptr<weld::Container> weld_container(const OUString&) 
override;
+    virtual std::unique_ptr<weld::Container> weld_container(const OUString& 
rId) override;
     virtual std::unique_ptr<weld::Box> weld_box(const OUString&) override;
     virtual std::unique_ptr<weld::Paned> weld_paned(const OUString&) override;
     virtual std::unique_ptr<weld::Frame> weld_frame(const OUString& rId) 
override;
diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index a8ced91c1af2..8db7c8cd9c6c 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -103,10 +103,18 @@ std::unique_ptr<weld::Widget> 
QtInstanceBuilder::weld_widget(const OUString& rId
     return xRet;
 }
 
-std::unique_ptr<weld::Container> QtInstanceBuilder::weld_container(const 
OUString&)
+std::unique_ptr<weld::Container> QtInstanceBuilder::weld_container(const 
OUString& rId)
 {
-    assert(false && "Not implemented yet");
-    return nullptr;
+    QLayout* pLayout = m_xBuilder->get<QLayout>(rId);
+    if (!pLayout)
+        return nullptr;
+
+    QWidget* pParentWidget = pLayout->parentWidget();
+    assert(pParentWidget && pParentWidget == pLayout->parent()
+           && "layout has no direct widget parent");
+    std::unique_ptr<weld::Container> xRet(
+        pParentWidget ? std::make_unique<QtInstanceContainer>(pParentWidget) : 
nullptr);
+    return xRet;
 }
 
 std::unique_ptr<weld::Box> QtInstanceBuilder::weld_box(const OUString&)
diff --git a/vcl/qt5/QtInstanceContainer.cxx b/vcl/qt5/QtInstanceContainer.cxx
index 35f0a4bbaa69..f86a8a1c06d4 100644
--- a/vcl/qt5/QtInstanceContainer.cxx
+++ b/vcl/qt5/QtInstanceContainer.cxx
@@ -12,6 +12,7 @@
 QtInstanceContainer::QtInstanceContainer(QWidget* pWidget)
     : QtInstanceWidget(pWidget)
 {
+    assert(pWidget->layout() && "no layout to use for container");
 }
 
 void QtInstanceContainer::move(weld::Widget*, weld::Container*) {}

Reply via email to