Browse Source

Add grid lines to video view

QGC4.4
Gus Grubba 8 years ago committed by Lorenz Meier
parent
commit
45cc573d95
  1. 32
      src/FlightDisplay/FlightDisplayViewVideo.qml
  2. 9
      src/Settings/Video.SettingsGroup.json
  3. 11
      src/Settings/VideoSettings.cc
  4. 4
      src/Settings/VideoSettings.h
  5. 14
      src/ui/preferences/GeneralSettings.qml

32
src/FlightDisplay/FlightDisplayViewVideo.qml

@ -23,7 +23,9 @@ import QGroundControl.Controllers 1.0
Item { Item {
id: root id: root
property double _ar: QGroundControl.settingsManager.videoSettings.aspectRatio.rawValue property double _ar: QGroundControl.settingsManager.videoSettings.aspectRatio.rawValue
property bool _showGrid: QGroundControl.settingsManager.videoSettings.gridLines.rawValue > 0
Rectangle { Rectangle {
id: noVideo id: noVideo
anchors.fill: parent anchors.fill: parent
@ -50,4 +52,32 @@ Item {
visible: QGroundControl.videoManager.videoRunning visible: QGroundControl.videoManager.videoRunning
} }
} }
Rectangle {
color: Qt.rgba(1,1,1,0.5)
height: parent.height
width: 1
x: parent.width * 0.33
visible: _showGrid
}
Rectangle {
color: Qt.rgba(1,1,1,0.5)
height: parent.height
width: 1
x: parent.width * 0.66
visible: _showGrid
}
Rectangle {
color: Qt.rgba(1,1,1,0.5)
width: parent.width
height: 1
y: parent.height * 0.33
visible: _showGrid
}
Rectangle {
color: Qt.rgba(1,1,1,0.5)
width: parent.width
height: 1
y: parent.height * 0.66
visible: _showGrid
}
} }

9
src/Settings/Video.SettingsGroup.json

@ -35,5 +35,14 @@
"type": "float", "type": "float",
"decimalPlaces": 6, "decimalPlaces": 6,
"defaultValue": 1.777777 "defaultValue": 1.777777
},
{
"name": "VideoGridLines",
"shortDescription": "Video Grid Lines",
"longDescription": "Displays a grid overlayed over the video view.",
"type": "uint32",
"enumStrings": "Hide,Show",
"enumValues": "1,0",
"defaultValue": 0
} }
] ]

11
src/Settings/VideoSettings.cc

@ -24,6 +24,7 @@ const char* VideoSettings::udpPortName = "VideoUDPPort";
const char* VideoSettings::rtspUrlName = "VideoRTSPUrl"; const char* VideoSettings::rtspUrlName = "VideoRTSPUrl";
const char* VideoSettings::videoSavePathName = "VideoSavePath"; const char* VideoSettings::videoSavePathName = "VideoSavePath";
const char* VideoSettings::videoAspectRatioName = "VideoAspectRatio"; const char* VideoSettings::videoAspectRatioName = "VideoAspectRatio";
const char* VideoSettings::videoGridLinesName = "VideoGridLines";
const char* VideoSettings::videoSourceNoVideo = "No Video Available"; const char* VideoSettings::videoSourceNoVideo = "No Video Available";
const char* VideoSettings::videoSourceUDP = "UDP Video Stream"; const char* VideoSettings::videoSourceUDP = "UDP Video Stream";
@ -36,6 +37,7 @@ VideoSettings::VideoSettings(QObject* parent)
, _rtspUrlFact(NULL) , _rtspUrlFact(NULL)
, _videoSavePathFact(NULL) , _videoSavePathFact(NULL)
, _videoAspectRatioFact(NULL) , _videoAspectRatioFact(NULL)
, _gridLinesFact(NULL)
{ {
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<VideoSettings>("QGroundControl.SettingsManager", 1, 0, "VideoSettings", "Reference only"); qmlRegisterUncreatableType<VideoSettings>("QGroundControl.SettingsManager", 1, 0, "VideoSettings", "Reference only");
@ -115,3 +117,12 @@ Fact* VideoSettings::aspectRatio(void)
return _videoAspectRatioFact; return _videoAspectRatioFact;
} }
Fact* VideoSettings::gridLines(void)
{
if (!_gridLinesFact) {
_gridLinesFact = _createSettingsFact(videoGridLinesName);
}
return _gridLinesFact;
}

4
src/Settings/VideoSettings.h

@ -24,12 +24,14 @@ public:
Q_PROPERTY(Fact* rtspUrl READ rtspUrl CONSTANT) Q_PROPERTY(Fact* rtspUrl READ rtspUrl CONSTANT)
Q_PROPERTY(Fact* videoSavePath READ videoSavePath CONSTANT) Q_PROPERTY(Fact* videoSavePath READ videoSavePath CONSTANT)
Q_PROPERTY(Fact* aspectRatio READ aspectRatio CONSTANT) Q_PROPERTY(Fact* aspectRatio READ aspectRatio CONSTANT)
Q_PROPERTY(Fact* gridLines READ gridLines CONSTANT)
Fact* videoSource (void); Fact* videoSource (void);
Fact* udpPort (void); Fact* udpPort (void);
Fact* rtspUrl (void); Fact* rtspUrl (void);
Fact* videoSavePath (void); Fact* videoSavePath (void);
Fact* aspectRatio (void); Fact* aspectRatio (void);
Fact* gridLines (void);
static const char* videoSettingsGroupName; static const char* videoSettingsGroupName;
@ -38,6 +40,7 @@ public:
static const char* rtspUrlName; static const char* rtspUrlName;
static const char* videoSavePathName; static const char* videoSavePathName;
static const char* videoAspectRatioName; static const char* videoAspectRatioName;
static const char* videoGridLinesName;
static const char* videoSourceNoVideo; static const char* videoSourceNoVideo;
static const char* videoSourceUDP; static const char* videoSourceUDP;
@ -49,6 +52,7 @@ private:
SettingsFact* _rtspUrlFact; SettingsFact* _rtspUrlFact;
SettingsFact* _videoSavePathFact; SettingsFact* _videoSavePathFact;
SettingsFact* _videoAspectRatioFact; SettingsFact* _videoAspectRatioFact;
SettingsFact* _gridLinesFact;
}; };
#endif #endif

14
src/ui/preferences/GeneralSettings.qml

@ -514,6 +514,20 @@ QGCView {
} }
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex < 2 && QGroundControl.settingsManager.videoSettings.gridLines.visible
QGCLabel {
anchors.baseline: gridField.baseline
text: qsTr("Grid Lines:")
width: _labelWidth
}
FactComboBox {
id: gridField
width: _editFieldWidth
fact: QGroundControl.settingsManager.videoSettings.gridLines
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.settingsManager.videoSettings.videoSavePath.visible && QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled visible: QGroundControl.settingsManager.videoSettings.videoSavePath.visible && QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled
QGCLabel { QGCLabel {
anchors.baseline: pathField.baseline anchors.baseline: pathField.baseline

Loading…
Cancel
Save