Use a series of property change notifications and bindings to derive the animation/
The PauseAnimation {} is needed because the dimmer doesn't fully dim without it :(
property int policyMode: CameraResources.None
property Camera cam: null
+ property Item dimmer: null
+
property bool controlsVisible: cam.running && !standby.visible
property bool zoomVisible: true
property bool modesVisible: true
}
BatteryInfo {
+ // TODO: replace this
id: batteryMonitor
monitorChargingStateChanges: cam.running
monitorBatteryStatusChanges: cam.running
height: 75
opacity: 0.5
onClicked: captureImage();
- visible: imageMode.canCapture && !cameraMode.animationRunning && !previewAnimationRunning && cam.running
+ visible: imageMode.canCapture && !cameraMode.busy && dimmer.opacity == 0.0 && !previewAnimationRunning && cam.running
onExited: {
if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
Item {
id: controller
- property int mode: settings.mode
property Camera cam: null
property Item dimmer: null
- property alias animationRunning: animation.running
+ property bool busy: cam.mode != settings.mode
- SequentialAnimation {
- id: animation
- property int mode: Camera.UnknownMode
-
- function setMode() {
- root.resetCamera(cam.deviceId, mode);
- }
-
- NumberAnimation { target: dimmer; property: "opacity"; from: 0; to: 1; duration: 150; alwaysRunToEnd: true }
-
- PauseAnimation { duration: 50 }
-
- ParallelAnimation {
- ScriptAction { script: animation.setMode(); }
- PauseAnimation { duration: 200 }
+ onBusyChanged: {
+ if (busy) {
+ controller.dimmer.dimmed = true;
}
-
- PauseAnimation { duration: 50 }
-
- NumberAnimation { target: dimmer; property: "opacity"; from: 1; to: 0; duration: 150; alwaysRunToEnd: true }
}
- onModeChanged: {
- if (!cam || cam.mode == mode) {
- return;
+ Connections {
+ target: controller.cam
+ onModeChanged: {
+ controller.dimmer.dimmed = false;
}
+ }
- animation.mode = mode;
+ PauseAnimation {
+ id: pause
+ duration: 50
+ running: controller.dimmer.opacity == 1.0 && controller.busy
- animation.start();
+ onRunningChanged: {
+ if (!running && controller.busy) {
+ root.resetCamera(cam.deviceId, settings.mode);
+ }
+ }
}
}
policyMode: CameraResources.Recording
- controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !error
+ controlsVisible: cam.running && videoMode.recording && !error
orientationLock: PageOrientation.LockLandscape
policyMode: CameraResources.Video
- controlsVisible: cam.running && !videoMode.recording && videoMode.canCapture && !cameraMode.animationRunning && !previewAnimationRunning
+ controlsVisible: cam.running && !videoMode.recording && videoMode.canCapture && !cameraMode.busy && dimmer.opacity == 0.0 && !previewAnimationRunning
orientationLock: PageOrientation.LockLandscape
function startRecording() {
}
function replacePage(file) {
- pageStack.replace(Qt.resolvedUrl(file), {cam: cam}, true);
+ pageStack.replace(Qt.resolvedUrl(file), {cam: cam, dimmer: root.dimmer}, true);
}
function openFile(file) {
- pageStack.push(Qt.resolvedUrl(file), {cam: cam});
+ pageStack.push(Qt.resolvedUrl(file), {cam: cam, dimmer: root.dimmer});
}
function openFileNow(file) {
- pageStack.push(Qt.resolvedUrl(file), {cam: cam}, true);
+ pageStack.push(Qt.resolvedUrl(file), {cam: cam, dimmer: root.dimmer}, true);
}
platformStyle: PageStackWindowStyle {
z: -1
Rectangle {
+ property bool dimmed: false
id: camDimmer
z: 1
anchors.fill: parent
- opacity: 0
+ opacity: dimmed ? 1.0 : 0.0
color: "black"
+ Behavior on opacity {
+ PropertyAnimation { duration: 150 }
+ }
}
notifications: Sounds {