diff --git a/ground/gcs/src/app/app.pro b/ground/gcs/src/app/app.pro index 0818a180f..af1903de6 100644 --- a/ground/gcs/src/app/app.pro +++ b/ground/gcs/src/app/app.pro @@ -20,8 +20,6 @@ include(../libs/version_info/version_info.pri) LIBS *= -l$$qtLibraryName(ExtensionSystem) -l$$qtLibraryName(Aggregation) -DEFINES += PLUGIN_REL_PATH=$$shell_quote(\"$$relative_path($$GCS_PLUGIN_PATH, $$GCS_APP_PATH)\") - win32 { RC_FILE = gcs.rc target.path = /bin diff --git a/ground/gcs/src/app/main.cpp b/ground/gcs/src/app/main.cpp index 41804c822..f13bcec76 100644 --- a/ground/gcs/src/app/main.cpp +++ b/ground/gcs/src/app/main.cpp @@ -312,19 +312,6 @@ void logInit(QString fileName) } } -inline QStringList getPluginPaths() -{ - QStringList rc; - - QString pluginPath = QApplication::applicationDirPath(); - - pluginPath += QLatin1Char('/'); - pluginPath += QLatin1String(PLUGIN_REL_PATH); - rc.push_back(pluginPath); - - return rc; -} - AppOptions options() { AppOptions appOptions; @@ -467,7 +454,7 @@ int main(int argc, char * *argv) // initialize the plugin manager ExtensionSystem::PluginManager pluginManager; pluginManager.setFileExtension(QLatin1String("pluginspec")); - pluginManager.setPluginPaths(getPluginPaths()); + pluginManager.setPluginPaths(Utils::GetPluginPaths()); // parse command line qDebug() << "Command line" << app.arguments(); @@ -564,7 +551,7 @@ int main(int argc, char * *argv) } } if (!coreplugin) { - QString nativePaths = QDir::toNativeSeparators(getPluginPaths().join(QLatin1String(","))); + QString nativePaths = QDir::toNativeSeparators(Utils::GetPluginPaths().join(QLatin1String(","))); const QString reason = QCoreApplication::translate("Application", "Could not find 'Core.pluginspec' in %1").arg( nativePaths); displayError(msgCoreLoadFailure(reason)); diff --git a/ground/gcs/src/libs/osgearth/osgearth.cpp b/ground/gcs/src/libs/osgearth/osgearth.cpp index 40eeca25c..a97221b9e 100644 --- a/ground/gcs/src/libs/osgearth/osgearth.cpp +++ b/ground/gcs/src/libs/osgearth/osgearth.cpp @@ -30,7 +30,6 @@ #include "utility.h" #include "qtwindowingsystem.h" -#include "utils/gcsdirs.h" #include "utils/pathutils.h" #include @@ -114,12 +113,12 @@ void OsgEarth::initializePathes() // initialize data file path list osgDB::FilePathList &dataFilePathList = osgDB::Registry::instance()->getDataFilePathList(); - dataFilePathList.push_front(GCSDirs::sharePath("osgearth").toStdString()); - dataFilePathList.push_front(GCSDirs::sharePath("osgearth/data").toStdString()); + dataFilePathList.push_front((Utils::GetDataPath() + "osgearth").toStdString()); + dataFilePathList.push_front((Utils::GetDataPath() + "osgearth/data").toStdString()); // initialize library file path list osgDB::FilePathList &libraryFilePathList = osgDB::Registry::instance()->getLibraryFilePathList(); - libraryFilePathList.push_front(GCSDirs::libraryPath("osg").toStdString()); + libraryFilePathList.push_front((Utils::GetLibraryPath() + "osg").toStdString()); } void OsgEarth::initializeCache() diff --git a/ground/gcs/src/libs/utils/gcsdirs.cpp b/ground/gcs/src/libs/utils/gcsdirs.cpp deleted file mode 100644 index 5735b98c2..000000000 --- a/ground/gcs/src/libs/utils/gcsdirs.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/** - ****************************************************************************** - * - * @file gcsdirs.cpp - * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. - * @addtogroup - * @{ - * @addtogroup - * @{ - * @brief - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "gcsdirs.h" - -#include -#include -#include -#include - -GCSDirs::GCSDirs() - : d(0) -{} - -QString GCSDirs::rootDir() -{ - // Figure out root : Up one from 'bin' - QDir rootDir = QApplication::applicationDirPath(); - - rootDir.cdUp(); - return rootDir.canonicalPath(); -} - -QString GCSDirs::libraryPath(QString provider) -{ - QString libPath = rootDir(); - -#ifdef Q_OS_MACX - // TODO not correct... - libPath += QLatin1String("/Plugins"); - Q_UNUSED(provider); -#else - // GCS_LIBRARY_BASENAME is a compiler define set by qmake - libPath += QLatin1Char('/') + QLatin1String(LIB_REL_PATH); - libPath += QLatin1Char('/') + provider; -#endif - return libPath; -} - -QString GCSDirs::pluginPath(QString provider) -{ - QString pluginPath = rootDir(); - -#ifdef Q_OS_MACX - // TODO not correct... - pluginPath += QLatin1String("/Plugins"); - Q_UNUSED(provider); -#else - // GCS_LIBRARY_BASENAME is a compiler define set by qmake - pluginPath += QLatin1Char('/') + QLatin1String(LIB_REL_PATH); - pluginPath += QLatin1Char('/') + provider; - pluginPath += QLatin1String("/plugins"); -#endif - return pluginPath; -} - -QString GCSDirs::sharePath(QString provider) -{ - QString sharePath = rootDir(); - -#ifdef Q_OS_MACX - sharePath += QLatin1String("/Resources"); - Q_UNUSED(provider); -#else - sharePath += QLatin1String("/share/openpilotgcs"); - sharePath += QLatin1Char('/') + provider; -#endif - return sharePath; -} - -QString GCSDirs::gcsPluginPath() -{ - return pluginPath("openpilotgcs"); -} - -QString GCSDirs::gcsSharePath() -{ - return sharePath("openpilotgcs"); -} - -void GCSDirs::debug() -{ - qDebug() << "=== GCSDirs ==="; - qDebug() << "GCS Share Path :" << gcsSharePath(); - qDebug() << "GCS Plugin Path :" << gcsPluginPath(); - qDebug() << "==================="; -} diff --git a/ground/gcs/src/libs/utils/gcsdirs.h b/ground/gcs/src/libs/utils/gcsdirs.h deleted file mode 100644 index d5d2e9b81..000000000 --- a/ground/gcs/src/libs/utils/gcsdirs.h +++ /dev/null @@ -1,59 +0,0 @@ -/** - ****************************************************************************** - * - * @file gcsdirs.h - * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015. - * @addtogroup - * @{ - * @addtogroup - * @{ - * @brief - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef GCSDIRS_H -#define GCSDIRS_H - -#include "utils_global.h" - -class QString; - -class QTCREATOR_UTILS_EXPORT GCSDirs { -public: - GCSDirs(); - - static QString rootDir(); - - static QString libraryPath(QString provider); - - static QString pluginPath(QString provider); - - static QString sharePath(QString provider); - - static QString gcsSharePath(); - - static QString gcsPluginPath(); - - static void debug(); - -private: - Q_DISABLE_COPY(GCSDirs) - class Private; - Private *const d; -}; - -#endif // GCSDIRS_H diff --git a/ground/gcs/src/libs/utils/pathutils.cpp b/ground/gcs/src/libs/utils/pathutils.cpp index 7a9ead317..a3f66ce7f 100644 --- a/ground/gcs/src/libs/utils/pathutils.cpp +++ b/ground/gcs/src/libs/utils/pathutils.cpp @@ -26,11 +26,10 @@ */ #include "pathutils.h" -#include "xmlconfig.h" -#include -#include -#include +#include +#include +#include namespace Utils { /** @@ -120,4 +119,32 @@ QString InsertStoragePath(QString path) } return QDir::toNativeSeparators(path); } + +/** + Returns the base path of the library directory. + + Path is in Qt/Unix conventions, separated by "/". + */ +QString GetLibraryPath() +{ + QString libPath = QApplication::applicationDirPath(); + + libPath += QLatin1Char('/'); + libPath += QLatin1String(LIB_REL_PATH); + libPath += QLatin1Char('/'); + return libPath; +} + +QStringList GetPluginPaths() +{ + QStringList rc; + + QString pluginPath = QApplication::applicationDirPath(); + + pluginPath += QLatin1Char('/'); + pluginPath += QLatin1String(PLUGIN_REL_PATH); + rc.push_back(pluginPath); + + return rc; +} } diff --git a/ground/gcs/src/libs/utils/pathutils.h b/ground/gcs/src/libs/utils/pathutils.h index d54ccf2a0..485168454 100644 --- a/ground/gcs/src/libs/utils/pathutils.h +++ b/ground/gcs/src/libs/utils/pathutils.h @@ -30,10 +30,8 @@ #define PATHUTILS_H #include "utils_global.h" -#include "../extensionsystem/pluginmanager.h" -#include -#include -#include + +#include namespace Utils { QTCREATOR_UTILS_EXPORT QString GetDataPath(); @@ -43,6 +41,10 @@ QTCREATOR_UTILS_EXPORT QString InsertDataPath(QString path); QTCREATOR_UTILS_EXPORT QString GetStoragePath(); QTCREATOR_UTILS_EXPORT QString RemoveStoragePath(QString path); QTCREATOR_UTILS_EXPORT QString InsertStoragePath(QString path); + +QTCREATOR_UTILS_EXPORT QString GetLibraryPath(); + +QTCREATOR_UTILS_EXPORT QStringList GetPluginPaths(); } #endif /* PATHUTILS_H */ diff --git a/ground/gcs/src/libs/utils/utils.pro b/ground/gcs/src/libs/utils/utils.pro index 99296013c..17ca57c65 100644 --- a/ground/gcs/src/libs/utils/utils.pro +++ b/ground/gcs/src/libs/utils/utils.pro @@ -8,10 +8,10 @@ DEFINES += QTCREATOR_UTILS_LIB include(../../library.pri) DEFINES += DATA_REL_PATH=$$shell_quote(\"$$relative_path($$GCS_DATA_PATH, $$GCS_APP_PATH)\") -DEFINES += LIB_REL_PATH=$$shell_quote(\"$$relative_path($$GCS_LIBRARY_PATH, $$GCS_PATH)\") +DEFINES += LIB_REL_PATH=$$shell_quote(\"$$relative_path($$GCS_LIBRARY_PATH, $$GCS_APP_PATH)\") +DEFINES += PLUGIN_REL_PATH=$$shell_quote(\"$$relative_path($$GCS_PLUGIN_PATH, $$GCS_APP_PATH)\") SOURCES += \ - gcsdirs.cpp \ reloadpromptutils.cpp \ settingsutils.cpp \ filesearch.cpp \ @@ -72,7 +72,6 @@ else:SOURCES += consoleprocess_unix.cpp HEADERS += \ utils_global.h \ - gcsdirs.h \ reloadpromptutils.h \ settingsutils.h \ filesearch.h \ diff --git a/ground/gcs/src/plugins/notify/notificationitem.cpp b/ground/gcs/src/plugins/notify/notificationitem.cpp index a5d0e702c..687de55ce 100644 --- a/ground/gcs/src/plugins/notify/notificationitem.cpp +++ b/ground/gcs/src/plugins/notify/notificationitem.cpp @@ -26,7 +26,8 @@ */ // Qt headers -#include +#include +#include #include // GCS headers