Update energy-plugin path environment variable behaviour
parent
f56afe4694
commit
f05fd88937
|
|
@ -1,6 +1,6 @@
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2022, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
|
|
@ -81,18 +81,30 @@ void ExperiencePluginEnergy::loadPlugins()
|
||||||
|
|
||||||
QStringList ExperiencePluginEnergy::pluginSearchDirs() const
|
QStringList ExperiencePluginEnergy::pluginSearchDirs() const
|
||||||
{
|
{
|
||||||
|
const char *envDefaultPath = "NYMEA_ENERGY_PLUGINS_PATH";
|
||||||
|
const char *envExtraPath = "NYMEA_ENERGY_PLUGINS_EXTRA_PATH";
|
||||||
|
|
||||||
QStringList searchDirs;
|
QStringList searchDirs;
|
||||||
QByteArray envPath = qgetenv("NYMEA_ENERGY_PLUGINS_PATH");
|
QByteArray envExtraPathData = qgetenv(envExtraPath);
|
||||||
if (!envPath.isEmpty()) {
|
if (!envExtraPathData.isEmpty()) {
|
||||||
searchDirs << QString(envPath).split(':');
|
searchDirs << QString::fromUtf8(envExtraPathData).split(':');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qEnvironmentVariableIsSet(envDefaultPath)) {
|
||||||
|
QByteArray envDefaultPathData = qgetenv(envDefaultPath);
|
||||||
|
if (!envDefaultPathData.isEmpty()) {
|
||||||
|
searchDirs << QString::fromUtf8(envDefaultPathData).split(':');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
foreach (QString libraryPath, QCoreApplication::libraryPaths()) {
|
||||||
searchDirs << libraryPath.replace("qt5", "nymea").replace("plugins", "energy");
|
searchDirs << libraryPath.replace("qt5", "nymea").replace("plugins", "energy");
|
||||||
}
|
}
|
||||||
searchDirs << QCoreApplication::applicationDirPath() + "/../lib/nymea/energy";
|
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../lib/nymea/energy").absolutePath();
|
||||||
searchDirs << QCoreApplication::applicationDirPath() + "/../energy/";
|
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../energy/").absolutePath();
|
||||||
searchDirs << QCoreApplication::applicationDirPath() + "/../../../energy/";
|
searchDirs << QDir(QCoreApplication::applicationDirPath() + "/../../../energy/").absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
searchDirs.removeDuplicates();
|
||||||
return searchDirs;
|
return searchDirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue