From ad4c2acbfc8fd8e63f688871c96b17d041c8f3b6 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Tue, 16 Apr 2019 23:29:58 +0200 Subject: [PATCH] Also drop hardcoded NYMEA_PLUGINS_PATH from .pro file --- libnymea/devicemanager.cpp | 9 ++++----- libnymea/translator.cpp | 7 +------ nymea.pri | 6 +----- nymea.pro | 1 - plugins/plugins.pri | 2 +- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/libnymea/devicemanager.cpp b/libnymea/devicemanager.cpp index 0c4eb13b..c2738282 100644 --- a/libnymea/devicemanager.cpp +++ b/libnymea/devicemanager.cpp @@ -245,14 +245,13 @@ QStringList DeviceManager::pluginSearchDirs() if (!envPath.isEmpty()) { searchDirs << QString(envPath).split(':'); } + + foreach (QString libraryPath, QCoreApplication::libraryPaths()) { + searchDirs << libraryPath.replace("qt5", "nymea"); + } searchDirs << QCoreApplication::applicationDirPath() + "/../lib/nymea/plugins"; searchDirs << QCoreApplication::applicationDirPath() + "/../plugins/"; searchDirs << QCoreApplication::applicationDirPath() + "/../../../plugins/"; - searchDirs << QString("%1").arg(NYMEA_PLUGINS_PATH); - QString snapDir = QString::fromUtf8(qgetenv("SNAP")); - if (!snapDir.isEmpty()) { - searchDirs << QString("%1%2").arg(snapDir).arg(NYMEA_PLUGINS_PATH); - } return searchDirs; } diff --git a/libnymea/translator.cpp b/libnymea/translator.cpp index 69c31d0b..af62f129 100644 --- a/libnymea/translator.cpp +++ b/libnymea/translator.cpp @@ -85,12 +85,7 @@ void Translator::loadTranslator(DevicePlugin *plugin, const QLocale &locale) } else { QString pluginId = plugin->pluginId().toString().remove(QRegExp("[{}]")); - QStringList searchDirs = QString(qgetenv("NYMEA_PLUGINS_PATH")).split(':'); - searchDirs << QCoreApplication::applicationDirPath() + "/../lib/nymea/plugins"; - searchDirs << QCoreApplication::applicationDirPath() + "/../plugins/"; - searchDirs << QCoreApplication::applicationDirPath() + "/../../../plugins/"; - - foreach (const QString &pluginPath, searchDirs) { + foreach (const QString &pluginPath, m_deviceManager->pluginSearchDirs()) { if (translator->load(locale, pluginId, "-", QDir(pluginPath + "/translations/").absolutePath(), ".qm")) { qCDebug(dcTranslations()) << "* Loaded translation" << locale.name() << "for plugin" << plugin->pluginName() << "from" << QDir(pluginPath + "/translations/").absolutePath(); loaded = true; diff --git a/nymea.pri b/nymea.pri index d25c25a8..3a1a78eb 100644 --- a/nymea.pri +++ b/nymea.pri @@ -1,9 +1,6 @@ # Parse and export NYMEA_VERSION_STRING NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"') -# Install path for plugins -NYMEA_PLUGINS_PATH=/usr/lib/nymea/plugins/ - # define protocol versions JSON_PROTOCOL_VERSION_MAJOR=2 JSON_PROTOCOL_VERSION_MINOR=0 @@ -15,8 +12,7 @@ COPYRIGHT_YEAR_TO=2019 DEFINES += NYMEA_VERSION_STRING=\\\"$${NYMEA_VERSION_STRING}\\\" \ JSON_PROTOCOL_VERSION=\\\"$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}\\\" \ REST_API_VERSION=\\\"$${REST_API_VERSION}\\\" \ - COPYRIGHT_YEAR_STRING=\\\"$${COPYRIGHT_YEAR_FROM}-$${COPYRIGHT_YEAR_TO}\\\" \ - NYMEA_PLUGINS_PATH=\\\"$${NYMEA_PLUGINS_PATH}\\\" + COPYRIGHT_YEAR_STRING=\\\"$${COPYRIGHT_YEAR_FROM}-$${COPYRIGHT_YEAR_TO}\\\" QT *= network websockets bluetooth dbus diff --git a/nymea.pro b/nymea.pro index fc6a7443..3713aa3e 100644 --- a/nymea.pro +++ b/nymea.pro @@ -58,7 +58,6 @@ message("Copyright $${COPYRIGHT_YEAR_FROM} - $${COPYRIGHT_YEAR_TO}") message("Building nymea version $${NYMEA_VERSION_STRING}") message("JSON-RPC API version $${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}") message("REST API version $${REST_API_VERSION}") -message("Plugin path $${NYMEA_PLUGINS_PATH}") message("Source directory: $${top_srcdir}") message("Build directory: $${top_builddir}") message("Translations: $${TRANSLATIONS}") diff --git a/plugins/plugins.pri b/plugins/plugins.pri index 0938aec8..3b83e3c6 100644 --- a/plugins/plugins.pri +++ b/plugins/plugins.pri @@ -34,5 +34,5 @@ PRE_TARGETDEPS += compiler_plugininfo_make_all compiler_externplugininfo_make_al QMAKE_EXTRA_COMPILERS += plugininfo externplugininfo # Install plugin -target.path = $$NYMEA_PLUGINS_PATH +target.path = /usr/lib/nymea/plugins/ INSTALLS += target