1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-16 08:29:15 +01:00

LP-29 merged gcsdirs into pathutils and related cleanups

This commit is contained in:
Philippe Renon 2015-08-30 22:14:58 +02:00
parent 7b1c49c8bc
commit 723ab39d59
9 changed files with 46 additions and 203 deletions

View File

@ -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

View File

@ -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));

View File

@ -30,7 +30,6 @@
#include "utility.h"
#include "qtwindowingsystem.h"
#include "utils/gcsdirs.h"
#include "utils/pathutils.h"
#include <osg/DisplaySettings>
@ -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()

View File

@ -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 <QDir>
#include <QDebug>
#include <QString>
#include <QApplication>
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() << "===================";
}

View File

@ -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

View File

@ -26,11 +26,10 @@
*/
#include "pathutils.h"
#include "xmlconfig.h"
#include <stdint.h>
#include <QDebug>
#include <QStandardPaths>
#include <QApplication>
#include <QDir>
#include <QStandardPaths>
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;
}
}

View File

@ -30,10 +30,8 @@
#define PATHUTILS_H
#include "utils_global.h"
#include "../extensionsystem/pluginmanager.h"
#include <QDir>
#include <QtWidgets/QApplication>
#include <QSettings>
#include <QStringList>
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 */

View File

@ -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 \

View File

@ -26,7 +26,8 @@
*/
// Qt headers
#include <QtCore/QDataStream>
#include <QDataStream>
#include <QDir>
#include <QFile>
// GCS headers