forked from qt-creator/qt-creator
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 <hjk@qt.io>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "openpagesmodel.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QApplication>
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user