diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index aa49c237bec3db07d2006122fc2a78be533b6bab..231e970ce2f8811f42ea392dea4a57fcc6d4efcb 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -144,6 +144,7 @@ src/FlightMap/Widgets/QGCPitchIndicator.qml src/FlightMap/QGCVideoBackground.qml src/FlightMap/qmldir + src/FlightMap/Widgets/CameraWidget.qml src/FlightMap/Widgets/ValuesWidget.qml src/FlightMap/Widgets/VehicleHealthWidget.qml src/FlightMap/MapItems/VehicleMapItem.qml diff --git a/src/FlightMap/Widgets/CameraWidget.qml b/src/FlightMap/Widgets/CameraWidget.qml new file mode 100644 index 0000000000000000000000000000000000000000..8e0ec95ce15a6ef7cfff29826b81e17cb4341eed --- /dev/null +++ b/src/FlightMap/Widgets/CameraWidget.qml @@ -0,0 +1,54 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.4 +import QtQuick.Layouts 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 + +/// Camera controls used in InstrumentSwipeView +QGCFlickable { + id: _root + height: Math.min(maxHeight, column.height) + contentHeight: column.height + flickableDirection: Flickable.VerticalFlick + clip: true + + property var qgcView + property color textColor + property var maxHeight + + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + + MouseArea { + anchors.fill: parent + onClicked: showNextPage() + } + + Column { + id: column + width: parent.width + spacing: ScreenTools.defaultFontPixelHeight + + QGCLabel { + anchors.horizontalCenter: parent.horizontalCenter + color: textColor + text: qsTr("Camera Controls") + } + + QGCButton { + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("Trigger Camera") + onClicked: _activeVehicle.triggerCamera() + enabled: _activeVehicle + } + } +} diff --git a/src/FlightMap/Widgets/InstrumentSwipeView.qml b/src/FlightMap/Widgets/InstrumentSwipeView.qml index 8a52ea4f80dd5bee002487035ebcd4ce73418b5d..22ec90583a3cf666723ca9ef51b12a0fc6b266f9 100644 --- a/src/FlightMap/Widgets/InstrumentSwipeView.qml +++ b/src/FlightMap/Widgets/InstrumentSwipeView.qml @@ -1,123 +1,101 @@ import QtQuick 2.5 -import QtQuick.Controls 1.4 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.3 import QGroundControl.Palette 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.FlightMap 1.0 Item { - id: _root - clip: true - height: valuesPage.height + pageIndicatorRow.anchors.topMargin + pageIndicatorRow.height + id: _root + clip: true + height: column.height - property var qgcView ///< QGCView to use for showing dialogs + property var qgcView ///< QGCView to use for showing dialogs property color textColor property color backgroundColor - property var maxHeight ///< Maximum height that should be taken, smaller than this is ok + property var maxHeight ///< Maximum height that should be taken, smaller than this is ok - property real _margins: ScreenTools.defaultFontPixelWidth / 2 - property real _pageWidth: _root.width - property int _currentPage: 0 - property int _maxPage: 2 + property real _margins: ScreenTools.defaultFontPixelWidth / 2 + property real _pageWidth: _root.width + property int _currentPage: 0 + property int _maxPage: 3 + + onWidthChanged: showPage(_currentPage) function showPicker() { valuesPage.showPicker() } function showPage(pageIndex) { - _root.height = Qt.binding(function() { return _root.children[pageIndex].height + pageIndicatorRow.anchors.topMargin + pageIndicatorRow.height } ) - _root.children[0].x = -(pageIndex * _pageWidth) - } - - ValuesWidget { - id: valuesPage - width: _pageWidth - qgcView: _root.qgcView - textColor: _root.textColor - maxHeight: _root.maxHeight - } - - VehicleHealthWidget { - id: healthPage - anchors.left: valuesPage.right - width: _pageWidth - qgcView: _root.qgcView - textColor: _root.textColor - maxHeight: _root.maxHeight + pageRow.x = -(pageIndex * _pageWidth) } - VibrationWidget { - id: vibrationPage - anchors.left: healthPage.right - width: _pageWidth - textColor: _root.textColor - backgroundColor: _root.backgroundColor - maxHeight: _root.maxHeight - } - - Row { - id: pageIndicatorRow - anchors.bottom: parent.bottom - anchors.horizontalCenter: parent.horizontalCenter - spacing: _margins - - Repeater { - model: _maxPage + 1 - - Rectangle { - height: radius * 2 - width: radius * 2 - radius: ScreenTools.defaultFontPixelWidth / 3 - border.color: textColor - border.width: 1 - color: _currentPage == index ? textColor : "transparent" - } + function showNextPage() { + if (_currentPage == _maxPage) { + _currentPage = 0 + } else { + _currentPage++ } + showPage(_currentPage) } MouseArea { - anchors.fill: parent - - onClicked: { - if (_currentPage == _maxPage) { - _currentPage = 0 - } else { - _currentPage++ - } - showPage(_currentPage) - } + anchors.fill: parent + onClicked: showNextPage() } - /* - Switching from swipe to click to change pages. Keeping swipe code for now in case of change back. - MouseArea { - anchors.fill: parent + Column { + id: column + anchors.left: parent.left + anchors.right: parent.right - property real xDragStart - property real xFirstPageSave + Row { + id: pageRow - onPressed: { - if (mouse.button == Qt.LeftButton) { - mouse.accepted = true - xDragStart = mouse.x - xFirstPageSave = _root.children[0].x + ValuesWidget { + id: valuesPage + width: _pageWidth + qgcView: _root.qgcView + textColor: _root.textColor + maxHeight: _root.maxHeight + } + CameraWidget { + width: _pageWidth + qgcView: _root.qgcView + textColor: _root.textColor + maxHeight: _root.maxHeight + } + VehicleHealthWidget { + width: _pageWidth + qgcView: _root.qgcView + textColor: _root.textColor + maxHeight: _root.maxHeight + } + VibrationWidget { + width: _pageWidth + textColor: _root.textColor + backgroundColor: _root.backgroundColor + maxHeight: _root.maxHeight } } - onPositionChanged: { - _root.children[0].x = xFirstPageSave + mouse.x - xDragStart - } - - onReleased: { - if (mouse.x < xDragStart) { - // Swipe left - _currentPage = Math.min(_currentPage + 1, _maxPage) - } else { - // Swipe right - _currentPage = Math.max(_currentPage - 1, 0) + Row { + anchors.horizontalCenter: parent.horizontalCenter + spacing: _margins + + Repeater { + model: _maxPage + 1 + + Rectangle { + height: radius * 2 + width: radius * 2 + radius: ScreenTools.defaultFontPixelWidth / 3 + border.color: textColor + border.width: 1 + color: _currentPage == index ? textColor : "transparent" + } } - showPage(_currentPage) } } - */ } diff --git a/src/FlightMap/Widgets/ValuesWidget.qml b/src/FlightMap/Widgets/ValuesWidget.qml index e4ba42bfeeac7877955bdb4d352c5deb1f38b347..62292194938a7151a7ad0e8fa0143727b54e2c1c 100644 --- a/src/FlightMap/Widgets/ValuesWidget.qml +++ b/src/FlightMap/Widgets/ValuesWidget.qml @@ -54,7 +54,7 @@ QGCFlickable { MouseArea { anchors.fill: parent - onClicked: showPicker() + onClicked: showNextPage() } Column { diff --git a/src/FlightMap/Widgets/VehicleHealthWidget.qml b/src/FlightMap/Widgets/VehicleHealthWidget.qml index 4b9b11663413cf10770b51afaee36bd384826254..b1c73ae9d00b5830070609428903275d20f11bfa 100644 --- a/src/FlightMap/Widgets/VehicleHealthWidget.qml +++ b/src/FlightMap/Widgets/VehicleHealthWidget.qml @@ -34,6 +34,11 @@ QGCFlickable { } } + MouseArea { + anchors.fill: parent + onClicked: showNextPage() + } + Column { id: healthColumn width: parent.width diff --git a/src/FlightMap/Widgets/VibrationWidget.qml b/src/FlightMap/Widgets/VibrationWidget.qml index e4ebade92fc7cad0e333e013d073495848e27451..0a7cb00875a909956d2c693b1c98b797a1a242ce 100644 --- a/src/FlightMap/Widgets/VibrationWidget.qml +++ b/src/FlightMap/Widgets/VibrationWidget.qml @@ -39,6 +39,11 @@ QGCFlickable { QGCPalette { id:qgcPal; colorGroupEnabled: true } + MouseArea { + anchors.fill: parent + onClicked: showNextPage() + } + Item { id: innerItem width: parent.width diff --git a/src/FlightMap/qmldir b/src/FlightMap/qmldir index 84cdd15c37a80593e0e4d740a7644492051f6948..8d6f8ededb2ef4047b93d5ec908e6b1f06bb2673 100644 --- a/src/FlightMap/qmldir +++ b/src/FlightMap/qmldir @@ -5,20 +5,21 @@ FlightMap 1.0 FlightMap.qml QGCVideoBackground 1.0 QGCVideoBackground.qml # Widgets -CenterMapDropButton 1.0 CenterMapDropButton.qml -CenterMapDropPanel 1.0 CenterMapDropPanel.qml -InstrumentSwipeView 1.0 InstrumentSwipeView.qml -MapFitFunctions 1.0 MapFitFunctions.qml -MapScale 1.0 MapScale.qml -QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml -QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml -QGCAttitudeWidget 1.0 QGCAttitudeWidget.qml -QGCCompassWidget 1.0 QGCCompassWidget.qml -QGCPitchIndicator 1.0 QGCPitchIndicator.qml -QGCSlider 1.0 QGCSlider.qml -ValuesWidget 1.0 ValuesWidget.qml -VehicleHealthWidget 1.0 VehicleHealthWidget.qml -VibrationWidget 1.0 VibrationWidget.qml +CameraWidget 1.0 CameraWidget.qml +CenterMapDropButton 1.0 CenterMapDropButton.qml +CenterMapDropPanel 1.0 CenterMapDropPanel.qml +InstrumentSwipeView 1.0 InstrumentSwipeView.qml +MapFitFunctions 1.0 MapFitFunctions.qml +MapScale 1.0 MapScale.qml +QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml +QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml +QGCAttitudeWidget 1.0 QGCAttitudeWidget.qml +QGCCompassWidget 1.0 QGCCompassWidget.qml +QGCPitchIndicator 1.0 QGCPitchIndicator.qml +QGCSlider 1.0 QGCSlider.qml +ValuesWidget 1.0 ValuesWidget.qml +VehicleHealthWidget 1.0 VehicleHealthWidget.qml +VibrationWidget 1.0 VibrationWidget.qml # Map items MissionItemIndicator 1.0 MissionItemIndicator.qml diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index cec74fee1d7f09f98795b42b6182df054c29eb58..c2d265162d51c8fe19118b774976daef3afcb056 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -2241,6 +2241,15 @@ void Vehicle::setOfflineEditingDefaultComponentId(int defaultComponentId) } } +void Vehicle::triggerCamera(void) +{ + sendMavCommand(FactSystem::defaultComponentId, + MAV_CMD_DO_DIGICAM_CONTROL, + true, // show errors + 0.0, 0.0, 0.0, 0.0, // param 1-4 unused + 1.0); // trigger camera +} + const char* VehicleGPSFactGroup::_hdopFactName = "hdop"; const char* VehicleGPSFactGroup::_vdopFactName = "vdop"; const char* VehicleGPSFactGroup::_courseOverGroundFactName = "courseOverGround"; diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index d8f774d6abb74133a01ca22d784707ab79bf733d..4c6c16dcbb567333ad370df0edeebf8b353b9599 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -409,6 +409,8 @@ public: /// Clear Messages Q_INVOKABLE void clearMessages(); + Q_INVOKABLE void triggerCamera(void); + #if 0 // Temporarily removed, waiting for new command implementation /// Test motor