Commit 86fd4a29 authored by dogmaphobic's avatar dogmaphobic

Completed Tool Bar settings in Preferences Dialog

parent cef33ce0
...@@ -131,6 +131,7 @@ public: ...@@ -131,6 +131,7 @@ public:
MainToolBar* getMainToolBar(void) { return _mainToolBar; } MainToolBar* getMainToolBar(void) { return _mainToolBar; }
#endif #endif
MainToolBar* getToolBar() { return _mainToolBar; }
public slots: public slots:
/** @brief Show the application settings */ /** @brief Show the application settings */
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "QGCApplication.h" #include "QGCApplication.h"
#include "QGCFileDialog.h" #include "QGCFileDialog.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "MainToolBar.h"
SettingsDialog::SettingsDialog(JoystickInput *joystick, QWidget *parent, int showTab, Qt::WindowFlags flags) : SettingsDialog::SettingsDialog(JoystickInput *joystick, QWidget *parent, int showTab, Qt::WindowFlags flags) :
QDialog(parent, flags), QDialog(parent, flags),
...@@ -63,6 +64,14 @@ _ui(new Ui::SettingsDialog) ...@@ -63,6 +64,14 @@ _ui(new Ui::SettingsDialog)
this->window()->setWindowTitle(tr("QGroundControl Settings")); 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 // Audio preferences
_ui->audioMuteCheckBox->setChecked(GAudioOutput::instance()->isMuted()); _ui->audioMuteCheckBox->setChecked(GAudioOutput::instance()->isMuted());
connect(_ui->audioMuteCheckBox, SIGNAL(toggled(bool)), GAudioOutput::instance(), SLOT(mute(bool))); connect(_ui->audioMuteCheckBox, SIGNAL(toggled(bool)), GAudioOutput::instance(), SLOT(mute(bool)));
...@@ -115,10 +124,11 @@ void SettingsDialog::styleChanged(int index) ...@@ -115,10 +124,11 @@ void SettingsDialog::styleChanged(int index)
void SettingsDialog::_deleteSettingsToggled(bool checked) void SettingsDialog::_deleteSettingsToggled(bool checked)
{ {
if (checked){ if (checked){
QGCMessageBox::StandardButton answer = QGCMessageBox::question(tr("Delete Settings"), QGCMessageBox::StandardButton answer =
tr("All saved settings will be deleted the next time you start QGroundControl. Is this really what you want?"), QGCMessageBox::question(tr("Delete Settings"),
QMessageBox::Yes | QMessageBox::No, tr("All saved settings will be deleted the next time you start QGroundControl. Is this really what you want?"),
QMessageBox::No); QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
if (answer == QMessageBox::Yes) { if (answer == QMessageBox::Yes) {
qgcApp()->deleteAllSettingsNextBoot(); qgcApp()->deleteAllSettingsNextBoot();
} else { } else {
...@@ -133,21 +143,17 @@ void SettingsDialog::_deleteSettingsToggled(bool checked) ...@@ -133,21 +143,17 @@ void SettingsDialog::_deleteSettingsToggled(bool checked)
void SettingsDialog::_validateBeforeClose(void) void SettingsDialog::_validateBeforeClose(void)
{ {
QGCApplication* app = qgcApp(); QGCApplication* app = qgcApp();
// Validate the saved file location // Validate the saved file location
QString saveLocation = _ui->savedFilesLocation->text(); QString saveLocation = _ui->savedFilesLocation->text();
if (!app->validatePossibleSavedFilesLocation(saveLocation)) { if (!app->validatePossibleSavedFilesLocation(saveLocation)) {
QGCMessageBox::warning(tr("Bad save location"), QGCMessageBox::warning(
tr("The location to save files to is invalid, or cannot be written to. Please provide a valid directory.")); tr("Invalid Save Location"),
tr("The location to save files is invalid, or cannot be written to. Please provide a valid directory."));
return; return;
} }
// Locations is valid, save // Locations is valid, save
app->setSavedFilesLocation(saveLocation); app->setSavedFilesLocation(saveLocation);
qgcApp()->setPromptFlightDataSave(_ui->promptFlightDataSave->checkState() == Qt::Checked); qgcApp()->setPromptFlightDataSave(_ui->promptFlightDataSave->checkState() == Qt::Checked);
// Close dialog // Close dialog
accept(); accept();
} }
...@@ -155,10 +161,36 @@ void SettingsDialog::_validateBeforeClose(void) ...@@ -155,10 +161,36 @@ void SettingsDialog::_validateBeforeClose(void)
/// @brief Displays a directory picker dialog to allow the user to select a saved file location /// @brief Displays a directory picker dialog to allow the user to select a saved file location
void SettingsDialog::_selectSavedFilesDirectory(void) void SettingsDialog::_selectSavedFilesDirectory(void)
{ {
QString newLocation = QGCFileDialog::getExistingDirectory(this, QString newLocation = QGCFileDialog::getExistingDirectory(
tr("Select the directory where you want to save files to."), this,
_ui->savedFilesLocation->text()); tr("Select the directory where you want to save files to."),
_ui->savedFilesLocation->text());
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::on_showGPS_clicked(bool checked)
{
_mainWindow->getToolBar()->viewStateChanged(TOOL_BAR_SHOW_GPS, checked);
}
void SettingsDialog::on_showBattery_clicked(bool checked)
{
_mainWindow->getToolBar()->viewStateChanged(TOOL_BAR_SHOW_BATTERY, checked);
}
void SettingsDialog::on_showMessages_clicked(bool checked)
{
_mainWindow->getToolBar()->viewStateChanged(TOOL_BAR_SHOW_MESSAGES, checked);
}
void SettingsDialog::on_showMav_clicked(bool checked)
{
_mainWindow->getToolBar()->viewStateChanged(TOOL_BAR_SHOW_MAV, checked);
} }
...@@ -56,6 +56,11 @@ private slots: ...@@ -56,6 +56,11 @@ private slots:
void _selectSavedFilesDirectory(void); void _selectSavedFilesDirectory(void);
void _validateBeforeClose(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: private:
MainWindow* _mainWindow; MainWindow* _mainWindow;
Ui::SettingsDialog* _ui; Ui::SettingsDialog* _ui;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>534</width> <width>500</width>
<height>681</height> <height>604</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -19,245 +19,356 @@ ...@@ -19,245 +19,356 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<widget class="QWidget" name="general"> <widget class="QWidget" name="general">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title"> <attribute name="title">
<string>General</string> <string>General</string>
</attribute> </attribute>
<attribute name="toolTip"> <attribute name="toolTip">
<string>General Settings</string> <string>General Settings</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_8">
<item> <item>
<widget class="QCheckBox" name="audioMuteCheckBox"> <layout class="QVBoxLayout" name="verticalLayout_6">
<property name="text"> <property name="topMargin">
<string>Mute all audio output</string> <number>10</number>
</property> </property>
<property name="icon"> <item>
<iconset resource="../../qgroundcontrol.qrc"> <widget class="QCheckBox" name="audioMuteCheckBox">
<normaloff>:/files/images/status/audio-volume-muted.svg</normaloff>:/files/images/status/audio-volume-muted.svg</iconset> <property name="sizePolicy">
</property> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
</widget> <horstretch>0</horstretch>
</item> <verstretch>0</verstretch>
<item> </sizepolicy>
<widget class="QCheckBox" name="reconnectCheckBox"> </property>
<property name="text"> <property name="text">
<string>Automatically reconnect last link on application startup</string> <string>Mute all audio output</string>
</property> </property>
<property name="icon"> <property name="iconSize">
<iconset resource="../../qgroundcontrol.qrc"> <size>
<normaloff>:/files/images/devices/network-wireless.svg</normaloff>:/files/images/devices/network-wireless.svg</iconset> <width>0</width>
</property> <height>0</height>
</widget> </size>
</item> </property>
<item> </widget>
<widget class="QCheckBox" name="lowPowerCheckBox"> </item>
<property name="toolTip"> <item>
<string>Lowers all update rates to save battery power</string> <widget class="QCheckBox" name="reconnectCheckBox">
</property> <property name="sizePolicy">
<property name="text"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<string>Enable low power mode</string> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
</widget> </sizepolicy>
</item> </property>
<item> <property name="text">
<widget class="QCheckBox" name="promptFlightDataSave"> <string>Automatically reconnect last link on application startup</string>
<property name="text"> </property>
<string>Prompt to save Flight Data Log after each flight</string> <property name="iconSize">
</property> <size>
</widget> <width>0</width>
</item> <height>0</height>
<item> </size>
<widget class="QGroupBox" name="groupBox"> </property>
<property name="title"> </widget>
<string>Style</string> </item>
</property> <item>
<property name="flat"> <widget class="QCheckBox" name="lowPowerCheckBox">
<bool>false</bool> <property name="sizePolicy">
</property> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<property name="checkable"> <horstretch>0</horstretch>
<bool>false</bool> <verstretch>0</verstretch>
</property> </sizepolicy>
<layout class="QVBoxLayout" name="verticalLayout_3"> </property>
<item> <property name="toolTip">
<layout class="QHBoxLayout" name="horizontalLayout"> <string>Lowers all update rates to save battery power</string>
<property name="sizeConstraint"> </property>
<enum>QLayout::SetMinimumSize</enum> <property name="text">
</property> <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">
<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">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinimumSize</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>
<widget class="QGroupBox" name="fileLocationsLayout">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>File Locations</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Specify the location you would like to save files:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QComboBox" name="styleChooser"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<property name="text"> <widget class="QLineEdit" name="savedFilesLocation">
<string>Dark (for indoor use)</string> <property name="minimumSize">
</property> <size>
<width>200</width>
<height>21</height>
</size>
</property>
<property name="maxLength">
<number>1024</number>
</property>
</widget>
</item> </item>
<item> <item>
<property name="text"> <widget class="QPushButton" name="browseSavedFilesLocation">
<string>Light (for outdoor use)</string> <property name="text">
</property> <string>Browse</string>
</property>
</widget>
</item> </item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Tool Bar</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="showGPS">
<property name="minimumSize">
<size>
<width>160</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Show GPS</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showMessages">
<property name="text">
<string>Show Messages</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="showBattery">
<property name="minimumSize">
<size>
<width>160</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Show Battery</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showMav">
<property name="text">
<string>Show Mav Icon</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</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> </widget>
</item> </item>
</layout> </layout>
</item> </widget>
</layout> </item>
</widget> <item>
</item> <spacer name="verticalSpacer">
<item> <property name="orientation">
<widget class="QGroupBox" name="fileLocationsLayout"> <enum>Qt::Vertical</enum>
<property name="sizePolicy"> </property>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> <property name="sizeHint" stdset="0">
<horstretch>0</horstretch> <size>
<verstretch>0</verstretch> <width>20</width>
</sizepolicy> <height>10</height>
</property> </size>
<property name="minimumSize"> </property>
<size> </spacer>
<width>0</width> </item>
<height>200</height> </layout>
</size>
</property>
<property name="title">
<string>File Locations</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Parameters will be saved here:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="flightDataLogLocation">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="browseSavedFilesLocation">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Specify the location you would like to save files to:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="savedFilesLocation">
<property name="minimumSize">
<size>
<width>0</width>
<height>21</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Flight Data Logs will be saved here:</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="parameterLocation">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</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>
<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>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
<zorder>audioMuteCheckBox</zorder>
<zorder>reconnectCheckBox</zorder>
<zorder>lowPowerCheckBox</zorder>
<zorder>promptFlightDataSave</zorder>
<zorder>groupBox</zorder>
<zorder>fileLocationsLayout</zorder>
<zorder>groupBox_2</zorder>
<zorder>groupBox_3</zorder>
</widget> </widget>
</widget> </widget>
</item> </item>
...@@ -276,8 +387,6 @@ ...@@ -276,8 +387,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <resources/>
<include location="../../qgroundcontrol.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>
...@@ -57,6 +57,10 @@ MainToolBar::MainToolBar(QWidget* parent) ...@@ -57,6 +57,10 @@ MainToolBar::MainToolBar(QWidget* parent)
, _satelliteCount(-1) , _satelliteCount(-1)
, _dotsPerInch(96.0) // Default to Windows as it's more likely not to report below , _dotsPerInch(96.0) // Default to Windows as it's more likely not to report below
, _satelliteLock(0) , _satelliteLock(0)
, _showGPS(true)
, _showMav(true)
, _showMessages(true)
, _showBattery(true)
, _rollDownMessages(0) , _rollDownMessages(0)
{ {
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
...@@ -76,7 +80,16 @@ MainToolBar::MainToolBar(QWidget* parent) ...@@ -76,7 +80,16 @@ MainToolBar::MainToolBar(QWidget* parent)
} else { } 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."; 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); setContextPropertyObject("mainToolBar", this);
setSource(QUrl::fromUserInput("qrc:/qml/MainToolBar.qml")); setSource(QUrl::fromUserInput("qrc:/qml/MainToolBar.qml"));
setVisible(true); setVisible(true);
...@@ -97,6 +110,32 @@ MainToolBar::~MainToolBar() ...@@ -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() void MainToolBar::onSetupView()
{ {
setCurrentView(ViewSetup); setCurrentView(ViewSetup);
......
...@@ -32,6 +32,12 @@ This file is part of the QGROUNDCONTROL project ...@@ -32,6 +32,12 @@ This file is part of the QGROUNDCONTROL project
#include "QGCQmlWidgetHolder.h" #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 UASInterface;
class UASMessage; class UASMessage;
class UASMessageViewRollDown; class UASMessageViewRollDown;
...@@ -88,6 +94,10 @@ public: ...@@ -88,6 +94,10 @@ public:
Q_PROPERTY(QString currentState READ currentState NOTIFY currentStateChanged) Q_PROPERTY(QString currentState READ currentState NOTIFY currentStateChanged)
Q_PROPERTY(double dotsPerInch READ dotsPerInch NOTIFY dotsPerInchChanged) Q_PROPERTY(double dotsPerInch READ dotsPerInch NOTIFY dotsPerInchChanged)
Q_PROPERTY(int satelliteLock READ satelliteLock NOTIFY satelliteLockChanged) 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; } int connectionCount () { return _connectionCount; }
double batteryVoltage () { return _batteryVoltage; } double batteryVoltage () { return _batteryVoltage; }
...@@ -108,8 +118,13 @@ public: ...@@ -108,8 +118,13 @@ public:
QString currentState () { return _currentState; } QString currentState () { return _currentState; }
double dotsPerInch () { return _dotsPerInch; } double dotsPerInch () { return _dotsPerInch; }
int satelliteLock () { return _satelliteLock; } 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 setCurrentView (int currentView);
void viewStateChanged (const QString& key, bool value);
signals: signals:
void connectionCountChanged (int count); void connectionCountChanged (int count);
...@@ -131,6 +146,10 @@ signals: ...@@ -131,6 +146,10 @@ signals:
void currentStateChanged (QString state); void currentStateChanged (QString state);
void dotsPerInchChanged (); void dotsPerInchChanged ();
void satelliteLockChanged (int lock); void satelliteLockChanged (int lock);
void showGPSChanged (bool value);
void showMavChanged (bool value);
void showMessagesChanged (bool value);
void showBatteryChanged (bool value);
private slots: private slots:
void _setActiveUAS (UASInterface* active); void _setActiveUAS (UASInterface* active);
...@@ -154,6 +173,7 @@ private slots: ...@@ -154,6 +173,7 @@ private slots:
private: private:
void _updateConnection (LinkInterface *disconnectedLink = NULL); void _updateConnection (LinkInterface *disconnectedLink = NULL);
void _setToolBarState (const QString& key, bool value);
private: private:
UASInterface* _mav; UASInterface* _mav;
...@@ -183,6 +203,10 @@ private: ...@@ -183,6 +203,10 @@ private:
QStringList _connectedList; QStringList _connectedList;
qreal _dotsPerInch; qreal _dotsPerInch;
int _satelliteLock; int _satelliteLock;
bool _showGPS;
bool _showMav;
bool _showMessages;
bool _showBattery;
UASMessageViewRollDown* _rollDownMessages; UASMessageViewRollDown* _rollDownMessages;
}; };
......
...@@ -190,7 +190,7 @@ Rectangle { ...@@ -190,7 +190,7 @@ Rectangle {
id: messages id: messages
width: (mainToolBar.newMessageCount > 99) ? 70 : 60 width: (mainToolBar.newMessageCount > 99) ? 70 : 60
height: cellHeight height: cellHeight
visible: (mainToolBar.connectionCount > 0) visible: (mainToolBar.connectionCount > 0) && (mainToolBar.showMessages)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: getMessageColor() color: getMessageColor()
radius: cellRadius radius: cellRadius
...@@ -266,7 +266,7 @@ Rectangle { ...@@ -266,7 +266,7 @@ Rectangle {
id: mavIcon id: mavIcon
width: cellHeight width: cellHeight
height: cellHeight height: cellHeight
visible: showMavStatus() visible: showMavStatus() && (mainToolBar.showMav)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: colorBlue color: colorBlue
radius: cellRadius radius: cellRadius
...@@ -285,7 +285,7 @@ Rectangle { ...@@ -285,7 +285,7 @@ Rectangle {
id: satelitte id: satelitte
width: 60 width: 60
height: cellHeight height: cellHeight
visible: showMavStatus(); visible: showMavStatus() && (mainToolBar.showGPS)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: getSatelliteColor(); color: getSatelliteColor();
radius: cellRadius radius: cellRadius
...@@ -320,7 +320,7 @@ Rectangle { ...@@ -320,7 +320,7 @@ Rectangle {
id: battery id: battery
width: 80 width: 80
height: cellHeight height: cellHeight
visible: showMavStatus() visible: showMavStatus() && (mainToolBar.showBattery)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: (mainToolBar.batteryPercent > 40.0 || mainToolBar.batteryPercent < 0.01) ? colorGreen : colorRed color: (mainToolBar.batteryPercent > 40.0 || mainToolBar.batteryPercent < 0.01) ? colorGreen : colorRed
radius: cellRadius radius: cellRadius
......
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