1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-27 21:24:47 +01:00

Do not duplicate the same paths in the "open recent" menu

This commit is contained in:
Martin Tůma 2024-01-18 09:53:50 +01:00
parent cedca8725b
commit 9cacf1906e

View File

@ -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<QAction *> 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);
}