Commit 207270a5 authored by Don Gagne's avatar Don Gagne
Browse files

Merge pull request #1455 from DonLakeFlyer/ViewWidgets

Qml based dock widget support
parents 3df5bb48 23aab118
......@@ -147,7 +147,6 @@ INCLUDEPATH += \
src/input \
src/lib/qmapcontrol \
src/ui/mavlink \
src/ui/param \
src/ui/map3D \
src/ui/mission \
src/ui/designer \
......@@ -159,7 +158,8 @@ INCLUDEPATH += \
src/ui/mapdisplay \
src/VehicleSetup \
src/AutoPilotPlugins \
src/QmlControls
src/QmlControls \
src/ViewWidgets
FORMS += \
src/ui/MainWindow.ui \
......@@ -169,13 +169,11 @@ FORMS += \
src/ui/UASInfo.ui \
src/ui/Linechart.ui \
src/ui/UASView.ui \
src/ui/ParameterInterface.ui \
src/ui/WaypointList.ui \
src/ui/JoystickWidget.ui \
src/ui/DebugConsole.ui \
src/ui/HDDisplay.ui \
src/ui/MAVLinkSettingsWidget.ui \
src/ui/QGCSensorSettingsWidget.ui \
src/ui/QGCDataPlot2D.ui \
src/ui/QMap3D.ui \
src/ui/uas/QGCUnconnectedInfoWidget.ui \
......@@ -263,7 +261,7 @@ HEADERS += \
src/comm/MAVLinkSimulationLink.h \
src/comm/UDPLink.h \
src/comm/TCPLink.h \
src/ui/ParameterInterface.h \
src/ViewWidgets/ParameterEditorWidget.h \
src/ui/WaypointList.h \
src/Waypoint.h \
src/input/JoystickInput.h \
......@@ -273,8 +271,6 @@ HEADERS += \
src/ui/MAVLinkSettingsWidget.h \
src/GAudioOutput.h \
src/LogCompressor.h \
src/ui/QGCParamWidget.h \
src/ui/QGCSensorSettingsWidget.h \
src/ui/linechart/Linecharts.h \
src/uas/UASWaypointManager.h \
src/ui/HSIDisplay.h \
......@@ -352,8 +348,6 @@ HEADERS += \
src/ui/configuration/ApmHighlighter.h \
src/uas/UASParameterDataModel.h \
src/uas/UASParameterCommsMgr.h \
src/ui/QGCPendingParamWidget.h \
src/ui/QGCBaseParamWidget.h \
src/ui/px4_configuration/PX4RCCalibration.h \
src/ui/px4_configuration/RCValueWidget.h \
src/uas/UASManagerInterface.h \
......@@ -369,7 +363,6 @@ HEADERS += \
src/QGCQuickWidget.h \
src/QGCPalette.h \
src/QGCQmlWidgetHolder.h \
src/ui/QGCParamTreeWidget.h \
src/ui/QGCMapRCToParamDialog.h \
src/QGCDockWidget.h \
src/ui/QGCLinkConfiguration.h \
......@@ -379,9 +372,11 @@ HEADERS += \
src/uas/UASMessageHandler.h \
src/ui/toolbar/MainToolBar.h \
src/QmlControls/ScreenTools.h \
src/QmlControls/ParameterEditorController.h \
src/QGCLoggingCategory.h \
src/ui/flightdisplay/QGCFlightDisplay.h \
src/ui/mapdisplay/QGCMapDisplay.h
src/ui/mapdisplay/QGCMapDisplay.h \
src/ViewWidgets/ViewWidgetController.h \
SOURCES += \
src/main.cc \
......@@ -410,7 +405,7 @@ SOURCES += \
src/comm/MAVLinkSimulationLink.cc \
src/comm/UDPLink.cc \
src/comm/TCPLink.cc \
src/ui/ParameterInterface.cc \
src/ViewWidgets/ParameterEditorWidget.cc \
src/ui/WaypointList.cc \
src/Waypoint.cc \
src/input/JoystickInput.cc \
......@@ -420,8 +415,6 @@ SOURCES += \
src/ui/MAVLinkSettingsWidget.cc \
src/GAudioOutput.cc \
src/LogCompressor.cc \
src/ui/QGCParamWidget.cc \
src/ui/QGCSensorSettingsWidget.cc \
src/ui/linechart/Linecharts.cc \
src/uas/UASWaypointManager.cc \
src/ui/HSIDisplay.cc \
......@@ -496,8 +489,6 @@ SOURCES += \
src/ui/configuration/ApmHighlighter.cc \
src/uas/UASParameterDataModel.cc \
src/uas/UASParameterCommsMgr.cc \
src/ui/QGCPendingParamWidget.cc \
src/ui/QGCBaseParamWidget.cc \
src/ui/px4_configuration/PX4RCCalibration.cc \
src/ui/px4_configuration/RCValueWidget.cc \
src/uas/QGCUASFileManager.cc \
......@@ -510,7 +501,6 @@ SOURCES += \
src/QGCQuickWidget.cc \
src/QGCPalette.cc \
src/QGCQmlWidgetHolder.cpp \
src/ui/QGCParamTreeWidget.cpp \
src/ui/QGCMapRCToParamDialog.cpp \
src/QGCDockWidget.cc \
src/ui/QGCLinkConfiguration.cc \
......@@ -520,9 +510,11 @@ SOURCES += \
src/uas/UASMessageHandler.cc \
src/ui/toolbar/MainToolBar.cc \
src/QmlControls/ScreenTools.cc \
src/QmlControls/ParameterEditorController.cc \
src/QGCLoggingCategory.cc \
src/ui/flightdisplay/QGCFlightDisplay.cc \
src/ui/mapdisplay/QGCMapDisplay.cc
src/ui/mapdisplay/QGCMapDisplay.cc \
src/ViewWidgets/ViewWidgetController.cc \
#
# Unit Test specific configuration goes here
......@@ -605,7 +597,6 @@ HEADERS+= \
src/VehicleSetup/SetupView.h \
src/VehicleSetup/VehicleComponent.h \
src/VehicleSetup/FirmwareUpgradeController.h \
src/VehicleSetup/ParameterEditorController.h \
src/VehicleSetup/PX4Bootloader.h \
src/VehicleSetup/PX4FirmwareUpgradeThread.h \
src/AutoPilotPlugins/AutoPilotPluginManager.h \
......@@ -630,7 +621,6 @@ SOURCES += \
src/VehicleSetup/SetupView.cc \
src/VehicleSetup/VehicleComponent.cc \
src/VehicleSetup/FirmwareUpgradeController.cc \
src/VehicleSetup/ParameterEditorController.cc \
src/VehicleSetup/PX4Bootloader.cc \
src/VehicleSetup/PX4FirmwareUpgradeThread.cc \
src/AutoPilotPlugins/AutoPilotPluginManager.cc \
......
......@@ -29,13 +29,17 @@
<file alias="QGroundControl/Controls/VehicleRotationCal.qml">src/QmlControls/VehicleRotationCal.qml</file>
<file alias="QGroundControl/Controls/VehicleSummaryRow.qml">src/QmlControls/VehicleSummaryRow.qml</file>
<file alias="QGroundControl/Controls/arrow-down.png">src/QmlControls/arrow-down.png</file>
<file alias="QGroundControl/Controls/ViewWidget.qml">src/ViewWidgets/ViewWidget.qml</file>
<file alias="QGroundControl/Controls/ParameterEditor.qml">src/QmlControls/ParameterEditor.qml</file>
<file alias="ParameterEditorWidget.qml">src/ViewWidgets/ParameterEditorWidget.qml</file>
<file alias="SetupViewButtonsConnected.qml">src/VehicleSetup/SetupViewButtonsConnected.qml</file>
<file alias="SetupViewButtonsDisconnected.qml">src/VehicleSetup/SetupViewButtonsDisconnected.qml</file>
<file alias="VehicleSummary.qml">src/VehicleSetup/VehicleSummary.qml</file>
<file alias="FirmwareUpgrade.qml">src/VehicleSetup/FirmwareUpgrade.qml</file>
<file alias="ParameterEditor.qml">src/VehicleSetup/ParameterEditor.qml</file>
<file alias="SetupParameterEditor.qml">src/VehicleSetup/SetupParameterEditor.qml</file>
<file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file>
<file alias="PowerComponent.qml">src/AutoPilotPlugins/PX4/PowerComponent.qml</file>
<file alias="SensorsComponent.qml">src/AutoPilotPlugins/PX4/SensorsComponent.qml</file>
......
......@@ -33,6 +33,14 @@ AutoPilotPlugin::AutoPilotPlugin(UASInterface* uas, QObject* parent) :
_pluginReady(false)
{
Q_ASSERT(_uas);
connect(_uas, &UASInterface::disconnected, this, &AutoPilotPlugin::_uasDisconnected);
}
void AutoPilotPlugin::_uasDisconnected(void)
{
_pluginReady = false;
emit pluginReadyChanged(_pluginReady);
}
void AutoPilotPlugin::refreshAllParameters(void)
......
......@@ -51,8 +51,9 @@ class AutoPilotPlugin : public QObject
public:
AutoPilotPlugin(UASInterface* uas, QObject* parent);
Q_PROPERTY(bool pluginReady READ pluginReady NOTIFY pluginReadyChanged)
/// true: plugin is ready for use, plugin should no longer be used
Q_PROPERTY(bool pluginReady READ pluginReady NOTIFY pluginReadyChanged)
/// List of VehicleComponent objects
Q_PROPERTY(QVariantList vehicleComponents READ vehicleComponents CONSTANT)
......@@ -100,17 +101,15 @@ public:
// Must be implemented by derived class
virtual const QVariantList& vehicleComponents(void) = 0;
/// FIXME: Kind of hacky
static void clearStaticData(void);
bool pluginReady(void) { return _pluginReady; }
UASInterface* uas(void) { return _uas; }
bool pluginReady(void) { return _pluginReady; }
signals:
/// Signalled when plugin is ready for use
void pluginReadyChanged(bool pluginReady);
protected:
/// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
AutoPilotPlugin(QObject* parent = NULL) : QObject(parent) { }
......@@ -120,6 +119,9 @@ protected:
UASInterface* _uas;
bool _pluginReady;
private slots:
void _uasDisconnected(void);
};
#endif
......@@ -61,6 +61,8 @@
#include "QGCPalette.h"
#include "ScreenTools.h"
#include "QGCLoggingCategory.h"
#include "ViewWidgetController.h"
#include "ParameterEditorController.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
......@@ -262,6 +264,8 @@ void QGCApplication::_initCommon(void)
// Register our Qml objects
qmlRegisterType<QGCPalette>("QGroundControl.Palette", 1, 0, "QGCPalette");
qmlRegisterType<ScreenTools>("QGroundControl.ScreenTools", 1, 0, "ScreenTools");
qmlRegisterType<ViewWidgetController>("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<ParameterEditorController>("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
}
bool QGCApplication::_initForNormalAppBoot(void)
......
......@@ -12,7 +12,7 @@
// If you need to make an incompatible changes to stored settings, bump this version number
// up by 1. This will caused store settings to be cleared on next boot.
#define QGC_SETTINGS_VERSION 4
#define QGC_SETTINGS_VERSION 5
#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_ORG_NAME "QGroundControl.org"
......
......@@ -25,15 +25,23 @@
#include <QCloseEvent>
QGCDockWidget::QGCDockWidget(const QString& title, QWidget *parent, Qt::WindowFlags flags) :
QDockWidget(title, parent, flags)
QGCDockWidget::QGCDockWidget(const QString& title, QAction* action, QWidget *parent, Qt::WindowFlags flags) :
QDockWidget(title, parent, flags),
_action(action)
{
QDockWidget::DockWidgetFeatures features = QDockWidget::DockWidgetMovable;
if (action) {
features |= QDockWidget::DockWidgetClosable;
}
setFeatures(features);
}
// Instead of destroying the widget just hide it
void QGCDockWidget::closeEvent(QCloseEvent* event)
{
Q_ASSERT(_action);
event->ignore();
setVisible(false);
_action->trigger();
}
......@@ -25,6 +25,7 @@
#define QGCDockWidget_h
#include <QDockWidget>
#include <QAction>
/// @file
/// @brief Subclass of QDockWidget so we can intercept the closeEvent.
......@@ -35,9 +36,12 @@ class QGCDockWidget : public QDockWidget {
Q_OBJECT
public:
QGCDockWidget(const QString& title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
QGCDockWidget(const QString& title, QAction* action, QWidget *parent = 0, Qt::WindowFlags flags = 0);
void closeEvent(QCloseEvent* event);
private:
QAction* _action;
};
......
......@@ -21,6 +21,9 @@
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
......@@ -33,61 +36,51 @@ import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Rectangle {
QGCPalette { id: qgcPal; colorGroupEnabled: true }
ScreenTools { id: screenTools }
ParameterEditorController { id: controller }
QGCLabel { id: charWidth; text: "X"; visible: false }
/// true: show full information, false: for use in smaller widgets
property bool fullMode: true
QGCPalette { id: __qgcPal; colorGroupEnabled: true }
ScreenTools { id: __screenTools }
ParameterEditorController { id: __controller }
QGCLabel { id: __charWidth; text: "X"; visible: false }
readonly property real leftMargin: 10
readonly property real rightMargin: 20
readonly property int maxParamChars: 16
readonly property real __leftMargin: 10
readonly property real __rightMargin: 20
readonly property int __maxParamChars: 16
color: qgcPal.window
color: __qgcPal.window
// We use an ExclusiveGroup to maintain the visibility of a single editing control at a time
ExclusiveGroup {
id: exclusiveEditorGroup
id: __exclusiveEditorGroup
}
Column {
anchors.fill:parent
QGCLabel {
text: "PARAMETER EDITOR"
font.pointSize: screenTools.dpiAdjustedPointSize(20)
}
Item {
height: 20
width: 5
}
Row {
spacing: 10
layoutDirection: Qt.RightToLeft
width: parent.width
QGCButton {
text: "Clear RC to Param"
onClicked: controller.clearRCToParam()
text: "Clear RC to Param"
onClicked: __controller.clearRCToParam()
}
QGCButton {
text: "Save to file"
onClicked: controller.saveToFile()
text: "Save to file"
visible: fullMode
onClicked: __controller.saveToFile()
}
QGCButton {
text: "Load from file"
onClicked: controller.loadFromFile()
text: "Load from file"
visible: fullMode
onClicked: __controller.loadFromFile()
}
QGCButton {
id: firstButton
text: "Refresh"
onClicked: controller.refresh()
}
QGCLabel {
width: firstButton.x - parent.spacing
wrapMode: Text.WordWrap
text: "Click a parameter value to modify. Right-click to set an RC to Param mapping. Use caution when modifying parameters here since the values are not checked for validity."
id: firstButton
text: "Refresh"
onClicked: __controller.refresh()
}
}
......@@ -104,7 +97,7 @@ Rectangle {
Column {
Repeater {
model: controller.componentIds
model: __controller.componentIds
Column {
id: componentColumn
......@@ -113,7 +106,7 @@ Rectangle {
QGCLabel {
text: "Component #: " + componentId.toString()
font.pointSize: screenTools.dpiAdjustedPointSize(qgcPal.defaultFontPointSize + 4);
font.pointSize: __screenTools.dpiAdjustedPointSize(__qgcPal.defaultFontPointSize + 4);
}
Item {
......@@ -122,51 +115,51 @@ Rectangle {
}
Repeater {
model: controller.getGroupsForComponent(componentColumn.componentId)
model: __controller.getGroupsForComponent(componentColumn.componentId)
Column {
Rectangle {
id: groupRect
color: qgcPal.windowShade
color: __qgcPal.windowShade
height: groupBlock.height
width: scrollView.viewport.width - rightMargin
width: scrollView.viewport.width - __rightMargin
Column {
id: groupBlock
Rectangle {
color: qgcPal.windowShadeDark
color: __qgcPal.windowShadeDark
height: groupLabel.height
width: groupRect.width
QGCLabel {
id: groupLabel
height: contentHeight + 5
x: leftMargin
x: __leftMargin
text: modelData
verticalAlignment: Text.AlignVCenter
font.pointSize: screenTools.dpiAdjustedPointSize(qgcPal.defaultFontPointSize + 2);
font.pointSize: __screenTools.dpiAdjustedPointSize(__qgcPal.defaultFontPointSize + 2);
}
}
Repeater {
model: controller.getFactsForGroup(componentColumn.componentId, modelData)
model: __controller.getFactsForGroup(componentColumn.componentId, modelData)
Row {
spacing: 10
x: leftMargin
x: __leftMargin
Fact { id: modelFact; name: modelData + ":" + componentColumn.componentId }
QGCLabel {
text: modelFact.name
width: charWidth.contentWidth * (maxParamChars + 2)
width: __charWidth.contentWidth * (__maxParamChars + 2)
}
QGCLabel {
text: modelFact.valueString + " " + modelFact.units
width: charWidth.contentWidth * 20
width: __charWidth.contentWidth * 20
height: contentHeight
MouseArea {
......@@ -178,7 +171,7 @@ Rectangle {
editor.checked = true
editor.focus = true
} else if (mouse.button == Qt.RightButton) {
controller.setRCToParam(modelData)
__controller.setRCToParam(modelData)
}
}
}
......@@ -195,7 +188,7 @@ Rectangle {
// We use an ExclusiveGroup to manage visibility
property bool checked: false
property ExclusiveGroup exclusiveGroup: exclusiveEditorGroup
property ExclusiveGroup exclusiveGroup: __exclusiveEditorGroup
onExclusiveGroupChanged: {
if (exclusiveGroup)
exclusiveGroup.bindCheckable(editor)
......@@ -205,6 +198,7 @@ Rectangle {
QGCLabel {
text: modelFact.shortDescription
visible: fullMode
}
} // Row - Fact value
} // Repeater - Facts
......
......@@ -13,4 +13,6 @@ SubMenuButton 1.0 SubMenuButton.qml
IndicatorButton 1.0 IndicatorButton.qml
VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml
ParameterEditor 1.0 ParameterEditor.qml
ViewWidget 1.0 ViewWidget.qml
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
import QtQuick 2.3
import QtQuick.Controls 1.2
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
Rectangle {
QGCPalette { id: qgcPal; colorGroupEnabled: true }
ScreenTools { id: screenTools }
color: qgcPal.window
// We use an ExclusiveGroup to maintain the visibility of a single editing control at a time
ExclusiveGroup {
id: exclusiveEditorGroup
}
Column {
anchors.fill:parent
QGCLabel {
text: "PARAMETER EDITOR"
font.pointSize: screenTools.dpiAdjustedPointSize(20)
}
Item {
height: 20
width: 5
}
QGCLabel {
id: infoLabel
width: parent.width
wrapMode: Text.WordWrap
text: "Click a parameter value to modify. Right-click to set an RC to Param mapping. Use caution when modifying parameters here since the values are not checked for validity."
}
ParameterEditor {
width: parent.width
height: parent.height - (infoLabel.y + infoLabel.height)
}
}
}
......@@ -55,7 +55,6 @@ SetupView::SetupView(QWidget* parent) :
Q_ASSERT(fSucceeded);
qmlRegisterType<FirmwareUpgradeController>("QGroundControl.Controllers", 1, 0, "FirmwareUpgradeController");
qmlRegisterType<ParameterEditorController>("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
_ui->buttonHolder->rootContext()->setContextProperty("controller", this);
_ui->buttonHolder->setAutoPilot(NULL);
......@@ -137,7 +136,7 @@ void SetupView::parametersButtonClicked(void)
Q_ASSERT(_autoPilotPlugin);
setup->setAutoPilot(_autoPilotPlugin);
setup->setSource(QUrl::fromUserInput("qrc:/qml/ParameterEditor.qml"));
setup->setSource(QUrl::fromUserInput("qrc:/qml/SetupParameterEditor.qml"));
_changeSetupWidget(setup);
}
......
......@@ -23,49 +23,15 @@ This file is part of the QGROUNDCONTROL project
/**
* @file
* @brief Definition of class ParameterInterface
*
* @brief Definition of class ParameterEditorWidget
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef PARAMETERINTERFACE_H
#define PARAMETERINTERFACE_H
#include <QWidget>
#include "ui_ParameterInterface.h"
#include "UASInterface.h"
#include "QGCParamWidget.h"
#include "ParameterEditorWidget.h"
namespace Ui
ParameterEditorWidget::ParameterEditorWidget(QWidget *parent) :
QGCQmlWidgetHolder(parent)
{
class ParameterInterface;
setSource(QUrl::fromUserInput("qrc:/qml/ParameterEditorWidget.qml"));
}
/**
* @brief Container class for onboard parameter widgets
*
* @see QGCParamWidget
*/
class ParameterInterface : public QWidget
{
Q_OBJECT
public:
explicit ParameterInterface(QWidget *parent = 0);
virtual ~ParameterInterface();
public slots:
void addUAS(UASInterface* uas);
void selectUAS(int index);
protected:
virtual void changeEvent(QEvent *e);
QMap<int, QGCParamWidget*>* paramWidgets;
int curr;
private:
Ui::parameterWidget *m_ui;
};
#endif // PARAMETERINTERFACE_H
......@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
......@@ -21,65 +21,20 @@ This file is part of the QGROUNDCONTROL project
======================================================================*/
/**
* @file
* @brief Declaration of class QGCSensorSettingsWidget
* @author Lorenz Meier <mail@qgroundcontrol.org>
*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
#ifndef QGCSENSORSETTINGSWIDGET_H
#define QGCSENSORSETTINGSWIDGET_H
#ifndef PARAMETEREDITORWIDGET_H
#define PARAMETEREDITORWIDGET_H
#include <QWidget>
#include "QGCQmlWidgetHolder.h"
#include "UASInterface.h"
namespace Ui
{
class QGCSensorSettingsWidget;
}
class QGCSensorSettingsWidget : public QWidget
class ParameterEditorWidget : public QGCQmlWidgetHolder
{
Q_OBJECT
public:
QGCSensorSettingsWidget(UASInterface* uas, QWidget *parent = 0);
~QGCSensorSettingsWidget();
public slots:
void delayedSendRawSensor(int rate);
void delayedSendController(int rate);
void delayedSendExtended(int rate);
void delayedSendRC(int rate);
void delayedSendPosition(int rate);
void delayedSendExtra1(int rate);
void delayedSendExtra2(int rate);
void delayedSendExtra3(int rate);
protected:
UASInterface* mav;
QTimer delayedSendRawSensorTimer;
QTimer delayedSendControllerTimer;
QTimer delayedSendExtendedTimer;
QTimer delayedSendRCTimer;
QTimer delayedSendPositionTimer;
QTimer delayedSendExtra1Timer;
QTimer delayedSendExtra2Timer;
QTimer delayedSendExtra3Timer;
void changeEvent(QEvent *e);
protected slots:
void sendRawSensor();
void sendController();
void sendExtended();
void sendRC();
void sendPosition();
void sendExtra1();
void sendExtra2();
void sendExtra3();
private:
Ui::QGCSensorSettingsWidget *ui;
ParameterEditorWidget(QWidget *parent = 0);
};
#endif // QGCSENSORSETTINGSWIDGET_H
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Don Gagne <don@thegagnes.com>
import QtQuick 2.2
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
ViewWidget {
connectedComponent: editorComponent
Component {
id: editorComponent
ParameterEditor {
fullMode: false
}
}
}
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QGroundControl.Palette 1.0
import QGroundControl.Controllers 1.0
Rectangle {
property Component connectedComponent: __componentConnected
property Component disconnectedComponent: __componentDisconnected
QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
ViewWidgetController { id: __controller }
color: __qgcPal.window
Component.onCompleted: __controller.checkForVehicle()
Connections {
target: __controller
onPluginConnected: {
pageLoader.autopilot = autopilot
pageLoader.sourceComponent = connectedComponent
}
onPluginDisconnected: {
pageLoader.sourceComponent = disconnectedComponent
pageLoader.autopilot = {}
}
}
Loader {
id: pageLoader
anchors.fill: parent
property var autopilot
sourceComponent: __componentDisconnected
}
Component {
id: __componentConnected
Rectangle {
QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
anchors.fill: parent
color: __qgcPal.window
QGCLabel {
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: "missing connected implementation"
}
}
}
Component {
id: __componentDisconnected
Rectangle {
QGCPalette { id: __qgcPal; colorGroupEnabled: enabled }
anchors.fill: parent
color: __qgcPal.window
QGCLabel {
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: "no vehicle connected"
}
}
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @author Thomas Gubler <thomasgubler@gmail.com>
#include "ViewWidgetController.h"
#include "UASManager.h"
#include "AutoPilotPluginManager.h"
#include "QGCParamTreeWidget.h"
#include <QMenu>
#include <QTreeWidgetItem>
#include <QDebug>
QGCParamTreeWidget::QGCParamTreeWidget(QWidget *parent) :
QTreeWidget(parent)
ViewWidgetController::ViewWidgetController(void) :
_autopilot(NULL),
_uas(NULL)
{
setContextMenuPolicy(Qt::CustomContextMenu);
QObject::connect(this, &QGCParamTreeWidget::customContextMenuRequested,
this, &QGCParamTreeWidget::showContextMenu);
qDebug() << "create QGCParamTreeWidget";
_uasManager = UASManager::instance();
Q_ASSERT(_uasManager);
connect(_uasManager, &UASManagerInterface::activeUASSet, this, &ViewWidgetController::_activeUasChanged);
}
QGCParamTreeWidget::~QGCParamTreeWidget()
void ViewWidgetController::_activeUasChanged(UASInterface* currentUas)
{
if (currentUas != _uas) {
if (_uas) {
disconnect(_autopilot, &AutoPilotPlugin::pluginReadyChanged, this, &ViewWidgetController::_pluginReadyChanged);
_uas = NULL;
_autopilot = NULL;
emit pluginDisconnected();
}
if (currentUas) {
_uas = currentUas;
_autopilot = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(currentUas);
Q_ASSERT(_autopilot);
connect(_autopilot, &AutoPilotPlugin::pluginReadyChanged, this, &ViewWidgetController::_pluginReadyChanged);
if (_autopilot->pluginReady()) {
_pluginReadyChanged(true);
}
}
}
}
void QGCParamTreeWidget::showContextMenu(const QPoint &pos)
void ViewWidgetController::_pluginReadyChanged(bool pluginReady)
{
QMenu menu;
QTreeWidgetItem* item = itemAt(pos);
// Only show context menu for parameter items and not for group items
// (show for TEST_P but not for TEST)
// If a context menu is needed later for the groups then move this 'if'
// to below where the actions are created and filter out certain actions
// for the outer nodes
if (indexOfTopLevelItem(item) > -1 ||
indexOfTopLevelItem(item->parent()) > -1) {
return;
}
QString param_id = item->data(0, Qt::DisplayRole).toString();
// Refresh single parameter
QAction* act = new QAction(tr("Refresh this param"), this);
act->setProperty("action", "refresh");
act->setProperty("param_id", param_id);
connect(act, &QAction::triggered, this,
&QGCParamTreeWidget::contextMenuAction);
menu.addAction(act);
// RC to parameter mapping
act = new QAction(tr("Map Parameter to RC"), this);
act->setProperty("action", "maprc");
act->setProperty("param_id", param_id);
connect(act, &QAction::triggered, this,
&QGCParamTreeWidget::contextMenuAction);
menu.addAction(act);
menu.exec(mapToGlobal(pos));
Q_ASSERT(_autopilot);
if (pluginReady) {
emit pluginConnected(QVariant::fromValue(_autopilot));
} else {
_activeUasChanged(NULL);
}
}
void QGCParamTreeWidget::contextMenuAction() {
QString action = qobject_cast<QAction*>(
sender())->property("action").toString();
QString param_id = qobject_cast<QAction*>(
sender())->property("param_id").toString();
if (action == "refresh") {
emit refreshParamRequest(param_id);
} else if (action == "maprc") {
emit mapRCToParamRequest(param_id);
} else {
qDebug() << "Undefined context menu action";
}
Q_INVOKABLE void ViewWidgetController::checkForVehicle(void)
{
_activeUasChanged(_uasManager->getActiveUAS());
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
/// @brief A treeview with context menus for parameters
/// @author Thomas Gubler <thomasgubler@gmail.com>
#ifndef VIEWWIDGETCONTROLLER_H
#define VIEWWIDGETCONTROLLER_H
#ifndef QGCPARAMTREEWIDGET_H
#define QGCPARAMTREEWIDGET_H
#include <QObject>
#include <QTreeWidget>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "UASManagerInterface.h"
/// Implements individual context menus for the QTreeWidgetItems
class QGCParamTreeWidget : public QTreeWidget
class ViewWidgetController : public QObject
{
Q_OBJECT
Q_OBJECT
public:
QGCParamTreeWidget(QWidget *parent = 0);
~QGCParamTreeWidget();
ViewWidgetController(void);
Q_INVOKABLE void checkForVehicle(void);
signals:
void mapRCToParamRequest(QString param_id);
void refreshParamRequest(QString param_id);
public slots:
void showContextMenu(const QPoint &pos);
void contextMenuAction();
void pluginConnected(QVariant autopilot);
void pluginDisconnected(void);
private slots:
void _activeUasChanged(UASInterface* UAS);
void _pluginReadyChanged(bool pluginReady);
private:
AutoPilotPlugin* _autopilot;
UASManagerInterface* _uasManager;
UASInterface* _uas;
};
#endif // QGCPARAMTREEWIDGET_H
#endif
\ No newline at end of file
Supports Markdown
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