Merge lp:~fboucault/camera-app/hook_up_hdr into lp:camera-app

Proposed by Florian Boucault
Status: Merged
Approved by: Florian Boucault
Approved revision: 305
Merged at revision: 307
Proposed branch: lp:~fboucault/camera-app/hook_up_hdr
Merge into: lp:camera-app
Diff against target: 247 lines (+107/-7)
4 files modified
CameraApp/advancedcamerasettings.cpp (+67/-1)
CameraApp/advancedcamerasettings.h (+11/-0)
OptionValueButton.qml (+1/-0)
ViewFinderOverlay.qml (+28/-6)
To merge this branch: bzr merge lp:~fboucault/camera-app/hook_up_hdr
Reviewer Review Type Date Requested Status
Olivier Tilloy code Approve
PS Jenkins bot continuous-integration Approve
Florian Boucault (community) Needs Fixing
Review via email: mp+226219@code.launchpad.net

Commit message

Enabled HDR feature:
- linked it up to backend (qtubuntu-camera)
- fixed up overlay UI for icon less options

To post a comment you must log in.
Revision history for this message
Florian Boucault (fboucault) wrote :

Mostly good to go apart from that we need to define a better enum value for HDR than QCameraExposure::ExposureModeVendor

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

This can be merged independently but the feature will not work until the following MR has landed: https://code.launchpad.net/~fboucault/qtubuntu-camera/hdr_scene_mode/+merge/225993

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~fboucault/camera-app/hook_up_hdr updated
304. By Florian Boucault

Merged from trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~fboucault/camera-app/hook_up_hdr updated
305. By Florian Boucault

Define a custom ExposureMode for HDR.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Code changes look good to me, I haven’t tested them functionally though, as packages for qtubuntu-camera failed to build in silo 12.

One minor question:

10 +// Definition of this enum value is duplicated in qtubuntu-camera
11 +static const QCameraExposure::ExposureMode ExposureHdr = static_cast<QCameraExposure::ExposureMode>(QCameraExposure::ExposureModeVendor + 1);

Couldn’t we patch QtMultimedia to add this value to the QCameraExposure::ExposureMode enum? Or, if this doesn’t make sense, doesn’t qtubuntu-camera expose public headers that we could refer to instead of duplicating the definition of this custom value (which eventually will bite us when they get out of sync)?

Revision history for this message
Florian Boucault (fboucault) wrote :

There are valid packages for qtubuntu-media in https://code.launchpad.net/~fboucault/qtubuntu-camera/hdr_scene_mode/+merge/225993
The build had to be restarted in silo 12 after the libhybris changes landed in the image but it has not. Packages in MR are identical though.

About the question, I am not confident this patch would be accepted upstream. Also we cannot make the app depend on qtubuntu-camera which will only ever exist where we use Android (phone/tablet) (and the app should work on the desktop).

Revision history for this message
Olivier Tilloy (osomon) wrote :

