1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-17 16:20:48 +01:00

Compare commits

...

3 Commits

Author SHA1 Message Date
468e662e4f Yet another recent files fix 2024-03-03 23:31:08 +01:00
3ba6d2d24f Fixed recent paths update logic 2024-03-03 23:20:25 +01:00
d9e6c30567 Use the QAction data() for file paths rather than text()
As seen in KDE Neon, some Qt themes or distros mangle the text() by adding
automatic shortcut accelerators that break the paths for opening.
2024-03-03 23:11:48 +01:00

View File

@ -2079,7 +2079,7 @@ void GUI::updateRecentFiles(const QString &fileName)
QList<QAction *> actions(_recentFilesActionGroup->actions());
for (int i = 0; i < actions.size(); i++) {
if (actions.at(i)->text() == fileName) {
if (actions.at(i)->data().toString() == fileName) {
a = actions.at(i);
break;
}
@ -2092,8 +2092,9 @@ void GUI::updateRecentFiles(const QString &fileName)
actions = _recentFilesActionGroup->actions();
QAction *before = actions.size() ? actions.last() : _recentFilesEnd;
_recentFilesMenu->insertAction(before,
new QAction(fileName, _recentFilesActionGroup));
a = new QAction(fileName, _recentFilesActionGroup);
a->setData(fileName);
_recentFilesMenu->insertAction(before, a);
_recentFilesMenu->setEnabled(true);
}
@ -2110,7 +2111,7 @@ void GUI::clearRecentFiles()
void GUI::recentFileSelected(QAction *action)
{
int showError = 1;
openFile(action->text(), true, showError);
openFile(action->data().toString(), true, showError);
}
#endif // Q_OS_ANDROID
@ -2488,7 +2489,7 @@ void GUI::writeSettings()
QList<QAction*> recentActions(_recentFilesActionGroup->actions());
QStringList recent;
for (int i = 0; i < recentActions.size(); i++)
recent.append(recentActions.at(i)->text());
recent.append(recentActions.at(i)->data().toString());
settings.beginGroup(SETTINGS_FILE);
WRITE(recentDataFiles, recent);
@ -3229,6 +3230,7 @@ void GUI::loadRecentFiles(const QStringList &files)
for (int i = 0; i < files.size(); i++) {
QAction *a = new QAction(files.at(i), _recentFilesActionGroup);
a->setData(files.at(i));
_recentFilesMenu->insertAction(before, a);
before = a;
}