Merge lp:~uriboni/camera-app/handle-selfie-key into lp:camera-app

Proposed by Ugo Riboni on 2016-01-26
Status: Needs review
Proposed branch: lp:~uriboni/camera-app/handle-selfie-key
Merge into: lp:camera-app
Diff against target: 124 lines (+39/-10)
4 files modified
ViewFinderOverlay.qml (+29/-9)
ViewFinderOverlayLoader.qml (+5/-0)
ViewFinderView.qml (+2/-1)
camera-app.qml (+3/-0)
To merge this branch: bzr merge lp:~uriboni/camera-app/handle-selfie-key
Reviewer Review Type Date Requested Status
Florian Boucault (community) 2016-01-26 Needs Fixing on 2016-02-29
PS Jenkins bot continuous-integration Needs Fixing on 2016-01-26
Review via email: mp+283992@code.launchpad.net

Commit message

Handle various keypresses that are used by selfie sticks to trigger shooting

Description of the change

Handle various keypresses that are used by selfie sticks to trigger shooting

To post a comment you must log in.

Grabbed the deb from the jenkins run and installed it on my bq e4.5. I paired my selfie button and when I press the Android (enter key) button, nothing happens. When I press the iOS button (vol+) I get the volume overlay appear. Like this:-

http://people.canonical.com/~alan/screenshots/device-2016-02-03-113625.png

No photos are taken.

Florian Boucault (fboucault) wrote :

@Ugo: Submitted against wrong branch.
@Alan: camera is distributed as a click app so installing the deb while the original click is installed would cause the click to be run instead of the deb version.

Florian Boucault (fboucault) wrote :

There were changes to keyboard handling in staging in the meantime, please make sure it merges with no breakages.

review: Needs Fixing

Unmerged revisions

624. By Ugo Riboni on 2016-01-04

Shoot a picture on almost all media keys
with the exception of those used by the system for volume up and down

623. By Ugo Riboni on 2016-01-04

Merge changes from trunk

622. By Ugo Riboni on 2015-12-14

