00001 import QtQuick 1.0
00002 import com.nokia.symbian 1.0
00003
00004 ApplicationWindow {
00005 id: window
00006
00007 function setStateIfFound(target, name) {
00008 for (var i = 0; i < target.states.length; i++) {
00009 var curState = target.states[i];
00010 if(curState.name == name) {
00011 target.state = name
00012 break
00013 }
00014 }
00015 }
00016
00017 ToolBarLayout {
00018 id: commonTools
00019 ToolButton {
00020 flat: true
00021 iconSource: "image://theme/qtg_toolbar_back"
00022 onClicked: pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
00023 }
00024 ToolButton {
00025 flat: true
00026 iconSource: "image://theme/qtg_toolbar_options"
00027 }
00028 }
00029
00030 Page {
00031 id: page
00032 anchors.fill: parent
00033 tools: commonTools
00034
00035 Component.onCompleted: {
00036 if(screen.currentOrientation == Screen.Portrait) {
00037 setStateIfFound(page, "PortraitState")
00038 } else if(screen.currentOrientation == Screen.Landscape) {
00039 setStateIfFound(page, "LandscapeState")
00040 }
00041 }
00042
00043 TextArea {
00044 id: textArea
00045 height: 304
00046 text: "#Text Area"
00047 anchors.top: parent.top
00048 anchors.topMargin: 15
00049 anchors.right: parent.right
00050 anchors.rightMargin: 9
00051 anchors.left: parent.left
00052 anchors.leftMargin: 8
00053 }
00054
00055 Button {
00056 id: button
00057 text: "#Button"
00058 anchors.bottom: button_2.top
00059 anchors.bottomMargin: 31
00060 anchors.right: parent.right
00061 anchors.rightMargin: 77
00062 anchors.left: parent.left
00063 anchors.leftMargin: 70
00064 anchors.top: textArea.bottom
00065 anchors.topMargin: 27
00066 }
00067
00068 Button {
00069 id: button_2
00070 height: 50
00071 text: "#Button"
00072 anchors.bottom: parent.bottom
00073 anchors.bottomMargin: 77
00074 anchors.left: parent.left
00075 anchors.leftMargin: 72
00076 anchors.right: parent.right
00077 anchors.rightMargin: 78
00078 }
00079
00080 Connections {
00081 target: screen
00082 onCurrentOrientationChanged: {
00083 if(screen.currentOrientation == Screen.Portrait) {
00084 page.state = 'PortraitState'
00085 }
00086 if(screen.currentOrientation == Screen.Landscape) {
00087 page.state = 'LandscapeState'
00088 }
00089 }
00090 }
00091
00092 states: [
00093 State {
00094 name: "PortraitState"
00095
00096 PropertyChanges {
00097 width: 321
00098 target: textArea
00099 }
00100
00101 AnchorChanges {
00102 target: textArea
00103 anchors.left: parent.undefined
00104 }
00105 },
00106 State {
00107 name: "LandscapeState"
00108
00109 PropertyChanges {
00110 target: textArea
00111 height: 228
00112 anchors.rightMargin: 357
00113 }
00114
00115 PropertyChanges {
00116 target: button_2
00117 anchors.rightMargin: 60
00118 anchors.leftMargin: 412
00119 }
00120 }
00121 ]
00122 }
00123 Component.onCompleted: pageStack.push(page)
00124 }