From 16b8ab2461fb5172b001271024331ca28e2be344 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 6 Aug 2019 09:56:50 +0200 Subject: [PATCH] Help: Fix handling of ampersands in open pages pane E.g. for "Plug & Paint" example documentation. The list view may not show double ampersands, but for the context menu they must be "quoted". Change-Id: I773ac50f93b975504a5aff172336da77a703b52b Reviewed-by: hjk --- src/plugins/help/openpagesmodel.cpp | 3 +-- src/plugins/help/openpageswidget.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/plugins/help/openpagesmodel.cpp b/src/plugins/help/openpagesmodel.cpp index d00600737e6..3587acfc096 100644 --- a/src/plugins/help/openpagesmodel.cpp +++ b/src/plugins/help/openpagesmodel.cpp @@ -56,8 +56,7 @@ QVariant OpenPagesModel::data(const QModelIndex &index, int role) const case Qt::ToolTipRole: return m_pages.at(index.row())->source().toString(); case Qt::DisplayRole: { - QString title = m_pages.at(index.row())->title(); - title.replace('&', "&&"); + const QString title = m_pages.at(index.row())->title(); return title.isEmpty() ? tr("(Untitled)") : title; } default: diff --git a/src/plugins/help/openpageswidget.cpp b/src/plugins/help/openpageswidget.cpp index a6d98bbb702..55b55353f24 100644 --- a/src/plugins/help/openpageswidget.cpp +++ b/src/plugins/help/openpageswidget.cpp @@ -29,6 +29,7 @@ #include "openpagesmodel.h" #include +#include #include #include @@ -86,10 +87,9 @@ void OpenPagesWidget::contextMenuRequested(QPoint pos) if (index.column() == 1) index = index.sibling(index.row(), 0); QMenu contextMenu; - QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data() - .toString())); - QAction *closeOtherEditors = contextMenu.addAction(tr("Close All Except %1") - .arg(index.data().toString())); + const QString displayString = Utils::quoteAmpersands(index.data().toString()); + QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(displayString)); + QAction *closeOtherEditors = contextMenu.addAction(tr("Close All Except %1").arg(displayString)); if (model()->rowCount() == 1) { closeEditor->setEnabled(false);