Focus the overlay so that it can receive keypresses, and then handle the togglePlayPause media key to shoot a picture

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ViewFinderOverlay.qml'
--- ViewFinderOverlay.qml 2016-01-11 15:07:58 +0000
+++ ViewFinderOverlay.qml 2016-01-26 16:02:22 +0000
@@ -38,6 +38,24 @@
38 focusRing.show();38 focusRing.show();
39 }39 }
4040
41 readonly property var mediaKeys: [
42 Qt.Key_MediaPlay, Qt.Key_MediaStop, Qt.Key_MediaPrevious,
43 Qt.Key_MediaNext, Qt.Key_MediaRecord, Qt.Key_MediaPause,
44 Qt.Key_MediaTogglePlayPause,
45 // Note that Qt.Key_VolumeUp and Qt.Key_VolumeDown are not handled as
46 // they conflict with the hardware volume buttons on the device.
47 // We also handle the following media keysyms which are not mapped in
48 // the Qt namespace but are emitted by selfie sticks and defined in xkbcommon-keysyms.h:
49 // XKB_KEY_XF86AudioPlay, XKB_KEY_XF86AudioStop, XKB_KEY_XF86AudioPrev,
50 // XKB_KEY_XF86AudioNext, XKB_KEY_XF86AudioPause, XKB_KEY_XF86AudioMedia
51 // XKB_KEY_XF86AudioLowerVolume, XKB_KEY_XF86AudioRaiseVolume
52 0x1008FF14, 0x1008FF15, 0x1008FF16,
53 0x1008FF17, 0x1008FF31, 0x1008FF32,
54 0x1008FF11, 0x1008FF13,
55 ]
56
57 Keys.onPressed: if (mediaKeys.indexOf(event.key) != -1) shootButton.triggerShoot()
58
41 Settings {59 Settings {
42 id: settings60 id: settings
4361
@@ -804,7 +822,17 @@
804 state: (camera.captureMode == Camera.CaptureVideo) ?822 state: (camera.captureMode == Camera.CaptureVideo) ?
805 ((camera.videoRecorder.recorderState == CameraRecorder.StoppedState) ? "record_off" : "record_on") :823 ((camera.videoRecorder.recorderState == CameraRecorder.StoppedState) ? "record_off" : "record_on") :
806 "camera"824 "camera"
807 onClicked: {825 onClicked: triggerShoot()
826 rotation: Screen.angleBetween(Screen.primaryOrientation, Screen.orientation)
827 Behavior on rotation {
828 RotationAnimator {
829 duration: UbuntuAnimation.BriskDuration
830 easing: UbuntuAnimation.StandardEasing
831 direction: RotationAnimator.Shortest
832 }
833 }
834
835 function triggerShoot() {
808 if (camera.captureMode == Camera.CaptureVideo && camera.videoRecorder.recorderState == CameraRecorder.RecordingState) {836 if (camera.captureMode == Camera.CaptureVideo && camera.videoRecorder.recorderState == CameraRecorder.RecordingState) {
809 camera.videoRecorder.stop();837 camera.videoRecorder.stop();
810 } else {838 } else {
@@ -815,14 +843,6 @@
815 }843 }
816 }844 }
817 }845 }
818 rotation: Screen.angleBetween(Screen.primaryOrientation, Screen.orientation)
819 Behavior on rotation {
820 RotationAnimator {
821 duration: UbuntuAnimation.BriskDuration
822 easing: UbuntuAnimation.StandardEasing
823 direction: RotationAnimator.Shortest
824 }
825 }
826 }846 }
827847
828 CircleButton {848 CircleButton {
829849
=== modified file 'ViewFinderOverlayLoader.qml'
--- ViewFinderOverlayLoader.qml 2016-01-07 08:03:57 +0000
+++ ViewFinderOverlayLoader.qml 2016-01-26 16:02:22 +0000
@@ -37,4 +37,9 @@
37 Component.onCompleted: {37 Component.onCompleted: {
38 loader.setSource("ViewFinderOverlay.qml", { "camera": loader.camera });38 loader.setSource("ViewFinderOverlay.qml", { "camera": loader.camera });
39 }39 }
40
41 // If the source is set declaratively then the loaded item automatically
42 // get focus if the Loader has focus too. In this case we set the source later
43 // and therefore we need to focus the item explicitly.
44 onLoaded: item.focus = true
40}45}
4146
=== modified file 'ViewFinderView.qml'
--- ViewFinderView.qml 2016-01-14 15:55:52 +0000
+++ ViewFinderView.qml 2016-01-26 16:02:22 +0000
@@ -22,7 +22,7 @@
22import QtGraphicalEffects 1.022import QtGraphicalEffects 1.0
23import Ubuntu.Content 0.123import Ubuntu.Content 0.1
2424
25Item {25FocusScope {
26 id: viewFinderView26 id: viewFinderView
2727
28 property bool overlayVisible: true28 property bool overlayVisible: true
@@ -414,6 +414,7 @@
414 id: viewFinderOverlay414 id: viewFinderOverlay
415415
416 anchors.fill: parent416 anchors.fill: parent
417 focus: true
417 camera: camera418 camera: camera
418 opacity: status == Loader.Ready && overlayVisible && !photoRollHint.enabled ? 1.0 : 0.0419 opacity: status == Loader.Ready && overlayVisible && !photoRollHint.enabled ? 1.0 : 0.0
419 Behavior on opacity {UbuntuNumberAnimation {duration: UbuntuAnimation.SnapDuration}}420 Behavior on opacity {UbuntuNumberAnimation {duration: UbuntuAnimation.SnapDuration}}
420421
=== modified file 'camera-app.qml'
--- camera-app.qml 2016-01-07 08:03:57 +0000
+++ camera-app.qml 2016-01-26 16:02:22 +0000
@@ -77,6 +77,7 @@
77 anchors.fill: parent77 anchors.fill: parent
78 flickableDirection: state == "PORTRAIT" ? Flickable.HorizontalFlick : Flickable.VerticalFlick78 flickableDirection: state == "PORTRAIT" ? Flickable.HorizontalFlick : Flickable.VerticalFlick
79 boundsBehavior: Flickable.StopAtBounds79 boundsBehavior: Flickable.StopAtBounds
80 focus: true
8081
81 property real panesMargin: units.gu(1)82 property real panesMargin: units.gu(1)
82 property real ratio83 property real ratio
@@ -266,6 +267,7 @@
266 galleryView.showLastPhotoTaken();267 galleryView.showLastPhotoTaken();
267 galleryView.precacheThumbnail(filePath);268 galleryView.precacheThumbnail(filePath);
268 }269 }
270 focus: inView
269 }271 }
270272
271 GalleryViewLoader {273 GalleryViewLoader {
@@ -275,6 +277,7 @@
275 inView: viewSwitcher.ratio > 0.0277 inView: viewSwitcher.ratio > 0.0
276 onExit: viewSwitcher.switchToViewFinder()278 onExit: viewSwitcher.switchToViewFinder()
277 opacity: inView ? 1.0 : 0.0279 opacity: inView ? 1.0 : 0.0
280 focus: inView
278 }281 }
279 }282 }
280283

Subscribers

People subscribed via source and target branches