Commit 720ca30b authored by Don Gagne's avatar Don Gagne

Settings versioned independently from app version

parent f5ac24e4
......@@ -10,6 +10,10 @@
#define MAVLINK_HEARTBEAT_DEFAULT_RATE 1
#define WITH_TEXT_TO_SPEECH 1
// If you need to make an incompatible changes to stored settings, bump this version number
// up by 1. This will caused store settings to be cleared on next boot.
#define QGC_SETTINGS_VERSION 1
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_APPLICATION_VERSION_BASE "v2.0.3"
......
......@@ -55,6 +55,7 @@ This file is part of the QGROUNDCONTROL project
#include "MAVLinkSimulationLink.h"
#include "SerialLink.h"
const char* QGCCore::_settingsVersionKey = "SettingsVersion";
/**
* @brief Constructor for the main application.
......@@ -108,31 +109,25 @@ bool QGCCore::init(void)
// Exit main application when last window is closed
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
// Show user an upgrade message if QGC got upgraded (see code below, after splash screen)
bool upgraded = false;
// Show user an upgrade message if the settings version has been bumped up
bool settingsUpgraded = false;
enum MainWindow::CUSTOM_MODE mode = MainWindow::CUSTOM_MODE_PX4;
QString lastApplicationVersion("");
if (settings.contains("QGC_APPLICATION_VERSION"))
{
QString qgcVersion = settings.value("QGC_APPLICATION_VERSION").toString();
if (qgcVersion != QGC_APPLICATION_VERSION)
{
lastApplicationVersion = qgcVersion;
settings.clear(); // Clear settings from different version
// Write current application version
settings.setValue("QGC_APPLICATION_VERSION", QGC_APPLICATION_VERSION);
upgraded = true;
} else {
mode = (enum MainWindow::CUSTOM_MODE) settings.value("QGC_CUSTOM_MODE", (int)MainWindow::CUSTOM_MODE_PX4).toInt();
if (settings.contains(_settingsVersionKey)) {
if (settings.value(_settingsVersionKey).toInt() != QGC_SETTINGS_VERSION) {
settingsUpgraded = true;
}
} else {
// If application version is not set, clear settings anyway
} else if (settings.allKeys().count()) {
// Settings version key is missing and there are settings. This is an upgrade scenario.
settingsUpgraded = true;
}
if (settingsUpgraded) {
settings.clear();
// Write current application version
settings.setValue("QGC_APPLICATION_VERSION", QGC_APPLICATION_VERSION);
settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION);
}
mode = (enum MainWindow::CUSTOM_MODE) settings.value("QGC_CUSTOM_MODE", (int)MainWindow::CUSTOM_MODE_PX4).toInt();
settings.sync();
// Show splash screen
......@@ -192,8 +187,11 @@ bool QGCCore::init(void)
// Remove splash screen
splashScreen->finish(_mainWindow);
if (upgraded) _mainWindow->showInfoMessage(tr("Default Settings Loaded"),
tr("qgroundcontrol has been upgraded from version %1 to version %2. Some of your user preferences have been reset to defaults for safety reasons. Please adjust them where needed.").arg(lastApplicationVersion).arg(QGC_APPLICATION_VERSION));
if (settingsUpgraded) {
_mainWindow->showInfoMessage(tr("Settings Cleared"),
tr("The format for QGroundControl saved settings has been modified. "
"Your saved settings have been reset to defaults."));
}
// Check if link could be connected
if (udpLink && !udpLink->connect())
......
......@@ -72,7 +72,8 @@ protected:
void startUASManager();
private:
MainWindow* _mainWindow;
MainWindow* _mainWindow;
static const char* _settingsVersionKey;
};
#endif /* _CORE_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment