Skip to content

Commit

Permalink
MID DEV : screen flash feature (camera-app ubports#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
dark-eye committed Nov 11, 2017
1 parent 0aa5552 commit d0aff30
Show file tree
Hide file tree
Showing 7 changed files with 270 additions and 8 deletions.
1 change: 1 addition & 0 deletions OptionValueButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ AbstractButton {

property alias label: label.text
property alias iconName: icon.name
property alias iconSource: icon.source
property bool selected
property bool isLast
property int columnWidth
Expand Down
1 change: 1 addition & 0 deletions OptionsOverlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Item {

label: (model && model.label) ? i18n.tr(model.label) : ""
iconName: (model && model.icon) ? model.icon : ""
iconSource: (model && model.iconSource) ? model.iconSource : ""
selected: optionValueSelector.model.selectedIndex == index

isLast: index === optionValueSelector.count - 1
Expand Down
49 changes: 45 additions & 4 deletions ViewFinderOverlay.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Item {
id: settings

property int flashMode: Camera.FlashAuto
property bool screenFlash: false
property bool gpsEnabled: false
property bool hdrEnabled: false
property int videoFlashMode: Camera.FlashOff
Expand Down Expand Up @@ -389,6 +390,29 @@ Item {
value: Camera.FlashOff
}
},
ListModel {
id: screenFlashOptionsModel

property string settingsProperty: "screenFlash"
property string icon: ""
property string label: ""
property bool isToggle: true
property int selectedIndex: bottomEdge.indexForValue(screenFlashOptionsModel, settings.screenFlash)
property bool available: (!camera.advanced.hasFlash && camera.position === Camera.FrontFace)
property bool visible: camera.captureMode == Camera.CaptureStillImage
property bool showInIndicators: true

ListElement {
iconSource: "assets/screen_flash_on.png"
label: QT_TR_NOOP("On")
value: true
}
ListElement {
iconSource: "assets/screen_flash_off.png"
label: QT_TR_NOOP("Off")
value: false
}
},
ListModel {
id: videoFlashOptionsModel

Expand Down Expand Up @@ -691,6 +715,24 @@ Item {
timedShootFeedback.stop();
}
}
function prepareShoot() {
shootFeedback.start();
if (camera.captureMode == Camera.CaptureStillImage && shootFeedback.shouldFlash) {
// TODO this should be using 'camera.exposure.shutterSpeed' but currently it just returns -1.
// console.log(camera.exposure.shutterSpeed * 1000);
shootTimer.interval = 150;
} else {
shootTimer.interval = 0;
}
}

Timer {
id:shootTimer
interval: 0
repeat: false
running: false
onTriggered: controls.shoot();
}

function shoot() {
var orientation = 0;
Expand Down Expand Up @@ -740,9 +782,7 @@ Item {
camera.videoRecorder.record();
}
} else {
if (!main.contentExportMode) {
shootFeedback.start();
}

camera.photoCaptureInProgress = true;
camera.imageCapture.setMetadata("Orientation", orientation);
camera.imageCapture.setMetadata("Date", new Date());
Expand Down Expand Up @@ -885,7 +925,8 @@ Item {
if (settings.selfTimerDelay > 0) {
controls.timedShoot(settings.selfTimerDelay);
} else {
controls.shoot();
controls.prepareShoot();
shootTimer.start();
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions ViewFinderView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -387,23 +387,29 @@ FocusScope {
Rectangle {
id: shootFeedback
anchors.fill: parent
color: "black"
property bool shouldFlash : ( !camera.advanced.hasFlash
&& camera.position === Camera.FrontFace
&& viewFinderOverlay.settings.screenFlash )
color: shouldFlash ? "white" : "black"
visible: opacity != 0.0
opacity: 0.0

function start() {
shootFeedback.opacity = 1.0;
shootFeedbackAnimation.restart();
if (!main.contentExportMode) {
shootFeedback.opacity = 1.0;
shootFeedbackAnimation.restart();
}
}

OpacityAnimator {
id: shootFeedbackAnimation
target: shootFeedback
from: 1.0
to: 0.0
duration: UbuntuAnimation.SnapDuration
duration: UbuntuAnimation.BriskDuration
easing: UbuntuAnimation.StandardEasing
}

}
}

Expand Down
213 changes: 213 additions & 0 deletions assets/screen_flash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screen_flash_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screen_flash_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d0aff30

Please sign in to comment.