Commit 1a182ddd authored by Don Gagne's avatar Don Gagne

Merge pull request #965 from DonLakeFlyer/DeleteSettings

Delete Settings from preferences
parents aaba1308 9bfa9cec
......@@ -55,6 +55,7 @@ This file is part of the QGROUNDCONTROL project
#include "MAVLinkSimulationLink.h"
#include "SerialLink.h"
const char* QGCCore::deleteAllSettingsKey = "DeleteAllSettingsNextBoot";
const char* QGCCore::_settingsVersionKey = "SettingsVersion";
/**
......@@ -99,9 +100,13 @@ QGCCore::QGCCore(int &argc, char* argv[]) :
QSettings settings;
// The setting will delete all settings on this boot
fClearSettingsOptions |= settings.contains(deleteAllSettingsKey);
if (fClearSettingsOptions) {
// User requested settings to be cleared on command line
settings.clear();
settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION);
settings.sync();
}
......
......@@ -60,6 +60,8 @@ public:
/// @brief Initialize the applicaation.
/// @return false: init failed, app should exit
bool init(void);
static const char* deleteAllSettingsKey;
protected:
void startLinkManager();
......
......@@ -10,6 +10,7 @@
#include "MAVLinkProtocol.h"
#include "MAVLinkSettingsWidget.h"
#include "GAudioOutput.h"
#include "QGCCore.h"
QGCSettingsWidget::QGCSettingsWidget(JoystickInput *joystick, QWidget *parent, Qt::WindowFlags flags) :
QDialog(parent, flags),
......@@ -54,6 +55,8 @@ QGCSettingsWidget::QGCSettingsWidget(JoystickInput *joystick, QWidget *parent, Q
// Dock widget title bars
ui->titleBarCheckBox->setChecked(mainWindow->dockWidgetTitleBarsEnabled());
connect(ui->titleBarCheckBox,SIGNAL(clicked(bool)),mainWindow,SLOT(enableDockWidgetTitleBars(bool)));
connect(ui->deleteSettings, &QAbstractButton::toggled, this, &QGCSettingsWidget::_deleteSettingsToggled);
// Custom mode
......@@ -197,3 +200,20 @@ void QGCSettingsWidget::selectCustomMode(int mode)
MainWindow::instance()->setCustomMode(static_cast<enum MainWindow::CUSTOM_MODE>(ui->customModeComboBox->itemData(mode).toInt()));
MainWindow::instance()->showInfoMessage(tr("Please restart QGroundControl"), tr("The optimization selection was changed. The application needs to be closed and restarted to put all optimizations into effect."));
}
void QGCSettingsWidget::_deleteSettingsToggled(bool checked)
{
if (checked){
QMessageBox::StandardButton answer = QMessageBox::question(this,
tr("Delete Settings"),
tr("All saved settgings will be deleted the next time you start QGroundControl. Is this really what you want?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
if (answer == QMessageBox::Yes) {
QSettings settings;
settings.setValue(QGCCore::deleteAllSettingsKey, 1);
} else {
ui->deleteSettings->setChecked(false);
}
}
}
......@@ -24,6 +24,9 @@ public slots:
void selectStylesheet();
void selectCustomMode(int mode);
private slots:
void _deleteSettingsToggled(bool checked);
private:
MainWindow* mainWindow;
Ui::QGCSettingsWidget* ui;
......
......@@ -151,6 +151,22 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Danger Zone</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QCheckBox" name="deleteSettings">
<property name="text">
<string>Delete all saved settings on next boot</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......
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