• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kanagram

  • sources
  • kde-4.14
  • kdeedu
  • kanagram
  • src
  • package
  • contents
  • ui
Blackboard.qml
Go to the documentation of this file.
1 /******************************************************************************
2  * This file is part of the Kanagram project
3  * Copyright 2014 Debjit Mondal <debjitmondal05@gmail.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 import QtQuick 1.1
21 
22 Rectangle {
23 
24  id:blackboard
25  radius:4
26  property alias anagramText:anagram.text;
27  property alias hint:anagramHint.text;
28  property alias showHintTimeInterval:hintButton.countDownTimerValue;
29  property alias activeTimer:scoreTimer.running;
30  property alias totalScore:score.text;
31 
32  Item {
33  width: parent.width
34  height: parent.height
35 
36  Image {
37  id: background
38  smooth:true
39  anchors.fill: parent
40  source: "../ui/images/chalkboard.png"
41  }
42  }
43 
44  Rectangle {
45  id: categoryBar
46  width: parent.width; height: parent.height/5
47  opacity: .25
48  color: "black"
49  anchors.top: parent.top
50  }
51 
52  Text{
53  id:categoryName
54  anchors{verticalCenter: categoryBar.verticalCenter;horizontalCenter: categoryBar.horizontalCenter }
55  color:"white"
56  text: kanagramEngineHelper.categoryName();
57  font.pixelSize: parent.width/19.5
58  }
59 
60  Image{
61  id:nextVocabularyButton
62  smooth:true
63  opacity:0.5
64  height:categoryBar.height/2
65  anchors{verticalCenter: categoryBar.verticalCenter;left:categoryName.right;leftMargin:parent.width/20}
66  source: "../ui/icons/right-arrow.png"
67  fillMode: Image.PreserveAspectFit
68 
69  MouseArea {
70  anchors.fill: parent
71  hoverEnabled: true
72  onEntered:nextVocabularyButton.state="onEntered"
73  onExited:nextVocabularyButton.state="onExited"
74  onClicked:{
75  if(blackboard.activeTimer)
76  {
77  kanagramEngineHelper.increaseScore(kanagramEngineHelper.skippedWordScore());
78  blackboard.totalScore=i18n("Score : ")+kanagramEngineHelper.totalScore();
79  }
80  categoryName.text=kanagramEngineHelper.nextVocabulary();
81  anagram.text=kanagramEngineHelper.createNextAnagram();
82  anagramHint.text=kanagramEngineHelper.showHint();
83  if(kanagramEngineHelper.hintHideTime())
84  hintButton.countDownTimerValue=1;
85  }
86  }
87 
88  states: State {
89  name: "onEntered"
90  PropertyChanges {
91  target: nextVocabularyButton
92  opacity:1
93  }
94  }
95  State{
96  name:"onExited"
97  }
98 
99  transitions: Transition {
100  PropertyAnimation { properties: "x,y,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
101  }
102  }
103 
104  Image{
105  id:previousVocabularyButton
106  smooth:true
107  opacity:0.5
108  height:categoryBar.height/2
109  anchors{verticalCenter: categoryBar.verticalCenter;right:categoryName.left;rightMargin:parent.width/20}
110  source: "../ui/icons/left-arrow.png"
111  fillMode: Image.PreserveAspectFit
112 
113  MouseArea {
114  anchors.fill: parent
115  hoverEnabled: true
116  onEntered:previousVocabularyButton.state="onEntered"
117  onExited:previousVocabularyButton.state="onExited"
118  onClicked:{
119  if(blackboard.activeTimer)
120  {
121  kanagramEngineHelper.increaseScore(kanagramEngineHelper.skippedWordScore());
122  blackboard.totalScore=i18n("Score : ")+kanagramEngineHelper.totalScore();
123  }
124  categoryName.text=kanagramEngineHelper.previousVocabulary();
125  anagram.text=kanagramEngineHelper.createNextAnagram();
126  anagramHint.text=kanagramEngineHelper.showHint();
127  if(kanagramEngineHelper.hintHideTime())
128  hintButton.countDownTimerValue=1;
129  }
130  }
131 
132  states: State {
133  name: "onEntered"
134  PropertyChanges {
135  target: previousVocabularyButton
136  opacity:1
137  }
138  }
139  State{
140  name:"onExited"
141  }
142 
143  transitions: Transition {
144  PropertyAnimation { properties: "x,y,opacity"; easing.type: Easing.Linear;easing.amplitude: 5.0;easing.period: 1 }
145  }
146  }
147 
148  Text{
149  id:anagram
150  text:kanagramEngineHelper.createNextAnagram();
151  anchors{verticalCenter: parent.verticalCenter;horizontalCenter: parent.horizontalCenter}
152  color:"white"
153  font.pixelSize: parent.width/12.5
154  }
155 
156  Rectangle {
157  id: optionsBar
158  width: parent.width; height: parent.height/5
159  opacity: .25
160  color: "black"
161  anchors.bottom: parent.bottom
162  }
163 
164  Image{
165  id:timerButton
166  smooth:true
167  height:optionsBar.height
168  anchors{verticalCenter: optionsBar.verticalCenter;left:optionsBar.left}
169  source: "../ui/icons/timer.png"
170  fillMode: Image.PreserveAspectFit
171  property int countDownTimerValue:0;
172  property bool flagToggleTimer:false;
173 
174  MouseArea {
175  anchors.fill: parent
176  hoverEnabled: true
177  onEntered:timerButton.state="onEntered"
178  onExited:timerButton.state="onExited"
179  onClicked:{
180  if(!timerButton.flagToggleTimer)
181  {
182  timerButton.countDownTimerValue=kanagramEngineHelper.scoreTime();
183  scoreTimer.repeat=true;
184  scoreTimer.start();
185  kanagramEngineHelper.resetTotalScore();
186  score.text=i18n("Score : ")+kanagramEngineHelper.totalScore(0);
187  scoreSection.opacity=0.35;
188  score.opacity=1;
189  timerText.text=i18n("Stop Timer")
190  timerButton.flagToggleTimer=true;
191  }
192  else
193  {
194  timerButton.countDownTimerValue = 1;
195  timerButton.flagToggleTimer=false;
196  }
197  }
198  }
199 
200  states: State {
201  name: "onEntered"
202  PropertyChanges {
203  target: timerText
204  opacity:1
205  }
206  PropertyChanges {
207  target: timerBar
208  opacity:0.25
209  }
210  }
211  State{
212  name:"onExited"
213  }
214 
215  transitions: Transition {
216  PropertyAnimation { properties: "x,y,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
217  }
218  }
219 
220  Timer {
221  id: scoreTimer;
222  interval: 1000;
223  repeat: true;
224  running: false;
225  triggeredOnStart: false;
226 
227  onTriggered: {
228  if (--timerButton.countDownTimerValue == 0) {
229  stop();
230  timerSection.opacity=0;
231  timeRemaining.opacity=0;
232  scoreTimer.running=false;
233  timerText.text=i18n("Start Timer");
234  }
235  else{
236  scoreTimer.running=true;
237  timerSection.opacity=0.35;
238  if(timerButton.countDownTimerValue>9)
239  {
240  timeRemaining.text='00:'+timerButton.countDownTimerValue;
241  }
242  else
243  {
244  timeRemaining.text='00:0'+timerButton.countDownTimerValue;
245  }
246  timeRemaining.opacity=1;
247  }
248  }
249  }
250 
251  Rectangle {
252  id: timerBar
253  width: parent.width/6; height: parent.height/15
254  opacity: 0
255  radius: 4
256  color: "black"
257  anchors{bottom:optionsBar.top;horizontalCenter: timerButton.horizontalCenter}
258  }
259 
260  Text{
261  id:timerText
262  anchors{verticalCenter: timerBar.verticalCenter;horizontalCenter:timerBar.horizontalCenter}
263  color:"white"
264  text: i18n("Start Timer")
265  opacity: 0
266  font.pixelSize: parent.width/40
267  }
268 
269  Image{
270  id: hintButton
271  smooth:true
272  height:optionsBar.height
273  anchors{verticalCenter: optionsBar.verticalCenter;horizontalCenter:optionsBar.horizontalCenter}
274  source: "../ui/icons/hint.png"
275  fillMode: Image.PreserveAspectFit
276  property int countDownTimerValue:0;
277 
278  MouseArea {
279  anchors.fill: parent
280  hoverEnabled: true
281  onEntered:hintButton.state="onEntered"
282  onExited:hintButton.state="onExited"
283  onClicked:{
284  hintButton.countDownTimerValue = kanagramEngineHelper.hintHideTime();
285  hintTimer.repeat=true;
286  hintTimer.start();
287  }
288  }
289 
290  states: State {
291  name: "onEntered"
292  PropertyChanges {
293  target: hintText
294  opacity:1
295  }
296  PropertyChanges {
297  target: hintBar
298  opacity:0.25
299  }
300  }
301 
302  State{
303  name:"onExited"
304  }
305 
306  transitions: Transition {
307  PropertyAnimation { properties: "x,y,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
308  }
309  }
310 
311  Rectangle{
312  id: timerSection
313  width:blackboard.width/9;height:blackboard.height/7
314  anchors{top:blackboard.top;topMargin:blackboard.height/7;right: blackboard.left;rightMargin:blackboard.width/68.5}
315  color:"black"
316  opacity:0
317  }
318 
319  Text{
320  id:timeRemaining
321  anchors{verticalCenter: timerSection.verticalCenter;horizontalCenter:timerSection.horizontalCenter}
322  opacity:0
323  text: i18n(" ")
324  color:"white"
325  font.pixelSize: parent.width/32
326  }
327 
328  Rectangle {
329  id: hintSection
330  width: parent.width/3; height: parent.height/3
331  opacity:0
332  color: "black"
333  anchors{verticalCenter: blackboard.verticalCenter;right: blackboard.left;rightMargin:blackboard.width/68.5}
334  }
335 
336  Text{
337  id:anagramHint
338  anchors{verticalCenter: hintSection.verticalCenter;horizontalCenter:hintSection.horizontalCenter}
339  color:"white"
340  width:hintSection.width
341  wrapMode: Text.WordWrap
342  text: kanagramEngineHelper.showHint();
343  opacity:0
344  font.pixelSize: hintSection.width/10
345  }
346 
347  Timer {
348  id: hintTimer;
349  interval: 1000;
350  repeat: true;
351  running: false;
352  triggeredOnStart: false;
353 
354  onTriggered: {
355  if (--hintButton.countDownTimerValue == 0) {
356  hintSection.opacity=0;
357  anagramHint.opacity=0;
358  stop();
359  }
360  else{
361  hintSection.opacity=0.35;
362  anagramHint.opacity=1;
363  }
364  }
365  }
366 
367  Rectangle {
368  id: hintBar
369  width: parent.width/6; height: parent.height/15
370  opacity: 0
371  radius: 4
372  color: "black"
373  anchors{bottom:optionsBar.top;horizontalCenter: hintButton.horizontalCenter}
374  }
375 
376  Text{
377  id:hintText
378  anchors{verticalCenter: hintBar.verticalCenter;horizontalCenter:hintBar.horizontalCenter}
379  color:"white"
380  text: i18n("Hint")
381  opacity: 0
382  font.pixelSize: parent.width/40
383  }
384 
385  Rectangle{
386  id: scoreSection
387  width:blackboard.width/5;height:blackboard.height/7
388  anchors{bottom:blackboard.bottom;bottomMargin:blackboard.height/7;right: blackboard.left;rightMargin:blackboard.width/68.5}
389  color:"black"
390  opacity:0
391  }
392 
393  Text{
394  id:score
395  anchors{verticalCenter: scoreSection.verticalCenter;horizontalCenter:scoreSection.horizontalCenter}
396  color:"white"
397  text: i18n("Score : ")+kanagramEngineHelper.totalScore();
398  opacity:0
399  font.pixelSize: parent.width/40
400  }
401 
402  Image{
403  id: revealButton
404  smooth:true
405  height:optionsBar.height
406  anchors{verticalCenter: optionsBar.verticalCenter;right:optionsBar.right}
407  source: "../ui/icons/reveal.png"
408  fillMode: Image.PreserveAspectFit
409  property int countDownTimerValue:0
410 
411  MouseArea {
412  anchors.fill: parent
413  hoverEnabled: true
414  onEntered:revealButton.state="onEntered"
415  onExited:revealButton.state="onExited";
416  onClicked:{
417  anagram.text=kanagramEngineHelper.anagramOriginalWord();
418  if(blackboard.activeTimer)
419  {
420  kanagramEngineHelper.increaseScore(kanagramEngineHelper.revealAnswerScore());
421  blackboard.totalScore=i18n("Score : ")+kanagramEngineHelper.totalScore();
422  }
423  revealButton.countDownTimerValue=2;
424  showAnswerTimer.repeat=true;
425  showAnswerTimer.start();
426  }
427  }
428 
429  states: State {
430  name: "onEntered"
431  PropertyChanges {
432  target: revealText
433  opacity:1
434  }
435  PropertyChanges {
436  target: revealBar
437  opacity:0.25
438  }
439  }
440  State{
441  name:"onExited"
442  }
443 
444  transitions: Transition {
445  PropertyAnimation { properties: "x,y,opacity"; easing.type: Easing.Linear; easing.amplitude: 5.0; easing.period: 1 }
446  }
447  }
448 
449  Timer {
450  id: showAnswerTimer;
451  interval: 1000;
452  repeat: true;
453  running: false;
454  triggeredOnStart: false;
455 
456  onTriggered: {
457  if (--revealButton.countDownTimerValue == 0) {
458  blackboard.anagramText=kanagramEngineHelper.createNextAnagram();
459  blackboard.hint=kanagramEngineHelper.showHint();
460  if(kanagramEngineHelper.hintHideTime())
461  blackboard.showHintTimeInterval=1;
462  stop();
463  }
464  }
465  }
466 
467  Rectangle {
468  id: revealBar
469  width: parent.width/6; height: parent.height/15
470  opacity: 0
471  radius: 4
472  color: "black"
473  anchors{bottom:optionsBar.top;horizontalCenter: revealButton.horizontalCenter}
474  }
475 
476  Text{
477  id:revealText
478  anchors{verticalCenter: revealBar.verticalCenter;horizontalCenter:revealBar.horizontalCenter}
479  color:"white"
480  text: i18n("Reveal Word")
481  opacity: 0
482  font.pixelSize: parent.width/40
483  }
484 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:12:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kanagram

Skip menu "kanagram"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal