Commit 22d5010c authored by Don Gagne's avatar Don Gagne

Remove settings which are in Qml settings

This way you don’t have to implement things twice
parent 4e6c64ad
...@@ -39,11 +39,8 @@ ...@@ -39,11 +39,8 @@
#include "MainToolBarController.h" #include "MainToolBarController.h"
#include "FlightMapSettings.h" #include "FlightMapSettings.h"
SettingsDialog::SettingsDialog(GAudioOutput* audioOutput, FlightMapSettings* flightMapSettings, QWidget *parent, int showTab, Qt::WindowFlags flags) SettingsDialog::SettingsDialog(QWidget *parent, int showTab, Qt::WindowFlags flags)
: QDialog(parent, flags) : QDialog(parent, flags)
, _mainWindow(MainWindow::instance())
, _audioOutput(audioOutput)
, _flightMapSettings(flightMapSettings)
, _ui(new Ui::SettingsDialog) , _ui(new Ui::SettingsDialog)
{ {
_ui->setupUi(this); _ui->setupUi(this);
...@@ -66,43 +63,12 @@ SettingsDialog::SettingsDialog(GAudioOutput* audioOutput, FlightMapSettings* fli ...@@ -66,43 +63,12 @@ SettingsDialog::SettingsDialog(GAudioOutput* audioOutput, FlightMapSettings* fli
this->window()->setWindowTitle(tr("QGroundControl Settings")); this->window()->setWindowTitle(tr("QGroundControl Settings"));
// Audio preferences
_ui->audioMuteCheckBox->setChecked(_audioOutput->isMuted());
connect(_ui->audioMuteCheckBox, SIGNAL(toggled(bool)), _audioOutput, SLOT(mute(bool)));
connect(_audioOutput, SIGNAL(mutedChanged(bool)), _ui->audioMuteCheckBox, SLOT(setChecked(bool)));
// Reconnect
_ui->reconnectCheckBox->setChecked(_mainWindow->autoReconnectEnabled());
connect(_ui->reconnectCheckBox, SIGNAL(clicked(bool)), _mainWindow, SLOT(enableAutoReconnect(bool)));
// Low power mode
_ui->lowPowerCheckBox->setChecked(_mainWindow->lowPowerModeEnabled());
connect(_ui->lowPowerCheckBox, SIGNAL(clicked(bool)), _mainWindow, SLOT(enableLowPowerMode(bool)));
connect(_ui->deleteSettings, &QAbstractButton::toggled, this, &SettingsDialog::_deleteSettingsToggled);
// Application color style
_ui->styleChooser->setCurrentIndex(qgcApp()->styleIsDark() ? 0 : 1);
_ui->savedFilesLocation->setText(qgcApp()->savedFilesLocation()); _ui->savedFilesLocation->setText(qgcApp()->savedFilesLocation());
_ui->promptFlightDataSave->setChecked(qgcApp()->promptFlightDataSave());
// Connect signals // Connect signals
connect(_ui->styleChooser, SIGNAL(currentIndexChanged(int)), this, SLOT(styleChanged(int)));
connect(_ui->browseSavedFilesLocation, &QPushButton::clicked, this, &SettingsDialog::_selectSavedFilesDirectory); connect(_ui->browseSavedFilesLocation, &QPushButton::clicked, this, &SettingsDialog::_selectSavedFilesDirectory);
connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::_validateBeforeClose); connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::_validateBeforeClose);
// Flight Map settings
FlightMapSettings* fmSettings = _flightMapSettings;
_ui->bingMapRadio->setChecked(fmSettings->mapProvider() == "Bing");
_ui->googleMapRadio->setChecked(fmSettings->mapProvider() == "Google");
_ui->openMapRadio->setChecked(fmSettings->mapProvider() == "Open");
connect(_ui->bingMapRadio, &QRadioButton::clicked, this, &SettingsDialog::_bingMapRadioClicked);
connect(_ui->googleMapRadio, &QRadioButton::clicked, this, &SettingsDialog::_googleMapRadioClicked);
connect(_ui->openMapRadio, &QRadioButton::clicked, this, &SettingsDialog::_openMapRadioClicked);
switch (showTab) { switch (showTab) {
case ShowCommLinks: case ShowCommLinks:
_ui->tabWidget->setCurrentWidget(pLinkConf); _ui->tabWidget->setCurrentWidget(pLinkConf);
...@@ -118,29 +84,6 @@ SettingsDialog::~SettingsDialog() ...@@ -118,29 +84,6 @@ SettingsDialog::~SettingsDialog()
delete _ui; delete _ui;
} }
void SettingsDialog::styleChanged(int index)
{
qgcApp()->setStyle(index == 0);
}
void SettingsDialog::_deleteSettingsToggled(bool checked)
{
if (checked){
QGCMessageBox::StandardButton answer =
QGCMessageBox::question(tr("Delete Settings"),
tr("All saved settings 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) {
qgcApp()->deleteAllSettingsNextBoot();
} else {
_ui->deleteSettings->setChecked(false);
}
} else {
qgcApp()->clearDeleteAllSettingsNextBoot();
}
}
/// @brief Validates the settings before closing /// @brief Validates the settings before closing
void SettingsDialog::_validateBeforeClose(void) void SettingsDialog::_validateBeforeClose(void)
{ {
...@@ -155,7 +98,7 @@ void SettingsDialog::_validateBeforeClose(void) ...@@ -155,7 +98,7 @@ void SettingsDialog::_validateBeforeClose(void)
} }
// Locations is valid, save // Locations is valid, save
app->setSavedFilesLocation(saveLocation); app->setSavedFilesLocation(saveLocation);
qgcApp()->setPromptFlightDataSave(_ui->promptFlightDataSave->checkState() == Qt::Checked);
// Close dialog // Close dialog
accept(); accept();
} }
...@@ -170,30 +113,4 @@ void SettingsDialog::_selectSavedFilesDirectory(void) ...@@ -170,30 +113,4 @@ void SettingsDialog::_selectSavedFilesDirectory(void)
if (!newLocation.isEmpty()) { if (!newLocation.isEmpty()) {
_ui->savedFilesLocation->setText(newLocation); _ui->savedFilesLocation->setText(newLocation);
} }
// TODO:
// Once a directory is selected, we need to display the various subdirectories used underneath:
// * Flight data logs
// * Parameters
}
void SettingsDialog::_bingMapRadioClicked(bool checked)
{
if (checked) {
_flightMapSettings->setMapProvider("Bing");
}
}
void SettingsDialog::_googleMapRadioClicked(bool checked)
{
if (checked) {
_flightMapSettings->setMapProvider("Google");
}
}
void SettingsDialog::_openMapRadioClicked(bool checked)
{
if (checked) {
_flightMapSettings->setMapProvider("Open");
}
} }
...@@ -48,25 +48,14 @@ public: ...@@ -48,25 +48,14 @@ public:
ShowMavlink ShowMavlink
}; };
SettingsDialog(GAudioOutput* audioOuput, FlightMapSettings* flightMapSettings, QWidget *parent = 0, int showTab = ShowDefault, Qt::WindowFlags flags = Qt::Sheet); SettingsDialog(QWidget *parent = 0, int showTab = ShowDefault, Qt::WindowFlags flags = Qt::Sheet);
~SettingsDialog(); ~SettingsDialog();
public slots:
void styleChanged(int index);
private slots: private slots:
void _deleteSettingsToggled(bool checked);
void _selectSavedFilesDirectory(void); void _selectSavedFilesDirectory(void);
void _validateBeforeClose(void); void _validateBeforeClose(void);
void _bingMapRadioClicked(bool checked);
void _googleMapRadioClicked(bool checked);
void _openMapRadioClicked(bool checked);
private: private:
MainWindow* _mainWindow;
GAudioOutput* _audioOutput;
FlightMapSettings* _flightMapSettings;
Ui::SettingsDialog* _ui; Ui::SettingsDialog* _ui;
}; };
......
...@@ -36,184 +36,6 @@ ...@@ -36,184 +36,6 @@
<string>General Settings</string> <string>General Settings</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_8"> <layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QCheckBox" name="audioMuteCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Mute all audio output</string>
</property>
<property name="iconSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="reconnectCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Automatically reconnect last link on application startup</string>
</property>
<property name="iconSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lowPowerCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Lowers all update rates to save battery power</string>
</property>
<property name="text">
<string>Enable low power mode</string>
</property>
<property name="iconSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="promptFlightDataSave">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Prompt to save Flight Data Log after each flight</string>
</property>
<property name="iconSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Map Provider</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="bingMapRadio">
<property name="text">
<string>Bing</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="googleMapRadio">
<property name="text">
<string>Google</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="openMapRadio">
<property name="text">
<string>Open Streets</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Style</string>
</property>
<property name="flat">
<bool>false</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="topMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>80</number>
</property>
<item>
<widget class="QComboBox" name="styleChooser">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>Dark (for indoor use)</string>
</property>
</item>
<item>
<property name="text">
<string>Light (for outdoor use)</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QGroupBox" name="fileLocationsLayout"> <widget class="QGroupBox" name="fileLocationsLayout">
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -281,37 +103,6 @@ ...@@ -281,37 +103,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Reset All Settings to Default</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>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Note: You can also use --clear-settings as a command line option to accomplish this.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
......
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