main.qml Example File
barcodereader/assets/main.qml
import bb.cascades 1.0
import bb.cascades.multimedia 1.0
import bb.multimedia 1.0
Page {
id: page
Container {
background: Color.Black
layout: DockLayout {}
Camera {
id: camera
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
onCameraOpened: {
getSettings(cameraSettings)
cameraSettings.focusMode = CameraFocusMode.ContinuousAuto
cameraSettings.shootingMode = CameraShootingMode.Stabilization
applySettings(cameraSettings)
camera.startViewfinder()
}
attachedObjects: [
BarcodeDetector {
id: barcodeDetector
camera: camera
formats: BarcodeFormat.Any
onDetected: {
if (resultLabel.text != data) {
resultLabel.text = data;
resultArea.visible = true;
scannedSound.play()
}
}
},
SystemSound {
id: scannedSound
sound: SystemSound.GeneralNotification
},
CameraSettings {
id: cameraSettings
}
]
}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/overlay.png"
}
Container {
id: resultArea
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Top
layout: DockLayout {}
visible: false
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/result_background.png"
}
Label {
id: resultLabel
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
textStyle {
base: SystemDefaults.TextStyles.TitleText
color: Color.White
textAlign: TextAlign.Center
}
multiline: true
}
}
ImageView {
id: topCover
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Top
imageSource: "asset:///images/top_cover.png"
onTouch: {
if (event.isDown())
startupAnimation.play()
}
}
ImageView {
id: bottomCover
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Bottom
imageSource: "asset:///images/bottom_cover.png"
onTouch: {
if (event.isDown())
startupAnimation.play()
}
}
animations: ParallelAnimation {
id: startupAnimation
SequentialAnimation {
target: topCover
TranslateTransition {
fromY: 0
toY: -640
duration: 1250
easingCurve: StockCurve.QuarticInOut
}
}
SequentialAnimation {
target: bottomCover
TranslateTransition {
fromY: 0
toY: 680
duration: 1250
easingCurve: StockCurve.QuarticInOut
}
}
onStarted: {
camera.open()
}
}
}
}