1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

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.
This commit is contained in:
Martin Tůma 2024-03-03 23:11:48 +01:00
parent 20f1003ce6
commit d9e6c30567

View File

@ -2092,8 +2092,9 @@ 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, a = new QAction(fileName, _recentFilesActionGroup);
new QAction(fileName, _recentFilesActionGroup)); a->setData(fileName);
_recentFilesMenu->insertAction(before, a);
_recentFilesMenu->setEnabled(true); _recentFilesMenu->setEnabled(true);
} }
@ -2110,7 +2111,7 @@ void GUI::clearRecentFiles()
void GUI::recentFileSelected(QAction *action) void GUI::recentFileSelected(QAction *action)
{ {
int showError = 1; int showError = 1;
openFile(action->text(), true, showError); openFile(action->data().toString(), true, showError);
} }
#endif // Q_OS_ANDROID #endif // Q_OS_ANDROID
@ -3229,6 +3230,7 @@ void GUI::loadRecentFiles(const QStringList &files)
for (int i = 0; i < files.size(); i++) { for (int i = 0; i < files.size(); i++) {
QAction *a = new QAction(files.at(i), _recentFilesActionGroup); QAction *a = new QAction(files.at(i), _recentFilesActionGroup);
a->setData(files.at(i));
_recentFilesMenu->insertAction(before, a); _recentFilesMenu->insertAction(before, a);
before = a; before = a;
} }