From f2b48518ac393ca291370b9364c1f0aea40ff28b Mon Sep 17 00:00:00 2001 From: pixhawk Date: Mon, 10 Jan 2011 06:25:05 +0100 Subject: [PATCH] Fixed settings reset function, now tested and works. --- src/Core.cc | 17 +++++++++++++---- src/ui/MainWindow.cc | 6 +----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Core.cc b/src/Core.cc index 04645abca..9dcc7ba8d 100644 --- a/src/Core.cc +++ b/src/Core.cc @@ -39,6 +39,8 @@ This file is part of the QGROUNDCONTROL project #include #include +#include + #include "configuration.h" #include "QGC.h" #include "Core.h" @@ -65,29 +67,37 @@ This file is part of the QGROUNDCONTROL project Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) { + // Set application name this->setApplicationName(QGC_APPLICATION_NAME); this->setApplicationVersion(QGC_APPLICATION_VERSION); this->setOrganizationName(QLatin1String("OPENMAV")); - this->setOrganizationDomain("http://qgroundcontrol.org"); + this->setOrganizationDomain("org.qgroundcontrol"); + + // Set settings format + QSettings::setDefaultFormat(QSettings::IniFormat); // Check application settings // clear them if they mismatch // QGC then falls back to default QSettings settings; - settings.sync(); - if (settings.contains("QGC_APPLICATION_VERSION_INT")) + if (settings.contains("QGC_APPLICATION_VERSION")) { QString qgcVersion = settings.value("QGC_APPLICATION_VERSION").toString(); if (qgcVersion != QGC_APPLICATION_VERSION) { settings.clear(); + // Write current application version + settings.setValue("QGC_APPLICATION_VERSION", QGC_APPLICATION_VERSION); } } else { // If application version is not set, clear settings anyway settings.clear(); + // Write current application version + settings.setValue("QGC_APPLICATION_VERSION", QGC_APPLICATION_VERSION); } + settings.sync(); // Show splash screen @@ -98,7 +108,6 @@ Core::Core(int &argc, char* argv[]) : QApplication(argc, argv) splashScreen->show(); 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 connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit())); diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc index 7ff129650..c6f5f54fa 100644 --- a/src/ui/MainWindow.cc +++ b/src/ui/MainWindow.cc @@ -66,12 +66,8 @@ MainWindow::MainWindow(QWidget *parent): toolsMenuActions(), currentView(VIEW_ENGINEER), aboutToCloseFlag(false), - changingViewsFlag(false), - settings() + changingViewsFlag(false) { - // Get current settings - settings.sync(); - if (!settings.contains("CURRENT_VIEW")) { // Set this view as default view -- 2.22.0