include/vcl/builderbase.hxx   |    1 +
 vcl/qt5/QtBuilder.cxx         |   14 ++++++++++++--
 vcl/source/window/builder.cxx |   24 +++++++++++-------------
 3 files changed, 24 insertions(+), 15 deletions(-)

New commits:
commit ac3b954ad37d679ead4420bc4826af766b72a841
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Oct 24 01:42:13 2024 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Oct 24 09:11:00 2024 +0200

    tdf#130857 qt weld: Handle entry for editable comboboxes
    
    An editable GtkComboBox has a "has-entry" property of "true"
    and an internal GtkEntry child.
    
    Make the QComboBox editable depending on that "has-entry" property.
    Mark the QLineEdit object created for the "GtkEntry" for deletion
    again, as the QComboBox already has a QLineEdit by itself if it's
    editable, and the one created for the internal child would otherwise
    be useless and oddly overlap the combobox.
    
    (Seen e.g. with the "Tools" -> "Options" -> "Languages and Locales"
    -> "Writing Aids" -> "New" dialog" in a WIP branch where that dialog's
    .ui file ("cui/ui/optnewdictionarydialog.ui") was added to the list of
    supported files for QtInstanceBuilder. More work is needed
    on other aspects still.)
    
    Change-Id: I25ea74c732e60f50035604a4fc75dad50f4cf55f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175531
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/vcl/qt5/QtBuilder.cxx b/vcl/qt5/QtBuilder.cxx
index 29de12e0a678..3013cf48e4b4 100644
--- a/vcl/qt5/QtBuilder.cxx
+++ b/vcl/qt5/QtBuilder.cxx
@@ -147,7 +147,9 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, cons
     }
     else if (sName == u"GtkComboBoxText")
     {
-        pObject = new QComboBox(pParentWidget);
+        QComboBox* pComboBox = new QComboBox(pParentWidget);
+        pComboBox->setEditable(extractEntry(rMap));
+        pObject = pComboBox;
     }
     else if (sName == u"GtkDialog")
     {
@@ -213,8 +215,16 @@ QObject* QtBuilder::makeObject(QObject* pParent, 
std::u16string_view sName, cons
 }
 
 void QtBuilder::tweakInsertedChild(QObject* pParent, QObject* pCurrentChild, 
std::string_view sType,
-                                   std::string_view)
+                                   std::string_view sInternalChild)
 {
+    if (sInternalChild == "entry" && qobject_cast<QComboBox*>(pParent))
+    {
+        // an editable GtkComboBox has an internal GtkEntry child,
+        // but QComboBox doesn't need a separate widget for it, so
+        // delete it
+        pCurrentChild->deleteLater();
+    }
+
     if (sType == "label")
     {
         if (QLabel* pLabel = qobject_cast<QLabel*>(pCurrentChild))
commit 6565ce09647e5f7cb509776c3cd9615c062f821f
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Oct 24 01:43:18 2024 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Oct 24 09:10:53 2024 +0200

    tdf#130857 VclBuilder: Make extractEntry a static helper
    
    ... in the base class BuilderBase, in order to reuse it in
    QtBuilder in an upcoming commit.
    
    Change-Id: Ia115804a9d2bf22b47afb94d97109e9495b21cd4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175530
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/include/vcl/builderbase.hxx b/include/vcl/builderbase.hxx
index 909792d2ca52..64e6bf6532d1 100644
--- a/include/vcl/builderbase.hxx
+++ b/include/vcl/builderbase.hxx
@@ -80,6 +80,7 @@ protected:
     static void collectAccelerator(xmlreader::XmlReader& reader, accelmap& 
rMap);
     stringmap collectPackingProperties(xmlreader::XmlReader& reader);
     void collectProperty(xmlreader::XmlReader& rReader, stringmap& rMap) const;
+    static bool extractEntry(stringmap& rMap);
     static bool extractVisible(stringmap& rMap);
     void extractClassAndIdAndCustomProperty(xmlreader::XmlReader& reader, 
OUString& rClass,
                                             OUString& rId, OUString& 
rCustomProperty);
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 0320715b7a02..0a820713a680 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -972,18 +972,6 @@ namespace
         return bCloseable;
     }
 
-    bool extractEntry(VclBuilder::stringmap &rMap)
-    {
-        bool bHasEntry = false;
-        VclBuilder::stringmap::iterator aFind = rMap.find(u"has-entry"_ustr);
-        if (aFind != rMap.end())
-        {
-            bHasEntry = toBool(aFind->second);
-            rMap.erase(aFind);
-        }
-        return bHasEntry;
-    }
-
     bool extractVerticalTabPos(VclBuilder::stringmap &rMap)
     {
         bool bVertical = false;
@@ -3766,7 +3754,17 @@ bool 
BuilderBase::hasOrientationVertical(VclBuilder::stringmap &rMap)
     return bVertical;
 }
 
-
+bool BuilderBase::extractEntry(VclBuilder::stringmap &rMap)
+{
+    bool bHasEntry = false;
+    VclBuilder::stringmap::iterator aFind = rMap.find(u"has-entry"_ustr);
+    if (aFind != rMap.end())
+    {
+        bHasEntry = toBool(aFind->second);
+        rMap.erase(aFind);
+    }
+    return bHasEntry;
+}
 
 bool BuilderBase::extractVisible(VclBuilder::stringmap& rMap)
 {

Reply via email to