Commit d3676e36 authored by Gus Grubba's avatar Gus Grubba

Video camera widget only available when using manual video streaming configuration.

parent 4d55d0c5
...@@ -390,9 +390,52 @@ Column { ...@@ -390,9 +390,52 @@ Column {
} }
} }
//------------------------------------------- //-------------------------------------------
// Grid Lines
Row {
visible: _camera && _camera.autoStream
spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: qsTr("Grid Lines")
width: _labelFieldWidth
anchors.verticalCenter: parent.verticalCenter
}
QGCSwitch {
enabled: _streamingEnabled && activeVehicle
checked: QGroundControl.settingsManager.videoSettings.gridLines.rawValue
width: _editFieldWidth
anchors.verticalCenter: parent.verticalCenter
onClicked: {
if(checked) {
QGroundControl.settingsManager.videoSettings.gridLines.rawValue = 1
} else {
QGroundControl.settingsManager.videoSettings.gridLines.rawValue = 0
}
}
}
}
//-------------------------------------------
//-- Video Fit
Row {
visible: _camera && _camera.autoStream
spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
QGCLabel {
text: qsTr("Video Screen Fit")
width: _labelFieldWidth
anchors.verticalCenter: parent.verticalCenter
}
FactComboBox {
fact: QGroundControl.settingsManager.videoSettings.videoFit
indexModel: false
width: _editFieldWidth
anchors.verticalCenter: parent.verticalCenter
}
}
//-------------------------------------------
//-- Reset Camera //-- Reset Camera
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
QGCLabel { QGCLabel {
text: qsTr("Reset Camera Defaults") text: qsTr("Reset Camera Defaults")
......
...@@ -35,6 +35,10 @@ Item { ...@@ -35,6 +35,10 @@ Item {
property bool _recordingVideo: _videoReceiver && _videoReceiver.recording property bool _recordingVideo: _videoReceiver && _videoReceiver.recording
property bool _videoRunning: _videoReceiver && _videoReceiver.videoRunning property bool _videoRunning: _videoReceiver && _videoReceiver.videoRunning
property bool _streamingEnabled: QGroundControl.settingsManager.videoSettings.streamConfigured property bool _streamingEnabled: QGroundControl.settingsManager.videoSettings.streamConfigured
property var _dynamicCameras: activeVehicle ? activeVehicle.dynamicCameras : null
property int _curCameraIndex: _dynamicCameras ? _dynamicCameras.currentCamera : 0
property bool _isCamera: _dynamicCameras ? _dynamicCameras.cameras.count > 0 : false
property var _camera: _isCamera ? (_dynamicCameras.cameras.get(_curCameraIndex) && _dynamicCameras.cameras.get(_curCameraIndex).paramComplete ? _dynamicCameras.cameras.get(_curCameraIndex) : null) : null
QGCPalette { id:qgcPal; colorGroupEnabled: true } QGCPalette { id:qgcPal; colorGroupEnabled: true }
...@@ -55,9 +59,11 @@ Item { ...@@ -55,9 +59,11 @@ Item {
QGCLabel { QGCLabel {
text: qsTr("Enable Stream") text: qsTr("Enable Stream")
font.pointSize: ScreenTools.smallFontPointSize font.pointSize: ScreenTools.smallFontPointSize
visible: !_camera || !_camera.autoStream
} }
QGCSwitch { QGCSwitch {
id: enableSwitch id: enableSwitch
visible: !_camera || !_camera.autoStream
enabled: _streamingEnabled enabled: _streamingEnabled
checked: QGroundControl.settingsManager.videoSettings.streamEnabled.rawValue checked: QGroundControl.settingsManager.videoSettings.streamEnabled.rawValue
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
...@@ -93,10 +99,12 @@ Item { ...@@ -93,10 +99,12 @@ Item {
//-- Video Fit //-- Video Fit
QGCLabel { QGCLabel {
text: qsTr("Video Screen Fit") text: qsTr("Video Screen Fit")
visible: !_camera || !_camera.autoStream
font.pointSize: ScreenTools.smallFontPointSize font.pointSize: ScreenTools.smallFontPointSize
} }
FactComboBox { FactComboBox {
fact: QGroundControl.settingsManager.videoSettings.videoFit fact: QGroundControl.settingsManager.videoSettings.videoFit
visible: !_camera || !_camera.autoStream
indexModel: false indexModel: false
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
...@@ -104,7 +112,7 @@ Item { ...@@ -104,7 +112,7 @@ Item {
QGCLabel { QGCLabel {
text: _recordingVideo ? qsTr("Stop Recording") : qsTr("Record Stream") text: _recordingVideo ? qsTr("Stop Recording") : qsTr("Record Stream")
font.pointSize: ScreenTools.smallFontPointSize font.pointSize: ScreenTools.smallFontPointSize
visible: QGroundControl.settingsManager.videoSettings.showRecControl.rawValue visible: (!_camera || !_camera.autoStream) && QGroundControl.settingsManager.videoSettings.showRecControl.rawValue
} }
// Button to start/stop video recording // Button to start/stop video recording
Item { Item {
...@@ -112,7 +120,7 @@ Item { ...@@ -112,7 +120,7 @@ Item {
height: ScreenTools.defaultFontPixelHeight * 2 height: ScreenTools.defaultFontPixelHeight * 2
width: height width: height
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
visible: QGroundControl.settingsManager.videoSettings.showRecControl.rawValue visible: (!_camera || !_camera.autoStream) && QGroundControl.settingsManager.videoSettings.showRecControl.rawValue
Rectangle { Rectangle {
id: recordBtnBackground id: recordBtnBackground
anchors.top: parent.top anchors.top: parent.top
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "QmlObjectListModel.h" #include "QmlObjectListModel.h"
#include "VideoReceiver.h" #include "VideoReceiver.h"
#include "QGCLoggingCategory.h" #include "QGCLoggingCategory.h"
#include "QGCCameraManager.h"
#include <QtQml> #include <QtQml>
#include <QQmlEngine> #include <QQmlEngine>
...@@ -123,6 +124,63 @@ void QGCCorePlugin::setToolbox(QGCToolbox *toolbox) ...@@ -123,6 +124,63 @@ void QGCCorePlugin::setToolbox(QGCToolbox *toolbox)
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<QGCCorePlugin>("QGroundControl.QGCCorePlugin", 1, 0, "QGCCorePlugin", "Reference only"); qmlRegisterUncreatableType<QGCCorePlugin>("QGroundControl.QGCCorePlugin", 1, 0, "QGCCorePlugin", "Reference only");
qmlRegisterUncreatableType<QGCOptions>("QGroundControl.QGCOptions", 1, 0, "QGCOptions", "Reference only"); qmlRegisterUncreatableType<QGCOptions>("QGroundControl.QGCOptions", 1, 0, "QGCOptions", "Reference only");
//-- Handle Camera and Video Changes
connect(toolbox->multiVehicleManager(), &MultiVehicleManager::activeVehicleChanged, this, &QGCCorePlugin::_activeVehicleChanged);
}
void QGCCorePlugin::_activeVehicleChanged(Vehicle* activeVehicle)
{
if(activeVehicle != _activeVehicle) {
if(_activeVehicle) {
disconnect(_activeVehicle, &Vehicle::dynamicCamerasChanged, this, &QGCCorePlugin::_dynamicCamerasChanged);
}
if(_dynamicCameras) {
disconnect(_dynamicCameras, &QGCCameraManager::currentCameraChanged, this, &QGCCorePlugin::_currentCameraChanged);
}
_activeVehicle = activeVehicle;
connect(_activeVehicle, &Vehicle::dynamicCamerasChanged, this, &QGCCorePlugin::_dynamicCamerasChanged);
}
}
void QGCCorePlugin::_dynamicCamerasChanged()
{
if(_activeVehicle) {
_dynamicCameras = _activeVehicle->dynamicCameras();
connect(_dynamicCameras, &QGCCameraManager::currentCameraChanged, this, &QGCCorePlugin::_currentCameraChanged);
}
}
void QGCCorePlugin::_currentCameraChanged()
{
_resetInstrumentPages();
emit instrumentPagesChanged();
}
void QGCCorePlugin::_resetInstrumentPages()
{
if (_p->valuesPageWidgetInfo) {
_p->valuesPageWidgetInfo->deleteLater();
_p->valuesPageWidgetInfo = nullptr;
}
if(_p->cameraPageWidgetInfo) {
_p->cameraPageWidgetInfo->deleteLater();
_p->cameraPageWidgetInfo = nullptr;
}
#if defined(QGC_GST_STREAMING)
if(_p->videoPageWidgetInfo) {
_p->videoPageWidgetInfo->deleteLater();
_p->videoPageWidgetInfo = nullptr;
}
#endif
if(_p->healthPageWidgetInfo) {
_p->healthPageWidgetInfo->deleteLater();
_p->healthPageWidgetInfo = nullptr;
}
if(_p->vibrationPageWidgetInfo) {
_p->vibrationPageWidgetInfo->deleteLater();
_p->vibrationPageWidgetInfo = nullptr;
}
_p->instrumentPageWidgetList.clear();
} }
QVariantList &QGCCorePlugin::settingsPages() QVariantList &QGCCorePlugin::settingsPages()
...@@ -190,7 +248,10 @@ QVariantList& QGCCorePlugin::instrumentPages() ...@@ -190,7 +248,10 @@ QVariantList& QGCCorePlugin::instrumentPages()
_p->valuesPageWidgetInfo = new QmlComponentInfo(tr("Values"), QUrl::fromUserInput("qrc:/qml/ValuePageWidget.qml")); _p->valuesPageWidgetInfo = new QmlComponentInfo(tr("Values"), QUrl::fromUserInput("qrc:/qml/ValuePageWidget.qml"));
_p->cameraPageWidgetInfo = new QmlComponentInfo(tr("Camera"), QUrl::fromUserInput("qrc:/qml/CameraPageWidget.qml")); _p->cameraPageWidgetInfo = new QmlComponentInfo(tr("Camera"), QUrl::fromUserInput("qrc:/qml/CameraPageWidget.qml"));
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
_p->videoPageWidgetInfo = new QmlComponentInfo(tr("Video Stream"), QUrl::fromUserInput("qrc:/qml/VideoPageWidget.qml")); if(!_dynamicCameras || !_dynamicCameras->currentCameraInstance() || !_dynamicCameras->currentCameraInstance()->autoStream()) {
//-- Video Page Widget only available if using manual video streaming
_p->videoPageWidgetInfo = new QmlComponentInfo(tr("Video Stream"), QUrl::fromUserInput("qrc:/qml/VideoPageWidget.qml"));
}
#endif #endif
_p->healthPageWidgetInfo = new QmlComponentInfo(tr("Health"), QUrl::fromUserInput("qrc:/qml/HealthPageWidget.qml")); _p->healthPageWidgetInfo = new QmlComponentInfo(tr("Health"), QUrl::fromUserInput("qrc:/qml/HealthPageWidget.qml"));
_p->vibrationPageWidgetInfo = new QmlComponentInfo(tr("Vibration"), QUrl::fromUserInput("qrc:/qml/VibrationPageWidget.qml")); _p->vibrationPageWidgetInfo = new QmlComponentInfo(tr("Vibration"), QUrl::fromUserInput("qrc:/qml/VibrationPageWidget.qml"));
......
...@@ -33,6 +33,7 @@ class LinkInterface; ...@@ -33,6 +33,7 @@ class LinkInterface;
class QmlObjectListModel; class QmlObjectListModel;
class VideoReceiver; class VideoReceiver;
class PlanMasterController; class PlanMasterController;
class QGCCameraManager;
class QGCCorePlugin : public QGCTool class QGCCorePlugin : public QGCTool
{ {
...@@ -158,9 +159,19 @@ signals: ...@@ -158,9 +159,19 @@ signals:
void showTouchAreasChanged (bool showTouchAreas); void showTouchAreasChanged (bool showTouchAreas);
void showAdvancedUIChanged (bool showAdvancedUI); void showAdvancedUIChanged (bool showAdvancedUI);
protected slots:
void _activeVehicleChanged (Vehicle* activeVehicle);
void _dynamicCamerasChanged ();
void _currentCameraChanged ();
protected:
void _resetInstrumentPages ();
protected: protected:
bool _showTouchAreas; bool _showTouchAreas;
bool _showAdvancedUI; bool _showAdvancedUI;
Vehicle* _activeVehicle = nullptr;
QGCCameraManager* _dynamicCameras = nullptr;
private: private:
QGCCorePlugin_p* _p; QGCCorePlugin_p* _p;
......
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