Commit f2b48518 authored by pixhawk's avatar pixhawk

Fixed settings reset function, now tested and works.

parent ae730288
...@@ -39,6 +39,8 @@ This file is part of the QGROUNDCONTROL project ...@@ -39,6 +39,8 @@ This file is part of the QGROUNDCONTROL project
#include <QStyleFactory> #include <QStyleFactory>
#include <QAction> #include <QAction>
#include <QDebug>
#include "configuration.h" #include "configuration.h"
#include "QGC.h" #include "QGC.h"
#include "Core.h" #include "Core.h"
...@@ -65,29 +67,37 @@ This file is part of the QGROUNDCONTROL project ...@@ -65,29 +67,37 @@ This file is part of the QGROUNDCONTROL project
Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) Core::Core(int &argc, char* argv[]) : QApplication(argc, argv)
{ {
// Set application name
this->setApplicationName(QGC_APPLICATION_NAME); this->setApplicationName(QGC_APPLICATION_NAME);
this->setApplicationVersion(QGC_APPLICATION_VERSION); this->setApplicationVersion(QGC_APPLICATION_VERSION);
this->setOrganizationName(QLatin1String("OPENMAV")); this->setOrganizationName(QLatin1String("OPENMAV"));
this->setOrganizationDomain("http://qgroundcontrol.org"); this->setOrganizationDomain("org.qgroundcontrol");
// Set settings format
QSettings::setDefaultFormat(QSettings::IniFormat);
// Check application settings // Check application settings
// clear them if they mismatch // clear them if they mismatch
// QGC then falls back to default // QGC then falls back to default
QSettings settings; QSettings settings;
settings.sync(); if (settings.contains("QGC_APPLICATION_VERSION"))
if (settings.contains("QGC_APPLICATION_VERSION_INT"))
{ {
QString qgcVersion = settings.value("QGC_APPLICATION_VERSION").toString(); QString qgcVersion = settings.value("QGC_APPLICATION_VERSION").toString();
if (qgcVersion != QGC_APPLICATION_VERSION) if (qgcVersion != QGC_APPLICATION_VERSION)
{ {
settings.clear(); settings.clear();
// Write current application version
settings.setValue("QGC_APPLICATION_VERSION", QGC_APPLICATION_VERSION);
} }
} }
else else
{ {
// If application version is not set, clear settings anyway // If application version is not set, clear settings anyway
settings.clear(); settings.clear();
// Write current application version
settings.setValue("QGC_APPLICATION_VERSION", QGC_APPLICATION_VERSION);
} }
settings.sync(); settings.sync();
// Show splash screen // Show splash screen
...@@ -98,7 +108,6 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) ...@@ -98,7 +108,6 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv)
splashScreen->show(); splashScreen->show();
splashScreen->showMessage(tr("Loading application fonts"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141)); splashScreen->showMessage(tr("Loading application fonts"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
QSettings::setDefaultFormat(QSettings::IniFormat);
// Exit main application when last window is closed // Exit main application when last window is closed
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit())); connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
......
...@@ -66,12 +66,8 @@ MainWindow::MainWindow(QWidget *parent): ...@@ -66,12 +66,8 @@ MainWindow::MainWindow(QWidget *parent):
toolsMenuActions(), toolsMenuActions(),
currentView(VIEW_ENGINEER), currentView(VIEW_ENGINEER),
aboutToCloseFlag(false), aboutToCloseFlag(false),
changingViewsFlag(false), changingViewsFlag(false)
settings()
{ {
// Get current settings
settings.sync();
if (!settings.contains("CURRENT_VIEW")) if (!settings.contains("CURRENT_VIEW"))
{ {
// Set this view as default view // Set this view as default view
......
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