diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h
index eab3977..788e6db 100644
--- a/src/ui/MainWindow.h
+++ b/src/ui/MainWindow.h
@@ -126,11 +126,8 @@ public:
/// @brief Restore (and connects) the last used connection (if any)
void restoreLastUsedConnection();
-#ifdef UNITTEST_BUILD
- // Returns a pointer to the MainToolBar so that unit tests can change views.
+ /// @brief Gets a pointer to the Main Tool Bar
MainToolBar* getMainToolBar(void) { return _mainToolBar; }
-#endif
-
public slots:
/** @brief Show the application settings */
diff --git a/src/ui/SettingsDialog.cc b/src/ui/SettingsDialog.cc
index 8479b79..d856188 100644
--- a/src/ui/SettingsDialog.cc
+++ b/src/ui/SettingsDialog.cc
@@ -37,6 +37,7 @@
#include "QGCApplication.h"
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
+#include "MainToolBar.h"
SettingsDialog::SettingsDialog(JoystickInput *joystick, QWidget *parent, int showTab, Qt::WindowFlags flags) :
QDialog(parent, flags),
@@ -63,6 +64,14 @@ _ui(new Ui::SettingsDialog)
this->window()->setWindowTitle(tr("QGroundControl Settings"));
+ // Tool Bar Preferences
+ QSettings settings;
+ settings.beginGroup(TOOL_BAR_SETTINGS_GROUP);
+ _ui->showBattery->setChecked(settings.value( TOOL_BAR_SHOW_BATTERY, true).toBool());
+ _ui->showGPS->setChecked(settings.value( TOOL_BAR_SHOW_GPS, true).toBool());
+ _ui->showMav->setChecked(settings.value( TOOL_BAR_SHOW_MAV, true).toBool());
+ _ui->showMessages->setChecked(settings.value(TOOL_BAR_SHOW_MESSAGES, true).toBool());
+ settings.endGroup();
// Audio preferences
_ui->audioMuteCheckBox->setChecked(GAudioOutput::instance()->isMuted());
connect(_ui->audioMuteCheckBox, SIGNAL(toggled(bool)), GAudioOutput::instance(), SLOT(mute(bool)));
@@ -115,10 +124,11 @@ void SettingsDialog::styleChanged(int index)
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);
+ 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 {
@@ -133,21 +143,17 @@ void SettingsDialog::_deleteSettingsToggled(bool checked)
void SettingsDialog::_validateBeforeClose(void)
{
QGCApplication* app = qgcApp();
-
// Validate the saved file location
-
QString saveLocation = _ui->savedFilesLocation->text();
if (!app->validatePossibleSavedFilesLocation(saveLocation)) {
- QGCMessageBox::warning(tr("Bad save location"),
- tr("The location to save files to is invalid, or cannot be written to. Please provide a valid directory."));
+ QGCMessageBox::warning(
+ tr("Invalid Save Location"),
+ tr("The location to save files is invalid, or cannot be written to. Please provide a valid directory."));
return;
}
-
// Locations is valid, save
app->setSavedFilesLocation(saveLocation);
-
qgcApp()->setPromptFlightDataSave(_ui->promptFlightDataSave->checkState() == Qt::Checked);
-
// Close dialog
accept();
}
@@ -155,10 +161,36 @@ void SettingsDialog::_validateBeforeClose(void)
/// @brief Displays a directory picker dialog to allow the user to select a saved file location
void SettingsDialog::_selectSavedFilesDirectory(void)
{
- QString newLocation = QGCFileDialog::getExistingDirectory(this,
- tr("Select the directory where you want to save files to."),
- _ui->savedFilesLocation->text());
+ QString newLocation = QGCFileDialog::getExistingDirectory(
+ this,
+ tr("Select the directory where you want to save files to."),
+ _ui->savedFilesLocation->text());
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::on_showGPS_clicked(bool checked)
+{
+ _mainWindow->getMainToolBar()->viewStateChanged(TOOL_BAR_SHOW_GPS, checked);
+}
+
+void SettingsDialog::on_showBattery_clicked(bool checked)
+{
+ _mainWindow->getMainToolBar()->viewStateChanged(TOOL_BAR_SHOW_BATTERY, checked);
+}
+
+void SettingsDialog::on_showMessages_clicked(bool checked)
+{
+ _mainWindow->getMainToolBar()->viewStateChanged(TOOL_BAR_SHOW_MESSAGES, checked);
+}
+
+void SettingsDialog::on_showMav_clicked(bool checked)
+{
+ _mainWindow->getMainToolBar()->viewStateChanged(TOOL_BAR_SHOW_MAV, checked);
}
diff --git a/src/ui/SettingsDialog.h b/src/ui/SettingsDialog.h
index 1499ecd..b8a3f8b 100644
--- a/src/ui/SettingsDialog.h
+++ b/src/ui/SettingsDialog.h
@@ -56,6 +56,11 @@ private slots:
void _selectSavedFilesDirectory(void);
void _validateBeforeClose(void);
+ void on_showGPS_clicked(bool checked);
+ void on_showBattery_clicked(bool checked);
+ void on_showMessages_clicked(bool checked);
+ void on_showMav_clicked(bool checked);
+
private:
MainWindow* _mainWindow;
Ui::SettingsDialog* _ui;
diff --git a/src/ui/SettingsDialog.ui b/src/ui/SettingsDialog.ui
index fef2722..16bcdbe 100644
--- a/src/ui/SettingsDialog.ui
+++ b/src/ui/SettingsDialog.ui
@@ -6,8 +6,8 @@
0
0
- 534
- 681
+ 500
+ 604
@@ -19,245 +19,356 @@
Dialog
-
+
-
+
+
+ 0
+ 0
+
+
General
General Settings
-
+
-
-
-
- Mute all audio output
+
+
+ 10
-
-
- :/files/images/status/audio-volume-muted.svg:/files/images/status/audio-volume-muted.svg
-
-
-
- -
-
-
- Automatically reconnect last link on application startup
-
-
-
- :/files/images/devices/network-wireless.svg:/files/images/devices/network-wireless.svg
-
-
-
- -
-
-
- Lowers all update rates to save battery power
-
-
- Enable low power mode
-
-
-
- -
-
-
- Prompt to save Flight Data Log after each flight
-
-
-
- -
-
-
- Style
-
-
- false
-
-
- false
-
-
-
-
-
-
- QLayout::SetMinimumSize
-
+
-
+
+
+
+ 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
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Style
+
+
+ false
+
+
+ false
+
+
+
-
+
+
+ QLayout::SetMinimumSize
+
+
+ 0
+
+
+ 80
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 200
+ 0
+
+
+
-
+
+ Dark (for indoor use)
+
+
+ -
+
+ Light (for outdoor use)
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ File Locations
+
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ Specify the location you would like to save files:
+
+
+ true
+
+
+
-
-
+
-
-
- Dark (for indoor use)
-
+
+
+
+ 200
+ 21
+
+
+
+ 1024
+
+
-
-
- Light (for outdoor use)
-
+
+
+ Browse
+
+
+
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Tool Bar
+
+
+
-
+
+
-
+
+
-
+
+
+
+ 160
+ 0
+
+
+
+ Show GPS
+
+
+
+ -
+
+
+ Show Messages
+
+
+
+
+
+ -
+
+
-
+
+
+
+ 160
+ 0
+
+
+
+ Show Battery
+
+
+
+ -
+
+
+ Show Mav Icon
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+ 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
+
-
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 200
-
-
-
- File Locations
-
-
-
-
-
-
-
- 11
-
-
-
- Parameters will be saved here:
-
-
-
- -
-
-
-
- 11
-
-
-
- TextLabel
-
-
-
- -
-
-
- Browse
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 0
- 0
-
-
-
- Specify the location you would like to save files to:
-
-
- true
-
-
-
- -
-
-
-
- 0
- 21
-
-
-
-
- -
-
-
-
- 11
-
-
-
- Flight Data Logs will be saved here:
-
-
-
- -
-
-
-
- 11
-
-
-
- TextLabel
-
-
-
-
-
-
- -
-
-
- Danger Zone
-
-
-
-
-
-
- Delete all saved settings on next boot
-
-
-
- -
-
-
-
- 11
-
-
-
- Note: You can also use --clear-settings as a command line option to accomplish this.
-
-
- true
-
-
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 20
-
-
-
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 10
+
+
+
+
+
+ audioMuteCheckBox
+ reconnectCheckBox
+ lowPowerCheckBox
+ promptFlightDataSave
+ groupBox
+ fileLocationsLayout
+ groupBox_2
+ groupBox_3
@@ -276,8 +387,6 @@
-
-
-
+
diff --git a/src/ui/toolbar/MainToolBar.cc b/src/ui/toolbar/MainToolBar.cc
index 2091dac..fad4da2 100644
--- a/src/ui/toolbar/MainToolBar.cc
+++ b/src/ui/toolbar/MainToolBar.cc
@@ -57,6 +57,10 @@ MainToolBar::MainToolBar(QWidget* parent)
, _satelliteCount(-1)
, _dotsPerInch(96.0) // Default to Windows as it's more likely not to report below
, _satelliteLock(0)
+ , _showGPS(true)
+ , _showMav(true)
+ , _showMessages(true)
+ , _showBattery(true)
, _rollDownMessages(0)
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
@@ -76,7 +80,16 @@ MainToolBar::MainToolBar(QWidget* parent)
} else {
qWarning() << "System not reporting logical DPI, which is used to compute the appropriate font size. The default being used is 96dpi. If the text within buttons and UI elements are too big or too small, that's the reason.";
}
- // Give the QML code a way to reach us
+
+ // Tool Bar Preferences
+ QSettings settings;
+ settings.beginGroup(TOOL_BAR_SETTINGS_GROUP);
+ _showBattery = settings.value(TOOL_BAR_SHOW_BATTERY, true).toBool();
+ _showGPS = settings.value(TOOL_BAR_SHOW_GPS, true).toBool();
+ _showMav = settings.value(TOOL_BAR_SHOW_MAV, true).toBool();
+ _showMessages = settings.value(TOOL_BAR_SHOW_MESSAGES, true).toBool();
+ settings.endGroup();
+
setContextPropertyObject("mainToolBar", this);
setSource(QUrl::fromUserInput("qrc:/qml/MainToolBar.qml"));
setVisible(true);
@@ -97,6 +110,32 @@ MainToolBar::~MainToolBar()
}
+void MainToolBar::_setToolBarState(const QString& key, bool value)
+{
+ QSettings settings;
+ settings.beginGroup(TOOL_BAR_SETTINGS_GROUP);
+ settings.setValue(key, value);
+ settings.endGroup();
+ if(key == TOOL_BAR_SHOW_GPS) {
+ _showGPS = value;
+ emit showGPSChanged(value);
+ } else if(key == TOOL_BAR_SHOW_MAV) {
+ _showMav = value;
+ emit showMavChanged(value);
+ }else if(key == TOOL_BAR_SHOW_BATTERY) {
+ _showBattery = value;
+ emit showBatteryChanged(value);
+ } else if(key == TOOL_BAR_SHOW_MESSAGES) {
+ _showMessages = value;
+ emit showMessagesChanged(value);
+ }
+}
+
+void MainToolBar::viewStateChanged(const QString &key, bool value)
+{
+ _setToolBarState(key, value);
+}
+
void MainToolBar::onSetupView()
{
setCurrentView(ViewSetup);
diff --git a/src/ui/toolbar/MainToolBar.h b/src/ui/toolbar/MainToolBar.h
index 9d9fab3..4984918 100644
--- a/src/ui/toolbar/MainToolBar.h
+++ b/src/ui/toolbar/MainToolBar.h
@@ -32,6 +32,12 @@ This file is part of the QGROUNDCONTROL project
#include "QGCQmlWidgetHolder.h"
+#define TOOL_BAR_SETTINGS_GROUP "TOOLBAR_SETTINGS_GROUP"
+#define TOOL_BAR_SHOW_BATTERY "ShowBattery"
+#define TOOL_BAR_SHOW_GPS "ShowGPS"
+#define TOOL_BAR_SHOW_MAV "ShowMav"
+#define TOOL_BAR_SHOW_MESSAGES "ShowMessages"
+
class UASInterface;
class UASMessage;
class UASMessageViewRollDown;
@@ -88,6 +94,10 @@ public:
Q_PROPERTY(QString currentState READ currentState NOTIFY currentStateChanged)
Q_PROPERTY(double dotsPerInch READ dotsPerInch NOTIFY dotsPerInchChanged)
Q_PROPERTY(int satelliteLock READ satelliteLock NOTIFY satelliteLockChanged)
+ Q_PROPERTY(bool showGPS READ showGPS NOTIFY showGPSChanged)
+ Q_PROPERTY(bool showMav READ showMav NOTIFY showMavChanged)
+ Q_PROPERTY(bool showMessages READ showMessages NOTIFY showMessagesChanged)
+ Q_PROPERTY(bool showBattery READ showBattery NOTIFY showBatteryChanged)
int connectionCount () { return _connectionCount; }
double batteryVoltage () { return _batteryVoltage; }
@@ -108,8 +118,13 @@ public:
QString currentState () { return _currentState; }
double dotsPerInch () { return _dotsPerInch; }
int satelliteLock () { return _satelliteLock; }
+ bool showGPS () { return _showGPS; }
+ bool showMav () { return _showMav; }
+ bool showMessages () { return _showMessages; }
+ bool showBattery () { return _showBattery; }
void setCurrentView (int currentView);
+ void viewStateChanged (const QString& key, bool value);
signals:
void connectionCountChanged (int count);
@@ -131,6 +146,10 @@ signals:
void currentStateChanged (QString state);
void dotsPerInchChanged ();
void satelliteLockChanged (int lock);
+ void showGPSChanged (bool value);
+ void showMavChanged (bool value);
+ void showMessagesChanged (bool value);
+ void showBatteryChanged (bool value);
private slots:
void _setActiveUAS (UASInterface* active);
@@ -154,6 +173,7 @@ private slots:
private:
void _updateConnection (LinkInterface *disconnectedLink = NULL);
+ void _setToolBarState (const QString& key, bool value);
private:
UASInterface* _mav;
@@ -183,6 +203,10 @@ private:
QStringList _connectedList;
qreal _dotsPerInch;
int _satelliteLock;
+ bool _showGPS;
+ bool _showMav;
+ bool _showMessages;
+ bool _showBattery;
UASMessageViewRollDown* _rollDownMessages;
};
diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml
index 17f1e44..014c026 100644
--- a/src/ui/toolbar/MainToolBar.qml
+++ b/src/ui/toolbar/MainToolBar.qml
@@ -190,7 +190,7 @@ Rectangle {
id: messages
width: (mainToolBar.newMessageCount > 99) ? 70 : 60
height: cellHeight
- visible: (mainToolBar.connectionCount > 0)
+ visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages)
anchors.verticalCenter: parent.verticalCenter
color: getMessageColor()
radius: cellRadius
@@ -266,7 +266,7 @@ Rectangle {
id: mavIcon
width: cellHeight
height: cellHeight
- visible: showMavStatus()
+ visible: showMavStatus() && (mainToolBar.showMav)
anchors.verticalCenter: parent.verticalCenter
color: colorBlue
radius: cellRadius
@@ -285,7 +285,7 @@ Rectangle {
id: satelitte
width: 60
height: cellHeight
- visible: showMavStatus();
+ visible: showMavStatus() && (mainToolBar.showGPS)
anchors.verticalCenter: parent.verticalCenter
color: getSatelliteColor();
radius: cellRadius
@@ -320,7 +320,7 @@ Rectangle {
id: battery
width: 80
height: cellHeight
- visible: showMavStatus()
+ visible: showMavStatus() && (mainToolBar.showBattery)
anchors.verticalCenter: parent.verticalCenter
color: (mainToolBar.batteryPercent > 40.0 || mainToolBar.batteryPercent < 0.01) ? colorGreen : colorRed
radius: cellRadius