svx/source/form/fmPropBrw.cxx       |    3 +--
 svx/source/inc/fmPropBrw.hxx        |    1 -
 vcl/inc/qt5/QtInstanceContainer.hxx |    3 +++
 vcl/qt5/QtInstanceContainer.cxx     |   30 +++++++++++++++++++++++++++++-
 4 files changed, 33 insertions(+), 4 deletions(-)

New commits:
commit 21d067ecc329a25d9fba1479981d083c2459c86a
Author:     Michael Weghorn <[email protected]>
AuthorDate: Tue Jan 20 18:10:26 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Jan 22 11:15:23 2026 +0100

    tdf#130857 qt weld: Implement QtInstanceContainer::child_grab_focus
    
    Untested in practice so far, but this will e.g. triggered
    with SAL_VCL_QT_USE_WELDED_WIDGETS=1 once support for native
    Qt widgets is declared for the "Form Properties" dialog
    that can be triggered like this:
    
    * start Writer
    * "Form" -> "Form Navigator"
    * right-click on "Forms" to open the context menu
    * activate menu entry "New" -> "Form" and confirm
      the default name by pressing Enter
    * right-click on "Form" to open the context menu
    * activate the "Properties" menu entry
    
    Change-Id: I2953fee19f3304e69b7f70f42707a030a4003631
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197683
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtInstanceContainer.hxx 
b/vcl/inc/qt5/QtInstanceContainer.hxx
index 41f7e31438de..68ce170ede07 100644
--- a/vcl/inc/qt5/QtInstanceContainer.hxx
+++ b/vcl/inc/qt5/QtInstanceContainer.hxx
@@ -30,6 +30,9 @@ public:
 
 protected:
     virtual QLayout& getLayout() const;
+
+private:
+    static QWidget* findFocusableWidget(QWidget* pWidget);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/qt5/QtInstanceContainer.cxx b/vcl/qt5/QtInstanceContainer.cxx
index 87dd8122037a..f3f37d3a5ef0 100644
--- a/vcl/qt5/QtInstanceContainer.cxx
+++ b/vcl/qt5/QtInstanceContainer.cxx
@@ -49,7 +49,35 @@ css::uno::Reference<css::awt::XWindow> 
QtInstanceContainer::CreateChildFrame()
     return css::uno::Reference<css::awt::XWindow>();
 }
 
-void QtInstanceContainer::child_grab_focus() { assert(false && "Not 
implemented yet"); }
+QWidget* QtInstanceContainer::findFocusableWidget(QWidget* pWidget)
+{
+    if (!pWidget)
+        return nullptr;
+
+    if (QWidget* pFocusWidget = pWidget->focusWidget())
+        return pFocusWidget;
+
+    if (pWidget->focusPolicy() & Qt::FocusPolicy::StrongFocus)
+        return pWidget;
+
+    for (QObject* pChild : pWidget->children())
+    {
+        if (pChild->isWidgetType())
+            return findFocusableWidget(static_cast<QWidget*>(pChild));
+    }
+
+    return nullptr;
+}
+
+void QtInstanceContainer::child_grab_focus()
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] {
+        if (QWidget* pFocusWidget = findFocusableWidget(getQWidget()))
+            pFocusWidget->setFocus();
+    });
+}
 
 void QtInstanceContainer::connect_container_focus_changed(const 
Link<Container&, void>& rLink)
 {
commit fb0606c17d6bea8ff209c4a9915cf40f6598a9b5
Author:     Michael Weghorn <[email protected]>
AuthorDate: Tue Jan 20 17:49:18 2026 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Jan 22 11:15:15 2026 +0100

    tdf#130857 propctrlr: Don't use dialog's internal vbox
    
    A GtkDialog's internal vbox child in the .ui file
    (svx/uiconfig/ui/formpropertydialog.ui) isn't represented
    like this at least with the native Qt implementation
    (SAL_VCL_QT_USE_WELDED_WIDGETS=1), so avoid using it directly.
    
    Since the vbox is the top-level child of the dialog that
    contains all other widgets, the dialog itself can be used
    here instead.
    
    This prevents a null dereference in a WIP branch
    experimenting with adding support for using native
    Qt widgets for this dialog with SAL_VCL_QT_USE_WELDED_WIDGETS=1.
    
    The dialog can e.g. be triggered like this:
    
    * start Writer
    * "Form" -> "Form Navigator"
    * right-click on "Forms" to open the context menu
    * activate menu entry "New" -> "Form" and confirm
      the default name by pressing Enter
    * right-click on "Form" to open the context menu
    * activate the "Properties" menu entry
    
    Change-Id: I056d66f27d64f4f984304f03e8fad648c508b9c8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197682
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx
index b63bc7188dbc..37e977a6b405 100644
--- a/svx/source/form/fmPropBrw.cxx
+++ b/svx/source/form/fmPropBrw.cxx
@@ -177,7 +177,6 @@ FmPropBrw::FmPropBrw(const Reference< XComponentContext >& 
_xORB, SfxBindings* _
     , m_bInitialStateChange(true)
     , m_pParent(_pParent)
     , m_nAsyncGetFocusId(nullptr)
-    , m_xDialogBox(m_xBuilder->weld_box(u"dialog-vbox1"_ustr))
     , m_xContainer(m_xBuilder->weld_container(u"container"_ustr))
     , m_xORB(_xORB)
 {
@@ -395,7 +394,7 @@ void FmPropBrw::FillInfo( SfxChildWinInfo& rInfo ) const
 
 IMPL_LINK_NOARG( FmPropBrw, OnAsyncGetFocus, void*, void )
 {
-    m_xDialogBox->child_grab_focus();
+    m_xDialog->child_grab_focus();
     m_nAsyncGetFocusId = nullptr;
 }
 
diff --git a/svx/source/inc/fmPropBrw.hxx b/svx/source/inc/fmPropBrw.hxx
index e5b735c0eee3..b33597b24d6c 100644
--- a/svx/source/inc/fmPropBrw.hxx
+++ b/svx/source/inc/fmPropBrw.hxx
@@ -45,7 +45,6 @@ class FmPropBrw final : public SfxModelessDialogController, 
public SfxController
     weld::Window*   m_pParent;
     ImplSVEvent*    m_nAsyncGetFocusId;
     OUString        m_sLastActivePage;
-    std::unique_ptr<weld::Box> m_xDialogBox;
     std::unique_ptr<weld::Container> m_xContainer;
     css::uno::Reference< css::uno::XComponentContext >
                     m_xInspectorContext;

Reply via email to