diff --git a/src/ui/QGCSettingsWidget.cc b/src/ui/QGCSettingsWidget.cc index 125e8b6..4bd74e5 100644 --- a/src/ui/QGCSettingsWidget.cc +++ b/src/ui/QGCSettingsWidget.cc @@ -38,6 +38,10 @@ QGCSettingsWidget::QGCSettingsWidget(QWidget *parent, Qt::WindowFlags flags) : ui->reconnectCheckBox->setChecked(MainWindow::instance()->autoReconnectEnabled()); connect(ui->reconnectCheckBox, SIGNAL(clicked(bool)), MainWindow::instance(), SLOT(enableAutoReconnect(bool))); + // Low power mode + ui->lowPowerCheckBox->setChecked(MainWindow::instance()->lowPowerModeEnabled()); + connect(ui->lowPowerCheckBox, SIGNAL(clicked(bool)), MainWindow::instance(), SLOT(enableLowPowerMode(bool))); + // Style MainWindow::QGC_MAINWINDOW_STYLE style = (MainWindow::QGC_MAINWINDOW_STYLE)MainWindow::instance()->getStyle(); switch (style) { diff --git a/src/ui/QGCSettingsWidget.ui b/src/ui/QGCSettingsWidget.ui index 1be65e8..a184265 100644 --- a/src/ui/QGCSettingsWidget.ui +++ b/src/ui/QGCSettingsWidget.ui @@ -46,7 +46,7 @@ - + Use native platform look and feel (Windows/Linux/Mac OS) @@ -56,20 +56,30 @@ - + Use indoor mission style (black background) - + Use outdoor mission style (light background) + + + + Lowers all update rates to save battery power + + + Enable low power mode + + + diff --git a/src/ui/designer/QGCToolWidget.cc b/src/ui/designer/QGCToolWidget.cc index c763b30..d5ced7f 100644 --- a/src/ui/designer/QGCToolWidget.cc +++ b/src/ui/designer/QGCToolWidget.cc @@ -174,6 +174,24 @@ void QGCToolWidget::contextMenuEvent (QContextMenuEvent* event) menu.exec(event->globalPos()); } +void QGCToolWidget::hideEvent(QHideEvent* event) +{ + // Store settings + storeWidgetsToSettings(); + QWidget::hideEvent(event); +} + +/** + * The widgets current view and the applied dock widget area. + * Both values are only stored internally and allow an external + * widget to configure it accordingly + */ +void QGCToolWidget::setViewVisibilityAndDockWidgetArea(int view, bool visible, Qt::DockWidgetArea area) +{ + viewVisible.insert(view, visible); + dockWidgetArea.insert(view, area); +} + void QGCToolWidget::createActions() { addParamAction = new QAction(tr("New &Parameter Slider"), this); diff --git a/src/ui/designer/QGCToolWidget.h b/src/ui/designer/QGCToolWidget.h index 918ccfa..b1a890d 100644 --- a/src/ui/designer/QGCToolWidget.h +++ b/src/ui/designer/QGCToolWidget.h @@ -29,6 +29,9 @@ public: /** @brief All instances of this class */ static QMap* instances(); + int isVisible(int view) { return viewVisible.value(view, false); } + Qt::DockWidgetArea getDockWidgetArea(int view) { return dockWidgetArea.value(view, Qt::BottomDockWidgetArea); } + public slots: void addUAS(UASInterface* uas); /** @brief Delete this widget */ @@ -39,6 +42,8 @@ public slots: void importWidget(const QString& fileName); /** @brief Store all widgets of this type to QSettings */ static void storeWidgetsToSettings(); + /** @brief Store the view id and dock widget area */ + void setViewVisibilityAndDockWidgetArea(int view, bool visible, Qt::DockWidgetArea area); signals: void titleChanged(QString); @@ -53,7 +58,9 @@ protected: QAction* importAction; QVBoxLayout* toolLayout; UAS* mav; - QAction* mainMenuAction; + QAction* mainMenuAction; ///< Main menu action + QMap dockWidgetArea; ///< Dock widget area desired by this widget + QMap viewVisible; ///< Visibility in one view void contextMenuEvent(QContextMenuEvent* event); void createActions(); @@ -62,6 +69,8 @@ protected: /** @brief Add an existing tool widget */ void addToolWidget(QGCToolWidgetItem* widget); + void hideEvent(QHideEvent* event); + protected slots: void addParam(); /** @deprecated */