From 9cacf1906e05936af7d1c875135cdd9134edb2e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Thu, 18 Jan 2024 09:53:50 +0100 Subject: [PATCH] Do not duplicate the same paths in the "open recent" menu --- src/GUI/gui.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/GUI/gui.cpp b/src/GUI/gui.cpp index a944ba63..b5d32f8d 100644 --- a/src/GUI/gui.cpp +++ b/src/GUI/gui.cpp @@ -2026,11 +2026,13 @@ void GUI::updateWindowTitle() #ifndef Q_OS_ANDROID void GUI::updateRecentFiles(const QString &fileName) { + QFileInfo fi(fileName); + QString canonicalFileName(fi.canonicalFilePath()); QAction *a = 0; QList actions(_recentFilesActionGroup->actions()); for (int i = 0; i < actions.size(); i++) { - if (actions.at(i)->text() == fileName) { + if (actions.at(i)->text() == canonicalFileName) { a = actions.at(i); break; } @@ -2044,7 +2046,7 @@ void GUI::updateRecentFiles(const QString &fileName) actions = _recentFilesActionGroup->actions(); QAction *before = actions.size() ? actions.last() : _recentFilesEnd; _recentFilesMenu->insertAction(before, - new QAction(fileName, _recentFilesActionGroup)); + new QAction(canonicalFileName, _recentFilesActionGroup)); _recentFilesMenu->setEnabled(true); }