OK, that makes sense.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CameraApp/advancedcamerasettings.cpp'
--- CameraApp/advancedcamerasettings.cpp 2014-06-30 07:28:08 +0000
+++ CameraApp/advancedcamerasettings.cpp 2014-07-10 17:01:25 +0000
@@ -25,6 +25,10 @@
25#include <QtMultimedia/QMediaService>25#include <QtMultimedia/QMediaService>
26#include <QtMultimedia/QVideoDeviceSelectorControl>26#include <QtMultimedia/QVideoDeviceSelectorControl>
27#include <QtMultimedia/QCameraFlashControl>27#include <QtMultimedia/QCameraFlashControl>
28#include <QtMultimedia/QCameraExposureControl>
29
30// Definition of this enum value is duplicated in qtubuntu-camera
31static const QCameraExposure::ExposureMode ExposureHdr = static_cast<QCameraExposure::ExposureMode>(QCameraExposure::ExposureModeVendor + 1);
2832
29AdvancedCameraSettings::AdvancedCameraSettings(QObject *parent) :33AdvancedCameraSettings::AdvancedCameraSettings(QObject *parent) :
30 QObject(parent),34 QObject(parent),
@@ -33,7 +37,8 @@
33 m_camera(0),37 m_camera(0),
34 m_deviceSelector(0),38 m_deviceSelector(0),
35 m_viewFinderControl(0),39 m_viewFinderControl(0),
36 m_cameraFlashControl(0)40 m_cameraFlashControl(0),
41 m_cameraExposureControl(0)
37{42{
38}43}
3944
@@ -134,6 +139,19 @@
134 return flashControl;139 return flashControl;
135}140}
136141
142QCameraExposureControl* AdvancedCameraSettings::exposureControlFromCamera(QCamera *camera) const
143{
144 QMediaControl *control = mediaControlFromCamera(camera, QCameraExposureControl_iid);
145 QCameraExposureControl *exposureControl = qobject_cast<QCameraExposureControl*>(control);
146
147 if (exposureControl == 0) {
148 qWarning() << "No exposure control support";
149 }
150
151 return exposureControl;
152}
153
154
137QObject* AdvancedCameraSettings::camera() const155QObject* AdvancedCameraSettings::camera() const
138{156{
139 return m_cameraObject;157 return m_cameraObject;
@@ -181,9 +199,18 @@
181 }199 }
182200
183 m_cameraFlashControl = flashControlFromCamera(m_camera);201 m_cameraFlashControl = flashControlFromCamera(m_camera);
202 m_cameraExposureControl = exposureControlFromCamera(m_camera);
203
204 if (m_cameraExposureControl) {
205 QObject::connect(m_cameraExposureControl,
206 SIGNAL(actualValueChanged(int)),
207 this, SLOT(onExposureValueChanged(int)));
208 }
184209
185 Q_EMIT resolutionChanged();210 Q_EMIT resolutionChanged();
186 Q_EMIT hasFlashChanged();211 Q_EMIT hasFlashChanged();
212 Q_EMIT hasHdrChanged();
213 Q_EMIT hdrEnabledChanged();
187}214}
188215
189void AdvancedCameraSettings::onCameraStateChanged()216void AdvancedCameraSettings::onCameraStateChanged()
@@ -228,3 +255,42 @@
228 return false;255 return false;
229 }256 }
230}257}
258
259bool AdvancedCameraSettings::hasHdr() const
260{
261 if (m_cameraExposureControl) {
262 bool continuous;
263 if (m_cameraExposureControl->isParameterSupported(QCameraExposureControl::ExposureMode)) {
264 QVariantList range = m_cameraExposureControl->supportedParameterRange(QCameraExposureControl::ExposureMode, &continuous);
265 return range.contains(QVariant::fromValue(ExposureHdr));
266 }
267 } else {
268 return false;
269 }
270}
271
272bool AdvancedCameraSettings::hdrEnabled() const
273{
274 if (m_cameraExposureControl) {
275 QVariant exposureMode = m_cameraExposureControl->actualValue(QCameraExposureControl::ExposureMode);
276 return exposureMode.value<QCameraExposure::ExposureMode>() == ExposureHdr;
277 } else {
278 return false;
279 }
280}
281
282void AdvancedCameraSettings::setHdrEnabled(bool enabled)
283{
284 if (m_cameraExposureControl) {
285 QVariant exposureMode = enabled ? QVariant::fromValue(ExposureHdr)
286 : QVariant::fromValue(QCameraExposure::ExposureAuto);
287 m_cameraExposureControl->setValue(QCameraExposureControl::ExposureMode, exposureMode);
288 }
289}
290
291void AdvancedCameraSettings::onExposureValueChanged(int parameter)
292{
293 if (parameter == QCameraExposureControl::ExposureMode) {
294 Q_EMIT hdrEnabledChanged();
295 }
296}
231297
=== modified file 'CameraApp/advancedcamerasettings.h'
--- CameraApp/advancedcamerasettings.h 2014-06-17 07:40:12 +0000
+++ CameraApp/advancedcamerasettings.h 2014-07-10 17:01:25 +0000
@@ -24,6 +24,7 @@
24#include <QtMultimedia/QCamera>24#include <QtMultimedia/QCamera>
25#include <QtMultimedia/QVideoDeviceSelectorControl>25#include <QtMultimedia/QVideoDeviceSelectorControl>
26#include <QtMultimedia/QCameraViewfinderSettingsControl>26#include <QtMultimedia/QCameraViewfinderSettingsControl>
27#include <QtMultimedia/QCameraExposureControl>
27#include <QtMultimedia/QMediaControl>28#include <QtMultimedia/QMediaControl>
2829
29class QCameraControl;30class QCameraControl;
@@ -37,6 +38,8 @@
37 NOTIFY activeCameraIndexChanged)38 NOTIFY activeCameraIndexChanged)
38 Q_PROPERTY (QSize resolution READ resolution NOTIFY resolutionChanged)39 Q_PROPERTY (QSize resolution READ resolution NOTIFY resolutionChanged)
39 Q_PROPERTY (bool hasFlash READ hasFlash NOTIFY hasFlashChanged)40 Q_PROPERTY (bool hasFlash READ hasFlash NOTIFY hasFlashChanged)
41 Q_PROPERTY (bool hdrEnabled READ hdrEnabled WRITE setHdrEnabled NOTIFY hdrEnabledChanged)
42 Q_PROPERTY (bool hasHdr READ hasHdr NOTIFY hasHdrChanged)
4043
41public:44public:
42 explicit AdvancedCameraSettings(QObject *parent = 0);45 explicit AdvancedCameraSettings(QObject *parent = 0);
@@ -46,6 +49,9 @@
46 void setActiveCameraIndex(int index);49 void setActiveCameraIndex(int index);
47 QSize resolution() const;50 QSize resolution() const;
48 bool hasFlash() const;51 bool hasFlash() const;
52 bool hasHdr() const;
53 bool hdrEnabled() const;
54 void setHdrEnabled(bool enabled);
49 void readCapabilities();55 void readCapabilities();
5056
51Q_SIGNALS:57Q_SIGNALS:
@@ -53,15 +59,19 @@
53 void activeCameraIndexChanged();59 void activeCameraIndexChanged();
54 void resolutionChanged();60 void resolutionChanged();
55 void hasFlashChanged();61 void hasFlashChanged();
62 void hasHdrChanged();
63 void hdrEnabledChanged();
5664
57private Q_SLOTS:65private Q_SLOTS:
58 void onCameraStateChanged();66 void onCameraStateChanged();
67 void onExposureValueChanged(int parameter);
5968
60private:69private:
61 QVideoDeviceSelectorControl* selectorFromCamera(QCamera *camera) const;70 QVideoDeviceSelectorControl* selectorFromCamera(QCamera *camera) const;
62 QCameraViewfinderSettingsControl* viewfinderFromCamera(QCamera *camera) const;71 QCameraViewfinderSettingsControl* viewfinderFromCamera(QCamera *camera) const;
63 QCameraControl *camcontrolFromCamera(QCamera *camera) const;72 QCameraControl *camcontrolFromCamera(QCamera *camera) const;
64 QCameraFlashControl* flashControlFromCamera(QCamera* camera) const;73 QCameraFlashControl* flashControlFromCamera(QCamera* camera) const;
74 QCameraExposureControl* exposureControlFromCamera(QCamera *camera) const;
65 QCamera* cameraFromCameraObject(QObject* cameraObject) const;75 QCamera* cameraFromCameraObject(QObject* cameraObject) const;
66 QMediaControl* mediaControlFromCamera(QCamera *camera, const char* iid) const;76 QMediaControl* mediaControlFromCamera(QCamera *camera, const char* iid) const;
6777
@@ -72,6 +82,7 @@
72 QCameraViewfinderSettingsControl* m_viewFinderControl;82 QCameraViewfinderSettingsControl* m_viewFinderControl;
73 QCameraControl* m_cameraControl;83 QCameraControl* m_cameraControl;
74 QCameraFlashControl* m_cameraFlashControl;84 QCameraFlashControl* m_cameraFlashControl;
85 QCameraExposureControl* m_cameraExposureControl;
7586
76};87};
7788
7889
=== modified file 'OptionValueButton.qml'
--- OptionValueButton.qml 2014-06-26 11:38:24 +0000
+++ OptionValueButton.qml 2014-07-10 17:01:25 +0000
@@ -40,6 +40,7 @@
40 width: height40 width: height
41 color: "white"41 color: "white"
42 opacity: optionValueButton.selected ? 1.0 : 0.542 opacity: optionValueButton.selected ? 1.0 : 0.5
43 visible: name !== ""
43 }44 }
4445
45 Label {46 Label {
4647
=== modified file 'ViewFinderOverlay.qml'
--- ViewFinderOverlay.qml 2014-07-02 15:43:31 +0000
+++ ViewFinderOverlay.qml 2014-07-10 17:01:25 +0000
@@ -56,6 +56,12 @@
56 when: camera.captureMode == Camera.CaptureVideo56 when: camera.captureMode == Camera.CaptureVideo
57 }57 }
5858
59 Binding {
60 target: camera.advanced
61 property: "hdrEnabled"
62 value: settings.hdrEnabled
63 }
64
59 Connections {65 Connections {
60 target: camera.imageCapture66 target: camera.imageCapture
61 onReadyChanged: {67 onReadyChanged: {
@@ -155,11 +161,11 @@
155 id: hdrOptionsModel161 id: hdrOptionsModel
156162
157 property string settingsProperty: "hdrEnabled"163 property string settingsProperty: "hdrEnabled"
158 property string icon: "import-image"164 property string icon: ""
159 property string label: "HDR"165 property string label: "HDR"
160 property bool isToggle: true166 property bool isToggle: true
161 property int selectedIndex: bottomEdge.indexForValue(hdrOptionsModel, settings.hdrEnabled)167 property int selectedIndex: bottomEdge.indexForValue(hdrOptionsModel, settings.hdrEnabled)
162 property bool available: false168 property bool available: camera.advanced.hasHdr
163 property bool visible: true169 property bool visible: true
164170
165 ListElement {171 ListElement {
@@ -225,7 +231,7 @@
225231
226 Repeater {232 Repeater {
227 model: bottomEdge.options233 model: bottomEdge.options
228 delegate: Icon {234 delegate: Item {
229 anchors {235 anchors {
230 top: parent.top236 top: parent.top
231 topMargin: units.gu(0.5)237 topMargin: units.gu(0.5)
@@ -233,10 +239,26 @@
233 bottomMargin: units.gu(0.5)239 bottomMargin: units.gu(0.5)
234 }240 }
235 width: units.gu(2)241 width: units.gu(2)
236 color: "white"242 visible: modelData.available && modelData.visible ? (modelData.isToggle ? modelData.get(model.selectedIndex).value : true) : false
237 opacity: 0.5243 opacity: 0.5
238 name: modelData.isToggle ? modelData.icon : modelData.get(model.selectedIndex).icon244
239 visible: modelData.available && modelData.visible ? (modelData.isToggle ? modelData.get(model.selectedIndex).value : true) : false245 Icon {
246 id: indicatorIcon
247 anchors.fill: parent
248 color: "white"
249 name: modelData.isToggle ? modelData.icon : modelData.get(model.selectedIndex).icon
250 visible: name !== ""
251 }
252
253 Label {
254 id: indicatorLabel
255 anchors.fill: parent
256 fontSize: "xx-small"
257 color: "white"
258 text: modelData.label
259 verticalAlignment: Text.AlignVCenter
260 visible: indicatorIcon.name === ""
261 }
240 }262 }
241 }263 }
242 }264 }

Subscribers

People subscribed via source and target branches