Skip to content

Commit 1f3ee66

Browse files
authored
Disable capture video button when video not streaming
1 parent 4628716 commit 1f3ee66

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/Camera/SimulatedCameraControl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ SimulatedCameraControl::SimulatedCameraControl(Vehicle *vehicle, QObject *parent
2828
emit videoCaptureStatusChanged();
2929
});
3030
connect(videoManager, &VideoManager::hasVideoChanged, this, &SimulatedCameraControl::infoChanged);
31+
connect(videoManager, &VideoManager::decodingChanged, this, &SimulatedCameraControl::infoChanged);
3132

3233
(void) connect(SettingsManager::instance()->flyViewSettings()->showSimpleCameraControl(), &Fact::rawValueChanged, this, &SimulatedCameraControl::infoChanged);
3334

@@ -193,7 +194,7 @@ bool SimulatedCameraControl::capturesPhotos() const
193194

194195
bool SimulatedCameraControl::hasVideoStream() const
195196
{
196-
return VideoManager::instance()->hasVideo();
197+
return VideoManager::instance()->decoding();
197198
}
198199

199200
void SimulatedCameraControl::setPhotoCaptureMode(MavlinkCameraControl::PhotoCaptureMode photoCaptureMode)

src/FlightMap/Widgets/PhotoVideoControl.qml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ Rectangle {
3535
property bool _photoCaptureSingleIdle: _camera.photoCaptureStatus === MavlinkCameraControl.PHOTO_CAPTURE_IDLE
3636
property bool _photoCaptureIntervalIdle: _camera.photoCaptureStatus === MavlinkCameraControl.PHOTO_CAPTURE_INTERVAL_IDLE
3737
property bool _photoCaptureIdle: _photoCaptureSingleIdle || _photoCaptureIntervalIdle
38-
property color _captureButtonColor: _cameraInPhotoMode ? qgcPal.photoCaptureButtonColor : qgcPal.videoCaptureButtonColor
3938

4039
/*
4140
// Used for testing camera ui options. Set _camera to testCamera to use.
@@ -214,18 +213,24 @@ Rectangle {
214213

215214
// Take Photo, Start/Stop Video button
216215
Rectangle {
216+
id: captureButton
217217
Layout.alignment: Qt.AlignHCenter
218-
color: qgcPal.button
218+
color: captureButtonPalette.button
219219
width: ScreenTools.defaultFontPixelWidth * 6
220220
height: width
221221
radius: width * 0.5
222222
border.width: 1
223-
border.color: qgcPal.buttonBorder
223+
border.color: captureButtonPalette.buttonBorder
224+
enabled: _cameraInPhotoMode || (_cameraInVideoMode && _camera.hasVideoStream)
224225

225-
Rectangle {
226+
property color captureButtonColor: _cameraInPhotoMode ? captureButtonPalette.photoCaptureButtonColor : captureButtonPalette.videoCaptureButtonColor
227+
228+
QGCPalette { id: captureButtonPalette; colorGroupEnabled: captureButton.enabled }
229+
230+
Rectangle {
226231
anchors.centerIn: parent
227232
anchors.alignWhenCentered: false // Prevents anchors.centerIn from snapping to integer coordinates, which can throw off centering.
228-
color: qgcPal.buttonBorder
233+
color: captureButton.captureButtonPalette.buttonBorder
229234
width: parent.width * 0.75
230235
height: width
231236
radius: width * 0.5
@@ -237,9 +242,9 @@ Rectangle {
237242
width: parent.width * (_isShootingInCurrentMode ? 0.5 : 0.75)
238243
height: width
239244
radius: _isShootingInCurrentMode ? ScreenTools.defaultFontPixelWidth * 0.5 : width * 0.5
240-
color: _captureButtonColor
245+
color: captureButton.captureButtonColor
241246
border.width: 1
242-
border.color: qgcPal.buttonBorder
247+
border.color: captureButton.captureButtonPalette.buttonBorder
243248

244249
property bool _isShootingInPhotoMode: _cameraInPhotoMode && _camera.photoCaptureStatus === MavlinkCameraControl.PHOTO_CAPTURE_IN_PROGRESS
245250
property bool _isShootingInVideoMode: (!_cameraInPhotoMode && _camera.videoCaptureStatus === MavlinkCameraControl.VIDEO_CAPTURE_STATUS_RUNNING)
@@ -271,7 +276,7 @@ Rectangle {
271276
// Record time / Capture count
272277
Rectangle {
273278
Layout.alignment: Qt.AlignHCenter
274-
color: _videoCaptureIdle && _photoCaptureIdle ? "transparent" : _captureButtonColor
279+
color: _videoCaptureIdle && _photoCaptureIdle ? "transparent" : captureButton.captureButtonColor
275280
Layout.preferredWidth: (_cameraInVideoMode ? videoRecordTime.width : photoCaptureCount.width) + (_smallMargins * 2)
276281
Layout.preferredHeight: (_cameraInVideoMode ? videoRecordTime.height : photoCaptureCount.height)
277282
radius: _smallMargins

src/QmlControls/QGCPalette.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ void QGCPalette::_buildMap()
9292
DECLARE_QGC_NONTHEMED_COLOR(brandingPurple, "#4A2C6D", "#4A2C6D")
9393
DECLARE_QGC_NONTHEMED_COLOR(brandingBlue, "#48D6FF", "#6045c5")
9494
DECLARE_QGC_NONTHEMED_COLOR(toolStripFGColor, "#707070", "#ffffff")
95-
DECLARE_QGC_NONTHEMED_COLOR(photoCaptureButtonColor, "#ffffff", "#ffffff")
96-
DECLARE_QGC_NONTHEMED_COLOR(videoCaptureButtonColor, "#f32836", "#f32836")
95+
DECLARE_QGC_NONTHEMED_COLOR(photoCaptureButtonColor, "#707070", "#ffffff")
96+
DECLARE_QGC_NONTHEMED_COLOR(videoCaptureButtonColor, "#f89a9e", "#f32836")
9797

9898
// Colors not affecting by theming or enable/disable
9999
DECLARE_QGC_SINGLE_COLOR(mapWidgetBorderLight, "#ffffff")

0 commit comments

Comments
 (0)