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
1=== modified file 'CameraApp/advancedcamerasettings.cpp'
2--- CameraApp/advancedcamerasettings.cpp 2014-06-30 07:28:08 +0000
3+++ CameraApp/advancedcamerasettings.cpp 2014-07-10 17:01:25 +0000
4@@ -25,6 +25,10 @@
5 #include <QtMultimedia/QMediaService>
6 #include <QtMultimedia/QVideoDeviceSelectorControl>
7 #include <QtMultimedia/QCameraFlashControl>
8+#include <QtMultimedia/QCameraExposureControl>
9+
10+// Definition of this enum value is duplicated in qtubuntu-camera
11+static const QCameraExposure::ExposureMode ExposureHdr = static_cast<QCameraExposure::ExposureMode>(QCameraExposure::ExposureModeVendor + 1);
12
13 AdvancedCameraSettings::AdvancedCameraSettings(QObject *parent) :
14 QObject(parent),
15@@ -33,7 +37,8 @@
16 m_camera(0),
17 m_deviceSelector(0),
18 m_viewFinderControl(0),
19- m_cameraFlashControl(0)
20+ m_cameraFlashControl(0),
21+ m_cameraExposureControl(0)
22 {
23 }
24
25@@ -134,6 +139,19 @@
26 return flashControl;
27 }
28
29+QCameraExposureControl* AdvancedCameraSettings::exposureControlFromCamera(QCamera *camera) const
30+{
31+ QMediaControl *control = mediaControlFromCamera(camera, QCameraExposureControl_iid);
32+ QCameraExposureControl *exposureControl = qobject_cast<QCameraExposureControl*>(control);
33+
34+ if (exposureControl == 0) {
35+ qWarning() << "No exposure control support";
36+ }
37+
38+ return exposureControl;
39+}
40+
41+
42 QObject* AdvancedCameraSettings::camera() const
43 {
44 return m_cameraObject;
45@@ -181,9 +199,18 @@
46 }
47
48 m_cameraFlashControl = flashControlFromCamera(m_camera);
49+ m_cameraExposureControl = exposureControlFromCamera(m_camera);
50+
51+ if (m_cameraExposureControl) {
52+ QObject::connect(m_cameraExposureControl,
53+ SIGNAL(actualValueChanged(int)),
54+ this, SLOT(onExposureValueChanged(int)));
55+ }
56
57 Q_EMIT resolutionChanged();
58 Q_EMIT hasFlashChanged();
59+ Q_EMIT hasHdrChanged();
60+ Q_EMIT hdrEnabledChanged();
61 }
62
63 void AdvancedCameraSettings::onCameraStateChanged()
64@@ -228,3 +255,42 @@
65 return false;
66 }
67 }
68+
69+bool AdvancedCameraSettings::hasHdr() const
70+{
71+ if (m_cameraExposureControl) {
72+ bool continuous;
73+ if (m_cameraExposureControl->isParameterSupported(QCameraExposureControl::ExposureMode)) {
74+ QVariantList range = m_cameraExposureControl->supportedParameterRange(QCameraExposureControl::ExposureMode, &continuous);
75+ return range.contains(QVariant::fromValue(ExposureHdr));
76+ }
77+ } else {
78+ return false;
79+ }
80+}
81+
82+bool AdvancedCameraSettings::hdrEnabled() const
83+{
84+ if (m_cameraExposureControl) {
85+ QVariant exposureMode = m_cameraExposureControl->actualValue(QCameraExposureControl::ExposureMode);
86+ return exposureMode.value<QCameraExposure::ExposureMode>() == ExposureHdr;
87+ } else {
88+ return false;
89+ }
90+}
91+
92+void AdvancedCameraSettings::setHdrEnabled(bool enabled)
93+{
94+ if (m_cameraExposureControl) {
95+ QVariant exposureMode = enabled ? QVariant::fromValue(ExposureHdr)
96+ : QVariant::fromValue(QCameraExposure::ExposureAuto);
97+ m_cameraExposureControl->setValue(QCameraExposureControl::ExposureMode, exposureMode);
98+ }
99+}
100+
101+void AdvancedCameraSettings::onExposureValueChanged(int parameter)
102+{
103+ if (parameter == QCameraExposureControl::ExposureMode) {
104+ Q_EMIT hdrEnabledChanged();
105+ }
106+}
107
108=== modified file 'CameraApp/advancedcamerasettings.h'
109--- CameraApp/advancedcamerasettings.h 2014-06-17 07:40:12 +0000
110+++ CameraApp/advancedcamerasettings.h 2014-07-10 17:01:25 +0000
111@@ -24,6 +24,7 @@
112 #include <QtMultimedia/QCamera>
113 #include <QtMultimedia/QVideoDeviceSelectorControl>
114 #include <QtMultimedia/QCameraViewfinderSettingsControl>
115+#include <QtMultimedia/QCameraExposureControl>
116 #include <QtMultimedia/QMediaControl>
117
118 class QCameraControl;
119@@ -37,6 +38,8 @@
120 NOTIFY activeCameraIndexChanged)
121 Q_PROPERTY (QSize resolution READ resolution NOTIFY resolutionChanged)
122 Q_PROPERTY (bool hasFlash READ hasFlash NOTIFY hasFlashChanged)
123+ Q_PROPERTY (bool hdrEnabled READ hdrEnabled WRITE setHdrEnabled NOTIFY hdrEnabledChanged)
124+ Q_PROPERTY (bool hasHdr READ hasHdr NOTIFY hasHdrChanged)
125
126 public:
127 explicit AdvancedCameraSettings(QObject *parent = 0);
128@@ -46,6 +49,9 @@
129 void setActiveCameraIndex(int index);
130 QSize resolution() const;
131 bool hasFlash() const;
132+ bool hasHdr() const;
133+ bool hdrEnabled() const;
134+ void setHdrEnabled(bool enabled);
135 void readCapabilities();
136
137 Q_SIGNALS:
138@@ -53,15 +59,19 @@
139 void activeCameraIndexChanged();
140 void resolutionChanged();
141 void hasFlashChanged();
142+ void hasHdrChanged();
143+ void hdrEnabledChanged();
144
145 private Q_SLOTS:
146 void onCameraStateChanged();
147+ void onExposureValueChanged(int parameter);
148
149 private:
150 QVideoDeviceSelectorControl* selectorFromCamera(QCamera *camera) const;
151 QCameraViewfinderSettingsControl* viewfinderFromCamera(QCamera *camera) const;
152 QCameraControl *camcontrolFromCamera(QCamera *camera) const;
153 QCameraFlashControl* flashControlFromCamera(QCamera* camera) const;
154+ QCameraExposureControl* exposureControlFromCamera(QCamera *camera) const;
155 QCamera* cameraFromCameraObject(QObject* cameraObject) const;
156 QMediaControl* mediaControlFromCamera(QCamera *camera, const char* iid) const;
157
158@@ -72,6 +82,7 @@
159 QCameraViewfinderSettingsControl* m_viewFinderControl;
160 QCameraControl* m_cameraControl;
161 QCameraFlashControl* m_cameraFlashControl;
162+ QCameraExposureControl* m_cameraExposureControl;
163
164 };
165
166
167=== modified file 'OptionValueButton.qml'
168--- OptionValueButton.qml 2014-06-26 11:38:24 +0000
169+++ OptionValueButton.qml 2014-07-10 17:01:25 +0000
170@@ -40,6 +40,7 @@
171 width: height
172 color: "white"
173 opacity: optionValueButton.selected ? 1.0 : 0.5
174+ visible: name !== ""
175 }
176
177 Label {
178
179=== modified file 'ViewFinderOverlay.qml'
180--- ViewFinderOverlay.qml 2014-07-02 15:43:31 +0000
181+++ ViewFinderOverlay.qml 2014-07-10 17:01:25 +0000
182@@ -56,6 +56,12 @@
183 when: camera.captureMode == Camera.CaptureVideo
184 }
185
186+ Binding {
187+ target: camera.advanced
188+ property: "hdrEnabled"
189+ value: settings.hdrEnabled
190+ }
191+
192 Connections {
193 target: camera.imageCapture
194 onReadyChanged: {
195@@ -155,11 +161,11 @@
196 id: hdrOptionsModel
197
198 property string settingsProperty: "hdrEnabled"
199- property string icon: "import-image"
200+ property string icon: ""
201 property string label: "HDR"
202 property bool isToggle: true
203 property int selectedIndex: bottomEdge.indexForValue(hdrOptionsModel, settings.hdrEnabled)
204- property bool available: false
205+ property bool available: camera.advanced.hasHdr
206 property bool visible: true
207
208 ListElement {
209@@ -225,7 +231,7 @@
210
211 Repeater {
212 model: bottomEdge.options
213- delegate: Icon {
214+ delegate: Item {
215 anchors {
216 top: parent.top
217 topMargin: units.gu(0.5)
218@@ -233,10 +239,26 @@
219 bottomMargin: units.gu(0.5)
220 }
221 width: units.gu(2)
222- color: "white"
223+ visible: modelData.available && modelData.visible ? (modelData.isToggle ? modelData.get(model.selectedIndex).value : true) : false
224 opacity: 0.5
225- name: modelData.isToggle ? modelData.icon : modelData.get(model.selectedIndex).icon
226- visible: modelData.available && modelData.visible ? (modelData.isToggle ? modelData.get(model.selectedIndex).value : true) : false
227+
228+ Icon {
229+ id: indicatorIcon
230+ anchors.fill: parent
231+ color: "white"
232+ name: modelData.isToggle ? modelData.icon : modelData.get(model.selectedIndex).icon
233+ visible: name !== ""
234+ }
235+
236+ Label {
237+ id: indicatorLabel
238+ anchors.fill: parent
239+ fontSize: "xx-small"
240+ color: "white"
241+ text: modelData.label
242+ verticalAlignment: Text.AlignVCenter
243+ visible: indicatorIcon.name === ""
244+ }
245 }
246 }
247 }

Subscribers

People subscribed via source and target branches