main.qml Example File
bpstoqml/assets/main.qml
import bb.cascades 1.0
import bb.cascades.bps 1.0
Page {
content: Container {
attachedObjects: [
BPSMonitor {
id: bpsMonitor
azimuthPitchRollService: AzimuthPitchRollService {
onAzimuthPitchRollData: {
cloud3.rotationZ = roll
cloud2.rotationZ = pitch
cloud1.rotationZ = azimuth
}
}
lightService: LightService {
id: lightService
onIlluminanceData: {
if (illuminance == 0) {
alertSign.opacity = 1;
} else {
var logIlluminance = 1 - Math.pow(illuminance, 1 / 5) / 9.177;
alertSign.opacity = logIlluminance;
}
}
}
virtualKeyboardService: VirtualKeyboardService {
id: virtualKeyboardService
onKeyboardVisible: {
statusBar.translationY = 768 - statusBar.preferredHeight - 300
statusBar.setText("Keyboard Visible");
}
onKeyboardHidden: {
statusBar.translationY = 768 - statusBar.preferredHeight
statusBar.setText("Keyboard Hidden");
}
}
geolocationService: GeolocationService {
id: geolocationService
period: 20
onLocationUpdate: {
statusBar.setText("Location Update: " + latitude + ", " + longitude);
}
}
proximityService: ProximityService {
id: proximityService
property int proximityVal: 1
onProximityData: {
if (proximity != proximityVal) {
proximityVal = proximity;
if (proximityVal == 0) {
statusBar.setText("I need some space!");
} else {
statusBar.setText("Space received, thank-you");
}
}
}
}
}
]
layout: AbsoluteLayout {
}
preferredWidth: 1280
preferredHeight: 768
onCreationCompleted: {
lightService.setEnableSkipDuplicates(true);
}
ImageView {
imageSource: "asset:///images/Sky.png"
}
AlertSign {
id: alertSign
}
ImageView {
id: hills
imageSource: "asset:///images/Hills.png"
translationY: 314.0
}
Container {
preferredHeight: 350
preferredWidth: 1280
layout: DockLayout {
}
Container {
id: cloud1
CloudButton {
imageSource: "asset:///images/Cloud1.png"
shadowImageSource: "asset:///images/Cloud1_shadow.png"
text: "Azimuth"
onSelected: {
alertSign.activate()
statusBar.setText("Azimuth Pressed")
}
}
rotationZ: -10.0
translationX: 19.0
horizontalAlignment: HorizontalAlignment.Left
verticalAlignment: VerticalAlignment.Center
}
CloudButton {
id: cloud2
imageSource: "asset:///images/Cloud2.png"
shadowImageSource: "asset:///images/Cloud2_shadow.png"
text: "Pitch"
rotationZ: 1.0
translationY: 13.0
onSelected: {
alertSign.deactivate()
statusBar.setText("Pitch Pressed")
}
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Top
}
Container {
id: cloud3
CloudButton {
imageSource: "asset:///images/Cloud3.png"
shadowImageSource: "asset:///images/Cloud3_shadow.png"
text: "Roll"
onSelected: {
statusBar.setText("Roll Pressed")
}
}
rotationZ: 28.0
horizontalAlignment: HorizontalAlignment.Right
verticalAlignment: VerticalAlignment.Center
}
}
StatusBar {
id: statusBar
preferredHeight: 150
preferredWidth: 1280
translationY: 768 - statusBar.preferredHeight
}
}
}