27
27
28
28
#include " QGCLogging.h"
29
29
#include " AudioOutput.h"
30
- #include " CmdLineOptParser.h"
31
30
#include " FollowMe.h"
32
31
#include " JoystickManager.h"
33
32
#include " JsonHelper.h"
36
35
#include " MultiVehicleManager.h"
37
36
#include " ParameterManager.h"
38
37
#include " PositionManager.h"
38
+ #include " QGCCommandLineParser.h"
39
39
#include " QGCCorePlugin.h"
40
40
#include " QGCFileDownload.h"
41
41
#include " QGCImageProvider.h"
42
42
#include " QGCLoggingCategory.h"
43
43
#include " SettingsManager.h"
44
+ #include " MavlinkSettings.h"
44
45
#include " AppSettings.h"
45
46
#include " UDPLink.h"
46
47
#include " Vehicle.h"
53
54
54
55
QGC_LOGGING_CATEGORY (QGCApplicationLog, " qgc.qgcapplication" )
55
56
56
- QGCApplication::QGCApplication(int &argc, char *argv[], bool unitTesting, bool simpleBootTest )
57
+ QGCApplication::QGCApplication(int &argc, char *argv[], const QGCCommandLineParser::CommandLineParseResult &cli )
57
58
: QApplication(argc, argv)
58
- , _runningUnitTests(unitTesting)
59
- , _simpleBootTest(simpleBootTest)
59
+ , _runningUnitTests(cli.runningUnitTests)
60
+ , _simpleBootTest(cli.simpleBootTest)
61
+ , _fakeMobile(cli.fakeMobile)
62
+ , _logOutput(cli.logOutput)
63
+ , _systemId(cli.systemId.value_or(0 ))
60
64
{
61
65
_msecsElapsedTime.start ();
62
66
63
67
// Setup for network proxy support
64
68
QNetworkProxyFactory::setUseSystemConfiguration (true );
65
69
66
- // Parse command line options
67
- bool fClearSettingsOptions = false ; // Clear stored settings
68
- bool fClearCache = false ; // Clear parameter/airframe caches
69
- bool logging = false ; // Turn on logging
70
- QString loggingOptions;
71
-
72
- CmdLineOpt_t rgCmdLineOptions[] = {
73
- { " --clear-settings" , &fClearSettingsOptions , nullptr },
74
- { " --clear-cache" , &fClearCache , nullptr },
75
- { " --logging" , &logging, &loggingOptions },
76
- { " --fake-mobile" , &_fakeMobile, nullptr },
77
- { " --log-output" , &_logOutput, nullptr },
78
- // Add additional command line option flags here
79
- };
80
-
81
- ParseCmdLineOptions (argc, argv, rgCmdLineOptions, std::size (rgCmdLineOptions), false );
70
+ bool fClearSettingsOptions = cli.clearSettingsOptions ; // Clear stored settings
71
+ const bool fClearCache = cli.clearCache ; // Clear parameter/airframe caches
72
+ const QString loggingOptions = cli.loggingOptions .value_or (QString (" " ));
82
73
83
74
// Set up timer for delayed missing fact display
84
75
_missingParamsDelayedDisplayTimer.setSingleShot (true );
@@ -87,7 +78,7 @@ QGCApplication::QGCApplication(int &argc, char *argv[], bool unitTesting, bool s
87
78
88
79
// Set application information
89
80
QString applicationName;
90
- if (_runningUnitTests || simpleBootTest ) {
81
+ if (_runningUnitTests || _simpleBootTest ) {
91
82
// We don't want unit tests to use the same QSettings space as the normal app. So we tweak the app
92
83
// name. Also we want to run unit tests with clean settings every time.
93
84
applicationName = QStringLiteral (" %1_unittest" ).arg (QGC_APP_NAME);
@@ -117,7 +108,7 @@ QGCApplication::QGCApplication(int &argc, char *argv[], bool unitTesting, bool s
117
108
// The setting will delete all settings on this boot
118
109
fClearSettingsOptions |= settings.contains (_deleteAllSettingsKey);
119
110
120
- if (_runningUnitTests || simpleBootTest ) {
111
+ if (_runningUnitTests || _simpleBootTest ) {
121
112
// Unit tests run with clean settings
122
113
fClearSettingsOptions = true ;
123
114
}
@@ -219,13 +210,17 @@ QGCApplication::~QGCApplication()
219
210
void QGCApplication::init ()
220
211
{
221
212
SettingsManager::instance ()->init ();
213
+ if (_systemId > 0 ) {
214
+ qCDebug (QGCApplicationLog) << " Setting MAVLink System ID to:" << _systemId;
215
+ SettingsManager::instance ()->mavlinkSettings ()->gcsMavlinkSystemID ()->setRawValue (_systemId);
216
+ }
222
217
223
218
// Although this should really be in _initForNormalAppBoot putting it here allowws us to create unit tests which pop up more easily
224
- if (QFontDatabase::addApplicationFont (" :/fonts/opensans" ) < 0 ) {
219
+ if (QFontDatabase::addApplicationFont (" :/fonts/opensans" ) < 0 ) {
225
220
qCWarning (QGCApplicationLog) << " Could not load /fonts/opensans font" ;
226
221
}
227
222
228
- if (QFontDatabase::addApplicationFont (" :/fonts/opensans-demibold" ) < 0 ) {
223
+ if (QFontDatabase::addApplicationFont (" :/fonts/opensans-demibold" ) < 0 ) {
229
224
qCWarning (QGCApplicationLog) << " Could not load /fonts/opensans-demibold font" ;
230
225
}
231
226
0 commit comments