WSL/SLF GitLab Repository

Commit 5dc3bb6e authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The search paths for the xml files has been improved in order to handle the...

The search paths for the xml files has been improved in order to handle the case of symlinks to the binary
parent cdfa01f7
......@@ -40,45 +40,6 @@
namespace os {
/**
* @brief Choose a number of locations to look for applications at.
* @param[out] locations List of locations which will have the system specific ones appended.
*/
void getSystemLocations(QStringList &locations)
{
#if defined Q_OS_WIN
locations << "../.."; //this is useful for some out of tree builds
locations << QCoreApplication::applicationDirPath(); //directory that contains the application executable
locations << QCoreApplication::applicationDirPath() + "/../share";
locations << QCoreApplication::applicationDirPath() + "/..";
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); //location where persistent application data can be stored
#endif
#if defined Q_OS_MAC
locations << "./../../../.."; //this is useful for some out of tree builds: we must get out of the bundle
locations << QCoreApplication::applicationDirPath();
locations << QCoreApplication::applicationDirPath() + "/../share";
locations << QCoreApplication::applicationDirPath() + "/..";
locations << QCoreApplication::applicationDirPath() + "/../../../.."; //we must get out of the bundle
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QDir::homePath() + "/usr/share";
#endif
#if !defined Q_OS_WIN && !defined Q_OS_MAC
locations << QCoreApplication::applicationDirPath(); //directory that contains the application executable
locations << QCoreApplication::applicationDirPath() + "/../share";
locations << QCoreApplication::applicationDirPath() + "/..";
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); //$HOME/Documents
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DataLocation);
locations << QDir::homePath() + "/usr/share";
#endif
}
/**
* @brief resolve and simplify a path. Unfortunatelly, there is no guarantee for a proper handling of UTF encodings,
* so only use this call to display nicer paths!
......@@ -156,6 +117,65 @@ bool isDarkTheme()
#endif
}
/**
* @brief Choose a number of locations to look for applications at.
* @param[out] locations List of locations which will have the system specific ones appended.
*/
void getSystemLocations(QStringList &locations)
{
const QString app_path( QCoreApplication::applicationDirPath() ); //directory that contains the application executable
//redundant locations are kept in each #ifdef in order to control the priority of each path, per plateform
#if defined Q_OS_WIN
locations << "../.."; //this is useful for some out of tree builds
locations << app_path;
locations << app_path + "/..";
locations << app_path + "/../share";
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); //location where persistent application data can be stored
#endif
#if defined Q_OS_MAC
locations << "./../../../.."; //this is useful for some out of tree builds: we must get out of the bundle
locations << app_path;
locations << app_path + "/..";
locations << app_path + "/../share";
locations << app_path + "/../../../.."; //we must get out of the bundle
const QString app_real_path( prettyPath(app_path) );
if (app_real_path!=app_path) {
locations << app_real_path;
locations << app_real_path + "/..";
locations << app_real_path + "/../share";
locations << app_real_path + "/../../../.."; //we must get out of the bundle
}
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QDir::homePath() + "/usr/share";
#endif
#if !defined Q_OS_WIN && !defined Q_OS_MAC
locations << app_path;
locations << app_path + "/..";
locations << app_path + "/../share";
const QString app_real_path( prettyPath(app_path) );
if (app_real_path!=app_path) {
locations << app_real_path;
locations << app_real_path + "/..";
locations << app_real_path + "/../share";
}
locations << QStandardPaths::standardLocations(QStandardPaths::DesktopLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); //$HOME/Documents
locations << QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
locations << QStandardPaths::standardLocations(QStandardPaths::DataLocation);
locations << QDir::homePath() + "/usr/share";
#endif
}
/**
* @brief Extended search paths for executables, to preprend or append to a PATH variable.
* @param[in] appname application's name.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment