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
1=== modified file 'ViewFinderOverlay.qml'
2--- ViewFinderOverlay.qml 2016-01-11 15:07:58 +0000
3+++ ViewFinderOverlay.qml 2016-01-26 16:02:22 +0000
4@@ -38,6 +38,24 @@
5 focusRing.show();
6 }
7
8+ readonly property var mediaKeys: [
9+ Qt.Key_MediaPlay, Qt.Key_MediaStop, Qt.Key_MediaPrevious,
10+ Qt.Key_MediaNext, Qt.Key_MediaRecord, Qt.Key_MediaPause,
11+ Qt.Key_MediaTogglePlayPause,
12+ // Note that Qt.Key_VolumeUp and Qt.Key_VolumeDown are not handled as
13+ // they conflict with the hardware volume buttons on the device.
14+ // We also handle the following media keysyms which are not mapped in
15+ // the Qt namespace but are emitted by selfie sticks and defined in xkbcommon-keysyms.h:
16+ // XKB_KEY_XF86AudioPlay, XKB_KEY_XF86AudioStop, XKB_KEY_XF86AudioPrev,
17+ // XKB_KEY_XF86AudioNext, XKB_KEY_XF86AudioPause, XKB_KEY_XF86AudioMedia
18+ // XKB_KEY_XF86AudioLowerVolume, XKB_KEY_XF86AudioRaiseVolume
19+ 0x1008FF14, 0x1008FF15, 0x1008FF16,
20+ 0x1008FF17, 0x1008FF31, 0x1008FF32,
21+ 0x1008FF11, 0x1008FF13,
22+ ]
23+
24+ Keys.onPressed: if (mediaKeys.indexOf(event.key) != -1) shootButton.triggerShoot()
25+
26 Settings {
27 id: settings
28
29@@ -804,7 +822,17 @@
30 state: (camera.captureMode == Camera.CaptureVideo) ?
31 ((camera.videoRecorder.recorderState == CameraRecorder.StoppedState) ? "record_off" : "record_on") :
32 "camera"
33- onClicked: {
34+ onClicked: triggerShoot()
35+ rotation: Screen.angleBetween(Screen.primaryOrientation, Screen.orientation)
36+ Behavior on rotation {
37+ RotationAnimator {
38+ duration: UbuntuAnimation.BriskDuration
39+ easing: UbuntuAnimation.StandardEasing
40+ direction: RotationAnimator.Shortest
41+ }
42+ }
43+
44+ function triggerShoot() {
45 if (camera.captureMode == Camera.CaptureVideo && camera.videoRecorder.recorderState == CameraRecorder.RecordingState) {
46 camera.videoRecorder.stop();
47 } else {
48@@ -815,14 +843,6 @@
49 }
50 }
51 }
52- rotation: Screen.angleBetween(Screen.primaryOrientation, Screen.orientation)
53- Behavior on rotation {
54- RotationAnimator {
55- duration: UbuntuAnimation.BriskDuration
56- easing: UbuntuAnimation.StandardEasing
57- direction: RotationAnimator.Shortest
58- }
59- }
60 }
61
62 CircleButton {
63
64=== modified file 'ViewFinderOverlayLoader.qml'
65--- ViewFinderOverlayLoader.qml 2016-01-07 08:03:57 +0000
66+++ ViewFinderOverlayLoader.qml 2016-01-26 16:02:22 +0000
67@@ -37,4 +37,9 @@
68 Component.onCompleted: {
69 loader.setSource("ViewFinderOverlay.qml", { "camera": loader.camera });
70 }
71+
72+ // If the source is set declaratively then the loaded item automatically
73+ // get focus if the Loader has focus too. In this case we set the source later
74+ // and therefore we need to focus the item explicitly.
75+ onLoaded: item.focus = true
76 }
77
78=== modified file 'ViewFinderView.qml'
79--- ViewFinderView.qml 2016-01-14 15:55:52 +0000
80+++ ViewFinderView.qml 2016-01-26 16:02:22 +0000
81@@ -22,7 +22,7 @@
82 import QtGraphicalEffects 1.0
83 import Ubuntu.Content 0.1
84
85-Item {
86+FocusScope {
87 id: viewFinderView
88
89 property bool overlayVisible: true
90@@ -414,6 +414,7 @@
91 id: viewFinderOverlay
92
93 anchors.fill: parent
94+ focus: true
95 camera: camera
96 opacity: status == Loader.Ready && overlayVisible && !photoRollHint.enabled ? 1.0 : 0.0
97 Behavior on opacity {UbuntuNumberAnimation {duration: UbuntuAnimation.SnapDuration}}
98
99=== modified file 'camera-app.qml'
100--- camera-app.qml 2016-01-07 08:03:57 +0000
101+++ camera-app.qml 2016-01-26 16:02:22 +0000
102@@ -77,6 +77,7 @@
103 anchors.fill: parent
104 flickableDirection: state == "PORTRAIT" ? Flickable.HorizontalFlick : Flickable.VerticalFlick
105 boundsBehavior: Flickable.StopAtBounds
106+ focus: true
107
108 property real panesMargin: units.gu(1)
109 property real ratio
110@@ -266,6 +267,7 @@
111 galleryView.showLastPhotoTaken();
112 galleryView.precacheThumbnail(filePath);
113 }
114+ focus: inView
115 }
116
117 GalleryViewLoader {
118@@ -275,6 +277,7 @@
119 inView: viewSwitcher.ratio > 0.0
120 onExit: viewSwitcher.switchToViewFinder()
121 opacity: inView ? 1.0 : 0.0
122+ focus: inView
123 }
124 }
125

Subscribers

People subscribed via source and target branches