main.qml Example File
jsonreadwrite/assets/main.qml
import bb.cascades 1.0
Page {
Container {
layout: DockLayout {}
ImageView {
imageSource: "asset:///images/background.png"
}
Container {
leftPadding: 30
topPadding: 30
rightPadding: 30
bottomPadding: 30
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
Container {
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
Button {
text: qsTr ("Load JSON")
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
onClicked: {
_app.loadOriginalJson ()
}
}
Button {
text: qsTr ("JSON to Qt")
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
enabled: _app.state > 0
onClicked: {
_app.convertJsonToQt ()
}
}
Button {
text: qsTr ("Qt to JSON")
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
enabled: _app.state > 1
onClicked: {
_app.convertQtToJson ()
}
}
Button {
text: qsTr ("Write & Reload")
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
enabled: _app.state > 2
onClicked: {
_app.writeToJsonFileAndReload ()
}
}
}
Container {
layoutProperties: StackLayoutProperties {
spaceQuota: 2
}
Container {
horizontalAlignment: HorizontalAlignment.Fill
layoutProperties: StackLayoutProperties {
spaceQuota: 5
}
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
Container {
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
Label {
horizontalAlignment: HorizontalAlignment.Center
text: qsTr ("JSON Data")
textStyle {
base: SystemDefaults.TextStyles.BodyText
color: Color.White
textAlign: TextAlign.Center
}
}
TextArea {
id: jsonTextArea
text: _app.jsonData
hintText: ""
textStyle.base: SystemDefaults.TextStyles.SmallText
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
onTextChanged: {
_app.updateJsonDataFromQml (text);
}
}
}
Container {
leftMargin: 20
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
Label {
id: rhsTextLabel
horizontalAlignment: HorizontalAlignment.Center
text: _app.rhsTitle
textStyle {
base: SystemDefaults.TextStyles.BodyText
color: Color.White
textAlign: TextAlign.Center
}
}
Container {
background: Color.create("#66000000")
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
layout: DockLayout {}
TextArea {
id: rhsTextArea
text: _app.rhsText
editable: false
textStyle {
base: SystemDefaults.TextStyles.SmallText
color: Color.White
}
}
}
}
}
Container {
topMargin: 20
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
layout: DockLayout {}
background: Color.create("#66000000")
TextArea {
id: resultsText
text: _app.result
enabled: false
backgroundVisible: false
textStyle {
base: SystemDefaults.TextStyles.SmallText
color: Color.Red
}
}
}
}
}
}
}