summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2024-10-24 01:42:13 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2024-10-24 09:11:00 +0200
commitac3b954ad37d679ead4420bc4826af766b72a841 (patch)
treee3953a55f8d6795148a2a944fcdf62affda00d37 /vcl
parent6565ce09647e5f7cb509776c3cd9615c062f821f (diff)
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 <m.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qt5/QtBuilder.cxx14
1 files changed, 12 insertions, 2 deletions
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))