|
|
|
@ -117,19 +117,13 @@ QGCApplication* QGCApplication::_app = NULL;
@@ -117,19 +117,13 @@ QGCApplication* QGCApplication::_app = NULL;
|
|
|
|
|
|
|
|
|
|
const char* QGCApplication::_deleteAllSettingsKey = "DeleteAllSettingsNextBoot"; |
|
|
|
|
const char* QGCApplication::_settingsVersionKey = "SettingsVersion"; |
|
|
|
|
const char* QGCApplication::_savedFilesLocationKey = "SavedFilesLocation"; |
|
|
|
|
const char* QGCApplication::_promptFlightDataSave = "PromptFLightDataSave"; |
|
|
|
|
const char* QGCApplication::_promptFlightDataSaveNotArmed = "PromptFLightDataSaveNotArmed"; |
|
|
|
|
const char* QGCApplication::_styleKey = "StyleIsDark"; |
|
|
|
|
|
|
|
|
|
const char* QGCApplication::_defaultSavedFileDirectoryName = "QGroundControl"; |
|
|
|
|
const char* QGCApplication::_savedFileMavlinkLogDirectoryName = "FlightData"; |
|
|
|
|
const char* QGCApplication::_savedFileParameterDirectoryName = "SavedParameters"; |
|
|
|
|
|
|
|
|
|
const char* QGCApplication::_darkStyleFile = ":/res/styles/style-dark.css"; |
|
|
|
|
const char* QGCApplication::_lightStyleFile = ":/res/styles/style-light.css"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Qml Singleton factories
|
|
|
|
|
|
|
|
|
|
static QObject* screenToolsControllerSingletonFactory(QQmlEngine*, QJSEngine*) |
|
|
|
@ -429,40 +423,6 @@ void QGCApplication::_initCommon(void)
@@ -429,40 +423,6 @@ void QGCApplication::_initCommon(void)
|
|
|
|
|
"Your saved settings have been reset to defaults."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Load saved files location and validate
|
|
|
|
|
|
|
|
|
|
QString savedFilesLocation; |
|
|
|
|
if (settings.contains(_savedFilesLocationKey)) { |
|
|
|
|
savedFilesLocation = settings.value(_savedFilesLocationKey).toString(); |
|
|
|
|
if (!validatePossibleSavedFilesLocation(savedFilesLocation)) { |
|
|
|
|
savedFilesLocation.clear(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (savedFilesLocation.isEmpty()) { |
|
|
|
|
// No location set (or invalid). Create a default one in Documents standard location.
|
|
|
|
|
|
|
|
|
|
QString documentsLocation = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); |
|
|
|
|
|
|
|
|
|
QDir documentsDir(documentsLocation); |
|
|
|
|
if (!documentsDir.exists()) { |
|
|
|
|
qWarning() << "Documents directory doesn't exist" << documentsDir.absolutePath(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool pathCreated = documentsDir.mkpath(_defaultSavedFileDirectoryName); |
|
|
|
|
Q_UNUSED(pathCreated); |
|
|
|
|
Q_ASSERT(pathCreated); |
|
|
|
|
savedFilesLocation = documentsDir.filePath(_defaultSavedFileDirectoryName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!savedFilesLocation.isEmpty()) { |
|
|
|
|
if (!validatePossibleSavedFilesLocation(savedFilesLocation)) { |
|
|
|
|
savedFilesLocation.clear(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
qDebug() << "Saved files location" << savedFilesLocation; |
|
|
|
|
settings.setValue(_savedFilesLocationKey, savedFilesLocation); |
|
|
|
|
|
|
|
|
|
settings.sync(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -487,14 +447,6 @@ bool QGCApplication::_initForNormalAppBoot(void)
@@ -487,14 +447,6 @@ bool QGCApplication::_initForNormalAppBoot(void)
|
|
|
|
|
MainWindow* mainWindow = MainWindow::_create(); |
|
|
|
|
Q_CHECK_PTR(mainWindow); |
|
|
|
|
|
|
|
|
|
// If we made it this far and we still don't have a location. Either the specfied location was invalid
|
|
|
|
|
// or we coudn't create a default location. Either way, we need to let the user know and prompt for a new
|
|
|
|
|
/// settings.
|
|
|
|
|
QString savedFilesLocation = settings.value(_savedFilesLocationKey).toString(); |
|
|
|
|
if (savedFilesLocation.isEmpty()) { |
|
|
|
|
showMessage("The location to save files to is invalid, or cannot be written to. Please provide a new one."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Now that main window is up check for lost log files
|
|
|
|
|
connect(this, &QGCApplication::checkForLostLogFiles, toolbox()->mavlinkProtocol(), &MAVLinkProtocol::checkForLostLogFiles); |
|
|
|
|
emit checkForLostLogFiles(); |
|
|
|
@ -523,70 +475,6 @@ void QGCApplication::clearDeleteAllSettingsNextBoot(void)
@@ -523,70 +475,6 @@ void QGCApplication::clearDeleteAllSettingsNextBoot(void)
|
|
|
|
|
settings.remove(_deleteAllSettingsKey); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QGCApplication::setSavedFilesLocation(QString& location) |
|
|
|
|
{ |
|
|
|
|
QSettings settings; |
|
|
|
|
settings.setValue(_savedFilesLocationKey, location); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool QGCApplication::validatePossibleSavedFilesLocation(QString& location) |
|
|
|
|
{ |
|
|
|
|
// Make sure we can write to the directory
|
|
|
|
|
|
|
|
|
|
QString filename = QDir(location).filePath("QGCTempXXXXXXXX.tmp"); |
|
|
|
|
QGCTemporaryFile tempFile(filename); |
|
|
|
|
if (!tempFile.open()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
tempFile.remove(); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString QGCApplication::savedFilesLocation(void) |
|
|
|
|
{ |
|
|
|
|
QSettings settings; |
|
|
|
|
|
|
|
|
|
return settings.value(_savedFilesLocationKey).toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString QGCApplication::savedParameterFilesLocation(void) |
|
|
|
|
{ |
|
|
|
|
QString location; |
|
|
|
|
QDir parentDir(savedFilesLocation()); |
|
|
|
|
|
|
|
|
|
location = parentDir.filePath(_savedFileParameterDirectoryName); |
|
|
|
|
|
|
|
|
|
if (!QDir(location).exists()) { |
|
|
|
|
// If directory doesn't exist, try to create it
|
|
|
|
|
if (!parentDir.mkpath(_savedFileParameterDirectoryName)) { |
|
|
|
|
// Return an error
|
|
|
|
|
location.clear(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return location; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString QGCApplication::mavlinkLogFilesLocation(void) |
|
|
|
|
{ |
|
|
|
|
QString location; |
|
|
|
|
QDir parentDir(savedFilesLocation()); |
|
|
|
|
|
|
|
|
|
location = parentDir.filePath(_savedFileMavlinkLogDirectoryName); |
|
|
|
|
|
|
|
|
|
if (!QDir(location).exists()) { |
|
|
|
|
// If directory doesn't exist, try to create it
|
|
|
|
|
if (!parentDir.mkpath(_savedFileMavlinkLogDirectoryName)) { |
|
|
|
|
// Return an error
|
|
|
|
|
location.clear(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return location; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool QGCApplication::promptFlightDataSave(void) |
|
|
|
|
{ |
|
|
|
|
QSettings settings; |
|
|
|
@ -655,7 +543,7 @@ void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile)
@@ -655,7 +543,7 @@ void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile)
|
|
|
|
|
QString saveFilename = QGCFileDialog::getSaveFileName( |
|
|
|
|
MainWindow::instance(), |
|
|
|
|
tr("Save Flight Data Log"), |
|
|
|
|
qgcApp()->mavlinkLogFilesLocation(), |
|
|
|
|
QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), |
|
|
|
|
tr("Flight Data Log Files (*.mavlink)"), |
|
|
|
|
"mavlink"); |
|
|
|
|
|
|
|
|
|