diff --git a/src/core/kioglobal_p.cpp b/src/core/kioglobal_p.cpp --- a/src/core/kioglobal_p.cpp +++ b/src/core/kioglobal_p.cpp @@ -18,14 +18,16 @@ #include "kioglobal_p.h" +#include + #include static QMap standardLocationsMap() { static const struct { QStandardPaths::StandardLocation location; QString name; } - mapping[] = { + standardPathMapping[] = { { QStandardPaths::MusicLocation, QStringLiteral("folder-music") }, { QStandardPaths::MoviesLocation, QStringLiteral("folder-videos") }, { QStandardPaths::PicturesLocation, QStringLiteral("folder-pictures") }, @@ -38,15 +40,30 @@ { QStandardPaths::DocumentsLocation, QStringLiteral("folder-documents") }, { QStandardPaths::DesktopLocation, QStringLiteral("user-desktop") }, { QStandardPaths::HomeLocation, QStringLiteral("user-home") } }; - static const int count = sizeof mapping / sizeof *mapping; + static const int standardPathMappingCount = sizeof standardPathMapping / sizeof *standardPathMapping; + + + // Now we add additional paths not in the XDG spec, but for which we nonetheless + // have an appropriate icon that could be used by default. For these, we match + // not only the translated string but also the English string literal, because + // some people like to use English names even with a different locale + const QString homePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QStringLiteral("/"); + const QMap additionalPathMapping { + { homePath + QStringLiteral("Games"), QStringLiteral("folder-games") }, + { homePath + i18n("Games"), QStringLiteral("folder-games") } + }; + QMap map; - for (int i = 0 ; i < count; ++i) { - auto locations = QStandardPaths::standardLocations(mapping[i].location); - Q_FOREACH(const QString &location, locations) { - map.insert(location, mapping[i].name); + for (int i = 0 ; i < standardPathMappingCount; ++i) { + auto standardLocations = QStandardPaths::standardLocations(standardPathMapping[i].location); + for (const QString location : standardLocations) { + map.insert(location, standardPathMapping[i].name); } } + for (const QString location : additionalPathMapping.keys()) { + map.insert(location, additionalPathMapping.value(location)); + } return map; }