tdf#130857 sw: Place dummy combobox into an (invisible) dialog

Quoting from earlier commit

    Change-Id: If88bbbb853b92d29dab41a48aaf81e406a52c151
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Jul 22 11:35:21 2026 +0200

        tdf#130857 qt weld: Support Writer "List Style" dialog

:

> The "Customize" tab handled in the
> "customize" case in SwTemplateDlgController::PageCreated
> uses an additional UI file "modules/swriter/ui/comboboxfragment.ui"
> for a combobox that is not actually (supposed to be) shown.
> That one will be handled in a separate commit, as it would
> result in an empty window being created without further
> changes.
> (The reason why that combobox is used seems to be simply that
> FillCharStyleListBox requires a weld::ComboBox& param;
> then the combobox entries are added to a different list
> and the combobox itself is discarded/ignored in
> SwTemplateDlgController::PageCreated. Having a non-native
> combobox (i.e. a vcl/SalInstance... implementation for that
> case doesn't cause any issues.)

Extend the UI file for that dummy combobox to
put the combobox into a dialog that doesn't get shown,
and set the actual dialog for its parent.

Since the new dialog is not visible/shown, this prevents
the above problem when declaring support for using
native Qt widgets for that dialog.

Simply setting the GtkBox to not visible like

    diff --git a/sw/uiconfig/swriter/ui/comboboxfragment.ui b/sw/uiconfig/swriter/ui/comboboxfragment.ui
    index e8551ae7d3ae..5659a3f589f5 100644
    --- a/sw/uiconfig/swriter/ui/comboboxfragment.ui
    +++ b/sw/uiconfig/swriter/ui/comboboxfragment.ui
    @@ -3,7 +3,6 @@
     <interface domain="sw">
       <requires lib="gtk+" version="3.24"/>
       <object class="GtkBox">
    -    <property name="visible">True</property>
         <property name="can-focus">False</property>
         <property name="orientation">vertical</property>
         <child>

would also prevent the useless top-level from showing
up.
However, in that case, that widget would be leaked, since
it is created on the stack and never deleted again.
Having it inside the SwTemplateDlgController's widget
hierarchy ensures that it will be deleted along with the
QDialog used for that SwTemplateDlgController.

Behavior could be observed e.g. in GammaRay [1]
with upcoming commit

    Change-Id: Ib176be098fa5530b736c32c48594cb75ae9304b0
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Jul 22 11:57:25 2026 +0200

        tdf#130857 qt weld: Support dummy combobox for Writer "List Style" dialog

in place.

[1] https://github.com/KDAB/GammaRay

Change-Id: Ibb216647749416ac62674a35f6f88193def13937
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208460
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Michael Weghorn
2026-07-24 15:23:52 +02:00
parent 325a7e00f9
commit d73a8b653e
2 changed files with 44 additions and 11 deletions
+2 -1
View File
@@ -28,6 +28,7 @@
#include <svl/cjkoptions.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld/Builder.hxx>
#include <vcl/weld/Dialog.hxx>
#include <numpara.hxx>
#include <swmodule.hxx>
#include <wrtsh.hxx>
@@ -494,7 +495,7 @@ void SwTemplateDlgController::PageCreated(const OUString& rId, SfxTabPage &rPage
aSet.Put (SfxStringItem(SID_BULLET_CHAR_FMT,sBulletCharFormat.toString()));
// collect character styles
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(nullptr, u"modules/swriter/ui/comboboxfragment.ui"_ustr));
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getDialog(), u"modules/swriter/ui/comboboxfragment.ui"_ustr));
std::unique_ptr<weld::ComboBox> xCharFormatLB(xBuilder->weld_combo_box(u"combobox"_ustr));
xCharFormatLB->clear();
xCharFormatLB->append_text(SwViewShell::GetShellRes()->aStrNone);
+42 -10
View File
@@ -2,19 +2,51 @@
<!-- Generated with glade 3.40.0 -->
<interface domain="sw">
<requires lib="gtk+" version="3.24"/>
<object class="GtkBox">
<property name="visible">True</property>
<object class="GtkDialog">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkComboBoxText" id="combobox">
<property name="type-hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkComboBoxText" id="combobox">
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</interface>