[GUI] Handle ampersand in windowTitle
This commit is contained in:
@@ -937,7 +937,9 @@ void RecentFilesAction::setFiles(const QStringList& files)
|
||||
for (int index = 0; index < numRecentFiles; index++) {
|
||||
QString numberLabel = numberToLabel(index + 1);
|
||||
QFileInfo fi(files[index]);
|
||||
recentFiles[index]->setText(QStringLiteral("%1 %2").arg(numberLabel).arg(fi.fileName()));
|
||||
QString fileName {fi.fileName()};
|
||||
fileName.replace(QLatin1Char('&'), QStringLiteral("&&"));
|
||||
recentFiles[index]->setText(QStringLiteral("%1 %2").arg(numberLabel, fileName));
|
||||
recentFiles[index]->setStatusTip(tr("Open file %1").arg(files[index]));
|
||||
recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving
|
||||
recentFiles[index]->setData(QVariant(index));
|
||||
|
||||
@@ -527,4 +527,11 @@ QString MDIView::buildWindowTitle() const
|
||||
return windowTitle;
|
||||
}
|
||||
|
||||
void MDIView::setWindowTitle(const QString& title)
|
||||
{
|
||||
QString newerTitle {title};
|
||||
newerTitle.replace(QLatin1Char('&'), QStringLiteral("&&"));
|
||||
QMainWindow::setWindowTitle(newerTitle);
|
||||
}
|
||||
|
||||
#include "moc_MDIView.cpp"
|
||||
|
||||
@@ -78,6 +78,8 @@ public:
|
||||
|
||||
/// build window title
|
||||
QString buildWindowTitle() const;
|
||||
/// reimplementation of QWidget::setWindowTitle(const QString &title)
|
||||
void setWindowTitle(const QString& title);
|
||||
|
||||
/// Message handler
|
||||
bool onMsg(const char* pMsg, const char** ppReturn) override;
|
||||
|
||||
Reference in New Issue
Block a user