1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Use the canonical file name also for the "already open" check

This commit is contained in:
Martin Tůma 2024-01-21 17:50:56 +01:00
parent c9f44506e7
commit 536d12469a

View File

@ -1028,13 +1028,16 @@ void GUI::openDir()
bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError) bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
{ {
if (_files.contains(fileName)) QFileInfo fi(fileName);
QString canonicalFileName(fi.canonicalFilePath());
if (_files.contains(canonicalFileName))
return true; return true;
if (!loadFile(fileName, tryUnknown, showError)) if (!loadFile(fileName, tryUnknown, showError))
return false; return false;
_files.append(fileName); _files.append(canonicalFileName);
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
_browser->setCurrent(fileName); _browser->setCurrent(fileName);
#endif // Q_OS_ANDROID #endif // Q_OS_ANDROID
@ -1047,7 +1050,7 @@ bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
updateStatusBarInfo(); updateStatusBarInfo();
updateWindowTitle(); updateWindowTitle();
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
updateRecentFiles(fileName); updateRecentFiles(canonicalFileName);
#endif // Q_OS_ANDROID #endif // Q_OS_ANDROID
return true; return true;
@ -2026,13 +2029,11 @@ void GUI::updateWindowTitle()
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
void GUI::updateRecentFiles(const QString &fileName) void GUI::updateRecentFiles(const QString &fileName)
{ {
QFileInfo fi(fileName);
QString canonicalFileName(fi.canonicalFilePath());
QAction *a = 0; QAction *a = 0;
QList<QAction *> actions(_recentFilesActionGroup->actions()); QList<QAction *> actions(_recentFilesActionGroup->actions());
for (int i = 0; i < actions.size(); i++) { for (int i = 0; i < actions.size(); i++) {
if (actions.at(i)->text() == canonicalFileName) { if (actions.at(i)->text() == fileName) {
a = actions.at(i); a = actions.at(i);
break; break;
} }
@ -2046,7 +2047,7 @@ void GUI::updateRecentFiles(const QString &fileName)
actions = _recentFilesActionGroup->actions(); actions = _recentFilesActionGroup->actions();
QAction *before = actions.size() ? actions.last() : _recentFilesEnd; QAction *before = actions.size() ? actions.last() : _recentFilesEnd;
_recentFilesMenu->insertAction(before, _recentFilesMenu->insertAction(before,
new QAction(canonicalFileName, _recentFilesActionGroup)); new QAction(fileName, _recentFilesActionGroup));
_recentFilesMenu->setEnabled(true); _recentFilesMenu->setEnabled(true);
} }