From 0d2188d376829115bfb096f946973f05fde31a51 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 24 Oct 2024 12:37:15 +0200 Subject: tdf#130857 qt weld: Implement QtInstanceComboBox::{g,s}et_active_id This is made use of e.g. in 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. Change-Id: I5099672bac495bf47cc0d6aa806a69e8729066e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175546 Reviewed-by: Michael Weghorn Tested-by: Jenkins --- vcl/qt5/QtInstanceComboBox.cxx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'vcl') diff --git a/vcl/qt5/QtInstanceComboBox.cxx b/vcl/qt5/QtInstanceComboBox.cxx index bf0dbb1a092e..3915f2728c4a 100644 --- a/vcl/qt5/QtInstanceComboBox.cxx +++ b/vcl/qt5/QtInstanceComboBox.cxx @@ -145,11 +145,27 @@ int QtInstanceComboBox::find_text(const OUString& rStr) const OUString QtInstanceComboBox::get_active_id() const { - assert(false && "Not implemented yet"); - return OUString(); + SolarMutexGuard g; + + OUString sId; + GetQtInstance().RunInMainThread([&] { + QVariant aUserData = m_pComboBox->currentData(); + if (aUserData.canConvert()) + sId = toOUString(aUserData.toString()); + }); + + return sId; } -void QtInstanceComboBox::set_active_id(const OUString&) { assert(false && "Not implemented yet"); } +void QtInstanceComboBox::set_active_id(const OUString& rId) +{ + SolarMutexGuard g; + + GetQtInstance().RunInMainThread([&] { + int nIndex = find_id(rId); + set_active(nIndex); + }); +} OUString QtInstanceComboBox::get_id(int nPos) const { -- cgit v1.2.3