@ -249,13 +249,21 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
connect ( & _missingParamsDelayedDisplayTimer , & QTimer : : timeout , this , & QGCApplication : : _missingParamsDisplay ) ;
connect ( & _missingParamsDelayedDisplayTimer , & QTimer : : timeout , this , & QGCApplication : : _missingParamsDisplay ) ;
// Set application information
// Set application information
QString applicationName ;
if ( _runningUnitTests ) {
if ( _runningUnitTests ) {
// We don't want unit tests to use the same QSettings space as the normal app. So we tweak the app
// 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.
// name. Also we want to run unit tests with clean settings every time.
setApplicationName ( QString ( " %1_unittest " ) . arg ( QGC_APPLICATION_NAME ) ) ;
applicationName = QStringLiteral ( " %1_unittest " ) . arg ( QGC_APPLICATION_NAME ) ;
} else {
} else {
setApplicationName ( QGC_APPLICATION_NAME ) ;
# 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 ) ;
# else
applicationName = QGC_APPLICATION_NAME ;
# endif
}
}
setApplicationName ( applicationName ) ;
setOrganizationName ( QGC_ORG_NAME ) ;
setOrganizationName ( QGC_ORG_NAME ) ;
setOrganizationDomain ( QGC_ORG_DOMAIN ) ;
setOrganizationDomain ( QGC_ORG_DOMAIN ) ;
@ -295,10 +303,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting)
settings . clear ( ) ;
settings . clear ( ) ;
_settingsUpgraded = true ;
_settingsUpgraded = true ;
}
}
} else if ( settings . allKeys ( ) . count ( ) ) {
// Settings version key is missing and there are settings. This is an upgrade scenario.
settings . clear ( ) ;
_settingsUpgraded = true ;
}
}
}
}
settings . setValue ( _settingsVersionKey , QGC_SETTINGS_VERSION ) ;
settings . setValue ( _settingsVersionKey , QGC_SETTINGS_VERSION ) ;
@ -740,13 +744,13 @@ void QGCApplication::_missingParamsDisplay(void)
}
}
_missingParams . clear ( ) ;
_missingParams . clear ( ) ;
showAppMessage ( tr ( " Parameters are missing from firmware. You may be running a version of firmware QGC does not work correctly with or your firmware has a bug in it. Missing params: %1 " ) . arg ( params ) ) ;
showAppMessage ( tr ( " Parameters are missing from firmware. You may be running a version of firmware which is not fully supported or your firmware has a bug in it. Missing params: %1 " ) . arg ( params ) ) ;
}
}
}
}
QObject * QGCApplication : : _rootQmlObject ( )
QObject * QGCApplication : : _rootQmlObject ( )
{
{
if ( _qmlAppEngine & & _qmlAppEngine - > rootObjects ( ) . size ( ) )
if ( _qmlAppEngine & & _qmlAppEngine - > rootObjects ( ) . size ( ) )
return _qmlAppEngine - > rootObjects ( ) [ 0 ] ;
return _qmlAppEngine - > rootObjects ( ) [ 0 ] ;
return nullptr ;
return nullptr ;
}
}
@ -778,12 +782,26 @@ void QGCApplication::showAppMessage(const QString& message, const QString& title
if ( rootQmlObject ) {
if ( rootQmlObject ) {
QVariant varReturn ;
QVariant varReturn ;
QVariant varMessage = QVariant : : fromValue ( message ) ;
QVariant varMessage = QVariant : : fromValue ( message ) ;
QMetaObject : : invokeMethod ( _rootQmlObject ( ) , " showMessageDialog " , Q_RETURN_ARG ( QVariant , varReturn ) , Q_ARG ( QVariant , dialogTitle ) /* No title */ , Q_ARG ( QVariant , varMessage ) ) ;
QMetaObject : : invokeMethod ( _rootQmlObject ( ) , " showMessageDialog " , Q_RETURN_ARG ( QVariant , varReturn ) , Q_ARG ( QVariant , dialogTitle ) , Q_ARG ( QVariant , varMessage ) ) ;
} else if ( runningUnitTests ( ) ) {
} else if ( runningUnitTests ( ) ) {
// Unit tests can run without UI
// Unit tests can run without UI
qDebug ( ) < < " QGCApplication::showAppMessage unittest " < < message < < dialogTitle ;
qDebug ( ) < < " QGCApplication::showAppMessage unittest " < < message < < dialogTitle ;
} else {
} else {
qWarning ( ) < < " Internal error " ;
// UI isn't ready yet
_delayedAppMessages . append ( QPair < QString , QString > ( dialogTitle , message ) ) ;
QTimer : : singleShot ( 200 , this , & QGCApplication : : _showDelayedAppMessages ) ;
}
}
void QGCApplication : : _showDelayedAppMessages ( void )
{
if ( _rootQmlObject ( ) ) {
for ( const QPair < QString , QString > & appMsg : _delayedAppMessages ) {
showAppMessage ( appMsg . second , appMsg . first ) ;
}
_delayedAppMessages . clear ( ) ;
} else {
QTimer : : singleShot ( 200 , this , & QGCApplication : : _showDelayedAppMessages ) ;
}
}
}
}