MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / setSeachPaths

Function setSeachPaths

src/mapper_resource.cpp:35–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33namespace MapperResource {
34
35void setSeachPaths()
36{
37 QStringList data_paths;
38 data_paths.reserve(3);
39
40 QStringList doc_paths;
41 doc_paths.reserve(3);
42
43#if defined(MAPPER_DEVELOPMENT_BUILD) && defined(MAPPER_DEVELOPMENT_RES_DIR)
44 // Use the directory where Mapper is built during development,
45 // even for the unit tests located in other directories.
46 auto build_dir = QString::fromLocal8Bit(MAPPER_DEVELOPMENT_RES_DIR);
47 data_paths.append(build_dir);
48 doc_paths.append(build_dir + QLatin1String("/doc/licensing"));
49 doc_paths.append(build_dir + QLatin1String("/doc/manual"));
50#endif
51
52#if defined(Q_OS_MACOS)
53 // Mac OS X: load resources from the Resources directory of the bundle
54 auto app_dir = QDir { QCoreApplication::applicationDirPath() };
55 auto resources_dir = app_dir.absoluteFilePath(QLatin1String("../Resources"));
56 data_paths.append(resources_dir);
57 doc_paths.append(resources_dir + QLatin1String("/doc"));
58#elif defined(Q_OS_WIN)
59 // Windows: load resources from the application directory
60 auto app_dir = QDir(QCoreApplication::applicationDirPath()).absolutePath();
61 data_paths.append(app_dir);
62 doc_paths.append(app_dir + QLatin1String("/doc"));
63#elif defined(Q_OS_ANDROID)
64 // Android: load resources from the assets directory
65 auto assets = QString::fromLatin1("assets:");
66 data_paths.append(assets);
67 doc_paths.append(assets + QLatin1String("/doc"));
68#else
69 data_paths.append(QString::fromLatin1(MAPPER_DATA_DESTINATION));
70 doc_paths.append(QString::fromLatin1(MAPPER_ABOUT_DESTINATION));
71#endif
72
73 // General default path: Qt resource system
74 auto resources = QString{ QLatin1String{":"} };
75 data_paths.append(resources);
76 doc_paths.append(resources + QLatin1String("/doc"));
77
78 QDir::setSearchPaths(QLatin1String("data"), data_paths);
79 QDir::setSearchPaths(QLatin1String("doc"), doc_paths);
80}
81
82
83} // namespace MapperResource

Callers 1

mainFunction · 0.85

Calls 2

QLatin1StringClass · 0.85
QDirClass · 0.50

Tested by

no test coverage detected