nemo: Add support for camera torch mode

This is based on the work by Dmytro Poplavskiy
Original patch URL: https://codereview.qt-project.org/#/c/5503/1
This commit is contained in:
Mohammed Hassan
2016-02-29 13:00:57 +02:00
committed by Martin Jones
parent 3a328a2ff3
commit 1992c78705

View File

@@ -69,6 +69,12 @@ QCameraExposure::FlashModes CameraBinFlash::flashMode() const
modes |= QCameraExposure::FlashAuto;
break;
}
gboolean torchEnabled = false;
g_object_get(G_OBJECT(m_session->cameraSource()), "video-torch", &torchEnabled, NULL);
if (torchEnabled)
modes |= QCameraExposure::FlashTorch;
return modes;
}
@@ -84,10 +90,27 @@ void CameraBinFlash::setFlashMode(QCameraExposure::FlashModes mode)
else if (mode.testFlag(QCameraExposure::FlashRedEyeReduction)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE;
gst_photography_set_flash_mode(m_session->photography(), flashMode);
gboolean torchEnabled = false;
g_object_get(G_OBJECT(m_session->cameraSource()), "video-torch", &torchEnabled, NULL);
gboolean enableTorch = mode.testFlag(QCameraExposure::FlashTorch);
if (bool(enableTorch) != bool(torchEnabled)) {
g_object_set(G_OBJECT(m_session->cameraSource()), "video-torch", enableTorch, NULL);
}
}
bool CameraBinFlash::isFlashModeSupported(QCameraExposure::FlashModes mode) const
{
//torch light is allowed only in video capture mode
if (m_session->captureMode() == QCamera::CaptureVideo) {
if (mode == QCameraExposure::FlashTorch ||
mode == QCameraExposure::FlashTorch | QCameraExposure::FlashOff)
return true;
}
return mode == QCameraExposure::FlashOff ||
mode == QCameraExposure::FlashOn ||
mode == QCameraExposure::FlashAuto ||