#endif
#endif
#include "QGCMapEngine.h"
-class FinishVideoInitialization : public QRunnable
-{
+class FinishVideoInitialization : public QRunnable {
public:
- FinishVideoInitialization(VideoManager* manager)
- : _manager(manager)
- {}
+ FinishVideoInitialization(VideoManager *manager) : _manager(manager) {}
- void run () {
- _manager->_initVideo();
- }
+ void run() { _manager->_initVideo(); }
private:
- VideoManager* _manager;
+ VideoManager *_manager;
};
+QGCApplication *QGCApplication::_app = nullptr;
-QGCApplication* QGCApplication::_app = nullptr;
-
-const char* QGCApplication::_deleteAllSettingsKey = "DeleteAllSettingsNextBoot";
-const char* QGCApplication::_settingsVersionKey = "SettingsVersion";
+const char *QGCApplication::_deleteAllSettingsKey = "DeleteAllSettingsNextBoot";
+const char *QGCApplication::_settingsVersionKey = "SettingsVersion";
// Mavlink status structures for entire app
mavlink_status_t m_mavlink_status[MAVLINK_COMM_NUM_BUFFERS];
// Qml Singleton factories
-static QObject* screenToolsControllerSingletonFactory(QQmlEngine*, QJSEngine*)
-{
- ScreenToolsController* screenToolsController = new ScreenToolsController;
- return screenToolsController;
+static QObject *screenToolsControllerSingletonFactory(QQmlEngine *,
+ QJSEngine *) {
+ ScreenToolsController *screenToolsController = new ScreenToolsController;
+ return screenToolsController;
}
-static QObject* mavlinkSingletonFactory(QQmlEngine*, QJSEngine*)
-{
- return new QGCMAVLink();
+static QObject *mavlinkSingletonFactory(QQmlEngine *, QJSEngine *) {
+ return new QGCMAVLink();
}
-static QObject* qgroundcontrolQmlGlobalSingletonFactory(QQmlEngine*, QJSEngine*)
-{
- // We create this object as a QGCTool even though it isn't in the toolbox
- QGroundControlQmlGlobal* qmlGlobal = new QGroundControlQmlGlobal(qgcApp(), qgcApp()->toolbox());
- qmlGlobal->setToolbox(qgcApp()->toolbox());
+static QObject *qgroundcontrolQmlGlobalSingletonFactory(QQmlEngine *,
+ QJSEngine *) {
+ // We create this object as a QGCTool even though it isn't in the toolbox
+ QGroundControlQmlGlobal *qmlGlobal =
+ new QGroundControlQmlGlobal(qgcApp(), qgcApp()->toolbox());
+ qmlGlobal->setToolbox(qgcApp()->toolbox());
- return qmlGlobal;
+ return qmlGlobal;
}
-static QObject* shapeFileHelperSingletonFactory(QQmlEngine*, QJSEngine*)
-{
- return new ShapeFileHelper;
+static QObject *shapeFileHelperSingletonFactory(QQmlEngine *, QJSEngine *) {
+ return new ShapeFileHelper;
}
-QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
- : QApplication (argc, argv)
- , _runningUnitTests (unitTesting)
-{
- _app = this;
- _msecsElapsedTime.start();
+QGCApplication::QGCApplication(int &argc, char *argv[], bool unitTesting)
+ : QApplication(argc, argv), _runningUnitTests(unitTesting) {
+ _app = this;
+ _msecsElapsedTime.start();
#ifdef Q_OS_LINUX
#ifndef __mobile__
- if (!_runningUnitTests) {
- if (getuid() == 0) {
- _exitWithError(QString(
- tr("You are running %1 as root. "
- "You should not do this since it will cause other issues with %1."
- "%1 will now exit.
"
- "If you are having serial port issues on Ubuntu, execute the following commands to fix most issues:
"
- "sudo usermod -a -G dialout $USER
"
- "sudo apt-get remove modemmanager
").arg(qgcApp()->applicationName())));
- return;
- }
- // Determine if we have the correct permissions to access USB serial devices
- QFile permFile("/etc/group");
- if(permFile.open(QIODevice::ReadOnly)) {
- while(!permFile.atEnd()) {
- QString line = permFile.readLine();
- if (line.contains("dialout") && !line.contains(getenv("USER"))) {
- permFile.close();
- _exitWithError(QString(
- tr("The current user does not have the correct permissions to access serial devices. "
- "You should also remove modemmanager since it also interferes.
"
- "If you are using Ubuntu, execute the following commands to fix these issues:
"
- "sudo usermod -a -G dialout $USER
"
- "sudo apt-get remove modemmanager
")));
- return;
- }
- }
- permFile.close();
+ if (!_runningUnitTests) {
+ if (getuid() == 0) {
+ _exitWithError(QString(
+ tr("You are running %1 as root. "
+ "You should not do this since it will cause other issues with %1."
+ "%1 will now exit.
"
+ "If you are having serial port issues on Ubuntu, execute the "
+ "following commands to fix most issues:
"
+ "sudo usermod -a -G dialout $USER
"
+ "sudo apt-get remove modemmanager
")
+ .arg(qgcApp()->applicationName())));
+ return;
+ }
+ // Determine if we have the correct permissions to access USB serial devices
+ QFile permFile("/etc/group");
+ if (permFile.open(QIODevice::ReadOnly)) {
+ while (!permFile.atEnd()) {
+ QString line = permFile.readLine();
+ if (line.contains("dialout") && !line.contains(getenv("USER"))) {
+ permFile.close();
+ _exitWithError(
+ QString(tr("The current user does not have the correct "
+ "permissions to access serial devices. "
+ "You should also remove modemmanager since it also "
+ "interferes.
"
+ "If you are using Ubuntu, execute the following "
+ "commands to fix these issues:
"
+ "sudo usermod -a -G dialout $USER
"
+ "sudo apt-get remove modemmanager
")));
+ return;
}
-
- // Always set style to default, this way QT_QUICK_CONTROLS_STYLE environment variable doesn't cause random changes in ui
- QQuickStyle::setStyle("Default");
+ }
+ permFile.close();
}
+
+ // Always set style to default, this way QT_QUICK_CONTROLS_STYLE environment
+ // variable doesn't cause random changes in ui
+ QQuickStyle::setStyle("Default");
+ }
#endif
#endif
- // Setup for network proxy support
- QNetworkProxyFactory::setUseSystemConfiguration(true);
-
- // Parse command line options
-
- bool fClearSettingsOptions = false; // Clear stored settings
- bool fClearCache = false; // Clear parameter/airframe caches
- bool logging = false; // Turn on logging
- QString loggingOptions;
-
- CmdLineOpt_t rgCmdLineOptions[] = {
- { "--clear-settings", &fClearSettingsOptions, nullptr },
- { "--clear-cache", &fClearCache, nullptr },
- { "--logging", &logging, &loggingOptions },
- { "--fake-mobile", &_fakeMobile, nullptr },
- { "--log-output", &_logOutput, nullptr },
- // Add additional command line option flags here
- };
-
- ParseCmdLineOptions(argc, argv, rgCmdLineOptions, sizeof(rgCmdLineOptions)/sizeof(rgCmdLineOptions[0]), false);
-
- // Set up timer for delayed missing fact display
- _missingParamsDelayedDisplayTimer.setSingleShot(true);
- _missingParamsDelayedDisplayTimer.setInterval(_missingParamsDelayedDisplayTimerTimeout);
- connect(&_missingParamsDelayedDisplayTimer, &QTimer::timeout, this, &QGCApplication::_missingParamsDisplay);
-
- // Set application information
- QString applicationName;
- if (_runningUnitTests) {
- // We don't want unit tests to use the same QSettings space as the normal app. So we tweak the app
- // name. Also we want to run unit tests with clean settings every time.
- applicationName = QStringLiteral("%1_unittest").arg(QGC_APPLICATION_NAME);
- } else {
+ // Setup for network proxy support
+ QNetworkProxyFactory::setUseSystemConfiguration(true);
+
+ // Parse command line options
+
+ bool fClearSettingsOptions = false; // Clear stored settings
+ bool fClearCache = false; // Clear parameter/airframe caches
+ bool logging = false; // Turn on logging
+ QString loggingOptions;
+
+ CmdLineOpt_t rgCmdLineOptions[] = {
+ {"--clear-settings", &fClearSettingsOptions, nullptr},
+ {"--clear-cache", &fClearCache, nullptr},
+ {"--logging", &logging, &loggingOptions},
+ {"--fake-mobile", &_fakeMobile, nullptr},
+ {"--log-output", &_logOutput, nullptr},
+ // Add additional command line option flags here
+ };
+
+ ParseCmdLineOptions(argc, argv, rgCmdLineOptions,
+ sizeof(rgCmdLineOptions) / sizeof(rgCmdLineOptions[0]),
+ false);
+
+ // Set up timer for delayed missing fact display
+ _missingParamsDelayedDisplayTimer.setSingleShot(true);
+ _missingParamsDelayedDisplayTimer.setInterval(
+ _missingParamsDelayedDisplayTimerTimeout);
+ connect(&_missingParamsDelayedDisplayTimer, &QTimer::timeout, this,
+ &QGCApplication::_missingParamsDisplay);
+
+ // Set application information
+ QString applicationName;
+ if (_runningUnitTests) {
+ // We don't want unit tests to use the same QSettings space as the normal
+ // app. So we tweak the app name. Also we want to run unit tests with clean
+ // settings every time.
+ applicationName = QStringLiteral("%1_unittest").arg(QGC_APPLICATION_NAME);
+ } else {
#ifdef DAILY_BUILD
- // This gives daily builds their own separate settings space. Allowing you to use daily and stable builds
- // side by side without daily screwing up your stable settings.
- applicationName = QStringLiteral("%1 Daily").arg(QGC_APPLICATION_NAME);
+ // This gives daily builds their own separate settings space. Allowing you
+ // to use daily and stable builds side by side without daily screwing up
+ // your stable settings.
+ applicationName = QStringLiteral("%1 Daily").arg(QGC_APPLICATION_NAME);
#else
- applicationName = QGC_APPLICATION_NAME;
+ applicationName = QGC_APPLICATION_NAME;
#endif
- }
- setApplicationName(applicationName);
- setOrganizationName(QGC_ORG_NAME);
- setOrganizationDomain(QGC_ORG_DOMAIN);
+ }
+ setApplicationName(applicationName);
+ setOrganizationName(QGC_ORG_NAME);
+ setOrganizationDomain(QGC_ORG_DOMAIN);
- this->setApplicationVersion(QString(GIT_VERSION));
+ this->setApplicationVersion(QString(GIT_VERSION));
- // Set settings format
- QSettings::setDefaultFormat(QSettings::IniFormat);
- QSettings settings;
- qDebug() << "Settings location" << settings.fileName() << "Is writable?:" << settings.isWritable();
+ // Set settings format
+ QSettings::setDefaultFormat(QSettings::IniFormat);
+ QSettings settings;
+ qDebug() << "Settings location" << settings.fileName()
+ << "Is writable?:" << settings.isWritable();
#ifdef UNITTEST_BUILD
- if (!settings.isWritable()) {
- qWarning() << "Setings location is not writable";
- }
+ if (!settings.isWritable()) {
+ qWarning() << "Setings location is not writable";
+ }
#endif
- // The setting will delete all settings on this boot
- fClearSettingsOptions |= settings.contains(_deleteAllSettingsKey);
+ // The setting will delete all settings on this boot
+ fClearSettingsOptions |= settings.contains(_deleteAllSettingsKey);
- if (_runningUnitTests) {
- // Unit tests run with clean settings
- fClearSettingsOptions = true;
- }
+ if (_runningUnitTests) {
+ // Unit tests run with clean settings
+ fClearSettingsOptions = true;
+ }
- if (fClearSettingsOptions) {
- // User requested settings to be cleared on command line
+ if (fClearSettingsOptions) {
+ // User requested settings to be cleared on command line
+ settings.clear();
+
+ // Clear parameter cache
+ QDir paramDir(ParameterManager::parameterCacheDir());
+ paramDir.removeRecursively();
+ paramDir.mkpath(paramDir.absolutePath());
+ } else {
+ // Determine if upgrade message for settings version bump is required. Check
+ // and clear must happen before toolbox is started since that will write
+ // some settings.
+ if (settings.contains(_settingsVersionKey)) {
+ if (settings.value(_settingsVersionKey).toInt() != QGC_SETTINGS_VERSION) {
settings.clear();
-
- // Clear parameter cache
- QDir paramDir(ParameterManager::parameterCacheDir());
- paramDir.removeRecursively();
- paramDir.mkpath(paramDir.absolutePath());
- } else {
- // Determine if upgrade message for settings version bump is required. Check and clear must happen before toolbox is started since
- // that will write some settings.
- if (settings.contains(_settingsVersionKey)) {
- if (settings.value(_settingsVersionKey).toInt() != QGC_SETTINGS_VERSION) {
- settings.clear();
- _settingsUpgraded = true;
- }
- }
- }
- settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION);
-
- if (fClearCache) {
- QDir dir(ParameterManager::parameterCacheDir());
- dir.removeRecursively();
- QFile airframe(cachedAirframeMetaDataFile());
- airframe.remove();
- QFile parameter(cachedParameterMetaDataFile());
- parameter.remove();
+ _settingsUpgraded = true;
+ }
}
+ }
+ settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION);
+
+ if (fClearCache) {
+ QDir dir(ParameterManager::parameterCacheDir());
+ dir.removeRecursively();
+ QFile airframe(cachedAirframeMetaDataFile());
+ airframe.remove();
+ QFile parameter(cachedParameterMetaDataFile());
+ parameter.remove();
+ }
- // Set up our logging filters
- QGCLoggingCategoryRegister::instance()->setFilterRulesFromSettings(loggingOptions);
+ // Set up our logging filters
+ QGCLoggingCategoryRegister::instance()->setFilterRulesFromSettings(
+ loggingOptions);
- // Initialize Bluetooth
+ // Initialize Bluetooth
#ifdef QGC_ENABLE_BLUETOOTH
- QBluetoothLocalDevice localDevice;
- if (localDevice.isValid())
- {
- _bluetoothAvailable = true;
- }
+ QBluetoothLocalDevice localDevice;
+ if (localDevice.isValid()) {
+ _bluetoothAvailable = true;
+ }
#endif
- // Gstreamer debug settings
- int gstDebugLevel = 0;
- if (settings.contains(AppSettings::gstDebugLevelName)) {
- gstDebugLevel = settings.value(AppSettings::gstDebugLevelName).toInt();
- }
+ // Gstreamer debug settings
+ int gstDebugLevel = 0;
+ if (settings.contains(AppSettings::gstDebugLevelName)) {
+ gstDebugLevel = settings.value(AppSettings::gstDebugLevelName).toInt();
+ }
#if defined(QGC_GST_STREAMING)
- // Initialize Video Receiver
- GStreamer::initialize(argc, argv, gstDebugLevel);
+ // Initialize Video Receiver
+ GStreamer::initialize(argc, argv, gstDebugLevel);
#else
- Q_UNUSED(gstDebugLevel)
+ Q_UNUSED(gstDebugLevel)
#endif
- // We need to set language as early as possible prior to loading on JSON files.
- setLanguage();
+ // We need to set language as early as possible prior to loading on JSON
+ // files.
+ setLanguage();
- _toolbox = new QGCToolbox(this);
- _toolbox->setChildToolboxes();
+ _toolbox = new QGCToolbox(this);
+ _toolbox->setChildToolboxes();
#ifndef __mobile__
- _gpsRtkFactGroup = new GPSRTKFactGroup(this);
- GPSManager *gpsManager = _toolbox->gpsManager();
- if (gpsManager) {
- connect(gpsManager, &GPSManager::onConnect, this, &QGCApplication::_onGPSConnect);
- connect(gpsManager, &GPSManager::onDisconnect, this, &QGCApplication::_onGPSDisconnect);
- connect(gpsManager, &GPSManager::surveyInStatus, this, &QGCApplication::_gpsSurveyInStatus);
- connect(gpsManager, &GPSManager::satelliteUpdate, this, &QGCApplication::_gpsNumSatellites);
- }
+ _gpsRtkFactGroup = new GPSRTKFactGroup(this);
+ GPSManager *gpsManager = _toolbox->gpsManager();
+ if (gpsManager) {
+ connect(gpsManager, &GPSManager::onConnect, this,
+ &QGCApplication::_onGPSConnect);
+ connect(gpsManager, &GPSManager::onDisconnect, this,
+ &QGCApplication::_onGPSDisconnect);
+ connect(gpsManager, &GPSManager::surveyInStatus, this,
+ &QGCApplication::_gpsSurveyInStatus);
+ connect(gpsManager, &GPSManager::satelliteUpdate, this,
+ &QGCApplication::_gpsNumSatellites);
+ }
#endif /* __mobile__ */
- _checkForNewVersion();
-}
-
-void QGCApplication::_exitWithError(QString errorMessage)
-{
- _error = true;
- QQmlApplicationEngine* pEngine = new QQmlApplicationEngine(this);
- pEngine->addImportPath("qrc:/qml");
- pEngine->rootContext()->setContextProperty("errorMessage", errorMessage);
- pEngine->load(QUrl(QStringLiteral("qrc:/qml/ExitWithErrorWindow.qml")));
- // Exit main application when last window is closed
- connect(this, &QGCApplication::lastWindowClosed, this, QGCApplication::quit);
-}
-
-void QGCApplication::setLanguage()
-{
- _locale = QLocale::system();
- qDebug() << "System reported locale:" << _locale << "; Name" << _locale.name() << "; Preffered (used in maps): " << (QLocale::system().uiLanguages().length() > 0 ? QLocale::system().uiLanguages()[0] : "None");
-
- int langID = AppSettings::_languageID();
- //-- See App.SettinsGroup.json for index
- if(langID) {
- switch(langID) {
- case 1:
- _locale = QLocale(QLocale::Bulgarian);
- break;
- case 2:
- _locale = QLocale(QLocale::Chinese);
- break;
- case 3:
- _locale = QLocale(QLocale::Dutch);
- break;
- case 4:
- _locale = QLocale(QLocale::English);
- break;
- case 5:
- _locale = QLocale(QLocale::Finnish);
- break;
- case 6:
- _locale = QLocale(QLocale::French);
- break;
- case 7:
- _locale = QLocale(QLocale::German);
- break;
- case 8:
- _locale = QLocale(QLocale::Greek);
- break;
- case 9:
- _locale = QLocale(QLocale::Hebrew);
- break;
- case 10:
- _locale = QLocale(QLocale::Italian);
- break;
- case 11:
- _locale = QLocale(QLocale::Japanese);
- break;
- case 12:
- _locale = QLocale(QLocale::Korean);
- break;
- case 13:
- _locale = QLocale(QLocale::Norwegian);
- break;
- case 14:
- _locale = QLocale(QLocale::Polish);
- break;
- case 15:
- _locale = QLocale(QLocale::Portuguese);
- break;
- case 16:
- _locale = QLocale(QLocale::Russian);
- break;
- case 17:
- _locale = QLocale(QLocale::Spanish);
- break;
- case 18:
- _locale = QLocale(QLocale::Swedish);
- break;
- case 19:
- _locale = QLocale(QLocale::Turkish);
- break;
- case 20:
- _locale = QLocale(QLocale::Azerbaijani);
- break;
- }
+ _checkForNewVersion();
+}
+
+void QGCApplication::_exitWithError(QString errorMessage) {
+ _error = true;
+ QQmlApplicationEngine *pEngine = new QQmlApplicationEngine(this);
+ pEngine->addImportPath("qrc:/qml");
+ pEngine->rootContext()->setContextProperty("errorMessage", errorMessage);
+ pEngine->load(QUrl(QStringLiteral("qrc:/qml/ExitWithErrorWindow.qml")));
+ // Exit main application when last window is closed
+ connect(this, &QGCApplication::lastWindowClosed, this, QGCApplication::quit);
+}
+
+void QGCApplication::setLanguage() {
+ _locale = QLocale::system();
+ qDebug() << "System reported locale:" << _locale << "; Name" << _locale.name()
+ << "; Preffered (used in maps): "
+ << (QLocale::system().uiLanguages().length() > 0
+ ? QLocale::system().uiLanguages()[0]
+ : "None");
+
+ int langID = AppSettings::_languageID();
+ //-- See App.SettinsGroup.json for index
+ if (langID) {
+ switch (langID) {
+ case 1:
+ _locale = QLocale(QLocale::Bulgarian);
+ break;
+ case 2:
+ _locale = QLocale(QLocale::Chinese);
+ break;
+ case 3:
+ _locale = QLocale(QLocale::Dutch);
+ break;
+ case 4:
+ _locale = QLocale(QLocale::English);
+ break;
+ case 5:
+ _locale = QLocale(QLocale::Finnish);
+ break;
+ case 6:
+ _locale = QLocale(QLocale::French);
+ break;
+ case 7:
+ _locale = QLocale(QLocale::German);
+ break;
+ case 8:
+ _locale = QLocale(QLocale::Greek);
+ break;
+ case 9:
+ _locale = QLocale(QLocale::Hebrew);
+ break;
+ case 10:
+ _locale = QLocale(QLocale::Italian);
+ break;
+ case 11:
+ _locale = QLocale(QLocale::Japanese);
+ break;
+ case 12:
+ _locale = QLocale(QLocale::Korean);
+ break;
+ case 13:
+ _locale = QLocale(QLocale::Norwegian);
+ break;
+ case 14:
+ _locale = QLocale(QLocale::Polish);
+ break;
+ case 15:
+ _locale = QLocale(QLocale::Portuguese);
+ break;
+ case 16:
+ _locale = QLocale(QLocale::Russian);
+ break;
+ case 17:
+ _locale = QLocale(QLocale::Spanish);
+ break;
+ case 18:
+ _locale = QLocale(QLocale::Swedish);
+ break;
+ case 19:
+ _locale = QLocale(QLocale::Turkish);
+ break;
+ case 20:
+ _locale = QLocale(QLocale::Azerbaijani);
+ break;
}
- //-- We have specific fonts for Korean
- if(_locale == QLocale::Korean) {
- qCDebug(LocalizationLog) << "Loading Korean fonts" << _locale.name();
- if(QFontDatabase::addApplicationFont(":/fonts/NanumGothic-Regular") < 0) {
- qCWarning(LocalizationLog) << "Could not load /fonts/NanumGothic-Regular font";
- }
- if(QFontDatabase::addApplicationFont(":/fonts/NanumGothic-Bold") < 0) {
- qCWarning(LocalizationLog) << "Could not load /fonts/NanumGothic-Bold font";
- }
+ }
+ //-- We have specific fonts for Korean
+ if (_locale == QLocale::Korean) {
+ qCDebug(LocalizationLog) << "Loading Korean fonts" << _locale.name();
+ if (QFontDatabase::addApplicationFont(":/fonts/NanumGothic-Regular") < 0) {
+ qCWarning(LocalizationLog)
+ << "Could not load /fonts/NanumGothic-Regular font";
}
- qCDebug(LocalizationLog) << "Loading localizations for" << _locale.name();
- _app->removeTranslator(&_qgcTranslatorJSON);
- _app->removeTranslator(&_qgcTranslatorSourceCode);
- _app->removeTranslator(&_qgcTranslatorQtLibs);
- if (_locale.name() != "en_US") {
- QLocale::setDefault(_locale);
- if(_qgcTranslatorQtLibs.load("qt_" + _locale.name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
- _app->installTranslator(&_qgcTranslatorQtLibs);
- } else {
- qCWarning(LocalizationLog) << "Qt lib localization for" << _locale.name() << "is not present";
- }
- if(_qgcTranslatorSourceCode.load(_locale, QLatin1String("qgc_source_"), "", ":/i18n")) {
- _app->installTranslator(&_qgcTranslatorSourceCode);
- } else {
- qCWarning(LocalizationLog) << "Error loading source localization for" << _locale.name();
- }
- if(_qgcTranslatorJSON.load(_locale, QLatin1String("qgc_json_"), "", ":/i18n")) {
- _app->installTranslator(&_qgcTranslatorJSON);
- } else {
- qCWarning(LocalizationLog) << "Error loading json localization for" << _locale.name();
- }
+ if (QFontDatabase::addApplicationFont(":/fonts/NanumGothic-Bold") < 0) {
+ qCWarning(LocalizationLog)
+ << "Could not load /fonts/NanumGothic-Bold font";
+ }
+ }
+ qCDebug(LocalizationLog) << "Loading localizations for" << _locale.name();
+ _app->removeTranslator(&_qgcTranslatorJSON);
+ _app->removeTranslator(&_qgcTranslatorSourceCode);
+ _app->removeTranslator(&_qgcTranslatorQtLibs);
+ if (_locale.name() != "en_US") {
+ QLocale::setDefault(_locale);
+ if (_qgcTranslatorQtLibs.load(
+ "qt_" + _locale.name(),
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
+ _app->installTranslator(&_qgcTranslatorQtLibs);
+ } else {
+ qCWarning(LocalizationLog)
+ << "Qt lib localization for" << _locale.name() << "is not present";
+ }
+ if (_qgcTranslatorSourceCode.load(_locale, QLatin1String("qgc_source_"), "",
+ ":/i18n")) {
+ _app->installTranslator(&_qgcTranslatorSourceCode);
+ } else {
+ qCWarning(LocalizationLog)
+ << "Error loading source localization for" << _locale.name();
+ }
+ if (_qgcTranslatorJSON.load(_locale, QLatin1String("qgc_json_"), "",
+ ":/i18n")) {
+ _app->installTranslator(&_qgcTranslatorJSON);
+ } else {
+ qCWarning(LocalizationLog)
+ << "Error loading json localization for" << _locale.name();
}
- if(_qmlAppEngine)
- _qmlAppEngine->retranslate();
- emit languageChanged(_locale);
-}
-
-void QGCApplication::_shutdown()
-{
- // Close out all Qml before we delete toolbox. This way we don't get all sorts of null reference complaints from Qml.
- delete _qmlAppEngine;
- delete _toolbox;
- delete _gpsRtkFactGroup;
-}
-
-QGCApplication::~QGCApplication()
-{
- // Place shutdown code in _shutdown
- _app = nullptr;
-}
-
-void QGCApplication::_initCommon()
-{
- static const char* kRefOnly = "Reference only";
- static const char* kQGroundControl = "QGroundControl";
- static const char* kQGCControllers = "QGroundControl.Controllers";
- static const char* kQGCVehicle = "QGroundControl.Vehicle";
- static const char* kQGCTemplates = "QGroundControl.Templates";
-
- QSettings settings;
-
- // Register our Qml objects
-
- qmlRegisterType ("QGroundControl.Palette", 1, 0, "QGCPalette");
- qmlRegisterType ("QGroundControl.Palette", 1, 0, "QGCMapPalette");
-
- qmlRegisterUncreatableType (kQGCVehicle, 1, 0, "Vehicle", kRefOnly);
- qmlRegisterUncreatableType (kQGCVehicle, 1, 0, "MissionManager", kRefOnly);
- qmlRegisterUncreatableType (kQGCVehicle, 1, 0, "ParameterManager", kRefOnly);
- qmlRegisterUncreatableType (kQGCVehicle, 1, 0, "VehicleObjectAvoidance", kRefOnly);
- qmlRegisterUncreatableType (kQGCVehicle, 1, 0, "QGCCameraManager", kRefOnly);
- qmlRegisterUncreatableType (kQGCVehicle, 1, 0, "QGCCameraControl", kRefOnly);
- qmlRegisterUncreatableType (kQGCVehicle, 1, 0, "QGCVideoStreamInfo", kRefOnly);
- qmlRegisterUncreatableType (kQGCVehicle, 1, 0, "LinkInterface", kRefOnly);
- qmlRegisterUncreatableType (kQGCVehicle, 1, 0, "VehicleLinkManager", kRefOnly);
-
- qmlRegisterUncreatableType (kQGCControllers, 1, 0, "MissionController", kRefOnly);
- qmlRegisterUncreatableType (kQGCControllers, 1, 0, "GeoFenceController", kRefOnly);
- qmlRegisterUncreatableType (kQGCControllers, 1, 0, "RallyPointController", kRefOnly);
-
- qmlRegisterUncreatableType (kQGroundControl, 1, 0, "MissionItem", kRefOnly);
- qmlRegisterUncreatableType (kQGroundControl, 1, 0, "VisualMissionItem", kRefOnly);
- qmlRegisterUncreatableType (kQGroundControl, 1, 0, "FlightPathSegment", kRefOnly);
- qmlRegisterUncreatableType (kQGroundControl, 1, 0, "QmlObjectListModel", kRefOnly);
- qmlRegisterUncreatableType (kQGroundControl, 1, 0, "MissionCommandTree", kRefOnly);
- qmlRegisterUncreatableType (kQGroundControl, 1, 0, "CameraCalc", kRefOnly);
- qmlRegisterUncreatableType (kQGroundControl, 1, 0, "LogReplayLink", kRefOnly);
- qmlRegisterUncreatableType (kQGroundControl, 1, 0, "InstrumentValueData", kRefOnly);
- qmlRegisterType (kQGroundControl, 1, 0, "LogReplayLinkController");
+ }
+ if (_qmlAppEngine)
+ _qmlAppEngine->retranslate();
+ emit languageChanged(_locale);
+}
+
+void QGCApplication::_shutdown() {
+ // Close out all Qml before we delete toolbox. This way we don't get all sorts
+ // of null reference complaints from Qml.
+ delete _qmlAppEngine;
+ delete _toolbox;
+ delete _gpsRtkFactGroup;
+}
+
+QGCApplication::~QGCApplication() {
+ // Place shutdown code in _shutdown
+ _app = nullptr;
+}
+
+void QGCApplication::_initCommon() {
+ static const char *kRefOnly = "Reference only";
+ static const char *kQGroundControl = "QGroundControl";
+ static const char *kQGCControllers = "QGroundControl.Controllers";
+ static const char *kQGCVehicle = "QGroundControl.Vehicle";
+ static const char *kQGCTemplates = "QGroundControl.Templates";
+
+ QSettings settings;
+
+ // Register our Qml objects
+
+ qmlRegisterType("QGroundControl.Palette", 1, 0, "QGCPalette");
+ qmlRegisterType("QGroundControl.Palette", 1, 0,
+ "QGCMapPalette");
+
+ qmlRegisterUncreatableType(kQGCVehicle, 1, 0, "Vehicle", kRefOnly);
+ qmlRegisterUncreatableType(kQGCVehicle, 1, 0,
+ "MissionManager", kRefOnly);
+ qmlRegisterUncreatableType(kQGCVehicle, 1, 0,
+ "ParameterManager", kRefOnly);
+ qmlRegisterUncreatableType(
+ kQGCVehicle, 1, 0, "VehicleObjectAvoidance", kRefOnly);
+ qmlRegisterUncreatableType(kQGCVehicle, 1, 0,
+ "QGCCameraManager", kRefOnly);
+ qmlRegisterUncreatableType(kQGCVehicle, 1, 0,
+ "QGCCameraControl", kRefOnly);
+ qmlRegisterUncreatableType(
+ kQGCVehicle, 1, 0, "QGCVideoStreamInfo", kRefOnly);
+ qmlRegisterUncreatableType(kQGCVehicle, 1, 0, "LinkInterface",
+ kRefOnly);
+ qmlRegisterUncreatableType(
+ kQGCVehicle, 1, 0, "VehicleLinkManager", kRefOnly);
+
+ qmlRegisterUncreatableType(kQGCControllers, 1, 0,
+ "MissionController", kRefOnly);
+ qmlRegisterUncreatableType