vcl/inc/qt5/QtTools.hxx | 5 +++++ vcl/qt5/QtInstanceBuilder.cxx | 1 + vcl/qt5/QtInstanceButton.cxx | 2 +- vcl/qt5/QtInstanceLabel.cxx | 3 ++- vcl/qt5/QtTools.cxx | 22 ++++++++++++++++++++++ 5 files changed, 31 insertions(+), 2 deletions(-)
New commits: commit d91da3c1bc953afa9acf383b6710fbcb3e2ea465 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Feb 21 20:39:04 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Feb 22 10:55:33 2025 +0100 tdf#130857 qt weld: Convert Qt to VCL accelerator in get_label() In QtInstanceLabel::get_label and QtInstanceButton::get_label, convert the text potentially containing a Qt accelerator "&" and escaped "&" ("&&") to the VCL variant using "~" as accelerator. (The same is already done the other way around in `set_label()`). Without this, the "New" button in the dialog triggered as follows in a WIP branch where support for that dialog is declared for SAL_VCL_QT_USE_WELDED_WIDGETS=1 was displayed with a literal "&New" as its text, because SvxEditDictionaryDialog::SvxEditDictionaryDialog does this: sNew = m_xNewReplacePB->get_label(); // ... m_xNewReplacePB->set_label(sNew); To trigger the dialog: * "Tools" -> "Spelling" -> "Options" * select the Hungarian dictionary * click the "Edit" button Change-Id: Ia457f0d8c3dc03b33fa3cb026814830b18c5ca8a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182021 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/inc/qt5/QtTools.hxx b/vcl/inc/qt5/QtTools.hxx index c1b2b75fff5f..9284cc8826b1 100644 --- a/vcl/inc/qt5/QtTools.hxx +++ b/vcl/inc/qt5/QtTools.hxx @@ -161,6 +161,11 @@ QString vclMessageTypeToQtTitle(VclMessageType eType); */ QString vclToQtStringWithAccelerator(const OUString& rText); +/** Converts a string potentially containing a '&' character to indicate an accelerator + * to the VCL variant using '~' for the accelerator. + */ +OUString qtToVclStringWithAccelerator(const QString& rText); + template <typename charT, typename traits> inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, const QString& rString) diff --git a/vcl/qt5/QtInstanceButton.cxx b/vcl/qt5/QtInstanceButton.cxx index b41cf4528ede..67b457174326 100644 --- a/vcl/qt5/QtInstanceButton.cxx +++ b/vcl/qt5/QtInstanceButton.cxx @@ -68,7 +68,7 @@ OUString QtInstanceButton::get_label() const } assert(m_pButton); - return toOUString(m_pButton->text()); + return qtToVclStringWithAccelerator(m_pButton->text()); } void QtInstanceButton::set_font(const vcl::Font& /*rFont*/) diff --git a/vcl/qt5/QtInstanceLabel.cxx b/vcl/qt5/QtInstanceLabel.cxx index 47f4dbfe4a68..b0db5c8c7981 100644 --- a/vcl/qt5/QtInstanceLabel.cxx +++ b/vcl/qt5/QtInstanceLabel.cxx @@ -30,7 +30,8 @@ OUString QtInstanceLabel::get_label() const { SolarMutexGuard g; OUString sLabel; - GetQtInstance().RunInMainThread([&] { sLabel = toOUString(m_pLabel->text()); }); + GetQtInstance().RunInMainThread( + [&] { sLabel = qtToVclStringWithAccelerator(m_pLabel->text()); }); return sLabel; } diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx index 375cc892464f..c642e7706522 100644 --- a/vcl/qt5/QtTools.cxx +++ b/vcl/qt5/QtTools.cxx @@ -177,4 +177,26 @@ QString vclToQtStringWithAccelerator(const OUString& rText) return toQString(rText.replaceAll("&", "&&").replace('~', '&')); } +OUString qtToVclStringWithAccelerator(const QString& rText) +{ + // find and replace single "&" used for accelerator + qsizetype nIndex = 0; + while (nIndex < rText.size()) + { + nIndex = rText.indexOf('&', nIndex); + // skip "&&", i.e. escaped '&' + if (nIndex < rText.length() - 1 && rText.at(nIndex + 1) == '&') + nIndex += 2; + else + break; + } + + QString sModified = rText; + if (nIndex >= 0) + sModified.replace(nIndex, 1, '~'); + + // replace escaped "&&" with plain "&" + return toOUString(sModified.replace("&&", "&")); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ commit ad04dd44b013e7cbb20be5902392b12a7ce1a142 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Feb 21 20:00:09 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Sat Feb 22 10:55:28 2025 +0100 tdf#130857 qt weld: Support BreakNumberOption dialog This means that native Qt widgets are used for that dialog now when using the qt5 or qt6 VCL plugin and starting LO with environment variable SAL_VCL_QT_USE_WELDED_WIDGETS=1 set. Dialog can be triggered e.g. like this in Writer: * "Tools" -> "Spelling" -> "Options" * select the Hungarian dictionary * in the "Options" treeview, select "Minimal number of characters for hyphenation" * click the "Edit" button Change-Id: Ib039debda6e7fcaab1f20ba6cda9364e38b380f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182020 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx index b6f61314bf50..9dc90007c733 100644 --- a/vcl/qt5/QtInstanceBuilder.cxx +++ b/vcl/qt5/QtInstanceBuilder.cxx @@ -62,6 +62,7 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& rUIFile) // weld API at once. static std::unordered_set<OUString> aSupportedUIFiles = { u"cui/ui/aboutdialog.ui"_ustr, + u"cui/ui/breaknumberoption.ui"_ustr, u"cui/ui/insertrowcolumn.ui"_ustr, u"cui/ui/javastartparametersdialog.ui"_ustr, u"cui/ui/namedialog.ui"_ustr,