Commit eb13a148 authored by Don Gagne's avatar Don Gagne

Merge pull request #2248 from DonLakeFlyer/LogPlusSettings

Add support for log save even if Vehicle not armed [default off]
parents d9c32fc2 b03c171c
...@@ -107,11 +107,12 @@ ...@@ -107,11 +107,12 @@
QGCApplication* QGCApplication::_app = NULL; QGCApplication* QGCApplication::_app = NULL;
const char* QGCApplication::_deleteAllSettingsKey = "DeleteAllSettingsNextBoot"; const char* QGCApplication::_deleteAllSettingsKey = "DeleteAllSettingsNextBoot";
const char* QGCApplication::_settingsVersionKey = "SettingsVersion"; const char* QGCApplication::_settingsVersionKey = "SettingsVersion";
const char* QGCApplication::_savedFilesLocationKey = "SavedFilesLocation"; const char* QGCApplication::_savedFilesLocationKey = "SavedFilesLocation";
const char* QGCApplication::_promptFlightDataSave = "PromptFLightDataSave"; const char* QGCApplication::_promptFlightDataSave = "PromptFLightDataSave";
const char* QGCApplication::_styleKey = "StyleIsDark"; const char* QGCApplication::_promptFlightDataSaveNotArmed = "PromptFLightDataSaveNotArmed";
const char* QGCApplication::_styleKey = "StyleIsDark";
const char* QGCApplication::_defaultSavedFileDirectoryName = "QGroundControl"; const char* QGCApplication::_defaultSavedFileDirectoryName = "QGroundControl";
const char* QGCApplication::_savedFileMavlinkLogDirectoryName = "FlightData"; const char* QGCApplication::_savedFileMavlinkLogDirectoryName = "FlightData";
...@@ -554,12 +555,25 @@ bool QGCApplication::promptFlightDataSave(void) ...@@ -554,12 +555,25 @@ bool QGCApplication::promptFlightDataSave(void)
return settings.value(_promptFlightDataSave, true).toBool(); return settings.value(_promptFlightDataSave, true).toBool();
} }
bool QGCApplication::promptFlightDataSaveNotArmed(void)
{
QSettings settings;
return settings.value(_promptFlightDataSaveNotArmed, false).toBool();
}
void QGCApplication::setPromptFlightDataSave(bool promptForSave) void QGCApplication::setPromptFlightDataSave(bool promptForSave)
{ {
QSettings settings; QSettings settings;
settings.setValue(_promptFlightDataSave, promptForSave); settings.setValue(_promptFlightDataSave, promptForSave);
} }
void QGCApplication::setPromptFlightDataSaveNotArmed(bool promptForSave)
{
QSettings settings;
settings.setValue(_promptFlightDataSaveNotArmed, promptForSave);
}
/// @brief Returns the QGCApplication object singleton. /// @brief Returns the QGCApplication object singleton.
QGCApplication* qgcApp(void) QGCApplication* qgcApp(void)
{ {
......
...@@ -93,11 +93,14 @@ public: ...@@ -93,11 +93,14 @@ public:
/// @brief Validates that the specified location will work for the saved files location. /// @brief Validates that the specified location will work for the saved files location.
bool validatePossibleSavedFilesLocation(QString& location); bool validatePossibleSavedFilesLocation(QString& location);
/// @brief Returns true is all mavlink connections should be logged /// @return true: Prompt to save log file when vehicle goes away
bool promptFlightDataSave(void); bool promptFlightDataSave(void);
/// @brief Sets the flag to log all mavlink connections /// @return true: Prompt to save log file even if vehicle was not armed
bool promptFlightDataSaveNotArmed(void);
void setPromptFlightDataSave(bool promptForSave); void setPromptFlightDataSave(bool promptForSave);
void setPromptFlightDataSaveNotArmed(bool promptForSave);
/// @brief Returns truee if unit test are being run /// @brief Returns truee if unit test are being run
bool runningUnitTests(void) { return _runningUnitTests; } bool runningUnitTests(void) { return _runningUnitTests; }
...@@ -173,7 +176,8 @@ private: ...@@ -173,7 +176,8 @@ private:
static const char* _settingsVersionKey; ///< Settings key which hold settings version static const char* _settingsVersionKey; ///< Settings key which hold settings version
static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted static const char* _deleteAllSettingsKey; ///< If this settings key is set on boot, all settings will be deleted
static const char* _savedFilesLocationKey; ///< Settings key for user visible saved files location static const char* _savedFilesLocationKey; ///< Settings key for user visible saved files location
static const char* _promptFlightDataSave; ///< Settings key to prompt for saving Flight Data Log for all flights static const char* _promptFlightDataSave; ///< Settings key for promptFlightDataSave
static const char* _promptFlightDataSaveNotArmed; ///< Settings key for promptFlightDataSaveNotArmed
static const char* _styleKey; ///< Settings key for UI style static const char* _styleKey; ///< Settings key for UI style
static const char* _defaultSavedFileDirectoryName; ///< Default name for user visible save file directory static const char* _defaultSavedFileDirectoryName; ///< Default name for user visible save file directory
......
...@@ -154,3 +154,51 @@ void QGroundControlQmlGlobal::stopAllMockLinks(void) ...@@ -154,3 +154,51 @@ void QGroundControlQmlGlobal::stopAllMockLinks(void)
} }
#endif #endif
} }
void QGroundControlQmlGlobal::setIsDarkStyle(bool dark)
{
qgcApp()->setStyle(dark);
emit isDarkStyleChanged(dark);
}
void QGroundControlQmlGlobal::setIsAudioMuted(bool muted)
{
qgcApp()->toolbox()->audioOutput()->mute(muted);
emit isAudioMutedChanged(muted);
}
void QGroundControlQmlGlobal::setIsLowPowerMode(bool low)
{
MainWindow::instance()->enableLowPowerMode(low);
emit isLowPowerModeChanged(low);
}
void QGroundControlQmlGlobal::setIsSaveLogPrompt(bool prompt)
{
qgcApp()->setPromptFlightDataSave(prompt);
emit isSaveLogPromptChanged(prompt);
}
void QGroundControlQmlGlobal::setIsSaveLogPromptNotArmed(bool prompt)
{
qgcApp()->setPromptFlightDataSaveNotArmed(prompt);
emit isSaveLogPromptNotArmedChanged(prompt);
}
void QGroundControlQmlGlobal::setIsHeartBeatEnabled(bool enable)
{
qgcApp()->toolbox()->mavlinkProtocol()->enableHeartbeats(enable);
emit isHeartBeatEnabledChanged(enable);
}
void QGroundControlQmlGlobal::setIsMultiplexingEnabled(bool enable)
{
qgcApp()->toolbox()->mavlinkProtocol()->enableMultiplexing(enable);
emit isMultiplexingEnabledChanged(enable);
}
void QGroundControlQmlGlobal::setIsVersionCheckEnabled(bool enable)
{
qgcApp()->toolbox()->mavlinkProtocol()->enableVersionCheck(enable);
emit isVersionCheckEnabledChanged(enable);
}
...@@ -54,14 +54,25 @@ public: ...@@ -54,14 +54,25 @@ public:
Q_PROPERTY(qreal zOrderWidgets READ zOrderWidgets CONSTANT) ///< z order value to widgets, for example: zoom controls, hud widgetss Q_PROPERTY(qreal zOrderWidgets READ zOrderWidgets CONSTANT) ///< z order value to widgets, for example: zoom controls, hud widgetss
Q_PROPERTY(qreal zOrderMapItems READ zOrderMapItems CONSTANT) ///< z order value for map items, for example: mission item indicators Q_PROPERTY(qreal zOrderMapItems READ zOrderMapItems CONSTANT) ///< z order value for map items, for example: mission item indicators
/// Global "Advance Mode" preference. Certain UI elements and features are different based on this. // Various QGC settings exposed to Qml
Q_PROPERTY(bool isAdvancedMode READ isAdvancedMode CONSTANT) Q_PROPERTY(bool isAdvancedMode READ isAdvancedMode CONSTANT) ///< Global "Advance Mode" preference. Certain UI elements and features are different based on this.
Q_PROPERTY(bool isDarkStyle READ isDarkStyle WRITE setIsDarkStyle NOTIFY isDarkStyleChanged) // TODO: Should be in ScreenTools?
Q_PROPERTY(bool isAudioMuted READ isAudioMuted WRITE setIsAudioMuted NOTIFY isAudioMutedChanged)
Q_PROPERTY(bool isLowPowerMode READ isLowPowerMode WRITE setIsLowPowerMode NOTIFY isLowPowerModeChanged)
Q_PROPERTY(bool isSaveLogPrompt READ isSaveLogPrompt WRITE setIsSaveLogPrompt NOTIFY isSaveLogPromptChanged)
Q_PROPERTY(bool isSaveLogPromptNotArmed READ isSaveLogPromptNotArmed WRITE setIsSaveLogPromptNotArmed NOTIFY isSaveLogPromptNotArmedChanged)
Q_PROPERTY(bool isHeartBeatEnabled READ isHeartBeatEnabled WRITE setIsHeartBeatEnabled NOTIFY isHeartBeatEnabledChanged)
Q_PROPERTY(bool isMultiplexingEnabled READ isMultiplexingEnabled WRITE setIsMultiplexingEnabled NOTIFY isMultiplexingEnabledChanged)
Q_PROPERTY(bool isVersionCheckEnabled READ isVersionCheckEnabled WRITE setIsVersionCheckEnabled NOTIFY isVersionCheckEnabledChanged)
Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value); Q_INVOKABLE void saveGlobalSetting (const QString& key, const QString& value);
Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue); Q_INVOKABLE QString loadGlobalSetting (const QString& key, const QString& defaultValue);
Q_INVOKABLE void saveBoolGlobalSetting (const QString& key, bool value); Q_INVOKABLE void saveBoolGlobalSetting (const QString& key, bool value);
Q_INVOKABLE bool loadBoolGlobalSetting (const QString& key, bool defaultValue); Q_INVOKABLE bool loadBoolGlobalSetting (const QString& key, bool defaultValue);
Q_INVOKABLE void deleteAllSettingsNextBoot () { qgcApp()->deleteAllSettingsNextBoot(); }
Q_INVOKABLE void clearDeleteAllSettingsNextBoot () { qgcApp()->clearDeleteAllSettingsNextBoot(); }
Q_INVOKABLE void startPX4MockLink (bool sendStatusText); Q_INVOKABLE void startPX4MockLink (bool sendStatusText);
Q_INVOKABLE void startGenericMockLink (bool sendStatusText); Q_INVOKABLE void startGenericMockLink (bool sendStatusText);
Q_INVOKABLE void startAPMArduCopterMockLink (bool sendStatusText); Q_INVOKABLE void startAPMArduCopterMockLink (bool sendStatusText);
...@@ -77,57 +88,33 @@ public: ...@@ -77,57 +88,33 @@ public:
qreal zOrderWidgets () { return 100; } qreal zOrderWidgets () { return 100; }
qreal zOrderMapItems () { return 50; } qreal zOrderMapItems () { return 50; }
//-- TODO: This should be in ScreenTools but I don't understand the changes done there (ScreenToolsController versus ScreenTools) bool isDarkStyle () { return qgcApp()->styleIsDark(); }
Q_PROPERTY(bool isDarkStyle READ isDarkStyle WRITE setIsDarkStyle NOTIFY isDarkStyleChanged) bool isAudioMuted () { return qgcApp()->toolbox()->audioOutput()->isMuted(); }
bool isDarkStyle () { return qgcApp()->styleIsDark(); } bool isLowPowerMode () { return MainWindow::instance()->lowPowerModeEnabled(); }
void setIsDarkStyle (bool dark) { qgcApp()->setStyle(dark); } bool isSaveLogPrompt () { return qgcApp()->promptFlightDataSave(); }
bool isSaveLogPromptNotArmed () { return qgcApp()->promptFlightDataSaveNotArmed(); }
//-- Audio Muting bool isHeartBeatEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->heartbeatsEnabled(); }
Q_PROPERTY(bool isAudioMuted READ isAudioMuted WRITE setIsAudioMuted NOTIFY isAudioMutedChanged) bool isMultiplexingEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->multiplexingEnabled(); }
bool isAudioMuted () { return qgcApp()->toolbox()->audioOutput()->isMuted(); } bool isVersionCheckEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->versionCheckEnabled(); }
void setIsAudioMuted (bool muted) { qgcApp()->toolbox()->audioOutput()->mute(muted); }
//-- Low power mode
Q_PROPERTY(bool isLowPowerMode READ isLowPowerMode WRITE setIsLowPowerMode NOTIFY isLowPowerModeChanged)
bool isLowPowerMode () { return MainWindow::instance()->lowPowerModeEnabled(); }
void setIsLowPowerMode (bool low) { MainWindow::instance()->enableLowPowerMode(low); }
//-- Prompt save log
Q_PROPERTY(bool isSaveLogPrompt READ isSaveLogPrompt WRITE setIsSaveLogPrompt NOTIFY isSaveLogPromptChanged)
bool isSaveLogPrompt () { return qgcApp()->promptFlightDataSave(); }
void setIsSaveLogPrompt (bool prompt) { qgcApp()->setPromptFlightDataSave(prompt); }
//-- ClearSettings
Q_INVOKABLE void deleteAllSettingsNextBoot () { qgcApp()->deleteAllSettingsNextBoot(); }
Q_INVOKABLE void clearDeleteAllSettingsNextBoot () { qgcApp()->clearDeleteAllSettingsNextBoot(); }
//-- TODO: Make this into an actual preference. //-- TODO: Make this into an actual preference.
bool isAdvancedMode () { return false; } bool isAdvancedMode () { return false; }
//
//-- Mavlink Protocol
//
//-- Emit heartbeat
Q_PROPERTY(bool isHeartBeatEnabled READ isHeartBeatEnabled WRITE setIsHeartBeatEnabled NOTIFY isHeartBeatEnabledChanged)
bool isHeartBeatEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->heartbeatsEnabled(); }
void setIsHeartBeatEnabled (bool enable) { qgcApp()->toolbox()->mavlinkProtocol()->enableHeartbeats(enable); }
//-- Multiplexing
Q_PROPERTY(bool isMultiplexingEnabled READ isMultiplexingEnabled WRITE setIsMultiplexingEnabled NOTIFY isMultiplexingEnabledChanged)
bool isMultiplexingEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->multiplexingEnabled(); }
void setIsMultiplexingEnabled(bool enable) { qgcApp()->toolbox()->mavlinkProtocol()->enableMultiplexing(enable); }
//-- Version Check void setIsDarkStyle (bool dark);
Q_PROPERTY(bool isVersionCheckEnabled READ isVersionCheckEnabled WRITE setIsVersionCheckEnabled NOTIFY isVersionCheckEnabledChanged) void setIsAudioMuted (bool muted);
bool isVersionCheckEnabled () { return qgcApp()->toolbox()->mavlinkProtocol()->versionCheckEnabled(); } void setIsLowPowerMode (bool low);
void setIsVersionCheckEnabled(bool enable) { qgcApp()->toolbox()->mavlinkProtocol()->enableVersionCheck(enable); } void setIsSaveLogPrompt (bool prompt);
void setIsSaveLogPromptNotArmed (bool prompt);
void setIsHeartBeatEnabled (bool enable);
void setIsMultiplexingEnabled (bool enable);
void setIsVersionCheckEnabled (bool enable);
signals: signals:
void isDarkStyleChanged (bool dark); void isDarkStyleChanged (bool dark);
void isAudioMutedChanged (bool muted); void isAudioMutedChanged (bool muted);
void isLowPowerModeChanged (bool lowPower); void isLowPowerModeChanged (bool lowPower);
void isSaveLogPromptChanged (bool prompt); void isSaveLogPromptChanged (bool prompt);
void isSaveLogPromptNotArmedChanged (bool prompt);
void isHeartBeatEnabledChanged (bool enabled); void isHeartBeatEnabledChanged (bool enabled);
void isMultiplexingEnabledChanged (bool enabled); void isMultiplexingEnabledChanged (bool enabled);
void isVersionCheckEnabledChanged (bool enabled); void isVersionCheckEnabledChanged (bool enabled);
......
...@@ -57,7 +57,7 @@ MAVLinkProtocol::MAVLinkProtocol(QGCApplication* app) ...@@ -57,7 +57,7 @@ MAVLinkProtocol::MAVLinkProtocol(QGCApplication* app)
#ifndef __mobile__ #ifndef __mobile__
, _logSuspendError(false) , _logSuspendError(false)
, _logSuspendReplay(false) , _logSuspendReplay(false)
, _logWasArmed(false) , _logPromptForSave(false)
, _tempLogFile(QString("%2.%3").arg(_tempLogFileTemplate).arg(_logFileExtension)) , _tempLogFile(QString("%2.%3").arg(_tempLogFileTemplate).arg(_logFileExtension))
#endif #endif
, _heartbeatRate(MAVLINK_HEARTBEAT_DEFAULT_RATE) , _heartbeatRate(MAVLINK_HEARTBEAT_DEFAULT_RATE)
...@@ -343,11 +343,11 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b) ...@@ -343,11 +343,11 @@ void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
} }
// Check for the vehicle arming going by. This is used to trigger log save. // Check for the vehicle arming going by. This is used to trigger log save.
if (!_logWasArmed && message.msgid == MAVLINK_MSG_ID_HEARTBEAT) { if (!_logPromptForSave && message.msgid == MAVLINK_MSG_ID_HEARTBEAT) {
mavlink_heartbeat_t state; mavlink_heartbeat_t state;
mavlink_msg_heartbeat_decode(&message, &state); mavlink_msg_heartbeat_decode(&message, &state);
if (state.base_mode & MAV_MODE_FLAG_DECODE_POSITION_SAFETY) { if (state.base_mode & MAV_MODE_FLAG_DECODE_POSITION_SAFETY) {
_logWasArmed = true; _logPromptForSave = true;
} }
} }
} }
...@@ -674,7 +674,11 @@ void MAVLinkProtocol::_startLogging(void) ...@@ -674,7 +674,11 @@ void MAVLinkProtocol::_startLogging(void)
return; return;
} }
qDebug() << "Temp log" << _tempLogFile.fileName(); if (_app->promptFlightDataSaveNotArmed()) {
_logPromptForSave = true;
}
qDebug() << "Temp log" << _tempLogFile.fileName() << _logPromptForSave;
_logSuspendError = false; _logSuspendError = false;
} }
...@@ -685,13 +689,13 @@ void MAVLinkProtocol::_stopLogging(void) ...@@ -685,13 +689,13 @@ void MAVLinkProtocol::_stopLogging(void)
{ {
if (_closeLogFile()) { if (_closeLogFile()) {
// If the signals are not connected it means we are running a unit test. In that case just delete log files // If the signals are not connected it means we are running a unit test. In that case just delete log files
if (_logWasArmed && _app->promptFlightDataSave()) { if (_logPromptForSave && _app->promptFlightDataSave()) {
emit saveTempFlightDataLog(_tempLogFile.fileName()); emit saveTempFlightDataLog(_tempLogFile.fileName());
} else { } else {
QFile::remove(_tempLogFile.fileName()); QFile::remove(_tempLogFile.fileName());
} }
} }
_logWasArmed = false; _logPromptForSave = false;
} }
/// @brief Checks the temp directory for log files which may have been left there. /// @brief Checks the temp directory for log files which may have been left there.
......
...@@ -297,7 +297,7 @@ private: ...@@ -297,7 +297,7 @@ private:
bool _logSuspendError; ///< true: Logging suspended due to error bool _logSuspendError; ///< true: Logging suspended due to error
bool _logSuspendReplay; ///< true: Logging suspended due to replay bool _logSuspendReplay; ///< true: Logging suspended due to replay
bool _logWasArmed; ///< true: vehicle was armed during logging bool _logPromptForSave; ///< true: Prompt for log save when appropriate
QGCTemporaryFile _tempLogFile; ///< File to log to QGCTemporaryFile _tempLogFile; ///< File to log to
static const char* _tempLogFileTemplate; ///< Template for temporary log file static const char* _tempLogFileTemplate; ///< Template for temporary log file
......
...@@ -596,7 +596,7 @@ void MainWindow::_openUrl(const QString& url, const QString& errorMessage) ...@@ -596,7 +596,7 @@ void MainWindow::_openUrl(const QString& url, const QString& errorMessage)
void MainWindow::showSettings() void MainWindow::showSettings()
{ {
SettingsDialog settings(qgcApp()->toolbox()->audioOutput(), qgcApp()->toolbox()->flightMapSettings(), this); SettingsDialog settings(this);
settings.exec(); settings.exec();
} }
...@@ -619,7 +619,7 @@ void MainWindow::_storeCurrentViewState(void) ...@@ -619,7 +619,7 @@ void MainWindow::_storeCurrentViewState(void)
void MainWindow::manageLinks() void MainWindow::manageLinks()
{ {
SettingsDialog settings(qgcApp()->toolbox()->audioOutput(), qgcApp()->toolbox()->flightMapSettings(), this, SettingsDialog::ShowCommLinks); SettingsDialog settings(this, SettingsDialog::ShowCommLinks);
settings.exec(); settings.exec();
} }
......
...@@ -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>
......
...@@ -86,6 +86,7 @@ Rectangle { ...@@ -86,6 +86,7 @@ Rectangle {
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Prompt Save Log //-- Prompt Save Log
QGCCheckBox { QGCCheckBox {
id: promptSaveLog
text: "Prompt to save Flight Data Log after each flight" text: "Prompt to save Flight Data Log after each flight"
checked: QGroundControl.isSaveLogPrompt checked: QGroundControl.isSaveLogPrompt
visible: !ScreenTools.isMobile visible: !ScreenTools.isMobile
...@@ -94,6 +95,17 @@ Rectangle { ...@@ -94,6 +95,17 @@ Rectangle {
} }
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Prompt Save even if not armed
QGCCheckBox {
text: "Prompt to save Flight Data Log even if vehicle was not armed"
checked: QGroundControl.isSaveLogPromptNotArmed
visible: !ScreenTools.isMobile
enabled: promptSaveLog.checked
onClicked: {
QGroundControl.isSaveLogPromptNotArmed = checked
}
}
//-----------------------------------------------------------------
//-- Clear settings //-- Clear settings
QGCCheckBox { QGCCheckBox {
id: clearCheck id: clearCheck
......
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