From 5690acdb44e8017055bb88e86e19d207836bb95c Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 26 Oct 2018 23:09:24 +0200 Subject: tdf#120453 Preserve literal '&' in Qt menu texts As described in the QMenuBar documentation, a single ampersand in a menu item text is used to set the shortcut for the menu, while "&&" is used to get a real ampersand character. Change-Id: Idf510641c8919ff8223114413851cb3ee7d7b4a2 Reviewed-on: https://gerrit.libreoffice.org/62405 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- vcl/qt5/Qt5Menu.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'vcl') diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx index 51fcdf709bc4..17578ef4ce24 100644 --- a/vcl/qt5/Qt5Menu.cxx +++ b/vcl/qt5/Qt5Menu.cxx @@ -250,7 +250,13 @@ void Qt5Menu::slotMenuTriggered(Qt5MenuItem* pQItem) } } -void Qt5Menu::NativeItemText(OUString& rItemText) { rItemText = rItemText.replace('~', '&'); } +void Qt5Menu::NativeItemText(OUString& rItemText) +{ + // preserve literal '&'s in menu texts + rItemText = rItemText.replaceAll("&", "&&"); + + rItemText = rItemText.replace('~', '&'); +} Qt5MenuItem::Qt5MenuItem(const SalItemParams* pItemData) : mpParentMenu(nullptr) -- cgit v1.2.3