diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-24 12:37:15 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-10-25 08:57:24 +0200 |
commit | 0d2188d376829115bfb096f946973f05fde31a51 (patch) | |
tree | 02f8fedc3e69cc48d169c55124a5e87467dfecca /vcl | |
parent | 2db9f1c08e28d0ae06be7db5a20912f9198468f0 (diff) |
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 <m.weghorn@posteo.de>
Tested-by: Jenkins
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qt5/QtInstanceComboBox.cxx | 22 |
1 files changed, 19 insertions, 3 deletions
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<QString>()) + 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 { |