[GUI] Handle ampersand in windowTitle

(cherry picked from commit eb0c980c1d)
This commit is contained in:
xtemp09
2025-11-24 15:19:44 +01:00
committed by Max Wilfinger
parent 8c36c5390a
commit e3d0fe6bb6
3 changed files with 12 additions and 1 deletions
+3 -1
View File
@@ -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));
+7
View File
@@ -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"
+2
View File
@@ -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;