From 22d5010c6c41154ffe8799e6c6ffa48ced04b65c Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 19 Nov 2015 13:03:24 -0800 Subject: [PATCH] Remove settings which are in Qml settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way you don’t have to implement things twice --- src/ui/SettingsDialog.cc | 87 +--------------- src/ui/SettingsDialog.h | 13 +-- src/ui/SettingsDialog.ui | 209 --------------------------------------- 3 files changed, 3 insertions(+), 306 deletions(-) diff --git a/src/ui/SettingsDialog.cc b/src/ui/SettingsDialog.cc index f6a8db677..0d9bc946a 100644 --- a/src/ui/SettingsDialog.cc +++ b/src/ui/SettingsDialog.cc @@ -39,11 +39,8 @@ #include "MainToolBarController.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) - , _mainWindow(MainWindow::instance()) - , _audioOutput(audioOutput) - , _flightMapSettings(flightMapSettings) , _ui(new Ui::SettingsDialog) { _ui->setupUi(this); @@ -66,43 +63,12 @@ SettingsDialog::SettingsDialog(GAudioOutput* audioOutput, FlightMapSettings* fli 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->promptFlightDataSave->setChecked(qgcApp()->promptFlightDataSave()); // Connect signals - connect(_ui->styleChooser, SIGNAL(currentIndexChanged(int)), this, SLOT(styleChanged(int))); connect(_ui->browseSavedFilesLocation, &QPushButton::clicked, this, &SettingsDialog::_selectSavedFilesDirectory); 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) { case ShowCommLinks: _ui->tabWidget->setCurrentWidget(pLinkConf); @@ -118,29 +84,6 @@ SettingsDialog::~SettingsDialog() 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 void SettingsDialog::_validateBeforeClose(void) { @@ -155,7 +98,7 @@ void SettingsDialog::_validateBeforeClose(void) } // Locations is valid, save app->setSavedFilesLocation(saveLocation); - qgcApp()->setPromptFlightDataSave(_ui->promptFlightDataSave->checkState() == Qt::Checked); + // Close dialog accept(); } @@ -170,30 +113,4 @@ void SettingsDialog::_selectSavedFilesDirectory(void) if (!newLocation.isEmpty()) { _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"); - } } diff --git a/src/ui/SettingsDialog.h b/src/ui/SettingsDialog.h index 6878cff62..cd7647103 100644 --- a/src/ui/SettingsDialog.h +++ b/src/ui/SettingsDialog.h @@ -48,25 +48,14 @@ public: 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(); -public slots: - void styleChanged(int index); - private slots: - void _deleteSettingsToggled(bool checked); void _selectSavedFilesDirectory(void); void _validateBeforeClose(void); - - void _bingMapRadioClicked(bool checked); - void _googleMapRadioClicked(bool checked); - void _openMapRadioClicked(bool checked); private: - MainWindow* _mainWindow; - GAudioOutput* _audioOutput; - FlightMapSettings* _flightMapSettings; Ui::SettingsDialog* _ui; }; diff --git a/src/ui/SettingsDialog.ui b/src/ui/SettingsDialog.ui index 35bd7c871..d304d06be 100644 --- a/src/ui/SettingsDialog.ui +++ b/src/ui/SettingsDialog.ui @@ -36,184 +36,6 @@ General Settings - - - - - 0 - 0 - - - - Mute all audio output - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Automatically reconnect last link on application startup - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Lowers all update rates to save battery power - - - Enable low power mode - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Prompt to save Flight Data Log after each flight - - - - 0 - 0 - - - - - - - - Map Provider - - - - - - Bing - - - - - - - Google - - - - - - - Open Streets - - - - - - - - - - - 0 - 0 - - - - Style - - - false - - - false - - - - 8 - - - 8 - - - - - 0 - - - QLayout::SetDefaultConstraint - - - 0 - - - 80 - - - - - - 0 - 0 - - - - - 200 - 0 - - - - - Dark (for indoor use) - - - - - Light (for outdoor use) - - - - - - - - - @@ -281,37 +103,6 @@ - - - - Reset All Settings to Default - - - - - - Delete all saved settings on next boot - - - - - - - - 11 - - - - Note: You can also use --clear-settings as a command line option to accomplish this. - - - true - - - - - - -- 2.22.0