Changeset View
Changeset View
Standalone View
Standalone View
src/activities/gletters/Gletters.qml
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 66 | pageComponent: Image { | |||
---|---|---|---|---|---|
71 | 71 | | |||
72 | signal start | 72 | signal start | ||
73 | signal stop | 73 | signal stop | ||
74 | 74 | | |||
75 | // system locale by default | 75 | // system locale by default | ||
76 | property string locale: "system" | 76 | property string locale: "system" | ||
77 | 77 | | |||
78 | Component.onCompleted: { | 78 | Component.onCompleted: { | ||
79 | dialogActivityConfig.getInitialConfiguration() | 79 | dialogActivityConfig.initialize() | ||
80 | activity.start.connect(start) | 80 | activity.start.connect(start) | ||
81 | activity.stop.connect(stop) | 81 | activity.stop.connect(stop) | ||
82 | } | 82 | } | ||
83 | 83 | | |||
84 | QtObject { | 84 | QtObject { | ||
85 | id: items | 85 | id: items | ||
86 | property Item main: activity.main | 86 | property Item main: activity.main | ||
87 | property Item ourActivity: activity | 87 | property Item ourActivity: activity | ||
88 | property GCAudio audioVoices: activity.audioVoices | 88 | property GCAudio audioVoices: activity.audioVoices | ||
89 | property var levels: activity.datasetLoader.item !== null ? activity.datasetLoader.item.data : null | ||||
90 | property string instructionText: "" | ||||
jjazeix: string? | |||||
89 | property alias background: background | 91 | property alias background: background | ||
90 | property alias bar: bar | 92 | property alias bar: bar | ||
91 | property alias bonus: bonus | 93 | property alias bonus: bonus | ||
92 | property alias wordlist: wordlist | 94 | property alias wordlist: wordlist | ||
93 | property alias score: score | 95 | property alias score: score | ||
94 | property alias keyboard: keyboard | 96 | property alias keyboard: keyboard | ||
95 | property alias wordDropTimer: wordDropTimer | 97 | property alias wordDropTimer: wordDropTimer | ||
96 | property GCSfx audioEffects: activity.audioEffects | 98 | property GCSfx audioEffects: activity.audioEffects | ||
97 | property alias locale: background.locale | 99 | property alias locale: background.locale | ||
98 | property alias textinput: textinput | 100 | property alias textinput: textinput | ||
99 | } | 101 | } | ||
100 | 102 | | |||
101 | onStart: { | 103 | onStart: { | ||
102 | Activity.start(items, uppercaseOnly, mode); | 104 | Activity.start(items, uppercaseOnly, mode); | ||
103 | Activity.focusTextInput() | 105 | Activity.focusTextInput() | ||
104 | } | 106 | } | ||
105 | onStop: { Activity.stop() } | 107 | onStop: { Activity.stop() } | ||
106 | 108 | | |||
109 | //instruction rectangle | ||||
110 | Rectangle { | ||||
111 | id: instruction | ||||
112 | anchors { | ||||
113 | top: parent.top | ||||
114 | topMargin: 5 | ||||
115 | horizontalCenter: parent.horizontalCenter | ||||
116 | } | ||||
117 | height: instructionTxt.contentHeight * 1.1 | ||||
118 | width: Math.max(Math.min(parent.width * 0.8, instructionTxt.text.length * 10), parent.width * 0.3) | ||||
parent.width * 0.3 seems to small, can you make it at least half of the screen? jjazeix: parent.width * 0.3 seems to small, can you make it at least half of the screen? | |||||
@jjazeix I tried using 0.5, but it looks to far stretched https://snag.gy/zfLn6A.jpg (using 0.5) https://snag.gy/Bkx1MZ.jpg (using 0.3) what do you say AkshayCHD: @jjazeix I tried using 0.5, but it looks to far stretched https://snag.gy/zfLn6A.jpg (using 0. | |||||
2 points to take in account:
jjazeix: 2 points to take in account:
* how does it render on smaller screens (phones)
* when it is… | |||||
119 | opacity: 0.8 | ||||
120 | visible: items.levels | ||||
121 | radius: 10 | ||||
122 | border.width: 2 | ||||
123 | z: 10 | ||||
124 | border.color: "#DDD" | ||||
125 | color: "#373737" | ||||
126 | | ||||
127 | Behavior on opacity { PropertyAnimation { duration: 200 } } | ||||
128 | | ||||
129 | //shows/hides the Instruction | ||||
130 | MouseArea { | ||||
131 | anchors.fill: parent | ||||
132 | onClicked: instruction.opacity = instruction.opacity == 0 ? 0.8 : 0 | ||||
133 | } | ||||
134 | | ||||
135 | GCText { | ||||
136 | id: instructionTxt | ||||
137 | anchors { | ||||
138 | top: parent.top | ||||
139 | topMargin: 5 | ||||
140 | horizontalCenter: parent.horizontalCenter | ||||
141 | } | ||||
142 | opacity: instruction.opacity | ||||
143 | z: instruction.z | ||||
144 | fontSize: smallSize | ||||
145 | color: "white" | ||||
146 | text: items.instructionText | ||||
147 | horizontalAlignment: Text.AlignHCenter | ||||
148 | width: parent.width * 0.8 | ||||
149 | wrapMode: TextEdit.WordWrap | ||||
150 | } | ||||
151 | } | ||||
152 | | ||||
107 | TextInput { | 153 | TextInput { | ||
108 | // Helper element to capture composed key events like french ô which | 154 | // Helper element to capture composed key events like french ô which | ||
109 | // are not available via Keys.onPressed() on linux. Must be | 155 | // are not available via Keys.onPressed() on linux. Must be | ||
110 | // disabled on mobile! | 156 | // disabled on mobile! | ||
111 | id: textinput | 157 | id: textinput | ||
112 | anchors.centerIn: background | 158 | anchors.centerIn: background | ||
113 | enabled: !ApplicationInfo.isMobile | 159 | enabled: !ApplicationInfo.isMobile | ||
114 | focus: true | 160 | focus: true | ||
115 | visible: false | 161 | visible: false | ||
116 | 162 | | |||
117 | onTextChanged: { | 163 | onTextChanged: { | ||
118 | if (text != "") { | 164 | if (text != "") { | ||
119 | Activity.processKeyPress(text); | 165 | Activity.processKeyPress(text); | ||
120 | text = ""; | 166 | text = ""; | ||
121 | } | 167 | } | ||
122 | } | 168 | } | ||
123 | } | 169 | } | ||
124 | 170 | | |||
125 | //created to retrieve available menu modes for domino configurations | 171 | DialogChooseLevel { | ||
126 | Domino { | | |||
127 | id: invisibleDomino | | |||
128 | visible: false | | |||
129 | } | | |||
130 | | ||||
131 | DialogActivityConfig { | | |||
132 | id: dialogActivityConfig | 172 | id: dialogActivityConfig | ||
133 | currentActivity: activity | 173 | currentActivity: activity.activityInfo | ||
134 | content: Component { | 174 | onClose: { | ||
135 | Item { | 175 | home() | ||
136 | property alias localeBox: localeBox | | |||
137 | property alias dominoModeBox: dominoModeBox | | |||
138 | property alias uppercaseBox: uppercaseBox | | |||
139 | height: column.height | | |||
140 | | ||||
141 | property alias availableLangs: langs.languages | | |||
142 | LanguageList { | | |||
143 | id: langs | | |||
144 | } | | |||
145 | property var availableModes: invisibleDomino.menuModes | | |||
146 | | ||||
147 | Column { | | |||
148 | id: column | | |||
149 | spacing: 10 | | |||
150 | width: parent.width | | |||
151 | Flow { | | |||
152 | spacing: 5 | | |||
153 | width: dialogActivityConfig.width | | |||
154 | GCComboBox { | | |||
155 | id: localeBox | | |||
156 | visible: (activity.activityName == "gletters") | | |||
157 | model: langs.languages | | |||
158 | background: dialogActivityConfig | | |||
159 | label: qsTr("Select your locale") | | |||
160 | } | | |||
161 | GCComboBox { | | |||
162 | id: dominoModeBox | | |||
163 | visible: (activity.activityName == "smallnumbers2") | | |||
164 | model: availableModes | | |||
165 | background: dialogActivityConfig | | |||
166 | label: qsTr("Select Domino mode") | | |||
167 | } | | |||
168 | } | | |||
169 | GCDialogCheckBox { | | |||
170 | id: uppercaseBox | | |||
171 | visible: (activity.activityName == "gletters") | | |||
172 | width: dialogActivityConfig.width | | |||
173 | text: qsTr("Uppercase only mode") | | |||
174 | checked: activity.uppercaseOnly | | |||
175 | } | | |||
176 | } | | |||
177 | } | | |||
178 | } | | |||
179 | | ||||
180 | onClose: home() | | |||
181 | onLoadData: { | | |||
182 | if (activity.activityName == "gletters") { | | |||
183 | if(dataToSave && dataToSave["locale"]) { | | |||
184 | background.locale = dataToSave["locale"]; | | |||
185 | activity.uppercaseOnly = dataToSave["uppercaseMode"] === "true" ? true : false; | | |||
186 | } | | |||
187 | } else if (activity.activityName == "smallnumbers2") { | | |||
188 | if(dataToSave && dataToSave["mode"]) { | | |||
189 | activity.dominoMode = dataToSave["mode"]; | | |||
190 | } | | |||
191 | } | | |||
192 | } | 176 | } | ||
193 | onSaveData: { | 177 | onSaveData: { | ||
194 | var configHasChanged = false | 178 | levelFolder = dialogActivityConfig.chosenLevel | ||
195 | if (activity.activityName == "gletters") { | 179 | currentActivity.currentLevel = dialogActivityConfig.chosenLevel | ||
196 | var oldLocale = background.locale; | 180 | ApplicationSettings.setCurrentLevel(currentActivity.name, dialogActivityConfig.chosenLevel) | ||
197 | var newLocale = dialogActivityConfig.configItem.availableLangs[dialogActivityConfig.loader.item.localeBox.currentIndex].locale; | 181 | home() | ||
198 | // Remove .UTF-8 | 182 | background.stop() | ||
199 | if(newLocale.indexOf('.') != -1) { | 183 | background.start() | ||
200 | newLocale = newLocale.substring(0, newLocale.indexOf('.')) | | |||
201 | } | | |||
202 | | ||||
203 | var oldUppercaseMode = activity.uppercaseOnly | | |||
204 | activity.uppercaseOnly = dialogActivityConfig.configItem.uppercaseBox.checked | | |||
205 | dataToSave = {"locale": newLocale, "uppercaseMode": ""+activity.uppercaseOnly} | | |||
206 | | ||||
207 | background.locale = newLocale; | | |||
208 | if(oldLocale !== newLocale || oldUppercaseMode !== activity.uppercaseOnly) { | | |||
209 | configHasChanged = true; | | |||
210 | } | | |||
211 | } else if (activity.activityName == "smallnumbers2") { | | |||
212 | var newMode = dialogActivityConfig.configItem.availableModes[dialogActivityConfig.configItem.dominoModeBox.currentIndex].value; | | |||
213 | if (newMode !== activity.dominoMode) { | | |||
214 | activity.dominoMode = newMode; | | |||
215 | dataToSave = {"mode": activity.dominoMode}; | | |||
216 | configHasChanged = true; | | |||
217 | } | | |||
218 | } | 184 | } | ||
219 | 185 | onLoadData: { | |||
220 | // Restart the activity with new information | | |||
221 | if(configHasChanged) { | | |||
222 | background.stop(); | | |||
223 | background.start(); | | |||
224 | } | | |||
225 | } | | |||
226 | | ||||
227 | function setDefaultValues() { | | |||
228 | if (activity.activityName == "gletters") { | 186 | if (activity.activityName == "gletters") { | ||
229 | var localeUtf8 = background.locale; | 187 | if(activityData && activityData["locale"]) { | ||
230 | if(background.locale != "system") { | 188 | background.locale = activityData["locale"]; | ||
231 | localeUtf8 += ".UTF-8"; | 189 | activity.uppercaseOnly = activityData["uppercaseMode"] === "true" ? true : false; | ||
232 | } | | |||
233 | | ||||
234 | for(var i = 0 ; i < dialogActivityConfig.configItem.availableLangs.length ; i ++) { | | |||
235 | if(dialogActivityConfig.configItem.availableLangs[i].locale === localeUtf8) { | | |||
236 | dialogActivityConfig.configItem.localeBox.currentIndex = i; | | |||
237 | break; | | |||
238 | } | | |||
239 | } | 190 | } | ||
240 | } else if (activity.activityName == "smallnumbers2") { | 191 | } else if (activity.activityName == "smallnumbers2") { | ||
241 | for(var i = 0 ; i < dialogActivityConfig.configItem.availableModes.length ; i++) { | 192 | if(activityData && activityData["mode"]) { | ||
242 | if(dialogActivityConfig.configItem.availableModes[i].value === activity.dominoMode) { | 193 | activity.dominoMode = activityData["mode"]; | ||
243 | dialogActivityConfig.configItem.dominoModeBox.currentIndex = i; | | |||
244 | break; | | |||
245 | } | 194 | } | ||
246 | } | 195 | } | ||
247 | } | 196 | } | ||
197 | onStartActivity: { | ||||
198 | background.start() | ||||
248 | } | 199 | } | ||
249 | } | 200 | } | ||
250 | 201 | | |||
251 | DialogHelp { | 202 | DialogHelp { | ||
252 | id: dialogHelp | 203 | id: dialogHelp | ||
253 | onClose: home() | 204 | onClose: home() | ||
254 | } | 205 | } | ||
255 | 206 | | |||
256 | Bar { | 207 | Bar { | ||
257 | id: bar | 208 | id: bar | ||
258 | anchors.bottom: keyboard.top | 209 | anchors.bottom: keyboard.top | ||
259 | content: BarEnumContent { value: configurationButtonVisible ? (help | home | level | config) : (help | home | level)} | 210 | content: BarEnumContent { value: help | home | level | activityConfig } | ||
260 | onHelpClicked: { | 211 | onHelpClicked: { | ||
261 | displayDialog(dialogHelp) | 212 | displayDialog(dialogHelp) | ||
262 | } | 213 | } | ||
263 | onPreviousLevelClicked: Activity.previousLevel() | 214 | onPreviousLevelClicked: Activity.previousLevel() | ||
264 | onNextLevelClicked: Activity.nextLevel() | 215 | onNextLevelClicked: Activity.nextLevel() | ||
265 | onHomeClicked: activity.home() | 216 | onHomeClicked: activity.home() | ||
266 | onConfigClicked: { | 217 | onActivityConfigClicked: { | ||
267 | dialogActivityConfig.active = true | | |||
268 | dialogActivityConfig.setDefaultValues() | | |||
269 | displayDialog(dialogActivityConfig) | 218 | displayDialog(dialogActivityConfig) | ||
270 | } | 219 | } | ||
271 | } | 220 | } | ||
272 | 221 | | |||
273 | Bonus { | 222 | Bonus { | ||
274 | id: bonus | 223 | id: bonus | ||
275 | interval: 2000 | 224 | interval: 2000 | ||
276 | Component.onCompleted: win.connect(Activity.nextLevel) | 225 | Component.onCompleted: win.connect(Activity.nextLevel) | ||
Show All 40 Lines |
string?