Changeset View
Changeset View
Standalone View
Standalone View
src/activities/solar_system/SolarSystem.qml
Show All 30 Lines | 26 | ActivityBase { | |||
---|---|---|---|---|---|
31 | } | 31 | } | ||
32 | onStop: {} | 32 | onStop: {} | ||
33 | 33 | | |||
34 | pageComponent: Rectangle { | 34 | pageComponent: Rectangle { | ||
35 | id: background | 35 | id: background | ||
36 | anchors.fill: parent | 36 | anchors.fill: parent | ||
37 | property bool horizontalLayout: background.width >= background.height | 37 | property bool horizontalLayout: background.width >= background.height | ||
38 | 38 | | |||
39 | property bool keyNavigation: false | ||||
40 | | ||||
39 | Image { | 41 | Image { | ||
40 | id: stars | 42 | id: stars | ||
41 | fillMode: Image.PreserveAspectCrop | 43 | fillMode: Image.PreserveAspectCrop | ||
42 | source: "qrc:/gcompris/src/activities/solar_system/resource/background.svg" | 44 | source: "qrc:/gcompris/src/activities/solar_system/resource/background.svg" | ||
43 | width: horizontalLayout ? parent.width * 2.5 : parent.height * 2.5 | 45 | width: horizontalLayout ? parent.width * 2.5 : parent.height * 2.5 | ||
44 | height: stars.width | 46 | height: stars.width | ||
45 | sourceSize.width: stars.width | 47 | sourceSize.width: stars.width | ||
46 | sourceSize.height: stars.width | 48 | sourceSize.height: stars.width | ||
Show All 36 Lines | |||||
83 | 85 | | |||
84 | onStart: { | 86 | onStart: { | ||
85 | dialogActivityConfig.getInitialConfiguration() | 87 | dialogActivityConfig.getInitialConfiguration() | ||
86 | Activity.start(items) | 88 | Activity.start(items) | ||
87 | } | 89 | } | ||
88 | 90 | | |||
89 | onStop: Activity.stop() | 91 | onStop: Activity.stop() | ||
90 | 92 | | |||
93 | Keys.onPressed: { | ||||
94 | background.keyNavigation = true | ||||
95 | if(event.key === Qt.Key_Space) { | ||||
96 | Activity.showQuizScreen(planetView.currentIndex) | ||||
97 | event.accepted = true | ||||
98 | } | ||||
99 | if(event.key === Qt.Key_Enter) { | ||||
100 | Activity.showQuizScreen(planetView.currentIndex) | ||||
101 | event.accepted = true | ||||
102 | } | ||||
103 | if(event.key === Qt.Key_Return) { | ||||
104 | Activity.showQuizScreen(planetView.currentIndex) | ||||
105 | event.accepted = true | ||||
106 | } | ||||
107 | if(event.key === Qt.Key_Left) { | ||||
108 | planetView.moveCurrentIndexLeft() | ||||
109 | event.accepted = true | ||||
110 | } | ||||
111 | if(event.key === Qt.Key_Right) { | ||||
112 | planetView.moveCurrentIndexRight() | ||||
113 | event.accepted = true | ||||
114 | } | ||||
115 | if(event.key === Qt.Key_Up) { | ||||
116 | planetView.moveCurrentIndexUp() | ||||
117 | event.accepted = true | ||||
118 | } | ||||
119 | if(event.key === Qt.Key_Down) { | ||||
120 | planetView.moveCurrentIndexDown() | ||||
121 | event.accepted = true | ||||
122 | } | ||||
123 | } | ||||
124 | | ||||
91 | IntroMessage { | 125 | IntroMessage { | ||
92 | id: message | 126 | id: message | ||
93 | anchors { | 127 | anchors { | ||
94 | top: parent.top | 128 | top: parent.top | ||
95 | topMargin: 10 | 129 | topMargin: 10 | ||
96 | right: parent.right | 130 | right: parent.right | ||
97 | rightMargin: 5 | 131 | rightMargin: 5 | ||
98 | left: parent.left | 132 | left: parent.left | ||
Show All 27 Lines | |||||
126 | 160 | | |||
127 | readonly property int itemWidth: horizontalLayout ? background.width * 0.11 : (background.height - bar.height) * 0.11 | 161 | readonly property int itemWidth: horizontalLayout ? background.width * 0.11 : (background.height - bar.height) * 0.11 | ||
128 | 162 | | |||
129 | // Arrangement of all the planets in the solar system | 163 | // Arrangement of all the planets in the solar system | ||
130 | GridView { | 164 | GridView { | ||
131 | id: planetView | 165 | id: planetView | ||
132 | layoutDirection: Qt.LeftToRight | 166 | layoutDirection: Qt.LeftToRight | ||
133 | verticalLayoutDirection: GridView.BottomToTop | 167 | verticalLayoutDirection: GridView.BottomToTop | ||
134 | clip: false | 168 | clip: true | ||
135 | interactive: false | 169 | interactive: false | ||
136 | visible: items.solarSystemVisible | 170 | visible: items.solarSystemVisible | ||
137 | cellWidth: background.itemWidth | 171 | cellWidth: background.itemWidth | ||
138 | cellHeight: cellWidth | 172 | cellHeight: cellWidth | ||
139 | model: planetsModel | 173 | model: planetsModel | ||
140 | 174 | | |||
175 | highlight: Rectangle { | ||||
176 | width: planetView.width | ||||
177 | height: planetView.height | ||||
178 | color: "red" | ||||
179 | radius: 5 | ||||
180 | visible: background.keyNavigation | ||||
181 | Behavior on y { | ||||
182 | SpringAnimation { | ||||
183 | spring: 3 | ||||
184 | damping: 0.2 | ||||
185 | } | ||||
186 | } | ||||
187 | } | ||||
188 | | ||||
189 | highlightFollowsCurrentItem: true | ||||
190 | focus: true | ||||
191 | keyNavigationWraps: true | ||||
192 | | ||||
193 | | ||||
141 | delegate: PlanetInSolarModel { | 194 | delegate: PlanetInSolarModel { | ||
142 | planetImageSource: realImg | 195 | planetImageSource: realImg | ||
143 | planetName: bodyName | 196 | planetName: bodyName | ||
144 | planetSize: bodySize | 197 | planetSize: bodySize | ||
145 | } | 198 | } | ||
146 | } | 199 | } | ||
147 | states: [ | 200 | states: [ | ||
148 | State { | 201 | State { | ||
▲ Show 20 Lines • Show All 254 Lines • Show Last 20 Lines |