mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-769 main.cpp various cleanups
This commit is contained in:
parent
6074828807
commit
cfbd9b2728
@ -100,7 +100,6 @@
|
|||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
#include <QtGui/QMainWindow>
|
#include <QtGui/QMainWindow>
|
||||||
#include <QtGui/QSplashScreen>
|
#include <QtGui/QSplashScreen>
|
||||||
#include <QtGui/QPainter>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -108,9 +107,8 @@ namespace {
|
|||||||
typedef QMap<QString, bool> AppOptions;
|
typedef QMap<QString, bool> AppOptions;
|
||||||
typedef QMap<QString, QString> AppOptionValues;
|
typedef QMap<QString, QString> AppOptionValues;
|
||||||
|
|
||||||
enum {
|
const int OptionIndent = 4;
|
||||||
OptionIndent = 4, DescriptionIndent = 24
|
const int DescriptionIndent = 24;
|
||||||
};
|
|
||||||
|
|
||||||
const QLatin1String APP_NAME("OpenPilot GCS");
|
const QLatin1String APP_NAME("OpenPilot GCS");
|
||||||
|
|
||||||
@ -127,7 +125,7 @@ namespace {
|
|||||||
|
|
||||||
const char *DEFAULT_CONFIG_FILENAME = "OpenPilotGCS.xml";
|
const char *DEFAULT_CONFIG_FILENAME = "OpenPilotGCS.xml";
|
||||||
|
|
||||||
const char *fixedOptionsC = " [OPTION]...\n"
|
const char *fixedOptionsC = " [OPTION]... [FILE]...\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -help Display this help\n"
|
" -help Display this help\n"
|
||||||
" -version Display application version\n"
|
" -version Display application version\n"
|
||||||
@ -211,16 +209,16 @@ namespace {
|
|||||||
|
|
||||||
// Prepare a remote argument: If it is a relative file, add the current directory
|
// Prepare a remote argument: If it is a relative file, add the current directory
|
||||||
// since the the central instance might be running in a different directory.
|
// since the the central instance might be running in a different directory.
|
||||||
inline QString prepareRemoteArgument(const QString &a)
|
inline QString prepareRemoteArgument(const QString &arg)
|
||||||
{
|
{
|
||||||
QFileInfo fi(a);
|
QFileInfo fi(arg);
|
||||||
if (!fi.exists()) {
|
if (!fi.exists()) {
|
||||||
return a;
|
return arg;
|
||||||
}
|
}
|
||||||
if (fi.isRelative()) {
|
if (fi.isRelative()) {
|
||||||
return fi.absoluteFilePath();
|
return fi.absoluteFilePath();
|
||||||
}
|
}
|
||||||
return a;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send the arguments to an already running instance of application
|
// Send the arguments to an already running instance of application
|
||||||
@ -321,12 +319,12 @@ namespace {
|
|||||||
// check if command line option -config-file contains a file name
|
// check if command line option -config-file contains a file name
|
||||||
QString commandLine = appOptionValues.value(CONFIG_FILE_OPTION);
|
QString commandLine = appOptionValues.value(CONFIG_FILE_OPTION);
|
||||||
if (!commandLine.isEmpty()) {
|
if (!commandLine.isEmpty()) {
|
||||||
if (QFile::exists(directory.absolutePath() + QDir::separator() + commandLine)) {
|
QFileInfo fi(commandLine);
|
||||||
|
if (fi.isRelative()) {
|
||||||
// file name specified on command line has a relative path
|
// file name specified on command line has a relative path
|
||||||
fileName = directory.absolutePath() + QDir::separator() + commandLine;
|
commandLine = directory.absolutePath() + QDir::separator() + commandLine;
|
||||||
qDebug() << "Configuration file" << fileName << "specified on command line will be loaded.";
|
}
|
||||||
} else if (QFile::exists(commandLine)) {
|
if (QFile::exists(commandLine)) {
|
||||||
// file name specified on command line has an absolutee path
|
|
||||||
fileName = commandLine;
|
fileName = commandLine;
|
||||||
qDebug() << "Configuration file" << fileName << "specified on command line will be loaded.";
|
qDebug() << "Configuration file" << fileName << "specified on command line will be loaded.";
|
||||||
} else {
|
} else {
|
||||||
@ -543,8 +541,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
{
|
{
|
||||||
QStringList errors;
|
QStringList errors;
|
||||||
foreach (ExtensionSystem::PluginSpec *p, pluginManager.plugins())
|
foreach (ExtensionSystem::PluginSpec *p, pluginManager.plugins()) {
|
||||||
{
|
|
||||||
if (p->hasError()) {
|
if (p->hasError()) {
|
||||||
errors.append(p->errorString());
|
errors.append(p->errorString());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user